aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/applesmc.c
diff options
context:
space:
mode:
authorAlex Murray <murray.alex@gmail.com>2009-01-15 16:51:08 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-15 19:39:39 -0500
commitc3d6362b8717759de7f2086f9665a4d96cacbc51 (patch)
tree3474b8abc3a37cd645415f85ffc340c7d96c8d18 /drivers/hwmon/applesmc.c
parentdb92a6502d4e8cb885e85e862b24ba5c07036fbf (diff)
hwmon: applesmc: fix light sensor readings on newer MacBooks
The light sensors ALV0 and ALV1 on newer MacBooks (early 2008 and later) changed to report 10 bytes instead the earlier 6, and the sensor encoding subsequently changed. As a result, the reported light sensors readings are much too low. Via experiments leading up to this patch, it seems only the ALV0 is reporting data, and the most useful value therein is a 10-bit big-endian value at offset 6. This suggests that a new protocol was added as a backward-compatible replacement on top of the old one. This patch makes applesmc report the improved light sensor reading for the new machines, on a scale in conformance with earlier ones. Signed-off-by: Alex Murray <murray.alex@gmail.com> Signed-off-by: Henrik Rydberg <rydberg@euromail.se> Cc: Nicolas Boichat <nicolas@boichat.ch> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/hwmon/applesmc.c')
-rw-r--r--drivers/hwmon/applesmc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index dca47a591baf..e30186236588 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -590,6 +590,11 @@ static ssize_t applesmc_light_show(struct device *dev,
590 } 590 }
591 591
592 ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, buffer, data_length); 592 ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, buffer, data_length);
593 /* newer macbooks report a single 10-bit bigendian value */
594 if (data_length == 10) {
595 left = be16_to_cpu(*(__be16 *)(buffer + 6)) >> 2;
596 goto out;
597 }
593 left = buffer[2]; 598 left = buffer[2];
594 if (ret) 599 if (ret)
595 goto out; 600 goto out;