aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorMichael Hanselmann <linux-kernel@hansmi.ch>2006-07-10 07:44:45 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-07-10 16:24:20 -0400
commite01af0384f54023b4548b7742952da2ffcafd4cd (patch)
tree6ffd14821a0a1fedbf4430c5df7fa60822f4809f /arch/powerpc
parent58d383a6222d66be9483598c51bae34e7d3c2c37 (diff)
[PATCH] powermac: Combined fixes for backlight code
This patch fixes several problems: - pmac_backlight_key() is called under interrupt context, and therefore can't use mutexes or semaphores, so defer the backlight level for later, as it's not critical (original code by Aristeu S. Rozanski F. <aris@valeta.org>). - Add exports for functions that might be called from modules - Fix Kconfig depdencies on PMAC_BACKLIGHT. - Fix locking issues on calls from inside the driver (reported by Aristeu S. Rozanski F., too) - Fix wrong calculation of backlight values in some of the drivers - Replace pmac_backlight_key_up/down by inline functions [akpm@osdl.org: fix function prototypes] Signed-off-by: Michael Hanselmann <linux-kernel@hansmi.ch> Acked-by: Aristeu S. Rozanski F. <aris@valeta.org> Acked-by: Rene Nussbaumer <linux-kernel@killerfox.forkbomb.ch> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/platforms/powermac/backlight.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/arch/powerpc/platforms/powermac/backlight.c b/arch/powerpc/platforms/powermac/backlight.c
index 69f65e215a5c..74eed6b74cd6 100644
--- a/arch/powerpc/platforms/powermac/backlight.c
+++ b/arch/powerpc/platforms/powermac/backlight.c
@@ -15,6 +15,15 @@
15 15
16#define OLD_BACKLIGHT_MAX 15 16#define OLD_BACKLIGHT_MAX 15
17 17
18static void pmac_backlight_key_worker(void *data);
19static DECLARE_WORK(pmac_backlight_key_work, pmac_backlight_key_worker, NULL);
20
21/* Although this variable is used in interrupt context, it makes no sense to
22 * protect it. No user is able to produce enough key events per second and
23 * notice the errors that might happen.
24 */
25static int pmac_backlight_key_queued;
26
18/* Protect the pmac_backlight variable */ 27/* Protect the pmac_backlight variable */
19DEFINE_MUTEX(pmac_backlight_mutex); 28DEFINE_MUTEX(pmac_backlight_mutex);
20 29
@@ -71,7 +80,7 @@ int pmac_backlight_curve_lookup(struct fb_info *info, int value)
71 return level; 80 return level;
72} 81}
73 82
74static void pmac_backlight_key(int direction) 83static void pmac_backlight_key_worker(void *data)
75{ 84{
76 mutex_lock(&pmac_backlight_mutex); 85 mutex_lock(&pmac_backlight_mutex);
77 if (pmac_backlight) { 86 if (pmac_backlight) {
@@ -82,7 +91,8 @@ static void pmac_backlight_key(int direction)
82 props = pmac_backlight->props; 91 props = pmac_backlight->props;
83 92
84 brightness = props->brightness + 93 brightness = props->brightness +
85 ((direction?-1:1) * (props->max_brightness / 15)); 94 ((pmac_backlight_key_queued?-1:1) *
95 (props->max_brightness / 15));
86 96
87 if (brightness < 0) 97 if (brightness < 0)
88 brightness = 0; 98 brightness = 0;
@@ -97,14 +107,13 @@ static void pmac_backlight_key(int direction)
97 mutex_unlock(&pmac_backlight_mutex); 107 mutex_unlock(&pmac_backlight_mutex);
98} 108}
99 109
100void pmac_backlight_key_up() 110void pmac_backlight_key(int direction)
101{ 111{
102 pmac_backlight_key(0); 112 /* we can receive multiple interrupts here, but the scheduled work
103} 113 * will run only once, with the last value
104 114 */
105void pmac_backlight_key_down() 115 pmac_backlight_key_queued = direction;
106{ 116 schedule_work(&pmac_backlight_key_work);
107 pmac_backlight_key(1);
108} 117}
109 118
110int pmac_backlight_set_legacy_brightness(int brightness) 119int pmac_backlight_set_legacy_brightness(int brightness)
@@ -157,3 +166,7 @@ int pmac_backlight_get_legacy_brightness()
157 166
158 return result; 167 return result;
159} 168}
169
170EXPORT_SYMBOL_GPL(pmac_backlight);
171EXPORT_SYMBOL_GPL(pmac_backlight_mutex);
172EXPORT_SYMBOL_GPL(pmac_has_backlight_type);