diff mbox

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

Message ID 1341316074-14886-4-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-pwm.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

Comments

Bryan Wu July 4, 2012, 3:03 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 branch.

-Bryan

> ---
>  drivers/leds/leds-pwm.c |    7 ++-----
>  1 files changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
> index 3ed92f3..f2e44c7 100644
> --- a/drivers/leds/leds-pwm.c
> +++ b/drivers/leds/leds-pwm.c
> @@ -57,7 +57,8 @@ static int led_pwm_probe(struct platform_device *pdev)
>         if (!pdata)
>                 return -EBUSY;
>
> -       leds_data = kzalloc(sizeof(struct led_pwm_data) * pdata->num_leds,
> +       leds_data = devm_kzalloc(&pdev->dev,
> +                       sizeof(struct led_pwm_data) * pdata->num_leds,
>                                 GFP_KERNEL);
>         if (!leds_data)
>                 return -ENOMEM;
> @@ -103,8 +104,6 @@ err:
>                 }
>         }
>
> -       kfree(leds_data);
> -
>         return ret;
>  }
>
> @@ -121,8 +120,6 @@ static int __devexit led_pwm_remove(struct platform_device *pdev)
>                 pwm_free(leds_data[i].pwm);
>         }
>
> -       kfree(leds_data);
> -
>         return 0;
>  }
>
> --
> 1.7.4.1
>
diff mbox

Patch

diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index 3ed92f3..f2e44c7 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -57,7 +57,8 @@  static int led_pwm_probe(struct platform_device *pdev)
 	if (!pdata)
 		return -EBUSY;
 
-	leds_data = kzalloc(sizeof(struct led_pwm_data) * pdata->num_leds,
+	leds_data = devm_kzalloc(&pdev->dev,
+			sizeof(struct led_pwm_data) * pdata->num_leds,
 				GFP_KERNEL);
 	if (!leds_data)
 		return -ENOMEM;
@@ -103,8 +104,6 @@  err:
 		}
 	}
 
-	kfree(leds_data);
-
 	return ret;
 }
 
@@ -121,8 +120,6 @@  static int __devexit led_pwm_remove(struct platform_device *pdev)
 		pwm_free(leds_data[i].pwm);
 	}
 
-	kfree(leds_data);
-
 	return 0;
 }