mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
hwmon: (lm75) Fix write operations for negative temperatures
[ Upstream commit7d82fcc9d9] 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:e65365fed8("hwmon: (lm75) Convert to use regmap") Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
d9711896dd
commit
55027bf481
@@ -165,7 +165,7 @@ static int lm75_write(struct device *dev, enum hwmon_sensor_types type,
|
||||
temp = DIV_ROUND_CLOSEST(temp << (resolution - 8),
|
||||
1000) << (16 - resolution);
|
||||
|
||||
return regmap_write(data->regmap, reg, temp);
|
||||
return regmap_write(data->regmap, reg, (u16)temp);
|
||||
}
|
||||
|
||||
static umode_t lm75_is_visible(const void *data, enum hwmon_sensor_types type,
|
||||
|
||||
Reference in New Issue
Block a user