Linux Hardware Monitor development
 help / color / mirror / Atom feed
* [PATCH] hwmon: (asus-ec-sensors) sort sensor definition arrays
@ 2025-04-08 20:44 Eugene Shalygin
  2025-04-09  2:14 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Eugene Shalygin @ 2025-04-08 20:44 UTC (permalink / raw)
  To: eugene.shalygin; +Cc: Jean Delvare, Guenter Roeck, linux-hwmon, linux-kernel

The arrays have to be sorted by the sensor register bank and index
because this is what the sensor reading function expects. So sort them
and leave a comment for future contributors.

Signed-off-by: Eugene Shalygin <eugene.shalygin@gmail.com>
---
 drivers/hwmon/asus-ec-sensors.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c
index 006ced5ab6e6..ec428c5e97d4 100644
--- a/drivers/hwmon/asus-ec-sensors.c
+++ b/drivers/hwmon/asus-ec-sensors.c
@@ -169,7 +169,10 @@ enum board_family {
 	family_intel_600_series
 };
 
-/* All the known sensors for ASUS EC controllers */
+/* All the known sensors for ASUS EC controllers. These arrays have to be sorted
+ * by the full ((bank << 8) + index) register index (see asus_ec_block_read() as
+ * to why).
+*/
 static const struct ec_sensor_info sensors_family_amd_400[] = {
 	[ec_sensor_temp_chipset] =
 		EC_SENSOR("Chipset", hwmon_temp, 1, 0x00, 0x3a),
@@ -183,10 +186,10 @@ static const struct ec_sensor_info sensors_family_amd_400[] = {
 		EC_SENSOR("VRM", hwmon_temp, 1, 0x00, 0x3e),
 	[ec_sensor_in_cpu_core] =
 		EC_SENSOR("CPU Core", hwmon_in, 2, 0x00, 0xa2),
-	[ec_sensor_fan_cpu_opt] =
-		EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xbc),
 	[ec_sensor_fan_vrm_hs] =
 		EC_SENSOR("VRM HS", hwmon_fan, 2, 0x00, 0xb2),
+	[ec_sensor_fan_cpu_opt] =
+		EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xbc),
 	[ec_sensor_fan_chipset] =
 		/* no chipset fans in this generation */
 		EC_SENSOR("Chipset", hwmon_fan, 0, 0x00, 0x00),
@@ -194,10 +197,10 @@ static const struct ec_sensor_info sensors_family_amd_400[] = {
 		EC_SENSOR("Water_Flow", hwmon_fan, 2, 0x00, 0xb4),
 	[ec_sensor_curr_cpu] =
 		EC_SENSOR("CPU", hwmon_curr, 1, 0x00, 0xf4),
-	[ec_sensor_temp_water_in] =
-		EC_SENSOR("Water_In", hwmon_temp, 1, 0x01, 0x0d),
 	[ec_sensor_temp_water_out] =
 		EC_SENSOR("Water_Out", hwmon_temp, 1, 0x01, 0x0b),
+	[ec_sensor_temp_water_in] =
+		EC_SENSOR("Water_In", hwmon_temp, 1, 0x01, 0x0d),
 };
 
 static const struct ec_sensor_info sensors_family_amd_500[] = {
@@ -239,19 +242,20 @@ static const struct ec_sensor_info sensors_family_amd_500[] = {
 
 static const struct ec_sensor_info sensors_family_amd_600[] = {
 	[ec_sensor_temp_cpu] = EC_SENSOR("CPU", hwmon_temp, 1, 0x00, 0x30),
-	[ec_sensor_temp_cpu_package] = EC_SENSOR("CPU Package", hwmon_temp, 1, 0x00, 0x31),
+	[ec_sensor_temp_cpu_package] =
+		EC_SENSOR("CPU Package", hwmon_temp, 1, 0x00, 0x31),
 	[ec_sensor_temp_mb] =
 	EC_SENSOR("Motherboard", hwmon_temp, 1, 0x00, 0x32),
 	[ec_sensor_temp_vrm] =
 		EC_SENSOR("VRM", hwmon_temp, 1, 0x00, 0x33),
 	[ec_sensor_temp_t_sensor] =
 		EC_SENSOR("T_Sensor", hwmon_temp, 1, 0x00, 0x36),
+	[ec_sensor_fan_cpu_opt] =
+		EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xb0),
 	[ec_sensor_temp_water_in] =
 		EC_SENSOR("Water_In", hwmon_temp, 1, 0x01, 0x00),
 	[ec_sensor_temp_water_out] =
 		EC_SENSOR("Water_Out", hwmon_temp, 1, 0x01, 0x01),
-	[ec_sensor_fan_cpu_opt] =
-		EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xb0),
 };
 
 static const struct ec_sensor_info sensors_family_intel_300[] = {
-- 
2.49.0


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

* Re: [PATCH] hwmon: (asus-ec-sensors) sort sensor definition arrays
  2025-04-08 20:44 [PATCH] hwmon: (asus-ec-sensors) sort sensor definition arrays Eugene Shalygin
@ 2025-04-09  2:14 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2025-04-09  2:14 UTC (permalink / raw)
  To: Eugene Shalygin; +Cc: Jean Delvare, linux-hwmon, linux-kernel

On Tue, Apr 08, 2025 at 10:44:57PM +0200, Eugene Shalygin wrote:
> The arrays have to be sorted by the sensor register bank and index
> because this is what the sensor reading function expects. So sort them
> and leave a comment for future contributors.
> 
> Signed-off-by: Eugene Shalygin <eugene.shalygin@gmail.com>
> ---
>  drivers/hwmon/asus-ec-sensors.c | 20 ++++++++++++--------
>  1 file changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c
> index 006ced5ab6e6..ec428c5e97d4 100644
> --- a/drivers/hwmon/asus-ec-sensors.c
> +++ b/drivers/hwmon/asus-ec-sensors.c
> @@ -169,7 +169,10 @@ enum board_family {
>  	family_intel_600_series
>  };
>  
> -/* All the known sensors for ASUS EC controllers */
> +/* All the known sensors for ASUS EC controllers. These arrays have to be sorted
> + * by the full ((bank << 8) + index) register index (see asus_ec_block_read() as
> + * to why).
> +*/

WARNING: Block comments should align the * on each line
#123: FILE: drivers/hwmon/asus-ec-sensors.c:175:
+ * to why).
+*/

