diff options
Diffstat (limited to 'drivers/leds/leds-ns2.c')
-rw-r--r-- | drivers/leds/leds-ns2.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 01cf89ec6944..10528dafb043 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c | |||
@@ -273,29 +273,23 @@ static int __devinit ns2_led_probe(struct platform_device *pdev) | |||
273 | if (!pdata) | 273 | if (!pdata) |
274 | return -EINVAL; | 274 | return -EINVAL; |
275 | 275 | ||
276 | leds_data = kzalloc(sizeof(struct ns2_led_data) * | 276 | leds_data = devm_kzalloc(&pdev->dev, sizeof(struct ns2_led_data) * |
277 | pdata->num_leds, GFP_KERNEL); | 277 | pdata->num_leds, GFP_KERNEL); |
278 | if (!leds_data) | 278 | if (!leds_data) |
279 | return -ENOMEM; | 279 | return -ENOMEM; |
280 | 280 | ||
281 | for (i = 0; i < pdata->num_leds; i++) { | 281 | for (i = 0; i < pdata->num_leds; i++) { |
282 | ret = create_ns2_led(pdev, &leds_data[i], &pdata->leds[i]); | 282 | ret = create_ns2_led(pdev, &leds_data[i], &pdata->leds[i]); |
283 | if (ret < 0) | 283 | if (ret < 0) { |
284 | goto err; | 284 | for (i = i - 1; i >= 0; i--) |
285 | 285 | delete_ns2_led(&leds_data[i]); | |
286 | return ret; | ||
287 | } | ||
286 | } | 288 | } |
287 | 289 | ||
288 | platform_set_drvdata(pdev, leds_data); | 290 | platform_set_drvdata(pdev, leds_data); |
289 | 291 | ||
290 | return 0; | 292 | return 0; |
291 | |||
292 | err: | ||
293 | for (i = i - 1; i >= 0; i--) | ||
294 | delete_ns2_led(&leds_data[i]); | ||
295 | |||
296 | kfree(leds_data); | ||
297 | |||
298 | return ret; | ||
299 | } | 293 | } |
300 | 294 | ||
301 | static int __devexit ns2_led_remove(struct platform_device *pdev) | 295 | static int __devexit ns2_led_remove(struct platform_device *pdev) |
@@ -309,7 +303,6 @@ static int __devexit ns2_led_remove(struct platform_device *pdev) | |||
309 | for (i = 0; i < pdata->num_leds; i++) | 303 | for (i = 0; i < pdata->num_leds; i++) |
310 | delete_ns2_led(&leds_data[i]); | 304 | delete_ns2_led(&leds_data[i]); |
311 | 305 | ||
312 | kfree(leds_data); | ||
313 | platform_set_drvdata(pdev, NULL); | 306 | platform_set_drvdata(pdev, NULL); |
314 | 307 | ||
315 | return 0; | 308 | return 0; |