Message ID | 1353902984-10728-3-git-send-email-sachin.kamat@linaro.org |
---|---|
State | Accepted |
Headers | show |
On 26.11.2012 05:09, Sachin Kamat wrote: > devm_gpio_request_one is device managed and makes error handling > and cleanup simpler. > > Cc: Daniel Mack <daniel@caiaq.de> Acked-by: Daniel Mack <zonque@gmail.com> Thanks! > Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> > --- > drivers/leds/leds-lt3593.c | 11 +++-------- > 1 files changed, 3 insertions(+), 8 deletions(-) > > diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c > index 17b710c..5ee6b8b 100644 > --- a/drivers/leds/leds-lt3593.c > +++ b/drivers/leds/leds-lt3593.c > @@ -106,8 +106,8 @@ static int __devinit create_lt3593_led(const struct gpio_led *template, > if (!template->retain_state_suspended) > led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; > > - ret = gpio_request_one(template->gpio, GPIOF_DIR_OUT | state, > - template->name); > + ret = devm_gpio_request_one(parent, template->gpio, > + GPIOF_DIR_OUT | state, template->name); > if (ret < 0) > return ret; > > @@ -115,16 +115,12 @@ static int __devinit create_lt3593_led(const struct gpio_led *template, > > ret = led_classdev_register(parent, &led_dat->cdev); > if (ret < 0) > - goto err; > + return ret; > > printk(KERN_INFO "%s: registered LT3593 LED '%s' at GPIO %d\n", > KBUILD_MODNAME, template->name, template->gpio); > > return 0; > - > -err: > - gpio_free(led_dat->gpio); > - return ret; > } > > static void delete_lt3593_led(struct lt3593_led_data *led) > @@ -134,7 +130,6 @@ static void delete_lt3593_led(struct lt3593_led_data *led) > > led_classdev_unregister(&led->cdev); > cancel_work_sync(&led->work); > - gpio_free(led->gpio); > } > > static int __devinit lt3593_led_probe(struct platform_device *pdev) >
diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c index 17b710c..5ee6b8b 100644 --- a/drivers/leds/leds-lt3593.c +++ b/drivers/leds/leds-lt3593.c @@ -106,8 +106,8 @@ static int __devinit create_lt3593_led(const struct gpio_led *template, if (!template->retain_state_suspended) led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; - ret = gpio_request_one(template->gpio, GPIOF_DIR_OUT | state, - template->name); + ret = devm_gpio_request_one(parent, template->gpio, + GPIOF_DIR_OUT | state, template->name); if (ret < 0) return ret; @@ -115,16 +115,12 @@ static int __devinit create_lt3593_led(const struct gpio_led *template, ret = led_classdev_register(parent, &led_dat->cdev); if (ret < 0) - goto err; + return ret; printk(KERN_INFO "%s: registered LT3593 LED '%s' at GPIO %d\n", KBUILD_MODNAME, template->name, template->gpio); return 0; - -err: - gpio_free(led_dat->gpio); - return ret; } static void delete_lt3593_led(struct lt3593_led_data *led) @@ -134,7 +130,6 @@ static void delete_lt3593_led(struct lt3593_led_data *led) led_classdev_unregister(&led->cdev); cancel_work_sync(&led->work); - gpio_free(led->gpio); } static int __devinit lt3593_led_probe(struct platform_device *pdev)
devm_gpio_request_one is device managed and makes error handling and cleanup simpler. Cc: Daniel Mack <daniel@caiaq.de> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> --- drivers/leds/leds-lt3593.c | 11 +++-------- 1 files changed, 3 insertions(+), 8 deletions(-)