From: Larry Johnson <lrj@acm.org>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] LM75 bug fix for negative temperatures
Date: Thu, 21 Feb 2008 13:58:16 -0500 [thread overview]
Message-ID: <47BDC9C8.6090303@acm.org> (raw)
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 */
next reply other threads:[~2008-02-21 18:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-21 18:58 Larry Johnson [this message]
2008-02-22 15:33 ` [U-Boot-Users] [PATCH] LM75 bug fix for negative temperatures Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47BDC9C8.6090303@acm.org \
--to=lrj@acm.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox