• Jean Delvare's avatar
    [PATCH] I2C: Store lm83 and lm90 temperatures in signed · eb20210c
    Jean Delvare authored
    Back when I wrote the lm83 and lm90 drivers, I decided to use unsigned
    variables to store temperature values as mirrored from the chipset
    registers. I wonder why, since the registers use signed values
    themselves. The patch below changes the variables back to signed types,
    so as to simplify the conversions made by the driver, making them faster
    and easier to understand.
    
    Additionally, the lm90 driver was lacking boundary checkings and proper
    rounding when writing temperature limits to the chipset, so I added
    these. I also reworded the comments about internal temperature values
    representation for all chipsets.
    
    Tested to work fine on my (LM90-compatible) ADM1032 chip. lm83 patch
    untested, but it is more simple and directly copied from the lm90, so I
    am confident it works fine too.
    Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
    eb20210c
lm90.c 18.2 KB