summaryrefslogtreecommitdiff
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorLarry Johnson <lrj@acm.org>2008-02-21 13:58:16 -0500
committerWolfgang Denk <wd@denx.de>2008-02-22 16:33:09 +0100
commitd01b847c5cd070895c4ba178c85cd068a95cf7cd (patch)
treea5a4bcff6943bf094173e7355183ca987c8e96aa /drivers/hwmon
parent5a910c224b13e413bda41922379add6d75c32da3 (diff)
LM75 bug fix for negative temperatures
When the LM75 temperature sensor measures a temperature below 0 C, the current driver does not perform sign extension, so the result returned is 256 C too high. This patch fixes the problem. Signed-off-by: Larry Johnson <lrj@acm.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/lm75.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 63f3b7551e9..e29b29440f2 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -179,7 +179,13 @@ int dtt_init (void)
int dtt_get_temp(int sensor)
{
- return (dtt_read(sensor, DTT_READ_TEMP) / 256);
+ int const ret = dtt_read(sensor, DTT_READ_TEMP);
+
+ if (ret < 0) {
+ printf("DTT temperature read failed.\n");
+ return 0;
+ }
+ return (int)((int16_t) ret / 256);
} /* dtt_get_temp() */
#endif /* CONFIG_DTT_LM75 */