From: DENX Support System Date: Sat, 1 Apr 2006 00:20:33 +0200 Subject: [DNX#2006040142000759] [U-Boot-Users] Bug in DTT for temperatures below z [...] Message-ID: <1143843633.301456.208229663@castor.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello list, inside the automatic U-Boot patch tracking system a new ticket [DNX#2006040142000759] was created: > In message <42AFEBD3.3050008@imc-berlin.de> you wrote: > > > > there's a terrible bug in the current U-Boot CVS concerning DDT: > > > > For temperature below zero the function dtt_get_temp() (at least for lm75) > > returns wrong values! > > > > ... > > DTT: 1 is 235 C > > LCD: Hitachi TX14D11 5,7" 320x240 TFT (235?C) > > WDT: disabled > > > > This is because of the use of an "int" although the lm75 only returns two > > byte ("signed short"). > > Ummm... > > > This trivial fix is needed: > > Wait a moment... > > > --- u-boot/dtt/lm75.c 27 Jun 2003 21:32:38 -0000 1.2 > > +++ u-boot/dtt/lm75.c 15 Jun 2005 08:44:21 -0000 > > @@ -174,7 +170,7 @@ > > > > int dtt_get_temp(int sensor) > > { > > - return (dtt_read(sensor, DTT_READ_TEMP) / 256); > > + return ( ((signed short) dtt_read(sensor, DTT_READ_TEMP)) / 256); > > This is not the right way to fix it. I reject this patch. > > dtt_read() is declared to return "int", so no such cast should be > needed, i. e. you fix the symptoms instead of the cause. > > > I think the patch must be done in dtt_read(); IMO the line > > return ((int)((short)data[1] + (((short)data[0]) << 8))); > > is wrong; it should read > > return ((short)((short)data[1] + (((short)data[0]) << 8))); > > or, even better, > > short rc_s; > ... > rc_s = (short)data[1] + (((short)data[0]) << 8); > return (rc_s); > > And the same problem is with dlen == 1 - it should read > > return ((signed char)data[0]); > > > Do you agree with this assessment? And can you please confirm that my > suggested patch fixes your problem, too? > > Best regards, > > Wolfgang Denk > > -- > Software Engineering: Embedded and Realtime Systems, Embedded Linux > Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de > Of all possible committee reactions to any given agenda item, the > reaction that will occur is the one which will liberate the greatest > amount of hot air. -- Thomas L. Martin > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting > language > that extends applications into web and mobile media. Attend the live > webcast > and join the prime developer group breaking into this new coding > territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642 > _______________________________________________ > U-Boot-Users mailing list > U-Boot-Users at lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/u-boot-users Your U-Boot support team