From: Jean Delvare Date: Mon, 9 Jan 2006 21:43:08 +0000 (+0100) Subject: [PATCH] hwmon: Fix negative temperature readings in lm77 driver X-Git-Tag: v2.6.16-rc3~98^2~7 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=413b64515079a4063776d81067f69cc41bdb34ad;p=linux-2.6 [PATCH] hwmon: Fix negative temperature readings in lm77 driver Fix negative temperature readings in lm77 driver. Signed-off-by: Jean Delvare Acked-by: Michael Renzmann Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index a2f420d01f..df9e02aaa7 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c @@ -87,15 +87,15 @@ static struct i2c_driver lm77_driver = { /* In the temperature registers, the low 3 bits are not part of the temperature values; they are the status bits. */ -static inline u16 LM77_TEMP_TO_REG(int temp) +static inline s16 LM77_TEMP_TO_REG(int temp) { int ntemp = SENSORS_LIMIT(temp, LM77_TEMP_MIN, LM77_TEMP_MAX); - return (u16)((ntemp / 500) * 8); + return (ntemp / 500) * 8; } -static inline int LM77_TEMP_FROM_REG(u16 reg) +static inline int LM77_TEMP_FROM_REG(s16 reg) { - return ((int)reg / 8) * 500; + return (reg / 8) * 500; } /* sysfs stuff */