Commit bcbf0162 authored by Bryan Wu's avatar Bryan Wu

leds: convert ADP5520 LED driver to devm_kzalloc() and cleanup error exit path

Cc: Michael Hennerich <hennerich@blackfin.uclinux.org>
Signed-off-by: default avatarBryan Wu <bryan.wu@canonical.com>
parent 73759f6a
...@@ -119,7 +119,8 @@ static int __devinit adp5520_led_probe(struct platform_device *pdev) ...@@ -119,7 +119,8 @@ static int __devinit adp5520_led_probe(struct platform_device *pdev)
return -EFAULT; return -EFAULT;
} }
led = kzalloc(sizeof(*led) * pdata->num_leds, GFP_KERNEL); led = devm_kzalloc(&pdev->dev, sizeof(*led) * pdata->num_leds,
GFP_KERNEL);
if (led == NULL) { if (led == NULL) {
dev_err(&pdev->dev, "failed to alloc memory\n"); dev_err(&pdev->dev, "failed to alloc memory\n");
return -ENOMEM; return -ENOMEM;
...@@ -129,7 +130,7 @@ static int __devinit adp5520_led_probe(struct platform_device *pdev) ...@@ -129,7 +130,7 @@ static int __devinit adp5520_led_probe(struct platform_device *pdev)
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to write\n"); dev_err(&pdev->dev, "failed to write\n");
goto err_free; return ret;
} }
for (i = 0; i < pdata->num_leds; ++i) { for (i = 0; i < pdata->num_leds; ++i) {
...@@ -179,8 +180,6 @@ static int __devinit adp5520_led_probe(struct platform_device *pdev) ...@@ -179,8 +180,6 @@ static int __devinit adp5520_led_probe(struct platform_device *pdev)
} }
} }
err_free:
kfree(led);
return ret; return ret;
} }
...@@ -200,7 +199,6 @@ static int __devexit adp5520_led_remove(struct platform_device *pdev) ...@@ -200,7 +199,6 @@ static int __devexit adp5520_led_remove(struct platform_device *pdev)
cancel_work_sync(&led[i].work); cancel_work_sync(&led[i].work);
} }
kfree(led);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment