mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] W1: w1_therm.c ds18b20 decode freezing temperatures correctly
@ 2008-01-20  0:44 David Fries
  2008-01-21 12:22 ` Evgeniy Polyakov
  0 siblings, 1 reply; 2+ messages in thread
From: David Fries @ 2008-01-20  0:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Evgeniy Polyakov

commit c4ad974f3acef11e538e825ca0cb73be6faf2461
Author: David Fries <david@fries.net>
Date:   Sun Nov 4 18:14:21 2007 -0600

Corrected the decoding of negative C temperatures. The code did a binary
OR of two bytes to make a 16 bit value, but assignd it to an integer.
This caused the value to not be sign extended and to loose that it was a
negative number in the assignment.
Before the patch (in my freezer),
w1_slave
ed fe 4b 46 7f ff 03 10 e4 : crc=e4 YES
ed fe 4b 46 7f ff 03 10 e4 t=4078
With the patch,
e3 fe 4b 46 7f ff 0d 10 81 : crc=81 YES
e3 fe 4b 46 7f ff 0d 10 81 t=-17

diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index 4318935..feed89e 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -112,7 +112,7 @@ static struct w1_therm_family_converter w1_therm_families[] = {
 
 static inline int w1_DS18B20_convert_temp(u8 rom[9])
 {
-	int t = (rom[1] << 8) | rom[0];
+	s16 t = (rom[1] << 8) | rom[0];
 	t /= 16;
 	return t;
 }

-- 
David Fries <david@fries.net>
http://fries.net/~david/ (PGP encryption key available)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/2] W1: w1_therm.c ds18b20 decode freezing temperatures correctly
  2008-01-20  0:44 [PATCH 1/2] W1: w1_therm.c ds18b20 decode freezing temperatures correctly David Fries
@ 2008-01-21 12:22 ` Evgeniy Polyakov
  0 siblings, 0 replies; 2+ messages in thread
From: Evgeniy Polyakov @ 2008-01-21 12:22 UTC (permalink / raw)
  To: David Fries; +Cc: linux-kernel, Andrew Morton

Hi David.

Both patches looks ok, thanks a lot.
Andrew, please apply.

Acked-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>

-- 
	Evgeniy Polyakov

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-01-21 12:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-20  0:44 [PATCH 1/2] W1: w1_therm.c ds18b20 decode freezing temperatures correctly David Fries
2008-01-21 12:22 ` Evgeniy Polyakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome