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>
This commit is contained in:

committed by
Linus Torvalds

parent
1107d40a50
commit
ce969228fd
@@ -102,7 +102,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
pb = kzalloc(sizeof(*pb), GFP_KERNEL);
|
||||
pb = devm_kzalloc(&pdev->dev, sizeof(*pb), GFP_KERNEL);
|
||||
if (!pb) {
|
||||
dev_err(&pdev->dev, "no memory for state\n");
|
||||
ret = -ENOMEM;
|
||||
@@ -121,7 +121,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
|
||||
if (IS_ERR(pb->pwm)) {
|
||||
dev_err(&pdev->dev, "unable to request PWM for backlight\n");
|
||||
ret = PTR_ERR(pb->pwm);
|
||||
goto err_pwm;
|
||||
goto err_alloc;
|
||||
} else
|
||||
dev_dbg(&pdev->dev, "got pwm for backlight\n");
|
||||
|
||||
@@ -144,8 +144,6 @@ static int pwm_backlight_probe(struct platform_device *pdev)
|
||||
|
||||
err_bl:
|
||||
pwm_free(pb->pwm);
|
||||
err_pwm:
|
||||
kfree(pb);
|
||||
err_alloc:
|
||||
if (data->exit)
|
||||
data->exit(&pdev->dev);
|
||||
@@ -162,7 +160,6 @@ static int pwm_backlight_remove(struct platform_device *pdev)
|
||||
pwm_config(pb->pwm, 0, pb->period);
|
||||
pwm_disable(pb->pwm);
|
||||
pwm_free(pb->pwm);
|
||||
kfree(pb);
|
||||
if (data->exit)
|
||||
data->exit(&pdev->dev);
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user