From: Sachin Kamat Date: Sun, 25 Nov 2012 04:40:20 +0000 (+0530) Subject: leds: leds-gpio: use devm_gpio_request_one X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=e3b1d44c;p=linux-beck.git 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 Cc: Trent Piepho Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 6a2109638fbe..77e2e4057929 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -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) @@ -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) @@ -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 {