Commit e3b1d44c authored by Sachin Kamat's avatar Sachin Kamat Committed by Bryan Wu

leds: leds-gpio: use devm_gpio_request_one

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: default avatarSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: default avatarBryan Wu <cooloney@gmail.com>
parent 4401e487
...@@ -126,7 +126,7 @@ static int __devinit create_gpio_led(const struct gpio_led *template, ...@@ -126,7 +126,7 @@ static int __devinit create_gpio_led(const struct gpio_led *template,
if (!template->retain_state_suspended) if (!template->retain_state_suspended)
led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; 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), GPIOF_DIR_OUT | (led_dat->active_low ^ state),
template->name); template->name);
if (ret < 0) if (ret < 0)
...@@ -136,12 +136,9 @@ static int __devinit create_gpio_led(const struct gpio_led *template, ...@@ -136,12 +136,9 @@ static int __devinit create_gpio_led(const struct gpio_led *template,
ret = led_classdev_register(parent, &led_dat->cdev); ret = led_classdev_register(parent, &led_dat->cdev);
if (ret < 0) if (ret < 0)
goto err; return ret;
return 0; return 0;
err:
gpio_free(led_dat->gpio);
return ret;
} }
static void delete_gpio_led(struct gpio_led_data *led) static void delete_gpio_led(struct gpio_led_data *led)
...@@ -150,7 +147,6 @@ static void delete_gpio_led(struct gpio_led_data *led) ...@@ -150,7 +147,6 @@ static void delete_gpio_led(struct gpio_led_data *led)
return; return;
led_classdev_unregister(&led->cdev); led_classdev_unregister(&led->cdev);
cancel_work_sync(&led->work); cancel_work_sync(&led->work);
gpio_free(led->gpio);
} }
struct gpio_leds_priv { struct gpio_leds_priv {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment