[PATCH 4/4] led: gpio: Properly deal with deferred probing
Sebastian Hesselbarth
sebastian.hesselbarth at gmail.com
Thu Apr 9 18:02:46 PDT 2015
GPIO LEDs can suffer from deferred probing due to failing gpio request.
If of_get_named_gpio_flags returns -EPROBE_DEFER, skip current LED and
request deferred probing later. Since not all LEDs have to fail, build
a mask of already registered LEDs to be skipped later on deferred probe.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth at gmail.com>
---
Cc: barebox at lists.infradead.org
---
drivers/led/led-gpio.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/led/led-gpio.c b/drivers/led/led-gpio.c
index ae3f13f45b6c..91e5d5b76085 100644
--- a/drivers/led/led-gpio.c
+++ b/drivers/led/led-gpio.c
@@ -201,6 +201,8 @@ void led_gpio_rgb_unregister(struct gpio_led *led)
static int led_gpio_of_probe(struct device_d *dev)
{
struct device_node *child;
+ static u32 registered;
+ int ret = 0, n = 0;
for_each_child_of_node(dev->device_node, child) {
struct gpio_led *gled;
@@ -209,7 +211,15 @@ static int led_gpio_of_probe(struct device_d *dev)
int gpio;
const char *label;
+ /* On deferred probing, skip already registered LEDs */
+ if (registered & BIT(n)) {
+ n++;
+ continue;
+ }
+
gpio = of_get_named_gpio_flags(child, "gpios", 0, &flags);
+ if (gpio == -EPROBE_DEFER)
+ ret = -EPROBE_DEFER;
if (gpio < 0)
continue;
@@ -233,9 +243,12 @@ static int led_gpio_of_probe(struct device_d *dev)
else if (!strcmp(default_state, "off"))
led_gpio_set(&gled->led, 0);
}
+
+ registered |= BIT(n);
+ n++;
}
- return 0;
+ return ret;
}
static struct of_device_id led_gpio_of_ids[] = {
--
2.1.0
More information about the barebox
mailing list