[Voyage-linux] [Fwd: [PATCH 01/11] hwmon: Fix negative temperature readings in lm77 driver]

Punky Tse (spam-protected)
Tue Jan 10 20:16:19 HKT 2006


Hi Michael,

The debian kernel source shows the following so the patch is rejected 
when applied:

static inline u16 LM77_TEMP_TO_REG(int temp)
{
        int ntemp = SENSORS_LIMIT(temp, LM77_TEMP_MIN, LM77_TEMP_MAX);
        ntemp = (ntemp / 500) << 3;

        /* set all sign bits if necessary */
        if (ntemp & 0x200)
                ntemp |= 0xe000;

        return (u16)ntemp;
}

static inline int LM77_TEMP_FROM_REG(u16 reg)
{
        int val = ((reg & LM77_TEMP_MASK) >> 3);

        /* adjust for signedness if necessary */
        if (val & 0x200)
            val -= 1024;

        return (val *= 500);
}

Michael Renzmann wrote:

>Hi all.
>
>This is a revised version of my previous patch to fix negative
>temperature readings of the LM77 in kernel 2.6.x.
>
>Bye, Mike
>  
>
>
> ------------------------------------------------------------------------
>
> Subject:
> [PATCH 01/11] hwmon: Fix negative temperature readings in lm77 driver
> From:
> Jean Delvare <khali at linux-fr.org>
> Date:
> Mon, 9 Jan 2006 22:43:08 +0100
> To:
> Greg KH <greg at kroah.com>
>
> To:
> Greg KH <greg at kroah.com>
> CC:
> LM Sensors <lm-sensors at lm-sensors.org>, Michael Renzmann 
> <mrenzmann at otaku42.de>
>
>
>Content-Disposition: inline; filename=hwmon-lm77-negative-temp-fix.patch
>
>Fix negative temperature readings in lm77 driver.
>
>Signed-off-by: Jean Delvare <khali at linux-fr.org>
>Acked-by: Michael Renzmann <mrenzmann at otaku42.de>
>---
> drivers/hwmon/lm77.c |    8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
>--- linux-2.6.15-rc6.orig/drivers/hwmon/lm77.c	2005-12-19 20:15:58.000000000 +0100
>+++ linux-2.6.15-rc6/drivers/hwmon/lm77.c	2005-12-20 19:44:11.000000000 +0100
>@@ -87,15 +87,15 @@
> 
> /* In the temperature registers, the low 3 bits are not part of the
>    temperature values; they are the status bits. */
>-static inline u16 LM77_TEMP_TO_REG(int temp)
>+static inline s16 LM77_TEMP_TO_REG(int temp)
> {
> 	int ntemp = SENSORS_LIMIT(temp, LM77_TEMP_MIN, LM77_TEMP_MAX);
>-	return (u16)((ntemp / 500) * 8);
>+	return (ntemp / 500) * 8;
> }
> 
>-static inline int LM77_TEMP_FROM_REG(u16 reg)
>+static inline int LM77_TEMP_FROM_REG(s16 reg)
> {
>-	return ((int)reg / 8) * 500;
>+	return (reg / 8) * 500;
> }
> 
> /* sysfs stuff */
>
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Voyage-linux mailing list
>Voyage-linux at list.voyage.hk
>http://list.voyage.hk/mailman/listinfo/voyage-linux
>  
>


-- 
Regards,
Punky
P U N K N ! X  . c o m
Technology + Lifestyle
(http://www.punknix.com)

Voyage Linux
(http://www.voyage.hk/software/voyage.html)






More information about the Voyage-linux mailing list