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/pwm_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/pwm_bl.c')
-rw-r--r-- | drivers/video/backlight/pwm_bl.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 7496d04e1d3..342b7d7cbb6 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c | |||
@@ -102,7 +102,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
102 | return ret; | 102 | return ret; |
103 | } | 103 | } |
104 | 104 | ||
105 | pb = kzalloc(sizeof(*pb), GFP_KERNEL); | 105 | pb = devm_kzalloc(&pdev->dev, sizeof(*pb), GFP_KERNEL); |
106 | if (!pb) { | 106 | if (!pb) { |
107 | dev_err(&pdev->dev, "no memory for state\n"); | 107 | dev_err(&pdev->dev, "no memory for state\n"); |
108 | ret = -ENOMEM; | 108 | ret = -ENOMEM; |
@@ -121,7 +121,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
121 | if (IS_ERR(pb->pwm)) { | 121 | if (IS_ERR(pb->pwm)) { |
122 | dev_err(&pdev->dev, "unable to request PWM for backlight\n"); | 122 | dev_err(&pdev->dev, "unable to request PWM for backlight\n"); |
123 | ret = PTR_ERR(pb->pwm); | 123 | ret = PTR_ERR(pb->pwm); |
124 | goto err_pwm; | 124 | goto err_alloc; |
125 | } else | 125 | } else |
126 | dev_dbg(&pdev->dev, "got pwm for backlight\n"); | 126 | dev_dbg(&pdev->dev, "got pwm for backlight\n"); |
127 | 127 | ||
@@ -144,8 +144,6 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
144 | 144 | ||
145 | err_bl: | 145 | err_bl: |
146 | pwm_free(pb->pwm); | 146 | pwm_free(pb->pwm); |
147 | err_pwm: | ||
148 | kfree(pb); | ||
149 | err_alloc: | 147 | err_alloc: |
150 | if (data->exit) | 148 | if (data->exit) |
151 | data->exit(&pdev->dev); | 149 | data->exit(&pdev->dev); |
@@ -162,7 +160,6 @@ static int pwm_backlight_remove(struct platform_device *pdev) | |||
162 | pwm_config(pb->pwm, 0, pb->period); | 160 | pwm_config(pb->pwm, 0, pb->period); |
163 | pwm_disable(pb->pwm); | 161 | pwm_disable(pb->pwm); |
164 | pwm_free(pb->pwm); | 162 | pwm_free(pb->pwm); |
165 | kfree(pb); | ||
166 | if (data->exit) | 163 | if (data->exit) |
167 | data->exit(&pdev->dev); | 164 | data->exit(&pdev->dev); |
168 | return 0; | 165 | return 0; |