]> git.baikalelectronics.ru Git - kernel.git/commit
hwmon: (lm75) Fix write operations for negative temperatures
authorGuenter Roeck <linux@roeck-us.net>
Thu, 8 Aug 2019 19:00:18 +0000 (12:00 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Sat, 31 Aug 2019 15:04:57 +0000 (08:04 -0700)
commit136a43c1a9df9e1a174f1f71de679ecde7f656f5
treee18408f71287ae2b9ace8a52ed6ad421157431c3
parentce10318316d8e2c1f4d1c5e2db0477a98f17c565
hwmon: (lm75) Fix write operations for negative temperatures

Writes into limit registers fail if the temperature written is negative.
The regmap write operation checks the value range, regmap_write accepts
an unsigned int as parameter, and the temperature value passed to
regmap_write is kept in a variable declared as long. Negative values
are converted large unsigned integers, which fails the range check.
Fix by type casting the temperature to u16 when calling regmap_write().

Cc: Iker Perez del Palomar Sustatxa <iker.perez@codethink.co.uk>
Fixes: aef796578d07 ("hwmon: (lm75) Convert to use regmap")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/lm75.c