[PATCH 1/4] led: trigger: disable LEDs with trigger before installing it

Sebastian Hesselbarth sebastian.hesselbarth at gmail.com
Sat Nov 9 08:24:06 EST 2013


This disables LEDs that have a trigger function assigned right before
the trigger is installed. As the trigger was parsed before the LED has
been registered, also swap LED registration and trigger parsing.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth at gmail.com>
---
Cc: barebox at lists.infradead.org
---
 drivers/led/led-gpio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/led/led-gpio.c b/drivers/led/led-gpio.c
index 69db70f..7a5ef47 100644
--- a/drivers/led/led-gpio.c
+++ b/drivers/led/led-gpio.c
@@ -225,6 +225,8 @@ static void led_of_parse_trigger(struct led *led, struct device_node *np)
 	for (i = 0; i < ARRAY_SIZE(triggers); i++) {
 		struct led_trg *trg = &triggers[i];
 		if (!strcmp(trg->str, trigger)) {
+			/* disable LED before installing trigger */
+			led_set(led, 0);
 			led_set_trigger(trg->trg, led);
 			return;
 		}
@@ -252,8 +254,8 @@ static int led_gpio_of_probe(struct device_d *dev)
 		dev_dbg(dev, "register led %s on gpio%d, active_low = %d\n",
 			gled->led.name, gled->gpio, gled->active_low);
 
-		led_of_parse_trigger(&gled->led, child);
 		led_gpio_register(gled);
+		led_of_parse_trigger(&gled->led, child);
 	}
 
 	return 0;
-- 
1.8.4.rc3




More information about the barebox mailing list