All of lore.kernel.org
 help / color / mirror / Atom feed
* [1/1] w1: w1 temp calculation overflow fix.
@ 2009-02-09 21:42 Evgeniy Polyakov
  2009-02-09 21:48 ` Harvey Harrison
  2009-02-09 21:56 ` Andrew Morton
  0 siblings, 2 replies; 9+ messages in thread
From: Evgeniy Polyakov @ 2009-02-09 21:42 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Ian Dall

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];
 	t = t*1000/16;
 	return t;
 }


-- 
	Evgeniy Polyakov

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

* Re: [1/1] w1: w1 temp calculation overflow fix.
  2009-02-09 21:42 [1/1] w1: w1 temp calculation overflow fix Evgeniy Polyakov
@ 2009-02-09 21:48 ` Harvey Harrison
  2009-02-09 22:09   ` Evgeniy Polyakov
  2009-02-09 21:56 ` Andrew Morton
  1 sibling, 1 reply; 9+ messages in thread
From: Harvey Harrison @ 2009-02-09 21:48 UTC (permalink / raw)
  To: Evgeniy Polyakov; +Cc: Andrew Morton, linux-kernel, Ian Dall

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


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

* Re: [1/1] w1: w1 temp calculation overflow fix.
  2009-02-09 21:42 [1/1] w1: w1 temp calculation overflow fix Evgeniy Polyakov
  2009-02-09 21:48 ` Harvey Harrison
@ 2009-02-09 21:56 ` Andrew Morton
  2009-02-09 22:08   ` Evgeniy Polyakov
  1 sibling, 1 reply; 9+ messages in thread
From: Andrew Morton @ 2009-02-09 21:56 UTC (permalink / raw)
  To: Evgeniy Polyakov; +Cc: linux-kernel, ian

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.




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

* Re: [1/1] w1: w1 temp calculation overflow fix.
  2009-02-09 21:56 ` Andrew Morton
@ 2009-02-09 22:08   ` Evgeniy Polyakov
  2009-02-09 22:48     ` Andrew Morton
  0 siblings, 1 reply; 9+ messages in thread
From: Evgeniy Polyakov @ 2009-02-09 22:08 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, ian

On Mon, Feb 09, 2009 at 01:56:41PM -0800, Andrew Morton (akpm@linux-foundation.org) 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.
 
Yes, Ian is the author.
I will put appropriate From: field next time, I did not know it :)

> > --- 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.
 
That's what was placed into the documentation iirc, code for the more
advanced chip works ok. This code exists for way too long, but
apparently did not grow higher than 32 degrees, so it is applicable for
the earlier trees either.

-- 
	Evgeniy Polyakov

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

* Re: [1/1] w1: w1 temp calculation overflow fix.
  2009-02-09 21:48 ` Harvey Harrison
@ 2009-02-09 22:09   ` Evgeniy Polyakov
  0 siblings, 0 replies; 9+ messages in thread
From: Evgeniy Polyakov @ 2009-02-09 22:09 UTC (permalink / raw)
  To: Harvey Harrison; +Cc: Andrew Morton, linux-kernel, Ian Dall

On Mon, Feb 09, 2009 at 01:48:44PM -0800, Harvey Harrison (harvey.harrison@gmail.com) wrote:
> >  {
> > -	s16 t = (rom[1] << 8) | rom[0];
> > +	int t = ((s16)rom[1] << 8) | rom[0];
> 
> Alternatively,
> 
> 	int t = (s16)le16_to_cpup((__le16 *)rom);

Well, yes, but for the consistency with the other conversation functions
I think above is more appropriate.

-- 
	Evgeniy Polyakov

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

* Re: [1/1] w1: w1 temp calculation overflow fix.
  2009-02-09 22:08   ` Evgeniy Polyakov
@ 2009-02-09 22:48     ` Andrew Morton
  2009-02-09 23:31       ` Andrew Morton
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Morton @ 2009-02-09 22:48 UTC (permalink / raw)
  To: Evgeniy Polyakov; +Cc: linux-kernel, ian

On Tue, 10 Feb 2009 01:08:30 +0300
Evgeniy Polyakov <zbr@ioremap.net> wrote:

