* [PATCH 01/13] backlight: adp8860: use devm_ functions
@ 2012-05-25 2:16 Jingoo Han
2012-05-25 6:42 ` Michael Hennerich
0 siblings, 1 reply; 2+ messages in thread
From: Jingoo Han @ 2012-05-25 2:16 UTC (permalink / raw)
To: 'Andrew Morton', 'LKML'
Cc: 'Richard Purdie', 'Michael Hennerich',
'Jingoo Han'
The devm_ functions allocate memory that is released when a driver
detaches. This patch uses devm_kzalloc of these functions.
Cc: Michael Hennerich <michael.hennerich@analog.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/video/backlight/adp8860_bl.c | 22 +++++++---------------
1 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
index 550dbf0..48af78f 100644
--- a/drivers/video/backlight/adp8860_bl.c
+++ b/drivers/video/backlight/adp8860_bl.c
@@ -222,7 +222,8 @@ static int __devinit adp8860_led_probe(struct i2c_client *client)
struct led_info *cur_led;
int ret, i;
- led = kzalloc(sizeof(*led) * pdata->num_leds, GFP_KERNEL);
+ led = devm_kzalloc(&client->dev, sizeof(*led) * pdata->num_leds,
+ GFP_KERNEL);
if (led == NULL) {
dev_err(&client->dev, "failed to alloc memory\n");
return -ENOMEM;
@@ -236,7 +237,7 @@ static int __devinit adp8860_led_probe(struct i2c_client *client)
if (ret) {
dev_err(&client->dev, "failed to write\n");
- goto err_free;
+ return ret;
}
for (i = 0; i < pdata->num_leds; ++i) {
@@ -291,9 +292,6 @@ static int __devinit adp8860_led_probe(struct i2c_client *client)
cancel_work_sync(&led[i].work);
}
- err_free:
- kfree(led);
-
return ret;
}
@@ -309,7 +307,6 @@ static int __devexit adp8860_led_remove(struct i2c_client *client)
cancel_work_sync(&data->led[i].work);
}
- kfree(data->led);
return 0;
}
#else
@@ -675,13 +672,13 @@ static int __devinit adp8860_probe(struct i2c_client *client,
return -EINVAL;
}
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
if (data == NULL)
return -ENOMEM;
ret = adp8860_read(client, ADP8860_MFDVID, ®_val);
if (ret < 0)
- goto out2;
+ return ret;
switch (ADP8860_MANID(reg_val)) {
case ADP8863_MANUFID:
@@ -694,8 +691,7 @@ static int __devinit adp8860_probe(struct i2c_client *client,
break;
default:
dev_err(&client->dev, "failed to probe\n");
- ret = -ENODEV;
- goto out2;
+ return -ENODEV;
}
/* It's confirmed that the DEVID field is actually a REVID */
@@ -717,8 +713,7 @@ static int __devinit adp8860_probe(struct i2c_client *client,
&client->dev, data, &adp8860_bl_ops, &props);
if (IS_ERR(bl)) {
dev_err(&client->dev, "failed to register backlight\n");
- ret = PTR_ERR(bl);
- goto out2;
+ return PTR_ERR(bl);
}
bl->props.brightness = ADP8860_MAX_BRIGHTNESS;
@@ -756,8 +751,6 @@ out:
&adp8860_bl_attr_group);
out1:
backlight_device_unregister(bl);
-out2:
- kfree(data);
return ret;
}
@@ -776,7 +769,6 @@ static int __devexit adp8860_remove(struct i2c_client *client)
&adp8860_bl_attr_group);
backlight_device_unregister(data->bl);
- kfree(data);
return 0;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH 01/13] backlight: adp8860: use devm_ functions
2012-05-25 2:16 [PATCH 01/13] backlight: adp8860: use devm_ functions Jingoo Han
@ 2012-05-25 6:42 ` Michael Hennerich
0 siblings, 0 replies; 2+ messages in thread
From: Michael Hennerich @ 2012-05-25 6:42 UTC (permalink / raw)
To: Jingoo Han
Cc: 'Andrew Morton', 'LKML', 'Richard Purdie'
On 05/25/2012 04:16 AM, Jingoo Han wrote:
> The devm_ functions allocate memory that is released when a driver
> detaches. This patch uses devm_kzalloc of these functions.
>
> Cc: Michael Hennerich<michael.hennerich@analog.com>
> Cc: Richard Purdie<rpurdie@rpsys.net>
> Signed-off-by: Jingoo Han<jg1.han@samsung.com>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
> ---
> drivers/video/backlight/adp8860_bl.c | 22 +++++++---------------
> 1 files changed, 7 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
> index 550dbf0..48af78f 100644
> --- a/drivers/video/backlight/adp8860_bl.c
> +++ b/drivers/video/backlight/adp8860_bl.c
> @@ -222,7 +222,8 @@ static int __devinit adp8860_led_probe(struct i2c_client *client)
> struct led_info *cur_led;
> int ret, i;
>
> - led = kzalloc(sizeof(*led) * pdata->num_leds, GFP_KERNEL);
> + led = devm_kzalloc(&client->dev, sizeof(*led) * pdata->num_leds,
> + GFP_KERNEL);
> if (led == NULL) {
> dev_err(&client->dev, "failed to alloc memory\n");
> return -ENOMEM;
> @@ -236,7 +237,7 @@ static int __devinit adp8860_led_probe(struct i2c_client *client)
>
> if (ret) {
> dev_err(&client->dev, "failed to write\n");
> - goto err_free;
> + return ret;
> }
>
> for (i = 0; i< pdata->num_leds; ++i) {
> @@ -291,9 +292,6 @@ static int __devinit adp8860_led_probe(struct i2c_client *client)
> cancel_work_sync(&led[i].work);
> }
>
> - err_free:
> - kfree(led);
> -
> return ret;
> }
>
> @@ -309,7 +307,6 @@ static int __devexit adp8860_led_remove(struct i2c_client *client)
> cancel_work_sync(&data->led[i].work);
> }
>
> - kfree(data->led);
> return 0;
> }
> #else
> @@ -675,13 +672,13 @@ static int __devinit adp8860_probe(struct i2c_client *client,
> return -EINVAL;
> }
>
> - data = kzalloc(sizeof(*data), GFP_KERNEL);
> + data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
> if (data == NULL)
> return -ENOMEM;
>
> ret = adp8860_read(client, ADP8860_MFDVID,®_val);
> if (ret< 0)
> - goto out2;
> + return ret;
>
> switch (ADP8860_MANID(reg_val)) {
> case ADP8863_MANUFID:
> @@ -694,8 +691,7 @@ static int __devinit adp8860_probe(struct i2c_client *client,
> break;
> default:
> dev_err(&client->dev, "failed to probe\n");
> - ret = -ENODEV;
> - goto out2;
> + return -ENODEV;
> }
>
> /* It's confirmed that the DEVID field is actually a REVID */
> @@ -717,8 +713,7 @@ static int __devinit adp8860_probe(struct i2c_client *client,
> &client->dev, data,&adp8860_bl_ops,&props);
> if (IS_ERR(bl)) {
> dev_err(&client->dev, "failed to register backlight\n");
> - ret = PTR_ERR(bl);
> - goto out2;
> + return PTR_ERR(bl);
> }
>
> bl->props.brightness = ADP8860_MAX_BRIGHTNESS;
> @@ -756,8 +751,6 @@ out:
> &adp8860_bl_attr_group);
> out1:
> backlight_device_unregister(bl);
> -out2:
> - kfree(data);
>
> return ret;
> }
> @@ -776,7 +769,6 @@ static int __devexit adp8860_remove(struct i2c_client *client)
> &adp8860_bl_attr_group);
>
> backlight_device_unregister(data->bl);
> - kfree(data);
>
> return 0;
> }
--
Greetings,
Michael
--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin,
Margaret Seif
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-05-25 6:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-25 2:16 [PATCH 01/13] backlight: adp8860: use devm_ functions Jingoo Han
2012-05-25 6:42 ` Michael Hennerich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox