lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Tue, 13 Jan 2009 02:11:22 +0100
From:	"Henrik Rydberg" <rydberg@...omail.se>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Alex Murray <murray.alex@...il.com>,
	Nicolas Boichat <nicolas@...chat.ch>,
	lm-sensors@...sensors.org, linux-kernel@...r.kernel.org,
	Henrik Rydberg <rydberg@...omail.se>
Subject: [PATCH] hwmon: applesmc: Fix light sensor readings on newer MacBooks

From: Alex Murray <murray.alex@...il.com>

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.

>From 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@...il.com>
Signed-off-by: Henrik Rydberg <rydberg@...omail.se>
---
 drivers/hwmon/applesmc.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index dca47a5..e301862 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -590,6 +590,11 @@ static ssize_t applesmc_light_show(struct device *dev,
 	}
 
 	ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, buffer, data_length);
+	/* newer macbooks report a single 10-bit bigendian value */
+	if (data_length == 10) {
+		left = be16_to_cpu(*(__be16 *)(buffer + 6)) >> 2;
+		goto out;
+	}
 	left = buffer[2];
 	if (ret)
 		goto out;
-- 
1.5.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