> > 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.
>  
> That's what was placed into the documentation iirc, code for the more
> advanced chip works ok. This code exists for way too long, but
> apparently did not grow higher than 32 degrees, so it is applicable for
> the earlier trees either.

I think the above means that the patch is appropriate for earlier trees.

But we still don't have a _reason_.  Presumably the bug causes the
driver to malfunction in some manner.

There are two reasons for properly describing the patch:

a) the stable maintainers will want to understand why they should
   backport the patch - does the bug affect anyone and if so, how?

b) people who are using earlier kernel versions and who experience a
   bug will want to know whether this patch will fix their bug.  To do
   that, they will need a description of what the patch fixes!

So please, do describe the user-visible impact of the bug if that is at
all relevant or possible.

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

* Re: [1/1] w1: w1 temp calculation overflow fix.
  2009-02-09 22:48     ` Andrew Morton
@ 2009-02-09 23:31       ` Andrew Morton
  2009-02-10  8:54         ` Evgeniy Polyakov
  2009-02-11  6:41         ` Ian Dall
  0 siblings, 2 replies; 9+ messages in thread
From: Andrew Morton @ 2009-02-09 23:31 UTC (permalink / raw)
  To: zbr, linux-kernel, ian

On Mon, 9 Feb 2009 14:48:03 -0800
Andrew Morton <akpm@linux-foundation.org> wrote:

> But we still don't have a _reason_.  Presumably the bug causes the
> driver to malfunction in some manner.

ah-hah.  I discovered http://bugzilla.kernel.org/show_bug.cgi?id=12646

Now all is revealed!

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

* Re: [1/1] w1: w1 temp calculation overflow fix.
  2009-02-09 23:31       ` Andrew Morton
@ 2009-02-10  8:54         ` Evgeniy Polyakov
  2009-02-11  6:41         ` Ian Dall
  1 sibling, 0 replies; 9+ messages in thread
From: Evgeniy Polyakov @ 2009-02-10  8:54 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, ian

On Mon, Feb 09, 2009 at 03:31:25PM -0800, Andrew Morton (akpm@linux-foundation.org) wrote:
> On Mon, 9 Feb 2009 14:48:03 -0800
> Andrew Morton <akpm@linux-foundation.org> wrote:
> 
> > But we still don't have a _reason_.  Presumably the bug causes the
> > driver to malfunction in some manner.
> 
> ah-hah.  I discovered http://bugzilla.kernel.org/show_bug.cgi?id=12646
> 
> Now all is revealed!

Argh, I did not get that you need this description :)
Yes, reading sysfs temperature file may return wrong (overflown) value.

-- 
	Evgeniy Polyakov

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

* Re: [1/1] w1: w1 temp calculation overflow fix.
  2009-02-09 23:31       ` Andrew Morton
  2009-02-10  8:54         ` Evgeniy Polyakov
@ 2009-02-11  6:41         ` Ian Dall
  1 sibling, 0 replies; 9+ messages in thread
From: Ian Dall @ 2009-02-11  6:41 UTC (permalink / raw)
  To: Andrew Morton; +Cc: zbr, linux-kernel

On Mon, 2009-02-09 at 15:31 -0800, Andrew Morton wrote:
> On Mon, 9 Feb 2009 14:48:03 -0800
> Andrew Morton <akpm@linux-foundation.org> wrote:
> 
> > But we still don't have a _reason_.  Presumably the bug causes the
> > driver to malfunction in some manner.
> 
> ah-hah.  I discovered http://bugzilla.kernel.org/show_bug.cgi?id=12646
> 
> Now all is revealed!

I've been out of the loop a couple of days. Is there anything else
needed from me?

Regards,
Ian


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


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

end of thread, other threads:[~2009-02-11  7:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-09 21:42 [1/1] w1: w1 temp calculation overflow fix Evgeniy Polyakov
2009-02-09 21:48 ` Harvey Harrison
2009-02-09 22:09   ` Evgeniy Polyakov
2009-02-09 21:56 ` Andrew Morton
2009-02-09 22:08   ` Evgeniy Polyakov
2009-02-09 22:48     ` Andrew Morton
2009-02-09 23:31       ` Andrew Morton
2009-02-10  8:54         ` Evgeniy Polyakov
2009-02-11  6:41         ` 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.