hwmon: corsair-cpro: Read negative temperatures and remove magic values
Subsystems (2)
Marius Zachmann
maintainercover hwmon: corsair-cpro: Read negative temperatures and remove magic values
- 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(-)
Signature · 1 line
2.51.2
Marius Zachmann
maintainerPATCH 1/2 Read temperature as a signed value.
Convert temperature to s16 to correctly read negative temperatures.
--- drivers/hwmon/corsair-cpro.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/corsair-cpro.c +2 -2
@@ -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 ;
Signature · 1 line
2.51.2
Re: [PATCH 1/2] Read temperature as a signed value.
Quoted 21 lines · Marius Zachmann
Convert temperature to s16 to correctly read negative temperatures.
Signed-off-by Marius Zachmann <[email protected]>--- drivers/hwmon/corsair-cpro.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/hwmon/corsair-cpro.c +1
-1@@ -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/*
drivers/hwmon/corsair-cpro.c static int ccp_read(struct device *dev, enum hwmon_sensor_types type, · line 261
Quoted 5 lines
drivers/hwmon/corsair-cpro.c +1
-1@@ -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
Marius Zachmann
maintainerPATCH 2/2 Replace magic values with constants
In reply to Marius ZachmannReplace two magic values in ccp_device with
existing constants.
--- drivers/hwmon/corsair-cpro.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/corsair-cpro.c +2 -2
@@ -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 ]; };
Signature · 1 line
2.51.2
Re: [PATCH 2/2] Replace magic values with constants
Quoted 4 lines · Marius Zachmann
Replace two magic values in
ccp_devicewith
existing constants.Signed-off-by Marius Zachmann <[email protected]>
Applied. Please watch out for the subject line in the future. It should start with "hwmon: (corsair-cpro)".
Thanks,
Guenter