* [PATCH v2 2/3][RESEND] backlight: ot200_bl: use devm_ functions
@ 2012-05-29 0:00 Jingoo Han
0 siblings, 0 replies; 5+ messages in thread
From: Jingoo Han @ 2012-05-29 0:00 UTC (permalink / raw)
To: 'Andrew Morton', 'LKML'
Cc: 'Richard Purdie', 'Christian Gmeiner',
'Jingoo Han'
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@gmail.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
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
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 2/3][RESEND] backlight: ot200_bl: use devm_ functions
@ 2012-06-11 0:11 Jingoo Han
2012-06-12 6:17 ` Christian Gmeiner
2012-06-12 6:25 ` Axel Lin
0 siblings, 2 replies; 5+ messages in thread
From: Jingoo Han @ 2012-06-11 0:11 UTC (permalink / raw)
To: 'Andrew Morton', 'LKML'
Cc: 'Richard Purdie', 'Christian Gmeiner',
'Jingoo Han'
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@gmail.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2 2/3][RESEND] backlight: ot200_bl: use devm_ functions
2012-06-11 0:11 Jingoo Han
@ 2012-06-12 6:17 ` Christian Gmeiner
2012-06-12 6:25 ` Axel Lin
1 sibling, 0 replies; 5+ messages in thread
From: Christian Gmeiner @ 2012-06-12 6:17 UTC (permalink / raw)
To: Jingoo Han; +Cc: Andrew Morton, LKML, Richard Purdie
looks fine
Acked-by: Christian Gmeiner <christian.gmeiner@gmail.com>
---
Christian Gmeiner, MSc
2012/6/11 Jingoo Han <jg1.han@samsung.com>:
> 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@gmail.com>
> Cc: Richard Purdie <rpurdie@rpsys.net>
> Signed-off-by: Jingoo Han <jg1.han@samsung.com>
> ---
> 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
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2 2/3][RESEND] backlight: ot200_bl: use devm_ functions
2012-06-11 0:11 Jingoo Han
2012-06-12 6:17 ` Christian Gmeiner
@ 2012-06-12 6:25 ` Axel Lin
2012-06-12 7:50 ` Christian Gmeiner
1 sibling, 1 reply; 5+ messages in thread
From: Axel Lin @ 2012-06-12 6:25 UTC (permalink / raw)
To: Jingoo Han; +Cc: Andrew Morton, LKML, Richard Purdie, Christian Gmeiner
> error_mfgpt_alloc:
> gpio_free(GPIO_DIMM);
You can also use devm_gpio_request, so you can remove gpio_free here
and remove the gpio_free in ot200_backlight_remove().
> @@ -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;
> }
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2 2/3][RESEND] backlight: ot200_bl: use devm_ functions
2012-06-12 6:25 ` Axel Lin
@ 2012-06-12 7:50 ` Christian Gmeiner
0 siblings, 0 replies; 5+ messages in thread
From: Christian Gmeiner @ 2012-06-12 7:50 UTC (permalink / raw)
To: axel.lin; +Cc: Jingoo Han, Andrew Morton, LKML, Richard Purdie
2012/6/12 Axel Lin <axel.lin@gmail.com>:
>> error_mfgpt_alloc:
>> gpio_free(GPIO_DIMM);
>
> You can also use devm_gpio_request, so you can remove gpio_free here
> and remove the gpio_free in ot200_backlight_remove().
nice catch
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-06-12 7:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-29 0:00 [PATCH v2 2/3][RESEND] backlight: ot200_bl: use devm_ functions Jingoo Han
2012-06-11 0:11 Jingoo Han
2012-06-12 6:17 ` Christian Gmeiner
2012-06-12 6:25 ` Axel Lin
2012-06-12 7:50 ` Christian Gmeiner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®