public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] W1: w1_therm.c standardize units to millidegrees C
@ 2008-01-24  2:03 David Fries
  2008-01-24 12:39 ` Ville Syrjälä
  0 siblings, 1 reply; 4+ messages in thread
From: David Fries @ 2008-01-24  2:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: Evgeniy Polyakov

Here is the patch to standardize the temperature units to millidegrees
C for the two sensor conversion routines.  Previously the routines
were,

w1_DS18B20_convert_temp degrees C
w1_DS18S20_convert_temp millidegrees C

Unfortunately this will break any program using the ds18b20 value as
it will now be 1000 times bigger.  Fortunately there can't be that
many users out there, or some of these bugs will have been fixed by
now, such as the negative C error (see previous patch) that makes me
think the ds18b20 is the better choice to change because of the
current bugs.

Signed-off-by: David Fries <david@fries.net>

Index: slaves/w1_therm.c
===================================================================
RCS file: /home/david/kernel/k/spacedout/patches/linux/drivers/w1/slaves/w1_therm.c,v
retrieving revision 1.5
diff -u -p -r1.5 w1_therm.c
--- slaves/w1_therm.c	24 Jan 2008 01:23:46 -0000	1.5
+++ slaves/w1_therm.c	24 Jan 2008 01:57:39 -0000
@@ -92,6 +92,7 @@ struct w1_therm_family_converter
 	int			(*convert)(u8 rom[9]);
 };
 
+/* The return value is millidegrees Centigrade. */
 static inline int w1_DS18B20_convert_temp(u8 rom[9]);
 static inline int w1_DS18S20_convert_temp(u8 rom[9]);
 
@@ -113,7 +114,7 @@ static struct w1_therm_family_converter 
 static inline int w1_DS18B20_convert_temp(u8 rom[9])
 {
 	s16 t = (rom[1] << 8) | rom[0];
-	t /= 16;
+	t = t*1000/16;
 	return t;
 }
 

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

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

end of thread, other threads:[~2008-01-25  1:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-24  2:03 [PATCH] W1: w1_therm.c standardize units to millidegrees C David Fries
2008-01-24 12:39 ` Ville Syrjälä
2008-01-24 14:53   ` Evgeniy Polyakov
2008-01-25  1:49     ` David Fries

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