Skip to contentSkip to conversation

led: gpio: add support for default-state dt-property

PATCH Superseded [email protected] 2 participants 4 messages Feb 16, 2015 – Mar 4, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 led: gpio: add support for default-state dt-property

From: Hubert Feurstein <[email protected]>

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

---
 drivers/led/led-gpio.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/led/led-gpio.c +13 -0
index a1a6617..69ad7e7 100644
@@ -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,18 @@ 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)) {
+			int state = -1;
+
+			if (!strcmp(default_state, "on"))
+				state = 1;
+			else if (!strcmp(default_state, "off"))
+				state = 0;
+
+			if (state >= 0)
+				led_gpio_set(&gled->led, state ^ gled->active_low);
+		}
 	}
 
 	return 0;
Signature · 7 lines
2.3.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw
Quoted 26 lines · On Mon, Feb 16, 2015 at 02:03:28PM +0100, [email protected] wrote:

From: Hubert Feurstein <[email protected]>

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

---
 drivers/led/led-gpio.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/led/led-gpio.c +2 -0
index a1a6617..69ad7e7 100644
@@ -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,18 @@ static int led_gpio_of_probe(struct device_d *dev)
 
 		led_gpio_register(gled);
 		led_of_parse_trigger(&gled->led, child);
+

drivers/led/led-gpio.c static int led_gpio_of_probe(struct device_d *dev) · line 239

Quoted 10 lines
drivers/led/led-gpio.c +10 -0
+		if (!of_property_read_string(child, "default-state", &default_state)) {
+			int state = -1;
+
+			if (!strcmp(default_state, "on"))
+				state = 1;
+			else if (!strcmp(default_state, "off"))
+				state = 0;
+
+			if (state >= 0)
+				led_gpio_set(&gled->led, state ^ gled->active_low);

led_gpio_set already evaluates active_low, so doing it here again is wrong.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH v2 1/1 led: gpio: add support for default-state dt-property

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

---
 drivers/led/led-gpio.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/led/led-gpio.c +8 -0
index a1a6617..ae3f13f 100644
@@ -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;
Signature · 7 lines
2.3.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#3 lore raw
Quoted 6 lines · Hubert Feurstein

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

---
 drivers/led/led-gpio.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Nice, as it happens I can just make use of this patch to turn off an annoying LED on my beaglebone board.

Applied, thanks.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox