diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2012-03-23 18:02:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-23 19:58:33 -0400 |
commit | ce969228fdb54a7e3d7cc1ed27367fd4b9525d74 (patch) | |
tree | 9850c7cc96d582302769c442e00142ac30a7bbc3 /drivers/video/backlight/88pm860x_bl.c | |
parent | 1107d40a50956146d1272f5cffcdf1d83f7e703e (diff) |
drivers/video/backlight: use devm_ functions
The various devm_ functions allocate memory that is released when a driver
detaches. This patch uses these functions for data that is allocated in
the probe function of a platform device and is only freed in the remove
function.
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/backlight/88pm860x_bl.c')
-rw-r--r-- | drivers/video/backlight/88pm860x_bl.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c index a1376dc73d71..915943af3f21 100644 --- a/drivers/video/backlight/88pm860x_bl.c +++ b/drivers/video/backlight/88pm860x_bl.c | |||
@@ -187,7 +187,8 @@ static int pm860x_backlight_probe(struct platform_device *pdev) | |||
187 | return -EINVAL; | 187 | return -EINVAL; |
188 | } | 188 | } |
189 | 189 | ||
190 | data = kzalloc(sizeof(struct pm860x_backlight_data), GFP_KERNEL); | 190 | data = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_backlight_data), |
191 | GFP_KERNEL); | ||
191 | if (data == NULL) | 192 | if (data == NULL) |
192 | return -ENOMEM; | 193 | return -ENOMEM; |
193 | strncpy(name, res->name, MFD_NAME_SIZE); | 194 | strncpy(name, res->name, MFD_NAME_SIZE); |
@@ -200,7 +201,6 @@ static int pm860x_backlight_probe(struct platform_device *pdev) | |||
200 | data->port = pdata->flags; | 201 | data->port = pdata->flags; |
201 | if (data->port < 0) { | 202 | if (data->port < 0) { |
202 | dev_err(&pdev->dev, "wrong platform data is assigned"); | 203 | dev_err(&pdev->dev, "wrong platform data is assigned"); |
203 | kfree(data); | ||
204 | return -EINVAL; | 204 | return -EINVAL; |
205 | } | 205 | } |
206 | 206 | ||
@@ -211,7 +211,6 @@ static int pm860x_backlight_probe(struct platform_device *pdev) | |||
211 | &pm860x_backlight_ops, &props); | 211 | &pm860x_backlight_ops, &props); |
212 | if (IS_ERR(bl)) { | 212 | if (IS_ERR(bl)) { |
213 | dev_err(&pdev->dev, "failed to register backlight\n"); | 213 | dev_err(&pdev->dev, "failed to register backlight\n"); |
214 | kfree(data); | ||
215 | return PTR_ERR(bl); | 214 | return PTR_ERR(bl); |
216 | } | 215 | } |
217 | bl->props.brightness = MAX_BRIGHTNESS; | 216 | bl->props.brightness = MAX_BRIGHTNESS; |
@@ -247,17 +246,14 @@ static int pm860x_backlight_probe(struct platform_device *pdev) | |||
247 | return 0; | 246 | return 0; |
248 | out: | 247 | out: |
249 | backlight_device_unregister(bl); | 248 | backlight_device_unregister(bl); |
250 | kfree(data); | ||
251 | return ret; | 249 | return ret; |
252 | } | 250 | } |
253 | 251 | ||
254 | static int pm860x_backlight_remove(struct platform_device *pdev) | 252 | static int pm860x_backlight_remove(struct platform_device *pdev) |
255 | { | 253 | { |
256 | struct backlight_device *bl = platform_get_drvdata(pdev); | 254 | struct backlight_device *bl = platform_get_drvdata(pdev); |
257 | struct pm860x_backlight_data *data = bl_get_data(bl); | ||
258 | 255 | ||
259 | backlight_device_unregister(bl); | 256 | backlight_device_unregister(bl); |
260 | kfree(data); | ||
261 | return 0; | 257 | return 0; |
262 | } | 258 | } |
263 | 259 | ||