* [patch 2.6.29-rc7] leds-gpio: just ignore invalid GPIOs
@ 2009-03-06 0:46 David Brownell
2009-03-06 21:37 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: David Brownell @ 2009-03-06 0:46 UTC (permalink / raw)
To: Richard Purdie; +Cc: lkml, Diego Dompe, Jason Kridner
From: David Brownell <dbrownell@users.sourceforge.net>
Sometimes it's awkward to make sure that the array in the
platform_data handed to the leds-gpio driver has only valid
data ... some leds may not be always available, and coping
with that currently requires patching or rebuilding the array.
This patch fixes that by making it be OK to pass an invalid
GPIO (such as "-EINVAL") ... such table entries are skipped.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Tested-by: Diego Dompe <diego.dompe@ridgerun.com>
---
Noted on OMAP3 Beagle board ... one of the three programmable
LEDs is driven by a twl4030 GPIO, which might not be configured.
(In fact it's a PWM-capable LED, but the PWM support isn't yet
available.)
drivers/leds/leds-gpio.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -90,13 +90,19 @@ static int gpio_led_probe(struct platfor
cur_led = &pdata->leds[i];
led_dat = &leds_data[i];
+ /* skip leds that aren't available */
+ led_dat->gpio = cur_led->gpio;
+ if (!gpio_is_valid(led_dat->gpio)) {
+ dev_dbg(&pdev->dev, "skipping %s\n", cur_led->name);
+ continue;
+ }
+
ret = gpio_request(cur_led->gpio, cur_led->name);
if (ret < 0)
goto err;
led_dat->cdev.name = cur_led->name;
led_dat->cdev.default_trigger = cur_led->default_trigger;
- led_dat->gpio = cur_led->gpio;
led_dat->can_sleep = gpio_cansleep(cur_led->gpio);
led_dat->active_low = cur_led->active_low;
if (pdata->gpio_blink_set) {
@@ -125,6 +131,8 @@ static int gpio_led_probe(struct platfor
err:
if (i > 0) {
for (i = i - 1; i >= 0; i--) {
+ if (!gpio_is_valid(leds_data[i].gpio))
+ continue;
led_classdev_unregister(&leds_data[i].cdev);
cancel_work_sync(&leds_data[i].work);
gpio_free(leds_data[i].gpio);
@@ -145,6 +153,8 @@ static int __devexit gpio_led_remove(str
leds_data = platform_get_drvdata(pdev);
for (i = 0; i < pdata->num_leds; i++) {
+ if (!gpio_is_valid(leds_data[i].gpio))
+ continue;
led_classdev_unregister(&leds_data[i].cdev);
cancel_work_sync(&leds_data[i].work);
gpio_free(leds_data[i].gpio);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 2.6.29-rc7] leds-gpio: just ignore invalid GPIOs
2009-03-06 0:46 [patch 2.6.29-rc7] leds-gpio: just ignore invalid GPIOs David Brownell
@ 2009-03-06 21:37 ` Andrew Morton
2009-03-06 22:19 ` David Brownell
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2009-03-06 21:37 UTC (permalink / raw)
To: David Brownell; +Cc: rpurdie, linux-kernel, diego.dompe, jdk
On Thu, 5 Mar 2009 16:46:44 -0800
David Brownell <david-b@pacbell.net> wrote:
> From: David Brownell <dbrownell@users.sourceforge.net>
>
> Sometimes it's awkward to make sure that the array in the
> platform_data handed to the leds-gpio driver has only valid
> data ... some leds may not be always available, and coping
> with that currently requires patching or rebuilding the array.
>
> This patch fixes that by making it be OK to pass an invalid
> GPIO (such as "-EINVAL") ... such table entries are skipped.
>
> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
> Tested-by: Diego Dompe <diego.dompe@ridgerun.com>
> ---
> Noted on OMAP3 Beagle board ... one of the three programmable
> LEDs is driven by a twl4030 GPIO, which might not be configured.
> (In fact it's a PWM-capable LED, but the PWM support isn't yet
> available.)
>
> drivers/leds/leds-gpio.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> --- a/drivers/leds/leds-gpio.c
> +++ b/drivers/leds/leds-gpio.c
> @@ -90,13 +90,19 @@ static int gpio_led_probe(struct platfor
> cur_led = &pdata->leds[i];
> led_dat = &leds_data[i];
>
> + /* skip leds that aren't available */
> + led_dat->gpio = cur_led->gpio;
> + if (!gpio_is_valid(led_dat->gpio)) {
> + dev_dbg(&pdev->dev, "skipping %s\n", cur_led->name);
> + continue;
> + }
> +
> ret = gpio_request(cur_led->gpio, cur_led->name);
> if (ret < 0)
> goto err;
>
> led_dat->cdev.name = cur_led->name;
> led_dat->cdev.default_trigger = cur_led->default_trigger;
> - led_dat->gpio = cur_led->gpio;
> led_dat->can_sleep = gpio_cansleep(cur_led->gpio);
> led_dat->active_low = cur_led->active_low;
> if (pdata->gpio_blink_set) {
> @@ -125,6 +131,8 @@ static int gpio_led_probe(struct platfor
> err:
> if (i > 0) {
> for (i = i - 1; i >= 0; i--) {
> + if (!gpio_is_valid(leds_data[i].gpio))
> + continue;
> led_classdev_unregister(&leds_data[i].cdev);
> cancel_work_sync(&leds_data[i].work);
> gpio_free(leds_data[i].gpio);
> @@ -145,6 +153,8 @@ static int __devexit gpio_led_remove(str
> leds_data = platform_get_drvdata(pdev);
>
> for (i = 0; i < pdata->num_leds; i++) {
> + if (!gpio_is_valid(leds_data[i].gpio))
> + continue;
> led_classdev_unregister(&leds_data[i].cdev);
> cancel_work_sync(&leds_data[i].work);
> gpio_free(leds_data[i].gpio);
All this code has changed a lot in linux.next. Nothing applies and it
goes beyond my fix-it-up preparedness.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 2.6.29-rc7] leds-gpio: just ignore invalid GPIOs
2009-03-06 21:37 ` Andrew Morton
@ 2009-03-06 22:19 ` David Brownell
0 siblings, 0 replies; 3+ messages in thread
From: David Brownell @ 2009-03-06 22:19 UTC (permalink / raw)
To: Andrew Morton; +Cc: rpurdie, linux-kernel, diego.dompe, jdk
On Friday 06 March 2009, Andrew Morton wrote:
> All this code has changed a lot in linux.next. Nothing applies and it
> goes beyond my fix-it-up preparedness.
Well that's just no fun. :(
Unless someone else wants to handle that, I'm just going to
leave this version in my patch queue until those changes come
down from mainline and break it. An updated version would
come sometime later.
- Dave
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-03-06 22:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-06 0:46 [patch 2.6.29-rc7] leds-gpio: just ignore invalid GPIOs David Brownell
2009-03-06 21:37 ` Andrew Morton
2009-03-06 22:19 ` David Brownell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox