aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2012-11-24 23:40:20 -0500
committerBryan Wu <cooloney@gmail.com>2012-11-27 17:49:24 -0500
commite3b1d44c3550e5badfa5b78ffec80e15d7d9b287 (patch)
tree180a664bdfcee84392ea82272ea2539a75a33f40 /drivers/leds
parent4401e48737c4068604144a5c0ba23a9c82ea3a37 (diff)
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: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/leds-gpio.c8
1 files changed, 2 insertions, 6 deletions
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,
126 if (!template->retain_state_suspended) 126 if (!template->retain_state_suspended)
127 led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; 127 led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
128 128
129 ret = gpio_request_one(template->gpio, 129 ret = devm_gpio_request_one(parent, template->gpio,
130 GPIOF_DIR_OUT | (led_dat->active_low ^ state), 130 GPIOF_DIR_OUT | (led_dat->active_low ^ state),
131 template->name); 131 template->name);
132 if (ret < 0) 132 if (ret < 0)
@@ -136,12 +136,9 @@ static int __devinit create_gpio_led(const struct gpio_led *template,
136 136
137 ret = led_classdev_register(parent, &led_dat->cdev); 137 ret = led_classdev_register(parent, &led_dat->cdev);
138 if (ret < 0) 138 if (ret < 0)
139 goto err; 139 return ret;
140 140
141 return 0; 141 return 0;
142err:
143 gpio_free(led_dat->gpio);
144 return ret;
145} 142}
146 143
147static void delete_gpio_led(struct gpio_led_data *led) 144static void delete_gpio_led(struct gpio_led_data *led)
@@ -150,7 +147,6 @@ static void delete_gpio_led(struct gpio_led_data *led)
150 return; 147 return;
151 led_classdev_unregister(&led->cdev); 148 led_classdev_unregister(&led->cdev);
152 cancel_work_sync(&led->work); 149 cancel_work_sync(&led->work);
153 gpio_free(led->gpio);
154} 150}
155 151
156struct gpio_leds_priv { 152struct gpio_leds_priv {