dm: led: auto probe() LEDs with "default-state"
authorPatrick Bruenn <p.bruenn@beckhoff.com>
Wed, 11 Apr 2018 09:16:28 +0000 (11:16 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 8 May 2018 13:07:33 +0000 (09:07 -0400)
To avoid board specificy LED activation code, automatically
activate gpio-leds with "default-state" property during bind().

Signed-off-by: Patrick Bruenn <p.bruenn@beckhoff.com>
drivers/led/led_gpio.c

index 533587dc47434b12e1ef4477b51d73a53f8f8b98..a36942b9348bdad938f8478cd91be17931dab499 100644 (file)
@@ -10,6 +10,7 @@
 #include <led.h>
 #include <asm/gpio.h>
 #include <dm/lists.h>
+#include <dm/uclass-internal.h>
 
 struct led_gpio_priv {
        struct gpio_desc gpio;
@@ -117,6 +118,14 @@ static int led_gpio_bind(struct udevice *parent)
                        return ret;
                uc_plat = dev_get_uclass_platdata(dev);
                uc_plat->label = label;
+
+               if (ofnode_read_bool(node, "default-state")) {
+                       struct udevice *devp;
+
+                       ret = uclass_get_device_tail(dev, 0, &devp);
+                       if (ret)
+                               return ret;
+               }
        }
 
        return 0;