[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>
This commit is contained in:
Michael Hanselmann
2006-07-10 04:44:45 -07:00
committed by Linus Torvalds
parent 58d383a622
commit e01af0384f
10 changed files with 162 additions and 97 deletions

View File

@@ -15,6 +15,15 @@
#define OLD_BACKLIGHT_MAX 15
static void pmac_backlight_key_worker(void *data);
static DECLARE_WORK(pmac_backlight_key_work, pmac_backlight_key_worker, NULL);
/* Although this variable is used in interrupt context, it makes no sense to
* protect it. No user is able to produce enough key events per second and
* notice the errors that might happen.
*/
static int pmac_backlight_key_queued;
/* Protect the pmac_backlight variable */
DEFINE_MUTEX(pmac_backlight_mutex);
@@ -71,7 +80,7 @@ int pmac_backlight_curve_lookup(struct fb_info *info, int value)
return level;
}
static void pmac_backlight_key(int direction)
static void pmac_backlight_key_worker(void *data)
{
mutex_lock(&pmac_backlight_mutex);
if (pmac_backlight) {
@@ -82,7 +91,8 @@ static void pmac_backlight_key(int direction)
props = pmac_backlight->props;
brightness = props->brightness +
((direction?-1:1) * (props->max_brightness / 15));
((pmac_backlight_key_queued?-1:1) *
(props->max_brightness / 15));
if (brightness < 0)
brightness = 0;
@@ -97,14 +107,13 @@ static void pmac_backlight_key(int direction)
mutex_unlock(&pmac_backlight_mutex);
}
void pmac_backlight_key_up()
void pmac_backlight_key(int direction)
{
pmac_backlight_key(0);
}
void pmac_backlight_key_down()
{
pmac_backlight_key(1);
/* we can receive multiple interrupts here, but the scheduled work
* will run only once, with the last value
*/
pmac_backlight_key_queued = direction;
schedule_work(&pmac_backlight_key_work);
}
int pmac_backlight_set_legacy_brightness(int brightness)
@@ -157,3 +166,7 @@ int pmac_backlight_get_legacy_brightness()
return result;
}
EXPORT_SYMBOL_GPL(pmac_backlight);
EXPORT_SYMBOL_GPL(pmac_backlight_mutex);
EXPORT_SYMBOL_GPL(pmac_has_backlight_type);