aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/backlight
diff options
context:
space:
mode:
authorVladimir Zapolskiy <vladimir_zapolskiy@mentor.com>2014-10-11 09:46:26 -0400
committerLee Jones <lee.jones@linaro.org>2014-11-10 09:42:18 -0500
commitedf387b6d1a6993103ec95ed934a6daf559535f4 (patch)
tree2510d4c001381b7eefcdcdd0a2bf16b77c00f579 /drivers/video/backlight
parent0df1f2487d2f0d04703f142813d53615d62a1da4 (diff)
backlight: pwm: Clean-up pwm requested using legacy API
If PWM device is requested by means of legacy API pwm_request(), its resources are not freed on module unbind, which may cause an oops on access, e.g. by reading /sys/kernel/debug/pwm. Reported-by: Dmitry Eremin-Solenikov <dmitry_eremin@mentor.com> Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/video/backlight')
-rw-r--r--drivers/video/backlight/pwm_bl.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index cb5ae4c08469..3a145a643e0d 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -34,6 +34,7 @@ struct pwm_bl_data {
34 struct regulator *power_supply; 34 struct regulator *power_supply;
35 struct gpio_desc *enable_gpio; 35 struct gpio_desc *enable_gpio;
36 unsigned int scale; 36 unsigned int scale;
37 bool legacy;
37 int (*notify)(struct device *, 38 int (*notify)(struct device *,
38 int brightness); 39 int brightness);
39 void (*notify_after)(struct device *, 40 void (*notify_after)(struct device *,
@@ -274,7 +275,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
274 pb->pwm = devm_pwm_get(&pdev->dev, NULL); 275 pb->pwm = devm_pwm_get(&pdev->dev, NULL);
275 if (IS_ERR(pb->pwm)) { 276 if (IS_ERR(pb->pwm)) {
276 dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n"); 277 dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n");
277 278 pb->legacy = true;
278 pb->pwm = pwm_request(data->pwm_id, "pwm-backlight"); 279 pb->pwm = pwm_request(data->pwm_id, "pwm-backlight");
279 if (IS_ERR(pb->pwm)) { 280 if (IS_ERR(pb->pwm)) {
280 dev_err(&pdev->dev, "unable to request legacy PWM\n"); 281 dev_err(&pdev->dev, "unable to request legacy PWM\n");
@@ -339,6 +340,8 @@ static int pwm_backlight_remove(struct platform_device *pdev)
339 340
340 if (pb->exit) 341 if (pb->exit)
341 pb->exit(&pdev->dev); 342 pb->exit(&pdev->dev);
343 if (pb->legacy)
344 pwm_free(pb->pwm);
342 345
343 return 0; 346 return 0;
344} 347}