aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-mc13783.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/leds/leds-mc13783.c')
-rw-r--r--drivers/leds/leds-mc13783.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/leds/leds-mc13783.c b/drivers/leds/leds-mc13783.c
index 6515c11dbe6b..2a5d43400677 100644
--- a/drivers/leds/leds-mc13783.c
+++ b/drivers/leds/leds-mc13783.c
@@ -280,7 +280,8 @@ static int __devinit mc13783_led_probe(struct platform_device *pdev)
280 return -EINVAL; 280 return -EINVAL;
281 } 281 }
282 282
283 led = kcalloc(pdata->num_leds, sizeof(*led), GFP_KERNEL); 283 led = devm_kzalloc(&pdev->dev, pdata->num_leds * sizeof(*led),
284 GFP_KERNEL);
284 if (led == NULL) { 285 if (led == NULL) {
285 dev_err(&pdev->dev, "failed to alloc memory\n"); 286 dev_err(&pdev->dev, "failed to alloc memory\n");
286 return -ENOMEM; 287 return -ENOMEM;
@@ -289,7 +290,7 @@ static int __devinit mc13783_led_probe(struct platform_device *pdev)
289 ret = mc13783_leds_prepare(pdev); 290 ret = mc13783_leds_prepare(pdev);
290 if (ret) { 291 if (ret) {
291 dev_err(&pdev->dev, "unable to init led driver\n"); 292 dev_err(&pdev->dev, "unable to init led driver\n");
292 goto err_free; 293 return ret;
293 } 294 }
294 295
295 for (i = 0; i < pdata->num_leds; i++) { 296 for (i = 0; i < pdata->num_leds; i++) {
@@ -344,8 +345,6 @@ err_register:
344 cancel_work_sync(&led[i].work); 345 cancel_work_sync(&led[i].work);
345 } 346 }
346 347
347err_free:
348 kfree(led);
349 return ret; 348 return ret;
350} 349}
351 350
@@ -373,7 +372,6 @@ static int __devexit mc13783_led_remove(struct platform_device *pdev)
373 mc13xxx_unlock(dev); 372 mc13xxx_unlock(dev);
374 373
375 platform_set_drvdata(pdev, NULL); 374 platform_set_drvdata(pdev, NULL);
376 kfree(led);
377 return 0; 375 return 0;
378} 376}
379 377