mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] hwmon: corsair-cpro: Read negative temperatures and remove magic values
@ 2025-11-13 10:00 Marius Zachmann
  2025-11-13 10:00 ` [PATCH 1/2] Read temperature as a signed value Marius Zachmann
  2025-11-13 10:00 ` [PATCH 2/2] Replace magic values with constants Marius Zachmann
  0 siblings, 2 replies; 5+ messages in thread
From: Marius Zachmann @ 2025-11-13 10:00 UTC (permalink / raw)
  To: linux; +Cc: mail, linux-hwmon, linux-kernel

- The Commander Pro also allows reading negative temperatures.
  Adds a conversion to read it correctly.

- Replace two of the magic values in the ccp_device struct
  with constants.

Marius Zachmann (2):
  Read temperature as a signed value.
  Replace magic values with constants

 drivers/hwmon/corsair-cpro.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

-- 
2.51.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] Read temperature as a signed value.
  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
  2025-11-13 20:19   ` Guenter Roeck
  2025-11-13 10:00 ` [PATCH 2/2] Replace magic values with constants Marius Zachmann
  1 sibling, 1 reply; 5+ messages in thread
From: Marius Zachmann @ 2025-11-13 10:00 UTC (permalink / raw)
  To: linux; +Cc: mail, linux-hwmon, linux-kernel

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] Replace magic values with constants
  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 ` [PATCH 1/2] Read temperature as a signed value Marius Zachmann
@ 2025-11-13 10:00 ` Marius Zachmann
  2025-11-13 20:22   ` Guenter Roeck
  1 sibling, 1 reply; 5+ messages in thread
From: Marius Zachmann @ 2025-11-13 10:00 UTC (permalink / raw)
  To: linux; +Cc: mail, linux-hwmon, linux-kernel

Replace two magic values in ccp_device with
existing constants.

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 6e1c415f3e26..e755353dd461 100644
--- a/drivers/hwmon/corsair-cpro.c
+++ b/drivers/hwmon/corsair-cpro.c
@@ -90,10 +90,10 @@ struct ccp_device {
 	u8 *cmd_buffer;
 	u8 *buffer;
 	int buffer_recv_size; /* number of received bytes in buffer */
-	int target[6];
+	int target[NUM_FANS];
 	DECLARE_BITMAP(temp_cnct, NUM_TEMP_SENSORS);
 	DECLARE_BITMAP(fan_cnct, NUM_FANS);
-	char fan_label[6][LABEL_LENGTH];
+	char fan_label[NUM_FANS][LABEL_LENGTH];
 	u8 firmware_ver[3];
 	u8 bootloader_ver[2];
 };
-- 
2.51.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] Read temperature as a signed value.
  2025-11-13 10:00 ` [PATCH 1/2] Read temperature as a signed value Marius Zachmann
@ 2025-11-13 20:19   ` Guenter Roeck
  0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2025-11-13 20:19 UTC (permalink / raw)
  To: Marius Zachmann; +Cc: linux-hwmon, linux-kernel

On Thu, Nov 13, 2025 at 11:00:23AM +0100, Marius Zachmann wrote:
> 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;

checkpatch:

CHECK: No space necessary after a cast

No need to resend, I'll patch that up.

Applied.

Guenter

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] Replace magic values with constants
  2025-11-13 10:00 ` [PATCH 2/2] Replace magic values with constants Marius Zachmann
@ 2025-11-13 20:22   ` Guenter Roeck
  0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2025-11-13 20:22 UTC (permalink / raw)
  To: Marius Zachmann; +Cc: linux-hwmon, linux-kernel

On Thu, Nov 13, 2025 at 11:00:24AM +0100, Marius Zachmann wrote:
> Replace two magic values in ccp_device with
> existing constants.
> 
> Signed-off-by: Marius Zachmann <mail@mariuszachmann.de>

Applied. Please watch out for the subject line in the future. It should
start with "hwmon: (corsair-cpro)".

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-11-13 20:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 1/2] Read temperature as a signed value Marius Zachmann
2025-11-13 20:19   ` Guenter Roeck
2025-11-13 10:00 ` [PATCH 2/2] Replace magic values with constants Marius Zachmann
2025-11-13 20:22   ` Guenter Roeck

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®