aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-01 14:24:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-01 14:24:20 -0400
commit90c9d4f8eeb9dd31adfb97e897039033b7a72d14 (patch)
tree9cb4e0d0eee8a67dc4353ad93e6e07a54bd2ffaa /drivers
parent3344203948f40521c35a0a52e3f1bd9fbb7a1118 (diff)
parent306dd85c1d41e20a07d1e821e27f5df4927bb5e7 (diff)
Merge branch 'for-linus' of git://git.o-hand.com/linux-rpurdie-leds
* 'for-linus' of git://git.o-hand.com/linux-rpurdie-leds: leds: Remove incorrect use of preempt_count() from leds-gpio leds: Fix potential leds-gpio oops
Diffstat (limited to 'drivers')
-rw-r--r--drivers/leds/leds-gpio.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 6c0a9c4761ee..4c0b05852cb6 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -49,13 +49,13 @@ static void gpio_led_set(struct led_classdev *led_cdev,
49 if (led_dat->active_low) 49 if (led_dat->active_low)
50 level = !level; 50 level = !level;
51 51
52 /* setting GPIOs with I2C/etc requires a preemptible task context */ 52 /* Setting GPIOs with I2C/etc requires a task context, and we don't
53 * seem to have a reliable way to know if we're already in one; so
54 * let's just assume the worst.
55 */
53 if (led_dat->can_sleep) { 56 if (led_dat->can_sleep) {
54 if (preempt_count()) { 57 led_dat->new_level = level;
55 led_dat->new_level = level; 58 schedule_work(&led_dat->work);
56 schedule_work(&led_dat->work);
57 } else
58 gpio_set_value_cansleep(led_dat->gpio, level);
59 } else 59 } else
60 gpio_set_value(led_dat->gpio, level); 60 gpio_set_value(led_dat->gpio, level);
61} 61}
@@ -79,6 +79,10 @@ static int gpio_led_probe(struct platform_device *pdev)
79 cur_led = &pdata->leds[i]; 79 cur_led = &pdata->leds[i];
80 led_dat = &leds_data[i]; 80 led_dat = &leds_data[i];
81 81
82 ret = gpio_request(cur_led->gpio, cur_led->name);
83 if (ret < 0)
84 goto err;
85
82 led_dat->cdev.name = cur_led->name; 86 led_dat->cdev.name = cur_led->name;
83 led_dat->cdev.default_trigger = cur_led->default_trigger; 87 led_dat->cdev.default_trigger = cur_led->default_trigger;
84 led_dat->gpio = cur_led->gpio; 88 led_dat->gpio = cur_led->gpio;
@@ -87,10 +91,6 @@ static int gpio_led_probe(struct platform_device *pdev)
87 led_dat->cdev.brightness_set = gpio_led_set; 91 led_dat->cdev.brightness_set = gpio_led_set;
88 led_dat->cdev.brightness = LED_OFF; 92 led_dat->cdev.brightness = LED_OFF;
89 93
90 ret = gpio_request(led_dat->gpio, led_dat->cdev.name);
91 if (ret < 0)
92 goto err;
93
94 gpio_direction_output(led_dat->gpio, led_dat->active_low); 94 gpio_direction_output(led_dat->gpio, led_dat->active_low);
95 95
96 INIT_WORK(&led_dat->work, gpio_led_work); 96 INIT_WORK(&led_dat->work, gpio_led_work);