From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
To: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: barebox@lists.infradead.org
Subject: [PATCH 4/4] led: gpio: Properly deal with deferred probing
Date: Fri, 10 Apr 2015 03:02:46 +0200 [thread overview]
Message-ID: <1428627766-17178-5-git-send-email-sebastian.hesselbarth@gmail.com> (raw)
In-Reply-To: <1428627766-17178-1-git-send-email-sebastian.hesselbarth@gmail.com>
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@gmail.com>
---
Cc: barebox@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
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2015-04-10 1:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-10 1:02 [PATCH 0/4] Introduce " Sebastian Hesselbarth
2015-04-10 1:02 ` [PATCH 1/4] base: " Sebastian Hesselbarth
2015-04-13 6:54 ` Sascha Hauer
2015-04-13 14:26 ` Sebastian Hesselbarth
2015-04-10 1:02 ` [PATCH 2/4] gpio: Return -EPROBE_DEFER on gpio_get_num() Sebastian Hesselbarth
2015-04-10 1:02 ` [PATCH 3/4] OF: gpio: Silence error message on -EPROBE_DEFER Sebastian Hesselbarth
2015-04-10 1:02 ` Sebastian Hesselbarth [this message]
2015-04-13 8:14 ` [PATCH 0/4] Introduce deferred probing Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1428627766-17178-5-git-send-email-sebastian.hesselbarth@gmail.com \
--to=sebastian.hesselbarth@gmail.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox