Commit 050ea48bbfc80b6aa81f8df0d9f25e6e47d96e98

Authored by Julia Lawall
Committed by Linus Torvalds
1 parent ce969228fd

drivers/video/backlight/adp5520_bl.c: 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>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 1 additions and 5 deletions Side-by-side Diff

drivers/video/backlight/adp5520_bl.c
... ... @@ -289,7 +289,7 @@
289 289 struct adp5520_bl *data;
290 290 int ret = 0;
291 291  
292   - data = kzalloc(sizeof(*data), GFP_KERNEL);
  292 + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
293 293 if (data == NULL)
294 294 return -ENOMEM;
295 295  
... ... @@ -298,7 +298,6 @@
298 298  
299 299 if (data->pdata == NULL) {
300 300 dev_err(&pdev->dev, "missing platform data\n");
301   - kfree(data);
302 301 return -ENODEV;
303 302 }
304 303  
... ... @@ -314,7 +313,6 @@
314 313 &adp5520_bl_ops, &props);
315 314 if (IS_ERR(bl)) {
316 315 dev_err(&pdev->dev, "failed to register backlight\n");
317   - kfree(data);
318 316 return PTR_ERR(bl);
319 317 }
320 318  
... ... @@ -326,7 +324,6 @@
326 324 if (ret) {
327 325 dev_err(&pdev->dev, "failed to register sysfs\n");
328 326 backlight_device_unregister(bl);
329   - kfree(data);
330 327 }
331 328  
332 329 platform_set_drvdata(pdev, bl);
... ... @@ -348,7 +345,6 @@
348 345 &adp5520_bl_attr_group);
349 346  
350 347 backlight_device_unregister(bl);
351   - kfree(data);
352 348  
353 349 return 0;
354 350 }