]> git.baikalelectronics.ru Git - kernel.git/commit
hwmon: (lm77) Prevent overflow problem when writing large limits
authorAxel Lin <axel.lin@ingics.com>
Thu, 31 Jul 2014 14:58:04 +0000 (22:58 +0800)
committerGuenter Roeck <linux@roeck-us.net>
Thu, 31 Jul 2014 16:41:46 +0000 (09:41 -0700)
commit193af43a10a330f39f6a8e06fbef122c6d132321
tree0b61ca3e3fed886c05bfe4b0b51e332268e488a2
parent44d0630a4f342889f5656e9d118d5fd701178d22
hwmon: (lm77) Prevent overflow problem when writing large limits

On platforms with sizeof(int) < sizeof(long), writing a temperature
limit larger than MAXINT will result in unpredictable limit values
written to the chip.
Clamp the input values to the supported limits first to fix the problem.

For set_temp_hyst:
As Guenter pointed out that the temperature is read as unsigned and stored in
an unsigned long. This is wrong; nothing in the datasheet suggests that the
value (the absolute temperature) must be positive.
So change it to signed.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/lm77.c