• Guenter Roeck's avatar
    hwmon: (lm75) Fix write operations for negative temperatures · 55027bf4
    Guenter Roeck authored
    [ Upstream commit 7d82fcc9 ]
    
    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: e65365fe
    
     ("hwmon: (lm75) Convert to use regmap")
    Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
    Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
    55027bf4
lm75.c 15.7 KB