I'll fix that up and apply the patch, but _please_ run checkpatch on your patches.

Also, this is not the network subsystem. Please use standard multi-line comments.

Guenter

>  static const struct ec_sensor_info sensors_family_amd_400[] = {
>  	[ec_sensor_temp_chipset] =
>  		EC_SENSOR("Chipset", hwmon_temp, 1, 0x00, 0x3a),
> @@ -183,10 +186,10 @@ static const struct ec_sensor_info sensors_family_amd_400[] = {
>  		EC_SENSOR("VRM", hwmon_temp, 1, 0x00, 0x3e),
>  	[ec_sensor_in_cpu_core] =
>  		EC_SENSOR("CPU Core", hwmon_in, 2, 0x00, 0xa2),
> -	[ec_sensor_fan_cpu_opt] =
> -		EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xbc),
>  	[ec_sensor_fan_vrm_hs] =
>  		EC_SENSOR("VRM HS", hwmon_fan, 2, 0x00, 0xb2),
> +	[ec_sensor_fan_cpu_opt] =
> +		EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xbc),
>  	[ec_sensor_fan_chipset] =
>  		/* no chipset fans in this generation */
>  		EC_SENSOR("Chipset", hwmon_fan, 0, 0x00, 0x00),
> @@ -194,10 +197,10 @@ static const struct ec_sensor_info sensors_family_amd_400[] = {
>  		EC_SENSOR("Water_Flow", hwmon_fan, 2, 0x00, 0xb4),
>  	[ec_sensor_curr_cpu] =
>  		EC_SENSOR("CPU", hwmon_curr, 1, 0x00, 0xf4),
> -	[ec_sensor_temp_water_in] =
> -		EC_SENSOR("Water_In", hwmon_temp, 1, 0x01, 0x0d),
>  	[ec_sensor_temp_water_out] =
>  		EC_SENSOR("Water_Out", hwmon_temp, 1, 0x01, 0x0b),
> +	[ec_sensor_temp_water_in] =
> +		EC_SENSOR("Water_In", hwmon_temp, 1, 0x01, 0x0d),
>  };
>  
>  static const struct ec_sensor_info sensors_family_amd_500[] = {
> @@ -239,19 +242,20 @@ static const struct ec_sensor_info sensors_family_amd_500[] = {
>  
>  static const struct ec_sensor_info sensors_family_amd_600[] = {
>  	[ec_sensor_temp_cpu] = EC_SENSOR("CPU", hwmon_temp, 1, 0x00, 0x30),
> -	[ec_sensor_temp_cpu_package] = EC_SENSOR("CPU Package", hwmon_temp, 1, 0x00, 0x31),
> +	[ec_sensor_temp_cpu_package] =
> +		EC_SENSOR("CPU Package", hwmon_temp, 1, 0x00, 0x31),
>  	[ec_sensor_temp_mb] =
>  	EC_SENSOR("Motherboard", hwmon_temp, 1, 0x00, 0x32),
>  	[ec_sensor_temp_vrm] =
>  		EC_SENSOR("VRM", hwmon_temp, 1, 0x00, 0x33),
>  	[ec_sensor_temp_t_sensor] =
>  		EC_SENSOR("T_Sensor", hwmon_temp, 1, 0x00, 0x36),
> +	[ec_sensor_fan_cpu_opt] =
> +		EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xb0),
>  	[ec_sensor_temp_water_in] =
>  		EC_SENSOR("Water_In", hwmon_temp, 1, 0x01, 0x00),
>  	[ec_sensor_temp_water_out] =
>  		EC_SENSOR("Water_Out", hwmon_temp, 1, 0x01, 0x01),
> -	[ec_sensor_fan_cpu_opt] =
> -		EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xb0),
>  };
>  
>  static const struct ec_sensor_info sensors_family_intel_300[] = {

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

end of thread, other threads:[~2025-04-09  2:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-08 20:44 [PATCH] hwmon: (asus-ec-sensors) sort sensor definition arrays Eugene Shalygin
2025-04-09  2:14 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox