[PATCH v2] led: gpio: add support for default-state dt-property

Hubert Feurstein h.feurstein at gmail.com
Wed Mar 4 01:52:04 PST 2015


This patch adds support for the default-state device tree property.

Signed-off-by: Hubert Feurstein <h.feurstein at gmail.com>
---
 drivers/led/led-gpio.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/led/led-gpio.c b/drivers/led/led-gpio.c
index a1a6617..ae3f13f 100644
--- a/drivers/led/led-gpio.c
+++ b/drivers/led/led-gpio.c
@@ -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;
-- 
2.3.0




More information about the barebox mailing list