* [U-Boot-Users] [PATCH] LM75 bug fix for negative temperatures
@ 2008-02-21 18:58 Larry Johnson
2008-02-22 15:33 ` Wolfgang Denk
0 siblings, 1 reply; 2+ messages in thread
From: Larry Johnson @ 2008-02-21 18:58 UTC (permalink / raw)
To: u-boot
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>
---
The patch was tested on the AMCC Sequoia board, which uses the AD7414
temperature sensor. It appears that other drivers, such as "ds1621.c",
may have the same bug, but I have no way of testing these.
drivers/hwmon/lm75.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 63f3b75..e29b294 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 */
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot-Users] [PATCH] LM75 bug fix for negative temperatures
2008-02-21 18:58 [U-Boot-Users] [PATCH] LM75 bug fix for negative temperatures Larry Johnson
@ 2008-02-22 15:33 ` Wolfgang Denk
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2008-02-22 15:33 UTC (permalink / raw)
To: u-boot
In message <47BDC9C8.6090303@acm.org> you wrote:
> 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>
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
EMACS belongs in <sys/errno.h>: Editor too big!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-02-22 15:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-21 18:58 [U-Boot-Users] [PATCH] LM75 bug fix for negative temperatures Larry Johnson
2008-02-22 15:33 ` Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox