]> git.proxmox.com Git - mirror_ubuntu-bionic-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)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 14 Feb 2020 05:29:37 +0000 (00:29 -0500)
commit68bf3f5bf9b56e365f2a988ede99fdef7b9c829a
treef56473d28691819cd8e3b3a699cc1b7fbeaa731b
parentd60b6c5086d8d613a10961e6a343e35ba8ac8655
hwmon: (lm75) Fix write operations for negative temperatures

BugLink: https://bugs.launchpad.net/bugs/1863019
[ Upstream commit 7d82fcc9d9e81241778aaa22fda7be753e237d86 ]

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: e65365fed87f ("hwmon: (lm75) Convert to use regmap")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/hwmon/lm75.c