Skip to content

Commit

Permalink
leds: leds-gpio: use devm_gpio_request_one
Browse files Browse the repository at this point in the history
devm_gpio_request_one is device managed and makes error handling
and cleanup simpler.

Cc: Raphael Assenat <raph@8d.com>
Cc: Trent Piepho <tpiepho@freescale.com>
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
  • Loading branch information
Sachin Kamat authored and cooloney committed Nov 27, 2012
1 parent 4401e48 commit e3b1d44
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions drivers/leds/leds-gpio.c
Expand Up @@ -126,7 +126,7 @@ static int __devinit create_gpio_led(const struct gpio_led *template,
if (!template->retain_state_suspended)
led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;

ret = gpio_request_one(template->gpio,
ret = devm_gpio_request_one(parent, template->gpio,
GPIOF_DIR_OUT | (led_dat->active_low ^ state),
template->name);
if (ret < 0)
Expand All @@ -136,12 +136,9 @@ static int __devinit create_gpio_led(const struct gpio_led *template,

ret = led_classdev_register(parent, &led_dat->cdev);
if (ret < 0)
goto err;
return ret;

return 0;
err:
gpio_free(led_dat->gpio);
return ret;
}

static void delete_gpio_led(struct gpio_led_data *led)
Expand All @@ -150,7 +147,6 @@ static void delete_gpio_led(struct gpio_led_data *led)
return;
led_classdev_unregister(&led->cdev);
cancel_work_sync(&led->work);
gpio_free(led->gpio);
}

struct gpio_leds_priv {
Expand Down

0 comments on commit e3b1d44

Please sign in to comment.