All of lore.kernel.org
 help / color / mirror / Atom feed
* [1/1] w1: w1 temp. Fix negative termperature calculation.
@ 2010-04-19 12:10 Ian Dall
  0 siblings, 0 replies; only message in thread
From: Ian Dall @ 2010-04-19 12:10 UTC (permalink / raw)
  To: Andrew Morton, Evgeniy Polyakov; +Cc: linux-kernel

Bug 12646 has been outstanding for a long time. Is it possible to get
this fix committed?


Log:
From: Ian Dall <ian@beware.dropbear.id.au>

Fix regression caused by commit
507e2fbaaacb6f164b4125b87c5002f95143174b,
whereby negative temperatures for the DS18B20 are not converted
properly. Fixes bug 12646.

Signed-of-by: Ian Dall <ian@beware.dropbear.id.au>


diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index 1ed3d55..17726a0 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -115,9 +115,8 @@ static struct w1_therm_family_converter w1_therm_families[] = {
 
 static inline int w1_DS18B20_convert_temp(u8 rom[9])
 {
-	int t = ((s16)rom[1] << 8) | rom[0];
-	t = t*1000/16;
-	return t;
+	s16 t = le16_to_cpup((__le16 *)rom);
+	return t*1000/16;
 }
 
 static inline int w1_DS18S20_convert_temp(u8 rom[9])


-- 
Ian Dall <ian@beware.dropbear.id.au>


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-04-19 12:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-19 12:10 [1/1] w1: w1 temp. Fix negative termperature calculation Ian Dall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.