led: gpio: add support for default-state dt-property
This patch adds support for the default-state device tree property. Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
e2290aef31
commit
3d61b7b6a9
|
@ -204,6 +204,7 @@ static int led_gpio_of_probe(struct device_d *dev)
|
|||
|
||||
for_each_child_of_node(dev->device_node, child) {
|
||||
struct gpio_led *gled;
|
||||
const char *default_state;
|
||||
enum of_gpio_flags flags;
|
||||
int gpio;
|
||||
const char *label;
|
||||
|
@ -225,6 +226,13 @@ static int led_gpio_of_probe(struct device_d *dev)
|
|||
|
||||
led_gpio_register(gled);
|
||||
led_of_parse_trigger(&gled->led, child);
|
||||
|
||||
if (!of_property_read_string(child, "default-state", &default_state)) {
|
||||
if (!strcmp(default_state, "on"))
|
||||
led_gpio_set(&gled->led, 1);
|
||||
else if (!strcmp(default_state, "off"))
|
||||
led_gpio_set(&gled->led, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue