aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-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);