diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2012-07-03 23:35:44 -0400 |
---|---|---|
committer | Bryan Wu <bryan.wu@canonical.com> | 2012-07-23 19:52:36 -0400 |
commit | 198b8611315f793a8f674c3ca3324028e19634aa (patch) | |
tree | fe598835899f50c859c96ef8164679ff1c36553e /drivers | |
parent | 7f13bbf799f28d5c718a2f18c42f0c6ab56f501b (diff) |
leds: Use devm_kzalloc in leds-gpio.c file
devm_kzalloc() makes cleanup simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/leds/leds-gpio.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index f4c470a3bc8d..c032b2180340 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c | |||
@@ -178,7 +178,8 @@ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_dev | |||
178 | if (!count) | 178 | if (!count) |
179 | return NULL; | 179 | return NULL; |
180 | 180 | ||
181 | priv = kzalloc(sizeof_gpio_leds_priv(count), GFP_KERNEL); | 181 | priv = devm_kzalloc(&pdev->dev, sizeof_gpio_leds_priv(count), |
182 | GFP_KERNEL); | ||
182 | if (!priv) | 183 | if (!priv) |
183 | return NULL; | 184 | return NULL; |
184 | 185 | ||
@@ -215,7 +216,6 @@ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_dev | |||
215 | err: | 216 | err: |
216 | for (count = priv->num_leds - 2; count >= 0; count--) | 217 | for (count = priv->num_leds - 2; count >= 0; count--) |
217 | delete_gpio_led(&priv->leds[count]); | 218 | delete_gpio_led(&priv->leds[count]); |
218 | kfree(priv); | ||
219 | return NULL; | 219 | return NULL; |
220 | } | 220 | } |
221 | 221 | ||
@@ -239,8 +239,9 @@ static int __devinit gpio_led_probe(struct platform_device *pdev) | |||
239 | int i, ret = 0; | 239 | int i, ret = 0; |
240 | 240 | ||
241 | if (pdata && pdata->num_leds) { | 241 | if (pdata && pdata->num_leds) { |
242 | priv = kzalloc(sizeof_gpio_leds_priv(pdata->num_leds), | 242 | priv = devm_kzalloc(&pdev->dev, |
243 | GFP_KERNEL); | 243 | sizeof_gpio_leds_priv(pdata->num_leds), |
244 | GFP_KERNEL); | ||
244 | if (!priv) | 245 | if (!priv) |
245 | return -ENOMEM; | 246 | return -ENOMEM; |
246 | 247 | ||
@@ -253,7 +254,6 @@ static int __devinit gpio_led_probe(struct platform_device *pdev) | |||
253 | /* On failure: unwind the led creations */ | 254 | /* On failure: unwind the led creations */ |
254 | for (i = i - 1; i >= 0; i--) | 255 | for (i = i - 1; i >= 0; i--) |
255 | delete_gpio_led(&priv->leds[i]); | 256 | delete_gpio_led(&priv->leds[i]); |
256 | kfree(priv); | ||
257 | return ret; | 257 | return ret; |
258 | } | 258 | } |
259 | } | 259 | } |
@@ -277,7 +277,6 @@ static int __devexit gpio_led_remove(struct platform_device *pdev) | |||
277 | delete_gpio_led(&priv->leds[i]); | 277 | delete_gpio_led(&priv->leds[i]); |
278 | 278 | ||
279 | dev_set_drvdata(&pdev->dev, NULL); | 279 | dev_set_drvdata(&pdev->dev, NULL); |
280 | kfree(priv); | ||
281 | 280 | ||
282 | return 0; | 281 | return 0; |
283 | } | 282 | } |