9
0
Fork 0

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:
Hubert Feurstein 2015-03-04 10:52:04 +01:00 committed by Sascha Hauer
parent e2290aef31
commit 3d61b7b6a9
1 changed files with 8 additions and 0 deletions

View File

@ -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;