]> git.baikalelectronics.ru Git - kernel.git/commitdiff
hwmon: (adt7475) Fix masking of hysteresis registers
authorTony O'Brien <tony.obrien@alliedtelesis.co.nz>
Wed, 22 Feb 2023 00:52:28 +0000 (13:52 +1300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Mar 2023 12:28:07 +0000 (13:28 +0100)
[ Upstream commit 48e8186870d9d0902e712d601ccb7098cb220688 ]

The wrong bits are masked in the hysteresis register; indices 0 and 2
should zero bits [7:4] and preserve bits [3:0], and index 1 should zero
bits [3:0] and preserve bits [7:4].

Fixes: 9710f8bd109c ("hwmon: Add a driver for the ADT7475 hardware monitoring chip")
Signed-off-by: Tony O'Brien <tony.obrien@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20230222005228.158661-3-tony.obrien@alliedtelesis.co.nz
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hwmon/adt7475.c

index 20a4118bb3e1c2871b151db9d4b0a240f91166a3..5af7226657ab4827fe9d5f06932d69c590beed00 100644 (file)
@@ -484,10 +484,10 @@ static ssize_t temp_store(struct device *dev, struct device_attribute *attr,
                val = (temp - val) / 1000;
 
                if (sattr->index != 1) {
-                       data->temp[HYSTERSIS][sattr->index] &= 0xF0;
+                       data->temp[HYSTERSIS][sattr->index] &= 0x0F;
                        data->temp[HYSTERSIS][sattr->index] |= (val & 0xF) << 4;
                } else {
-                       data->temp[HYSTERSIS][sattr->index] &= 0x0F;
+                       data->temp[HYSTERSIS][sattr->index] &= 0xF0;
                        data->temp[HYSTERSIS][sattr->index] |= (val & 0xF);
                }