1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-28 14:01:16 +02:00

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>
This commit is contained in:
Larry Johnson
2008-02-21 13:58:16 -05:00
committed by Wolfgang Denk
parent 5a910c224b
commit d01b847c5c

View File

@@ -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 */