提交 507e2fba 编写于 作者: I Ian Dall 提交者: Linus Torvalds

w1: w1 temp calculation overflow fix

Addresses http://bugzilla.kernel.org/show_bug.cgi?id=12646

When the temperature exceeds 32767 milli-degrees the temperature overflows
to -32768 millidegrees.  These are bothe well within the -55 - +125 degree
range for the sensor.

Fix overflow in left-shift of a u8.
Signed-off-by: NIan Dall <ian@beware.dropbear.id.au>
Signed-off-by: NEvgeniy Polyakov <zbr@ioremap.net>
Cc: <stable@kernel.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 4d48a542
...@@ -115,7 +115,7 @@ static struct w1_therm_family_converter w1_therm_families[] = { ...@@ -115,7 +115,7 @@ static struct w1_therm_family_converter w1_therm_families[] = {
static inline int w1_DS18B20_convert_temp(u8 rom[9]) static inline int w1_DS18B20_convert_temp(u8 rom[9])
{ {
s16 t = (rom[1] << 8) | rom[0]; int t = ((s16)rom[1] << 8) | rom[0];
t = t*1000/16; t = t*1000/16;
return t; return t;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册