From: Peter Tyser Date: Wed, 29 Sep 2010 13:46:19 -0500 Subject: [U-Boot] [PATCH 3/3] ds1621: Fix negative temperature readings In-Reply-To: <1285785979-5074-1-git-send-email-ptyser@xes-inc.com> References: <1285785979-5074-1-git-send-email-ptyser@xes-inc.com> Message-ID: <1285785979-5074-3-git-send-email-ptyser@xes-inc.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: Jeff Dischler Fix bug where signed data was processed as unsigned. The bug previously resulted in negative temperature readings wrapping around, eg -10 became 245. Signed-off-by: Jeff Dischler Signed-off-by: Peter Tyser --- drivers/hwmon/ds1621.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index 60bf502..5a2ea62 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c @@ -80,7 +80,7 @@ int dtt_read(int sensor, int reg) /* Handle 2 byte result */ if (dlen == 2) - return ((int)((short)data[1] + (((short)data[0]) << 8))); + return (short)((data[0] << 8) | data[1]); return (int)data[0]; } -- 1.7.0.4