diff mbox

[5/5] leds: Use devm_kzalloc in leds-regulator.c file

Message ID 1341316074-14886-5-git-send-email-sachin.kamat@linaro.org
State Accepted
Headers show

Commit Message

Sachin Kamat July 3, 2012, 11:47 a.m. UTC
devm_kzalloc() makes cleanup simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/leds/leds-regulator.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

Comments

Bryan Wu July 4, 2012, 3:08 a.m. UTC | #1
On Tue, Jul 3, 2012 at 7:47 PM, Sachin Kamat <sachin.kamat@linaro.org> wrote:
> devm_kzalloc() makes cleanup simpler.
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>

Thanks, applied to my for-next

-Bryan

> ---
>  drivers/leds/leds-regulator.c |    9 +++------
>  1 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/leds/leds-regulator.c b/drivers/leds/leds-regulator.c
> index df7e963..25d382d 100644
> --- a/drivers/leds/leds-regulator.c
> +++ b/drivers/leds/leds-regulator.c
> @@ -158,7 +158,7 @@ static int __devinit regulator_led_probe(struct platform_device *pdev)
>                 return PTR_ERR(vcc);
>         }
>
> -       led = kzalloc(sizeof(*led), GFP_KERNEL);
> +       led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
>         if (led == NULL) {
>                 ret = -ENOMEM;
>                 goto err_vcc;
> @@ -169,7 +169,7 @@ static int __devinit regulator_led_probe(struct platform_device *pdev)
>                 dev_err(&pdev->dev, "Invalid default brightness %d\n",
>                                 pdata->brightness);
>                 ret = -EINVAL;
> -               goto err_led;
> +               goto err_vcc;
>         }
>         led->value = pdata->brightness;
>
> @@ -190,7 +190,7 @@ static int __devinit regulator_led_probe(struct platform_device *pdev)
>         ret = led_classdev_register(&pdev->dev, &led->cdev);
>         if (ret < 0) {
>                 cancel_work_sync(&led->work);
> -               goto err_led;
> +               goto err_vcc;
>         }
>
>         /* to expose the default value to userspace */
> @@ -201,8 +201,6 @@ static int __devinit regulator_led_probe(struct platform_device *pdev)
>
>         return 0;
>
> -err_led:
> -       kfree(led);
>  err_vcc:
>         regulator_put(vcc);
>         return ret;
> @@ -216,7 +214,6 @@ static int __devexit regulator_led_remove(struct platform_device *pdev)
>         cancel_work_sync(&led->work);
>         regulator_led_disable(led);
>         regulator_put(led->vcc);
> -       kfree(led);
>         return 0;
>  }
>
> --
> 1.7.4.1
>
diff mbox

Patch

diff --git a/drivers/leds/leds-regulator.c b/drivers/leds/leds-regulator.c
index df7e963..25d382d 100644
--- a/drivers/leds/leds-regulator.c
+++ b/drivers/leds/leds-regulator.c
@@ -158,7 +158,7 @@  static int __devinit regulator_led_probe(struct platform_device *pdev)
 		return PTR_ERR(vcc);
 	}
 
-	led = kzalloc(sizeof(*led), GFP_KERNEL);
+	led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
 	if (led == NULL) {
 		ret = -ENOMEM;
 		goto err_vcc;
@@ -169,7 +169,7 @@  static int __devinit regulator_led_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "Invalid default brightness %d\n",
 				pdata->brightness);
 		ret = -EINVAL;
-		goto err_led;
+		goto err_vcc;
 	}
 	led->value = pdata->brightness;
 
@@ -190,7 +190,7 @@  static int __devinit regulator_led_probe(struct platform_device *pdev)
 	ret = led_classdev_register(&pdev->dev, &led->cdev);
 	if (ret < 0) {
 		cancel_work_sync(&led->work);
-		goto err_led;
+		goto err_vcc;
 	}
 
 	/* to expose the default value to userspace */
@@ -201,8 +201,6 @@  static int __devinit regulator_led_probe(struct platform_device *pdev)
 
 	return 0;
 
-err_led:
-	kfree(led);
 err_vcc:
 	regulator_put(vcc);
 	return ret;
@@ -216,7 +214,6 @@  static int __devexit regulator_led_remove(struct platform_device *pdev)
 	cancel_work_sync(&led->work);
 	regulator_led_disable(led);
 	regulator_put(led->vcc);
-	kfree(led);
 	return 0;
 }