From: Bryan Wu Date: Tue, 3 Jul 2012 05:07:53 +0000 (+0800) Subject: leds: convert DA9030/DA9034 LED driver to devm_kzalloc() and cleanup error exit path X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bad1c898e8b70c644c6542f79802326cc7b11c77;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git leds: convert DA9030/DA9034 LED driver to devm_kzalloc() and cleanup error exit path Cc: Eric Miao Signed-off-by: Bryan Wu --- diff --git a/drivers/leds/leds-da903x.c b/drivers/leds/leds-da903x.c index d9cd73ebd6c4..cc77c9d92615 100644 --- a/drivers/leds/leds-da903x.c +++ b/drivers/leds/leds-da903x.c @@ -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; }