This is a note to let you know that I've just added the patch titled
hwmon: (lm95241) Fix negative temperature results
to the 2.6.39-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
hwmon-lm95241-fix-negative-temperature-results.patch
and it can be found in the queue-2.6.39 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.
>From 0c2a40e2fe4f4af0410f57e84b95b817ec15aa70 Mon Sep 17 00:00:00 2001
From: Guenter Roeck <[email protected]>
Date: Thu, 30 Jun 2011 02:09:37 -0700
Subject: hwmon: (lm95241) Fix negative temperature results
From: Guenter Roeck <[email protected]>
commit 0c2a40e2fe4f4af0410f57e84b95b817ec15aa70 upstream.
Negative temperatures were returned in degrees C instead of milli-Degrees C.
Also, negative temperatures were reported for remote temperature sensors even
if the chip was configured for positive-only results.
Fix by detecting temperature modes, and by treating negative temperatures
similar to positive temperatures, with appropriate sign extension.
Signed-off-by: Guenter Roeck <[email protected]>
Acked-by: Jean Delvare <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/hwmon/lm95241.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
--- a/drivers/hwmon/lm95241.c
+++ b/drivers/hwmon/lm95241.c
@@ -98,11 +98,16 @@ struct lm95241_data {
};
/* Conversions */
-static int TempFromReg(u8 val_h, u8 val_l)
+static int temp_from_reg_signed(u8 val_h, u8 val_l)
{
- if (val_h & 0x80)
- return val_h - 0x100;
- return val_h * 1000 + val_l * 1000 / 256;
+ s16 val_hl = (val_h << 8) | val_l;
+ return val_hl * 1000 / 256;
+}
+
+static int temp_from_reg_unsigned(u8 val_h, u8 val_l)
+{
+ u16 val_hl = (val_h << 8) | val_l;
+ return val_hl * 1000 / 256;
}
static struct lm95241_data *lm95241_update_device(struct device *dev)
@@ -135,10 +140,13 @@ static ssize_t show_input(struct device
char *buf)
{
struct lm95241_data *data = lm95241_update_device(dev);
+ int index = to_sensor_dev_attr(attr)->index;
return snprintf(buf, PAGE_SIZE - 1, "%d\n",
- TempFromReg(data->temp[to_sensor_dev_attr(attr)->index],
- data->temp[to_sensor_dev_attr(attr)->index + 1]));
+ index == 0 || (data->config & (1 << (index / 2))) ?
+ temp_from_reg_signed(data->temp[index], data->temp[index + 1]) :
+ temp_from_reg_unsigned(data->temp[index],
+ data->temp[index + 1]));
}
static ssize_t show_type(struct device *dev, struct device_attribute *attr,
Patches currently in stable-queue which might be from
[email protected] are
queue-2.6.39/hwmon-pmbus-improve-fan-detection.patch
queue-2.6.39/hwmon-pmbus-use-long-variables-for-register-to-data.patch
queue-2.6.39/hwmon-lm95241-fix-chip-detection-code.patch
queue-2.6.39/hwmon-pmbus-improve-auto-detection-of-temperature-status.patch
queue-2.6.39/hwmon-pmbus-drop-check-for-pmbus-revision-register-in.patch
queue-2.6.39/hwmon-pmbus-auto-detect-temp2-and-temp3.patch
queue-2.6.39/hwmon-lm95241-fix-negative-temperature-results.patch
_______________________________________________
stable mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/stable