lkml.org 
[lkml]   [2009]   [Feb]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [1/1] w1: w1 temp calculation overflow fix.
On Tue, 10 Feb 2009 00:42:17 +0300
Evgeniy Polyakov <zbr@ioremap.net> wrote:

> Signed-off-by: Ian Dall <ian@beware.dropbear.id.au>
> Signed-off-by: Evgeniy Polyakov <zbr@ioremap.net>

I assumed from the above that Ian authored this patch. Please let me
know if that was incorrect.

The way to track authorship is to put the originator's From: line at
the top of the changelog.

> diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
> index 2c8dff9..1ed3d55 100644
> --- a/drivers/w1/slaves/w1_therm.c
> +++ b/drivers/w1/slaves/w1_therm.c
> @@ -115,7 +115,7 @@ static struct w1_therm_family_converter w1_therm_families[] = {
>
> 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;
> return t;
> }

It seems strange to use s16 here, but it will fix the bug.

Perhaps this function should be using plain old `unsigned' everywhere.

Please provide changelogs. This bugfix is applicable to 2.6.28.x and
probably earlier. But due to the lack of any supporting information I
am not in a position to determine whether it should be backported.





\
 
 \ /
  Last update: 2009-02-09 22:59    [W:0.193 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site