From: Marius Zachmann <mail@mariuszachmann.de>
To: linux@roeck-us.net
Cc: mail@mariuszachmann.de, linux-hwmon@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] Read temperature as a signed value.
Date: Thu, 13 Nov 2025 11:00:23 +0100 [thread overview]
Message-ID: <20251113100024.11103-2-mail@mariuszachmann.de> (raw)
In-Reply-To: <20251113100024.11103-1-mail@mariuszachmann.de>
Convert temperature to s16 to correctly read negative temperatures.
Signed-off-by: Marius Zachmann <mail@mariuszachmann.de>
---
drivers/hwmon/corsair-cpro.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/corsair-cpro.c b/drivers/hwmon/corsair-cpro.c
index b7b911f8359c..6e1c415f3e26 100644
--- a/drivers/hwmon/corsair-cpro.c
+++ b/drivers/hwmon/corsair-cpro.c
@@ -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;
--
2.51.2
next prev parent reply other threads:[~2025-11-13 10:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-13 10:00 [PATCH 0/2] hwmon: corsair-cpro: Read negative temperatures and remove magic values Marius Zachmann
2025-11-13 10:00 ` Marius Zachmann [this message]
2025-11-13 20:19 ` [PATCH 1/2] Read temperature as a signed value Guenter Roeck
2025-11-13 10:00 ` [PATCH 2/2] Replace magic values with constants Marius Zachmann
2025-11-13 20:22 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251113100024.11103-2-mail@mariuszachmann.de \
--to=mail@mariuszachmann.de \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®