aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2007-02-08 17:25:09 -0500
committerRichard Purdie <rpurdie@rpsys.net>2007-02-20 03:38:45 -0500
commit28ee086d5b36aab2931f6740e409bb0fb6c65e5f (patch)
tree0a308c80affcc39c2c869f29f1109e5ee9d6140f /arch/powerpc
parenta8db3c1948eb30cd6988b5b96b654f591e6280b1 (diff)
backlight: Fix external uses of backlight internal semaphore
backlight_device->sem has a very specific use as documented in the header file. The external users of this are using it for a different reason, to serialise access to the update_status() method. backlight users were supposed to implement their own internal serialisation of update_status() if needed but everyone is doing things differently and incorrectly. Therefore add a global mutex to take care of serialisation for everyone, once and for all. Locking for get_brightness remains optional since most users don't need it. Also update the lcd class in a similar way. Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/kernel/traps.c4
-rw-r--r--arch/powerpc/platforms/powermac/backlight.c19
2 files changed, 6 insertions, 17 deletions
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index dcc6f159fd94..35ce07b6a5bc 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -107,12 +107,10 @@ int die(const char *str, struct pt_regs *regs, long err)
107 if (machine_is(powermac) && pmac_backlight) { 107 if (machine_is(powermac) && pmac_backlight) {
108 struct backlight_properties *props; 108 struct backlight_properties *props;
109 109
110 down(&pmac_backlight->sem);
111 props = pmac_backlight->props; 110 props = pmac_backlight->props;
112 props->brightness = props->max_brightness; 111 props->brightness = props->max_brightness;
113 props->power = FB_BLANK_UNBLANK; 112 props->power = FB_BLANK_UNBLANK;
114 props->update_status(pmac_backlight); 113 backlight_update_status(pmac_backlight);
115 up(&pmac_backlight->sem);
116 } 114 }
117 mutex_unlock(&pmac_backlight_mutex); 115 mutex_unlock(&pmac_backlight_mutex);
118#endif 116#endif
diff --git a/arch/powerpc/platforms/powermac/backlight.c b/arch/powerpc/platforms/powermac/backlight.c
index c3a89414ddc0..1be358c1448a 100644
--- a/arch/powerpc/platforms/powermac/backlight.c
+++ b/arch/powerpc/platforms/powermac/backlight.c
@@ -37,7 +37,9 @@ static int pmac_backlight_set_legacy_queued;
37 */ 37 */
38static atomic_t kernel_backlight_disabled = ATOMIC_INIT(0); 38static atomic_t kernel_backlight_disabled = ATOMIC_INIT(0);
39 39
40/* Protect the pmac_backlight variable */ 40/* Protect the pmac_backlight variable below.
41 You should hold this lock when using the pmac_backlight pointer to
42 prevent its potential removal. */
41DEFINE_MUTEX(pmac_backlight_mutex); 43DEFINE_MUTEX(pmac_backlight_mutex);
42 44
43/* Main backlight storage 45/* Main backlight storage
@@ -49,9 +51,6 @@ DEFINE_MUTEX(pmac_backlight_mutex);
49 * internal display, it doesn't matter. Other backlight drivers can be used 51 * internal display, it doesn't matter. Other backlight drivers can be used
50 * independently. 52 * independently.
51 * 53 *
52 * Lock ordering:
53 * pmac_backlight_mutex (global, main backlight)
54 * pmac_backlight->sem (backlight class)
55 */ 54 */
56struct backlight_device *pmac_backlight; 55struct backlight_device *pmac_backlight;
57 56
@@ -104,7 +103,6 @@ static void pmac_backlight_key_worker(struct work_struct *work)
104 struct backlight_properties *props; 103 struct backlight_properties *props;
105 int brightness; 104 int brightness;
106 105
107 down(&pmac_backlight->sem);
108 props = pmac_backlight->props; 106 props = pmac_backlight->props;
109 107
110 brightness = props->brightness + 108 brightness = props->brightness +
@@ -117,9 +115,7 @@ static void pmac_backlight_key_worker(struct work_struct *work)
117 brightness = props->max_brightness; 115 brightness = props->max_brightness;
118 116
119 props->brightness = brightness; 117 props->brightness = brightness;
120 props->update_status(pmac_backlight); 118 backlight_update_status(pmac_backlight);
121
122 up(&pmac_backlight->sem);
123 } 119 }
124 mutex_unlock(&pmac_backlight_mutex); 120 mutex_unlock(&pmac_backlight_mutex);
125} 121}
@@ -145,7 +141,6 @@ static int __pmac_backlight_set_legacy_brightness(int brightness)
145 if (pmac_backlight) { 141 if (pmac_backlight) {
146 struct backlight_properties *props; 142 struct backlight_properties *props;
147 143
148 down(&pmac_backlight->sem);
149 props = pmac_backlight->props; 144 props = pmac_backlight->props;
150 props->brightness = brightness * 145 props->brightness = brightness *
151 (props->max_brightness + 1) / 146 (props->max_brightness + 1) /
@@ -156,8 +151,7 @@ static int __pmac_backlight_set_legacy_brightness(int brightness)
156 else if (props->brightness < 0) 151 else if (props->brightness < 0)
157 props->brightness = 0; 152 props->brightness = 0;
158 153
159 props->update_status(pmac_backlight); 154 backlight_update_status(pmac_backlight);
160 up(&pmac_backlight->sem);
161 155
162 error = 0; 156 error = 0;
163 } 157 }
@@ -196,14 +190,11 @@ int pmac_backlight_get_legacy_brightness()
196 if (pmac_backlight) { 190 if (pmac_backlight) {
197 struct backlight_properties *props; 191 struct backlight_properties *props;
198 192
199 down(&pmac_backlight->sem);
200 props = pmac_backlight->props; 193 props = pmac_backlight->props;
201 194
202 result = props->brightness * 195 result = props->brightness *
203 (OLD_BACKLIGHT_MAX + 1) / 196 (OLD_BACKLIGHT_MAX + 1) /
204 (props->max_brightness + 1); 197 (props->max_brightness + 1);
205
206 up(&pmac_backlight->sem);
207 } 198 }
208 mutex_unlock(&pmac_backlight_mutex); 199 mutex_unlock(&pmac_backlight_mutex);
209 200