]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
leds: just ignore invalid GPIOs in leds-gpio
authorDavid Brownell <dbrownell@users.sourceforge.net>
Fri, 6 Mar 2009 00:46:44 +0000 (16:46 -0800)
committerRichard Purdie <rpurdie@linux.intel.com>
Mon, 6 Apr 2009 15:06:27 +0000 (16:06 +0100)
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>
drivers/leds/leds-gpio.c

index 8fa352ac20f84328f60e7c891db8825e5b363369..102ef4a14c5fea075c40226b3914cffe61f8b2d0 100644 (file)
@@ -78,6 +78,13 @@ static int __devinit create_gpio_led(const struct gpio_led *template,
 {
        int ret;
 
+       /* skip leds that aren't available */
+       if (!gpio_is_valid(template->gpio)) {
+               printk(KERN_INFO "Skipping unavilable LED gpio %d (%s)\n", 
+                               template->gpio, template->name);
+               return;
+       }
+
        ret = gpio_request(template->gpio, template->name);
        if (ret < 0)
                return ret;
@@ -114,6 +121,8 @@ err:
 
 static void delete_gpio_led(struct gpio_led_data *led)
 {
+       if (!gpio_is_valid(led->gpio))
+               return;
        led_classdev_unregister(&led->cdev);
        cancel_work_sync(&led->work);
        gpio_free(led->gpio);