leds: Fix potential leds-gpio oops
authorUwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
Sun, 9 Mar 2008 20:42:27 +0000 (20:42 +0000)
committerRichard Purdie <rpurdie@rpsys.net>
Mon, 31 Mar 2008 22:31:13 +0000 (23:31 +0100)
Call gpio_cansleep only after gpio_request succeeded avoiding an
oops.

Signed-off-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
drivers/leds/leds-gpio.c

index 6c0a9c4761ee13ffd2333db779c7b8f42091ea21..d13b622419df5c99f88a99cec37e03fccf984e9e 100644 (file)
@@ -79,6 +79,10 @@ static int gpio_led_probe(struct platform_device *pdev)
                cur_led = &pdata->leds[i];
                led_dat = &leds_data[i];
 
+               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;
@@ -87,10 +91,6 @@ static int gpio_led_probe(struct platform_device *pdev)
                led_dat->cdev.brightness_set = gpio_led_set;
                led_dat->cdev.brightness = LED_OFF;
 
-               ret = gpio_request(led_dat->gpio, led_dat->cdev.name);
-               if (ret < 0)
-                       goto err;
-
                gpio_direction_output(led_dat->gpio, led_dat->active_low);
 
                INIT_WORK(&led_dat->work, gpio_led_work);