Re: [PATCH 2/7] backlight: ot200_bl: use devm_gpio_request()

From: Christian Gmeiner
Date: Wed Jun 13 2012 - 08:21:47 EST


2012/6/13 Jingoo Han <jg1.han@xxxxxxxxxxx>:
> The devm_ functions allocate memory that is released when a driver
> detaches. This patch uses devm_gpio_request 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 | Â Â9 +++------
> Â1 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/video/backlight/ot200_bl.c b/drivers/video/backlight/ot200_bl.c
> index ef637ff..469cf0f 100644
> --- a/drivers/video/backlight/ot200_bl.c
> +++ b/drivers/video/backlight/ot200_bl.c
> @@ -84,7 +84,8 @@ static int ot200_backlight_probe(struct platform_device *pdev)
> Â Â Â Âint retval = 0;
>
> Â Â Â Â/* request gpio */
> - Â Â Â if (gpio_request(GPIO_DIMM, "ot200 backlight dimmer") < 0) {
> + Â Â Â if (devm_gpio_request(&pdev->dev, GPIO_DIMM,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "ot200 backlight dimmer") < 0) {
> Â Â Â Â Â Â Â Âdev_err(&pdev->dev, "failed to request GPIO %d\n", GPIO_DIMM);
> Â Â Â Â Â Â Â Âreturn -ENODEV;
> Â Â Â Â}
> @@ -93,8 +94,7 @@ static int ot200_backlight_probe(struct platform_device *pdev)
> Â Â Â Âpwm_timer = cs5535_mfgpt_alloc_timer(7, MFGPT_DOMAIN_ANY);
> Â Â Â Âif (!pwm_timer) {
> Â Â Â Â Â Â Â Âdev_err(&pdev->dev, "MFGPT 7 not available\n");
> - Â Â Â Â Â Â Â retval = -ENODEV;
> - Â Â Â Â Â Â Â goto error_mfgpt_alloc;
> + Â Â Â Â Â Â Â return -ENODEV;
> Â Â Â Â}
>
> Â Â Â Âdata = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
> @@ -131,8 +131,6 @@ static int ot200_backlight_probe(struct platform_device *pdev)
>
> Âerror_devm_kzalloc:
> Â Â Â Âcs5535_mfgpt_free_timer(pwm_timer);
> -error_mfgpt_alloc:
> - Â Â Â gpio_free(GPIO_DIMM);
> Â Â Â Âreturn retval;
> Â}
>
> @@ -149,7 +147,6 @@ static int ot200_backlight_remove(struct platform_device *pdev)
> Â Â Â Â Â Â Â ÂMAX_COMP2 - dim_table[100]);
>
> Â Â Â Âcs5535_mfgpt_free_timer(pwm_timer);
> - Â Â Â gpio_free(GPIO_DIMM);
>
> Â Â Â Âreturn 0;
> Â}
> --
> 1.7.1
>

Acked-by: Christian Gmeiner <christian.gmeiner@xxxxxxxxx>
--
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/