Re: [PATCH v2 2/3][RESEND] backlight: ot200_bl: use devm_ functions

From: Christian Gmeiner
Date: Tue Jun 12 2012 - 02:18:21 EST


looks fine

Acked-by: Christian Gmeiner <christian.gmeiner@xxxxxxxxx>

---
Christian Gmeiner, MSc


2012/6/11 Jingoo Han <jg1.han@xxxxxxxxxxx>:
> The devm_ functions allocate memory that is released when a driver
> detaches. This patch uses devm_kzalloc of these functions
>
> Cc: Christian Gmeiner <christian.gmeiner@xxxxxxxxx>
> Cc: Richard Purdie <rpurdie@xxxxxxxxx>
> Signed-off-by: Jingoo Han <jg1.han@xxxxxxxxxxx>
> ---
> Âdrivers/video/backlight/ot200_bl.c | Â 12 ++++--------
> Â1 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/video/backlight/ot200_bl.c b/drivers/video/backlight/ot200_bl.c
> index f519d55..ef637ff 100644
> --- a/drivers/video/backlight/ot200_bl.c
> +++ b/drivers/video/backlight/ot200_bl.c
> @@ -97,10 +97,10 @@ static int ot200_backlight_probe(struct platform_device *pdev)
> Â Â Â Â Â Â Â Âgoto error_mfgpt_alloc;
> Â Â Â Â}
>
> - Â Â Â data = kzalloc(sizeof(*data), GFP_KERNEL);
> + Â Â Â data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
> Â Â Â Âif (!data) {
> Â Â Â Â Â Â Â Âretval = -ENOMEM;
> - Â Â Â Â Â Â Â goto error_kzalloc;
> + Â Â Â Â Â Â Â goto error_devm_kzalloc;
> Â Â Â Â}
>
> Â Â Â Â/* setup gpio */
> @@ -122,16 +122,14 @@ static int ot200_backlight_probe(struct platform_device *pdev)
> Â Â Â Âif (IS_ERR(bl)) {
> Â Â Â Â Â Â Â Âdev_err(&pdev->dev, "failed to register backlight\n");
> Â Â Â Â Â Â Â Âretval = PTR_ERR(bl);
> - Â Â Â Â Â Â Â goto error_backlight_device_register;
> + Â Â Â Â Â Â Â goto error_devm_kzalloc;
> Â Â Â Â}
>
> Â Â Â Âplatform_set_drvdata(pdev, bl);
>
> Â Â Â Âreturn 0;
>
> -error_backlight_device_register:
> - Â Â Â kfree(data);
> -error_kzalloc:
> +error_devm_kzalloc:
> Â Â Â Âcs5535_mfgpt_free_timer(pwm_timer);
> Âerror_mfgpt_alloc:
> Â Â Â Âgpio_free(GPIO_DIMM);
> @@ -141,7 +139,6 @@ error_mfgpt_alloc:
> Âstatic int ot200_backlight_remove(struct platform_device *pdev)
> Â{
> Â Â Â Âstruct backlight_device *bl = platform_get_drvdata(pdev);
> - Â Â Â struct ot200_backlight_data *data = bl_get_data(bl);
>
> Â Â Â Âbacklight_device_unregister(bl);
>
> @@ -154,7 +151,6 @@ static int ot200_backlight_remove(struct platform_device *pdev)
> Â Â Â Âcs5535_mfgpt_free_timer(pwm_timer);
> Â Â Â Âgpio_free(GPIO_DIMM);
>
> - Â Â Â kfree(data);
> Â Â Â Âreturn 0;
> Â}
>
> --
> 1.7.1
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/