summaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorMichael Hanselmann <linux-kernel@hansmi.ch>2006-06-28 04:26:55 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-28 14:59:06 -0700
commitcab267c65f44337974e4f1eae490b21dce0e9811 (patch)
treed752bda111449ae7e9b7c85988f2993a9a068128 /arch/powerpc
parent96febe9fb7b04f2a078882d08bd6a997dee7cfa3 (diff)
downloadblackbird-op-linux-cab267c65f44337974e4f1eae490b21dce0e9811.tar.gz
blackbird-op-linux-cab267c65f44337974e4f1eae490b21dce0e9811.zip
[PATCH] powermac backlight fixes
Fix a erroneous calculation of the legacy brightness values as reported by Paul Collins. Additionally, it moves the calculation of the negative value in the radeonfb driver after the value check. Signed-off-by: Michael Hanselmann <linux-kernel@hansmi.ch> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: Paul Collins <paul@briny.ondioline.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.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/arch/powerpc/platforms/powermac/backlight.c b/arch/powerpc/platforms/powermac/backlight.c
index 498b042e1837..c7a27eddca6d 100644
--- a/arch/powerpc/platforms/powermac/backlight.c
+++ b/arch/powerpc/platforms/powermac/backlight.c
@@ -119,7 +119,14 @@ int pmac_backlight_set_legacy_brightness(int brightness)
down(&pmac_backlight->sem);
props = pmac_backlight->props;
props->brightness = brightness *
- props->max_brightness / OLD_BACKLIGHT_MAX;
+ (props->max_brightness + 1) /
+ (OLD_BACKLIGHT_MAX + 1);
+
+ if (props->brightness > props->max_brightness)
+ props->brightness = props->max_brightness;
+ else if (props->brightness < 0)
+ props->brightness = 0;
+
props->update_status(pmac_backlight);
up(&pmac_backlight->sem);
@@ -140,8 +147,11 @@ int pmac_backlight_get_legacy_brightness()
down(&pmac_backlight->sem);
props = pmac_backlight->props;
+
result = props->brightness *
- OLD_BACKLIGHT_MAX / props->max_brightness;
+ (OLD_BACKLIGHT_MAX + 1) /
+ (props->max_brightness + 1);
+
up(&pmac_backlight->sem);
}
mutex_unlock(&pmac_backlight_mutex);
OpenPOWER on IntegriCloud