diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /drivers/video/backlight/pwm_bl.c | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/video/backlight/pwm_bl.c')
-rw-r--r-- | drivers/video/backlight/pwm_bl.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 887166267443..550443518891 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c | |||
@@ -19,11 +19,14 @@ | |||
19 | #include <linux/err.h> | 19 | #include <linux/err.h> |
20 | #include <linux/pwm.h> | 20 | #include <linux/pwm.h> |
21 | #include <linux/pwm_backlight.h> | 21 | #include <linux/pwm_backlight.h> |
22 | #include <linux/slab.h> | ||
22 | 23 | ||
23 | struct pwm_bl_data { | 24 | struct pwm_bl_data { |
24 | struct pwm_device *pwm; | 25 | struct pwm_device *pwm; |
26 | struct device *dev; | ||
25 | unsigned int period; | 27 | unsigned int period; |
26 | int (*notify)(int brightness); | 28 | int (*notify)(struct device *, |
29 | int brightness); | ||
27 | }; | 30 | }; |
28 | 31 | ||
29 | static int pwm_backlight_update_status(struct backlight_device *bl) | 32 | static int pwm_backlight_update_status(struct backlight_device *bl) |
@@ -39,7 +42,7 @@ static int pwm_backlight_update_status(struct backlight_device *bl) | |||
39 | brightness = 0; | 42 | brightness = 0; |
40 | 43 | ||
41 | if (pb->notify) | 44 | if (pb->notify) |
42 | brightness = pb->notify(brightness); | 45 | brightness = pb->notify(pb->dev, brightness); |
43 | 46 | ||
44 | if (brightness == 0) { | 47 | if (brightness == 0) { |
45 | pwm_config(pb->pwm, 0, pb->period); | 48 | pwm_config(pb->pwm, 0, pb->period); |
@@ -56,13 +59,14 @@ static int pwm_backlight_get_brightness(struct backlight_device *bl) | |||
56 | return bl->props.brightness; | 59 | return bl->props.brightness; |
57 | } | 60 | } |
58 | 61 | ||
59 | static struct backlight_ops pwm_backlight_ops = { | 62 | static const struct backlight_ops pwm_backlight_ops = { |
60 | .update_status = pwm_backlight_update_status, | 63 | .update_status = pwm_backlight_update_status, |
61 | .get_brightness = pwm_backlight_get_brightness, | 64 | .get_brightness = pwm_backlight_get_brightness, |
62 | }; | 65 | }; |
63 | 66 | ||
64 | static int pwm_backlight_probe(struct platform_device *pdev) | 67 | static int pwm_backlight_probe(struct platform_device *pdev) |
65 | { | 68 | { |
69 | struct backlight_properties props; | ||
66 | struct platform_pwm_backlight_data *data = pdev->dev.platform_data; | 70 | struct platform_pwm_backlight_data *data = pdev->dev.platform_data; |
67 | struct backlight_device *bl; | 71 | struct backlight_device *bl; |
68 | struct pwm_bl_data *pb; | 72 | struct pwm_bl_data *pb; |
@@ -88,6 +92,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
88 | 92 | ||
89 | pb->period = data->pwm_period_ns; | 93 | pb->period = data->pwm_period_ns; |
90 | pb->notify = data->notify; | 94 | pb->notify = data->notify; |
95 | pb->dev = &pdev->dev; | ||
91 | 96 | ||
92 | pb->pwm = pwm_request(data->pwm_id, "backlight"); | 97 | pb->pwm = pwm_request(data->pwm_id, "backlight"); |
93 | if (IS_ERR(pb->pwm)) { | 98 | if (IS_ERR(pb->pwm)) { |
@@ -97,15 +102,16 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
97 | } else | 102 | } else |
98 | dev_dbg(&pdev->dev, "got pwm for backlight\n"); | 103 | dev_dbg(&pdev->dev, "got pwm for backlight\n"); |
99 | 104 | ||
100 | bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, | 105 | memset(&props, 0, sizeof(struct backlight_properties)); |
101 | pb, &pwm_backlight_ops); | 106 | props.max_brightness = data->max_brightness; |
107 | bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb, | ||
108 | &pwm_backlight_ops, &props); | ||
102 | if (IS_ERR(bl)) { | 109 | if (IS_ERR(bl)) { |
103 | dev_err(&pdev->dev, "failed to register backlight\n"); | 110 | dev_err(&pdev->dev, "failed to register backlight\n"); |
104 | ret = PTR_ERR(bl); | 111 | ret = PTR_ERR(bl); |
105 | goto err_bl; | 112 | goto err_bl; |
106 | } | 113 | } |
107 | 114 | ||
108 | bl->props.max_brightness = data->max_brightness; | ||
109 | bl->props.brightness = data->dft_brightness; | 115 | bl->props.brightness = data->dft_brightness; |
110 | backlight_update_status(bl); | 116 | backlight_update_status(bl); |
111 | 117 | ||
@@ -146,7 +152,7 @@ static int pwm_backlight_suspend(struct platform_device *pdev, | |||
146 | struct pwm_bl_data *pb = dev_get_drvdata(&bl->dev); | 152 | struct pwm_bl_data *pb = dev_get_drvdata(&bl->dev); |
147 | 153 | ||
148 | if (pb->notify) | 154 | if (pb->notify) |
149 | pb->notify(0); | 155 | pb->notify(pb->dev, 0); |
150 | pwm_config(pb->pwm, 0, pb->period); | 156 | pwm_config(pb->pwm, 0, pb->period); |
151 | pwm_disable(pb->pwm); | 157 | pwm_disable(pb->pwm); |
152 | return 0; | 158 | return 0; |