lkml.org 
[lkml]   [2009]   [Feb]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [1/1] w1: w1 temp calculation overflow fix.
From
Date
On Tue, 2009-02-10 at 00:42 +0300, Evgeniy Polyakov wrote:
> Signed-off-by: Ian Dall <ian@beware.dropbear.id.au>
> Signed-off-by: Evgeniy Polyakov <zbr@ioremap.net>
>
> 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];

Alternatively,

int t = (s16)le16_to_cpup((__le16 *)rom);

Cheers,

Harvey



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