dect
/
linux-2.6
Archived
13
0
Fork 0

leds: convert DA9030/DA9034 LED driver to devm_kzalloc() and cleanup error exit path

Cc: Eric Miao <eric.miao@canonical.com>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
This commit is contained in:
Bryan Wu 2012-07-03 13:07:53 +08:00
parent 9813d74fa5
commit bad1c898e8
1 changed files with 2 additions and 7 deletions

View File

@ -108,7 +108,7 @@ static int __devinit da903x_led_probe(struct platform_device *pdev)
return -EINVAL;
}
led = kzalloc(sizeof(struct da903x_led), GFP_KERNEL);
led = devm_kzalloc(&pdev->dev, sizeof(struct da903x_led), GFP_KERNEL);
if (led == NULL) {
dev_err(&pdev->dev, "failed to alloc memory for LED%d\n", id);
return -ENOMEM;
@ -129,15 +129,11 @@ static int __devinit da903x_led_probe(struct platform_device *pdev)
ret = led_classdev_register(led->master, &led->cdev);
if (ret) {
dev_err(&pdev->dev, "failed to register LED %d\n", id);
goto err;
return ret;
}
platform_set_drvdata(pdev, led);
return 0;
err:
kfree(led);
return ret;
}
static int __devexit da903x_led_remove(struct platform_device *pdev)
@ -145,7 +141,6 @@ static int __devexit da903x_led_remove(struct platform_device *pdev)
struct da903x_led *led = platform_get_drvdata(pdev);
led_classdev_unregister(&led->cdev);
kfree(led);
return 0;
}