aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-gpio.c
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2009-03-05 19:46:44 -0500
committerRichard Purdie <rpurdie@linux.intel.com>2009-04-06 11:06:27 -0400
commitd379ee8acd0719736ee7f1d1ccc3b5765880eaf8 (patch)
treef998ab138b72c5bd597b45ea28c04a3f92586f28 /drivers/leds/leds-gpio.c
parent7fbc3a9b132e93b2ba1fd889c1ad8a4135731cc3 (diff)
leds: just ignore invalid GPIOs in leds-gpio
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. [rpurdie@linux.intel.com: adjusted to apply against other led tree changes] Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Tested-by: Diego Dompe <diego.dompe@ridgerun.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'drivers/leds/leds-gpio.c')
-rw-r--r--drivers/leds/leds-gpio.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 8fa352ac20f8..102ef4a14c5f 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -78,6 +78,13 @@ static int __devinit create_gpio_led(const struct gpio_led *template,
78{ 78{
79 int ret; 79 int ret;
80 80
81 /* skip leds that aren't available */
82 if (!gpio_is_valid(template->gpio)) {
83 printk(KERN_INFO "Skipping unavilable LED gpio %d (%s)\n",
84 template->gpio, template->name);
85 return;
86 }
87
81 ret = gpio_request(template->gpio, template->name); 88 ret = gpio_request(template->gpio, template->name);
82 if (ret < 0) 89 if (ret < 0)
83 return ret; 90 return ret;
@@ -114,6 +121,8 @@ err:
114 121
115static void delete_gpio_led(struct gpio_led_data *led) 122static void delete_gpio_led(struct gpio_led_data *led)
116{ 123{
124 if (!gpio_is_valid(led->gpio))
125 return;
117 led_classdev_unregister(&led->cdev); 126 led_classdev_unregister(&led->cdev);
118 cancel_work_sync(&led->work); 127 cancel_work_sync(&led->work);
119 gpio_free(led->gpio); 128 gpio_free(led->gpio);