Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.o-hand.com/linux-rpurdie-leds
Browse files Browse the repository at this point in the history
* '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
  • Loading branch information
Linus Torvalds committed Apr 1, 2008
2 parents 3344203 + 306dd85 commit 90c9d4f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions drivers/leds/leds-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ static void gpio_led_set(struct led_classdev *led_cdev,
if (led_dat->active_low)
level = !level;

/* setting GPIOs with I2C/etc requires a preemptible task context */
/* Setting GPIOs with I2C/etc requires a task context, and we don't
* seem to have a reliable way to know if we're already in one; so
* let's just assume the worst.
*/
if (led_dat->can_sleep) {
if (preempt_count()) {
led_dat->new_level = level;
schedule_work(&led_dat->work);
} else
gpio_set_value_cansleep(led_dat->gpio, level);
led_dat->new_level = level;
schedule_work(&led_dat->work);
} else
gpio_set_value(led_dat->gpio, level);
}
Expand All @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 90c9d4f

Please sign in to comment.