]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
hwmon: (corsair-cpro) Read temperature as a signed value
authorMarius Zachmann <mail@mariuszachmann.de>
Thu, 13 Nov 2025 10:00:23 +0000 (11:00 +0100)
committerGuenter Roeck <linux@roeck-us.net>
Thu, 13 Nov 2025 20:23:26 +0000 (12:23 -0800)
Convert temperature to s16 to correctly read negative temperatures.

Signed-off-by: Marius Zachmann <mail@mariuszachmann.de>
Link: https://lore.kernel.org/r/20251113100024.11103-2-mail@mariuszachmann.de
[groeck: Updated subject, coding style]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/corsair-cpro.c

index b7b911f8359c7f31ed9744c3961f711730a159b9..f011d26eb0efa813401d6b1f3d776973ee23064c 100644 (file)
@@ -40,7 +40,7 @@
 #define CTL_GET_TMP            0x11    /*
                                         * send: byte 1 is channel, rest zero
                                         * rcv:  returns temp for channel in centi-degree celsius
-                                        * in bytes 1 and 2
+                                        * in bytes 1 and 2 as a two's complement value
                                         * returns 0x11 in byte 0 if no sensor is connected
                                         */
 #define CTL_GET_VOLT           0x12    /*
@@ -258,7 +258,7 @@ static int ccp_read(struct device *dev, enum hwmon_sensor_types type,
                        ret = get_data(ccp, CTL_GET_TMP, channel, true);
                        if (ret < 0)
                                return ret;
-                       *val = ret * 10;
+                       *val = (s16)ret * 10;
                        return 0;
                default:
                        break;