Skip to contentSkip to conversation

hwmon: (asus-ec-sensors) add driver for ASUS EC

PATCH In review Eugene Shalygin 4 participants 10 messages Dec 16, 2021 – Dec 18, 2021

Subsystems (3)
lore
Share & tools
lore

Eugene Shalygin

author maintainer
#0 lore raw

PATCH 1/3 hwmon: (asus-ec-sensors) add driver for ASUS EC

This driver provides the same data as the asus_wmi_ec_sensors driver (and gets it from the same source) but does not use WMI, polling the ACPI EC directly.

That provides two enhancements: sensor reading became quicker (on some systems or kernel configuration it took almost a full second to read all the sensors, that transfers less than 15 bytes of data), the driver became more fexible. The driver now relies on ACPI mutex to lock access to the EC, in the same way as the WMI DSDT code does.

---
 drivers/hwmon/Kconfig           |  12 +
 drivers/hwmon/Makefile          |   1 +
 drivers/hwmon/asus-ec-sensors.c | 753 ++++++++++++++++++++++++++++++++
 3 files changed, 766 insertions(+)
 create mode 100644 drivers/hwmon/asus-ec-sensors.c
drivers/hwmon/Kconfig +12 -0
index 43e5245874ad..c2227118b23a 100644
@@ -2253,6 +2253,18 @@ config SENSORS_ASUS_WMI_EC
 	  This driver can also be built as a module. If so, the module
 	  will be called asus_wmi_sensors_ec.
 
+config SENSORS_ASUS_EC
+	tristate "ASUS EC Sensors"
+	depends on ACPI
+	help
+	  If you say yes here you get support for the ACPI embedded controller
+	  hardware monitoring interface found in ASUS motherboards. The driver
+	  currently supports B550/X570 boards, although other ASUS boards might
+	  provide this monitoring interface as well.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called asus_ec_sensors.
+
 endif # ACPI
 
 endif # HWMON
drivers/hwmon/Makefile +1 -0
index 3a1551b3d570..2e5c216bb5d7 100644
@@ -9,6 +9,7 @@ obj-$(CONFIG_HWMON_VID)		+= hwmon-vid.o
 # APCI drivers
 obj-$(CONFIG_SENSORS_ACPI_POWER) += acpi_power_meter.o
 obj-$(CONFIG_SENSORS_ATK0110)	+= asus_atk0110.o
+obj-$(CONFIG_SENSORS_ASUS_EC)	+= asus-ec-sensors.o
 obj-$(CONFIG_SENSORS_ASUS_WMI)	+= asus_wmi_sensors.o
 obj-$(CONFIG_SENSORS_ASUS_WMI_EC)	+= asus_wmi_ec_sensors.o
 
drivers/hwmon/asus-ec-sensors.c new file +753 -0

753 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH 2/3 hwmon: update ASUS EC driver documentation

---
 ...wmi_ec_sensors.rst => asus_ec_sensors.rst} | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
 rename Documentation/hwmon/{asus_wmi_ec_sensors.rst => asus_ec_sensors.rst} (61%)
Documentation/hwmon/asus_ec_sensors.rst renamed from Documentation/hwmon/asus_wmi_ec_sensors.rst +10 -9
similarity index 61%
rename from Documentation/hwmon/asus_wmi_ec_sensors.rst
rename to Documentation/hwmon/asus_ec_sensors.rst
index 1b287f229e86..8b4baf83116f 100644
@@ -1,6 +1,6 @@
 .. SPDX-License-Identifier: GPL-2.0-or-later
 
-Kernel driver asus_wmi_ec_sensors
+Kernel driver asus_ec_sensors
 =================================
 
 Supported boards:
@@ -9,9 +9,11 @@ Supported boards:
  * ROG CROSSHAIR VIII DARK HERO,
  * ROG CROSSHAIR VIII FORMULA,
  * ROG CROSSHAIR VIII HERO,
+ * ROG CROSSHAIR VIII IMPACT,
  * ROG STRIX B550-E GAMING,
  * ROG STRIX B550-I GAMING,
- * ROG STRIX X570-E GAMING.
+ * ROG STRIX X570-E GAMING,
+ * ROG STRIX X570-I GAMING
 
 Authors:
     - Eugene Shalygin <[email protected]>
@@ -22,9 +24,7 @@ ASUS mainboards publish hardware monitoring information via Super I/O
 chip and the ACPI embedded controller (EC) registers. Some of the sensors
 are only available via the EC.
 
-ASUS WMI interface provides a method (BREC) to read data from EC registers,
-which is utilized by this driver to publish those sensor readings to the
-HWMON system. The driver is aware of and reads the following sensors:
+The driver is aware of and reads the following sensors:
 
 1. Chipset (PCH) temperature
 2. CPU package temperature
@@ -32,7 +32,8 @@ HWMON system. The driver is aware of and reads the following sensors:
 4. Readings from the T_Sensor header
 5. VRM temperature
 6. CPU_Opt fan RPM
-7. Chipset fan RPM
-8. Readings from the "Water flow meter" header (RPM)
-9. Readings from the "Water In" and "Water Out" temperature headers
-10. CPU current
+7. VRM heatsink fan RPM
+8. Chipset fan RPM
+9. Readings from the "Water flow meter" header (RPM)
+10. Readings from the "Water In" and "Water Out" temperature headers
+11. CPU current
Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH 3/3 hwmon: remove asus_wmi_ec_sensors driver

In reply to Eugene Shalygin

The driver is superceeded by asus-ec-sensors

---
 drivers/hwmon/Kconfig               |  12 -
 drivers/hwmon/Makefile              |   1 -
 drivers/hwmon/asus_wmi_ec_sensors.c | 621 ----------------------------
 3 files changed, 634 deletions(-)
 delete mode 100644 drivers/hwmon/asus_wmi_ec_sensors.c
drivers/hwmon/Kconfig +0 -12
index c2227118b23a..c9b2d71e8ac9 100644
@@ -2241,18 +2241,6 @@ config SENSORS_ASUS_WMI
 	  This driver can also be built as a module. If so, the module
 	  will be called asus_wmi_sensors.
 
-config SENSORS_ASUS_WMI_EC
-	tristate "ASUS WMI B550/X570"
-	depends on ACPI_WMI
-	help
-	  If you say yes here you get support for the ACPI embedded controller
-	  hardware monitoring interface found in B550/X570 ASUS motherboards.
-	  This driver will provide readings of fans, voltages and temperatures
-	  through the system firmware.
-
-	  This driver can also be built as a module. If so, the module
-	  will be called asus_wmi_sensors_ec.
-
 config SENSORS_ASUS_EC
 	tristate "ASUS EC Sensors"
 	depends on ACPI
drivers/hwmon/Makefile +0 -1
index 2e5c216bb5d7..71eb2d548e20 100644
@@ -11,7 +11,6 @@ obj-$(CONFIG_SENSORS_ACPI_POWER) += acpi_power_meter.o
 obj-$(CONFIG_SENSORS_ATK0110)	+= asus_atk0110.o
 obj-$(CONFIG_SENSORS_ASUS_EC)	+= asus-ec-sensors.o
 obj-$(CONFIG_SENSORS_ASUS_WMI)	+= asus_wmi_sensors.o
-obj-$(CONFIG_SENSORS_ASUS_WMI_EC)	+= asus_wmi_ec_sensors.o
 
 # Native drivers
 # asb100, then w83781d go first, as they can override other drivers' addresses.
drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -621

621 lines not on this page · raw message

Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH 3/3] hwmon: remove asus_wmi_ec_sensors driver

Hi Eugene,

Could you also remove a mention of the previous driver from MAINTERNERS?

Quoted 726 lines · On Thu, 16 Dec 2021 21:53:02 +0100 Eugene Shalygin <[email protected]>…

The driver is superceeded by asus-ec-sensors

---
 drivers/hwmon/Kconfig               |  12 -
 drivers/hwmon/Makefile              |   1 -
 drivers/hwmon/asus_wmi_ec_sensors.c | 621
---------------------------- 3 files changed, 634 deletions(-)
 delete mode 100644 drivers/hwmon/asus_wmi_ec_sensors.c
drivers/hwmon/Kconfig +0 -0
index c2227118b23a..c9b2d71e8ac9 100644
@@ -2241,18 +2241,6 @@ config SENSORS_ASUS_WMI
 	  This driver can also be built as a module. If so, the

module will be called asus_wmi_sensors.

drivers/hwmon/Kconfig +0 -5
-config SENSORS_ASUS_WMI_EC
-	tristate "ASUS WMI B550/X570"
-	depends on ACPI_WMI
-	help
-	  If you say yes here you get support for the ACPI embedded

controller

drivers/hwmon/Kconfig +0 -1
-	  hardware monitoring interface found in B550/X570 ASUS

motherboards.

drivers/hwmon/Kconfig +0 -1
-	  This driver will provide readings of fans, voltages and

temperatures

drivers/hwmon/Kconfig +0 -3
-	  through the system firmware.
-
-	  This driver can also be built as a module. If so, the

module

drivers/hwmon/Kconfig +0 -2
-	  will be called asus_wmi_sensors_ec.
-
 config SENSORS_ASUS_EC
 	tristate "ASUS EC Sensors"
 	depends on ACPI
drivers/hwmon/Makefile +0 -0
index 2e5c216bb5d7..71eb2d548e20 100644
@@ -11,7 +11,6 @@ obj-$(CONFIG_SENSORS_ACPI_POWER) +=

acpi_power_meter.o obj-$(CONFIG_SENSORS_ATK0110) +=
asus_atk0110.o obj-$(CONFIG_SENSORS_ASUS_EC) +=
asus-ec-sensors.o obj-$(CONFIG_SENSORS_ASUS_WMI) +=
asus_wmi_sensors.o -obj-$(CONFIG_SENSORS_ASUS_WMI_EC) +=
asus_wmi_ec_sensors.o
# Native drivers
# asb100, then w83781d go first, as they can override other drivers'
addresses. diff --git a/drivers/hwmon/asus_wmi_ec_sensors.c b/drivers/hwmon/asus_wmi_ec_sensors.c deleted file mode 100644 index 22a1459305a7..000000000000

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -37
@@ -1,621 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * HWMON driver for ASUS B550/X570 motherboards that publish sensor
- * values via the embedded controller registers.
- *
- * Copyright (C) 2021 Eugene Shalygin <[email protected]>
- * Copyright (C) 2018-2019 Ed Brindley <[email protected]>
- *
- * EC provides:
- * - Chipset temperature
- * - CPU temperature
- * - Motherboard temperature
- * - T_Sensor temperature
- * - VRM temperature
- * - Water In temperature
- * - Water Out temperature
- * - CPU Optional Fan RPM
- * - Chipset Fan RPM
- * - Water Flow Fan RPM
- * - CPU current
- */
-
-#include <linux/acpi.h>
-#include <linux/dmi.h>
-#include <linux/hwmon.h>
-#include <linux/init.h>
-#include <linux/jiffies.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/nls.h>
-#include <linux/units.h>
-#include <linux/wmi.h>
-
-#include <asm/unaligned.h>
-
-#define ASUSWMI_MONITORING_GUID

"466747A0-70EC-11DE-8A39-0800200C9A66" -#define
ASUSWMI_METHODID_BLOCK_READ_EC 0x42524543 /* BREC */ -/* From
the ASUS DSDT source */ -#define ASUSWMI_BREC_REGISTERS_MAX 16

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -30
-#define ASUSWMI_MAX_BUF_LEN		128
-#define SENSOR_LABEL_LEN		16
-
-static u32 hwmon_attributes[hwmon_max] = {
-	[hwmon_chip]	= HWMON_C_REGISTER_TZ,
-	[hwmon_temp]	= HWMON_T_INPUT | HWMON_T_LABEL,
-	[hwmon_in]	= HWMON_I_INPUT | HWMON_I_LABEL,
-	[hwmon_curr]	= HWMON_C_INPUT | HWMON_C_LABEL,
-	[hwmon_fan]	= HWMON_F_INPUT | HWMON_F_LABEL,
-};
-
-struct asus_wmi_ec_sensor_address {
-	u8 index;
-	u8 bank;
-	u8 size;
-};
-
-#define MAKE_SENSOR_ADDRESS(size_i, bank_i, index_i) {	\
-	.size = size_i,					\
-	.bank = bank_i,					\
-	.index = index_i,				\
-}
-
-struct ec_sensor_info {
-	struct asus_wmi_ec_sensor_address addr;
-	char label[SENSOR_LABEL_LEN];
-	enum hwmon_sensor_types type;
-};
-
-#define EC_SENSOR(sensor_label, sensor_type, size, bank, index)

{ \

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	.addr = MAKE_SENSOR_ADDRESS(size, bank, index),
		\
drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	.label = sensor_label,
		\
drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	.type = sensor_type,
	\ -}
drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -20
-
-enum known_ec_sensor {
-	SENSOR_TEMP_CHIPSET,
-	SENSOR_TEMP_CPU,
-	SENSOR_TEMP_MB,
-	SENSOR_TEMP_T_SENSOR,
-	SENSOR_TEMP_VRM,
-	SENSOR_FAN_CPU_OPT,
-	SENSOR_FAN_CHIPSET,
-	SENSOR_FAN_VRM_HS,
-	SENSOR_FAN_WATER_FLOW,
-	SENSOR_CURR_CPU,
-	SENSOR_TEMP_WATER_IN,
-	SENSOR_TEMP_WATER_OUT,
-	SENSOR_MAX
-};
-
-/* All known sensors for ASUS EC controllers */
-static const struct ec_sensor_info known_ec_sensors[] = {
-	[SENSOR_TEMP_CHIPSET]	= EC_SENSOR("Chipset",

hwmon_temp, 1, 0x00, 0x3a),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	[SENSOR_TEMP_CPU]	= EC_SENSOR("CPU", hwmon_temp, 1,

0x00, 0x3b),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	[SENSOR_TEMP_MB]	= EC_SENSOR("Motherboard",

hwmon_temp, 1, 0x00, 0x3c),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	[SENSOR_TEMP_T_SENSOR]	= EC_SENSOR("T_Sensor",

hwmon_temp, 1, 0x00, 0x3d),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	[SENSOR_TEMP_VRM]	= EC_SENSOR("VRM", hwmon_temp, 1,

0x00, 0x3e),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	[SENSOR_FAN_CPU_OPT]	= EC_SENSOR("CPU_Opt",

hwmon_fan, 2, 0x00, 0xb0),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	[SENSOR_FAN_VRM_HS]	= EC_SENSOR("VRM HS", hwmon_fan,

2, 0x00, 0xb2),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	[SENSOR_FAN_CHIPSET]	= EC_SENSOR("Chipset",

hwmon_fan, 2, 0x00, 0xb4),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	[SENSOR_FAN_WATER_FLOW]	= EC_SENSOR("Water_Flow",

hwmon_fan, 2, 0x00, 0xbc),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	[SENSOR_CURR_CPU]	= EC_SENSOR("CPU", hwmon_curr, 1,

0x00, 0xf4),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	[SENSOR_TEMP_WATER_IN]	= EC_SENSOR("Water_In",

hwmon_temp, 1, 0x01, 0x00),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	[SENSOR_TEMP_WATER_OUT]	= EC_SENSOR("Water_Out",

hwmon_temp, 1, 0x01, 0x01), -};

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -3
-
-struct asus_wmi_data {
-	const enum known_ec_sensor known_board_sensors[SENSOR_MAX +

1]; -};

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -5
-
-/* boards with EC support */
-static struct asus_wmi_data sensors_board_PW_X570_P = {
-	.known_board_sensors = {
-		SENSOR_TEMP_CHIPSET, SENSOR_TEMP_CPU,

SENSOR_TEMP_MB, SENSOR_TEMP_VRM,

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -8
-		SENSOR_FAN_CHIPSET,
-		SENSOR_MAX
-	},
-};
-
-static struct asus_wmi_data sensors_board_PW_X570_A = {
-	.known_board_sensors = {
-		SENSOR_TEMP_CHIPSET, SENSOR_TEMP_CPU,

SENSOR_TEMP_MB, SENSOR_TEMP_VRM,

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -12
-		SENSOR_FAN_CHIPSET,
-		SENSOR_CURR_CPU,
-		SENSOR_MAX
-	},
-};
-
-static struct asus_wmi_data sensors_board_R_C8H = {
-	.known_board_sensors = {
-		SENSOR_TEMP_CHIPSET, SENSOR_TEMP_CPU, SENSOR_TEMP_MB,
-		SENSOR_TEMP_T_SENSOR, SENSOR_TEMP_VRM,
-		SENSOR_TEMP_WATER_IN, SENSOR_TEMP_WATER_OUT,
-		SENSOR_FAN_CPU_OPT, SENSOR_FAN_CHIPSET,

SENSOR_FAN_WATER_FLOW,

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -58
-		SENSOR_CURR_CPU,
-		SENSOR_MAX
-	},
-};
-
-/* Same as Hero but without chipset fan */
-static struct asus_wmi_data sensors_board_R_C8DH = {
-	.known_board_sensors = {
-		SENSOR_TEMP_CHIPSET, SENSOR_TEMP_CPU, SENSOR_TEMP_MB,
-		SENSOR_TEMP_T_SENSOR, SENSOR_TEMP_VRM,
-		SENSOR_TEMP_WATER_IN, SENSOR_TEMP_WATER_OUT,
-		SENSOR_FAN_CPU_OPT, SENSOR_FAN_WATER_FLOW,
-		SENSOR_CURR_CPU,
-		SENSOR_MAX
-	},
-};
-
-/* Same as Hero but without water */
-static struct asus_wmi_data sensors_board_R_C8F = {
-	.known_board_sensors = {
-		SENSOR_TEMP_CHIPSET, SENSOR_TEMP_CPU, SENSOR_TEMP_MB,
-		SENSOR_TEMP_T_SENSOR, SENSOR_TEMP_VRM,
-		SENSOR_FAN_CPU_OPT, SENSOR_FAN_CHIPSET,
-		SENSOR_CURR_CPU,
-		SENSOR_MAX
-	},
-};
-
-static struct asus_wmi_data sensors_board_RS_B550_E_G = {
-	.known_board_sensors = {
-		SENSOR_TEMP_CHIPSET, SENSOR_TEMP_CPU, SENSOR_TEMP_MB,
-		SENSOR_TEMP_T_SENSOR, SENSOR_TEMP_VRM,
-		SENSOR_FAN_CPU_OPT,
-		SENSOR_MAX
-	},
-};
-
-static struct asus_wmi_data sensors_board_RS_B550_I_G = {
-	.known_board_sensors = {
-		SENSOR_TEMP_CHIPSET, SENSOR_TEMP_CPU, SENSOR_TEMP_MB,
-		SENSOR_TEMP_T_SENSOR, SENSOR_TEMP_VRM,
-		SENSOR_FAN_VRM_HS,
-		SENSOR_CURR_CPU,
-		SENSOR_MAX
-	},
-};
-
-static struct asus_wmi_data sensors_board_RS_X570_E_G = {
-	.known_board_sensors = {
-		SENSOR_TEMP_CHIPSET, SENSOR_TEMP_CPU, SENSOR_TEMP_MB,
-		SENSOR_TEMP_T_SENSOR, SENSOR_TEMP_VRM,
-		SENSOR_FAN_CHIPSET,
-		SENSOR_CURR_CPU,
-		SENSOR_MAX
-	},
-};
-
-#define DMI_EXACT_MATCH_ASUS_BOARD_NAME(name, sensors) {
		\
drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	.matches = {
		\
drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-		DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "ASUSTeK COMPUTER

INC."), \

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-		DMI_EXACT_MATCH(DMI_BOARD_NAME, name),
			\
drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	},
		\
drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	.driver_data = sensors,
			\ -}
drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -3
-
-static const struct dmi_system_id asus_wmi_ec_dmi_table[] = {
-	DMI_EXACT_MATCH_ASUS_BOARD_NAME("PRIME X570-PRO",

&sensors_board_PW_X570_P),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	DMI_EXACT_MATCH_ASUS_BOARD_NAME("Pro WS X570-ACE",

&sensors_board_PW_X570_A),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG CROSSHAIR VIII DARK

HERO", &sensors_board_R_C8DH),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG CROSSHAIR VIII

FORMULA", &sensors_board_R_C8F),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG CROSSHAIR VIII HERO",

&sensors_board_R_C8H),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX B550-E GAMING",

&sensors_board_RS_B550_E_G),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX B550-I GAMING",

&sensors_board_RS_B550_I_G),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX X570-E GAMING",

&sensors_board_RS_X570_E_G),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -16
-	{}
-};
-MODULE_DEVICE_TABLE(dmi, asus_wmi_ec_dmi_table);
-
-struct ec_sensor {
-	enum known_ec_sensor info_index;
-	long cached_value;
-};
-
-/**
- * struct asus_wmi_ec_info - sensor info.
- * @sensors: list of sensors.
- * @read_arg: UTF-16LE string to pass to BRxx() WMI function.
- * @read_buffer: decoded output from WMI result.
- * @nr_sensors: number of board EC sensors.
- * @nr_registers: number of EC registers to read (sensor might span

more than 1 register).
- * @last_updated: in jiffies.
- */

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -16
-struct asus_wmi_ec_info {
-	struct ec_sensor sensors[SENSOR_MAX];
-	char read_arg[(ASUSWMI_BREC_REGISTERS_MAX * 4 + 1) * 2];
-	u8 read_buffer[ASUSWMI_BREC_REGISTERS_MAX];
-	unsigned int nr_sensors;
-	unsigned int nr_registers;
-	unsigned long last_updated;
-};
-
-struct asus_wmi_sensors {
-	struct asus_wmi_ec_info ec;
-	/* lock access to internal cache */
-	struct mutex lock;
-};
-
-static int asus_wmi_ec_fill_board_sensors(struct asus_wmi_ec_info

*ec,

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-					  const enum known_ec_sensor

*bsi) -{

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -10
-	struct ec_sensor *s = ec->sensors;
-	int i;
-
-	ec->nr_sensors = 0;
-	ec->nr_registers = 0;
-
-	for (i = 0; bsi[i] != SENSOR_MAX; i++) {
-		s[i].info_index = bsi[i];
-		ec->nr_sensors++;
-		ec->nr_registers +=

known_ec_sensors[bsi[i]].addr.size;

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -7
-	}
-
-	return 0;
-}
-
-/*
- * The next four functions convert to or from BRxx string argument

format.
- * The format of the string is as follows:
- * - The string consists of two-byte UTF-16LE characters.
- * - The value of the very first byte in the string is equal to the total
- * length of the next string in bytes, thus excluding the first
two-byte
- * character.
- * - The rest of the string encodes the pairs of (bank, index) pairs, where
- * both values are byte-long (0x00 to 0xFF).
- * - Numbers are encoded as UTF-16LE hex values.
- */
-static int asus_wmi_ec_decode_reply_buffer(const u8 *in, u32 length, u8 *out) -{

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -4
-	char buffer[ASUSWMI_MAX_BUF_LEN * 2];
-	u32 len = min_t(u32, get_unaligned_le16(in), length - 2);
-
-	utf16s_to_utf8s((wchar_t *)(in + 2), len / 2,

UTF16_LITTLE_ENDIAN, buffer, sizeof(buffer)); -

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -4
-	return hex2bin(out, buffer, len / 4);
-}
-
-static void asus_wmi_ec_encode_registers(const u8 *in, u32 len, char

*out) -{

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -5
-	char buffer[ASUSWMI_MAX_BUF_LEN * 2];
-
-	bin2hex(buffer, in, len);
-
-	utf8s_to_utf16s(buffer, len * 2, UTF16_LITTLE_ENDIAN,

(wchar_t *)(out + 2), len * 2); -

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -4
-	put_unaligned_le16(len * 4, out);
-}
-
-static void asus_wmi_ec_make_block_read_query(struct

asus_wmi_ec_info *ec) -{

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -14
-	u8 registers[ASUSWMI_BREC_REGISTERS_MAX * 2];
-	const struct ec_sensor_info *si;
-	int i, j, offset;
-
-	offset = 0;
-	for (i = 0; i < ec->nr_sensors; i++) {
-		si = &known_ec_sensors[ec->sensors[i].info_index];
-		for (j = 0; j < si->addr.size; j++) {
-			registers[offset++] = si->addr.bank;
-			registers[offset++] = si->addr.index + j;
-		}
-	}
-
-	asus_wmi_ec_encode_registers(registers, offset,

ec->read_arg); -}

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -2
-
-static int asus_wmi_ec_block_read(u32 method_id, char *query, u8

*out) -{

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -7
-	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
-	struct acpi_buffer input;
-	union acpi_object *obj;
-	acpi_status status;
-	int ret;
-
-	/* The first byte of the BRxx() argument string has to be

the string size. */

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -3
-	input.length = query[0] + 2;
-	input.pointer = query;
-	status = wmi_evaluate_method(ASUSWMI_MONITORING_GUID, 0,

method_id, &input, &output);

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -8
-	if (ACPI_FAILURE(status))
-		return -EIO;
-
-	obj = output.pointer;
-	if (!obj)
-		return -EIO;
-
-	if (obj->type != ACPI_TYPE_BUFFER || obj->buffer.length < 2)

{

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -5
-		ret = -EIO;
-		goto out_free_obj;
-	}
-
-	ret = asus_wmi_ec_decode_reply_buffer(obj->buffer.pointer,

obj->buffer.length, out); -

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -6
-out_free_obj:
-	ACPI_FREE(obj);
-	return ret;
-}
-
-static inline long get_sensor_value(const struct ec_sensor_info *si,

u8 *data) -{

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -13
-	switch (si->addr.size) {
-	case 1:
-		return *data;
-	case 2:
-		return get_unaligned_be16(data);
-	case 4:
-		return get_unaligned_be32(data);
-	default:
-		return 0;
-	}
-}
-
-static void asus_wmi_ec_update_ec_sensors(struct asus_wmi_ec_info

*ec) -{

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -27
-	const struct ec_sensor_info *si;
-	struct ec_sensor *s;
-	u8 i_sensor;
-	u8 *data;
-
-	data = ec->read_buffer;
-	for (i_sensor = 0; i_sensor < ec->nr_sensors; i_sensor++) {
-		s = &ec->sensors[i_sensor];
-		si = &known_ec_sensors[s->info_index];
-		s->cached_value = get_sensor_value(si, data);
-		data += si->addr.size;
-	}
-}
-
-static long asus_wmi_ec_scale_sensor_value(long value, int data_type)
-{
-	switch (data_type) {
-	case hwmon_curr:
-	case hwmon_temp:
-	case hwmon_in:
-		return value * MILLI;
-	default:
-		return value;
-	}
-}
-
-static int asus_wmi_ec_find_sensor_index(const struct

asus_wmi_ec_info *ec,

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-					 enum hwmon_sensor_types

type, int channel) -{

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -4
-	int i;
-
-	for (i = 0; i < ec->nr_sensors; i++) {
-		if (known_ec_sensors[ec->sensors[i].info_index].type

== type) {

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -10
-			if (channel == 0)
-				return i;
-
-			channel--;
-		}
-	}
-	return -EINVAL;
-}
-
-static int asus_wmi_ec_get_cached_value_or_update(struct

asus_wmi_sensors *sensor_data,

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -10
-						  int sensor_index,
-						  long *value)
-{
-	struct asus_wmi_ec_info *ec = &sensor_data->ec;
-	int ret = 0;
-
-	mutex_lock(&sensor_data->lock);
-
-	if (time_after(jiffies, ec->last_updated + HZ)) {
-		ret =

asus_wmi_ec_block_read(ASUSWMI_METHODID_BLOCK_READ_EC,

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-					     ec->read_arg,

ec->read_buffer);

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -18
-		if (ret)
-			goto unlock;
-
-		asus_wmi_ec_update_ec_sensors(ec);
-		ec->last_updated = jiffies;
-	}
-
-	*value = ec->sensors[sensor_index].cached_value;
-
-unlock:
-	mutex_unlock(&sensor_data->lock);
-
-	return ret;
-}
-
-/* Now follow the functions that implement the hwmon interface */
-
-static int asus_wmi_ec_hwmon_read(struct device *dev, enum

hwmon_sensor_types type,

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -12
-				  u32 attr, int channel, long *val)
-{
-	struct asus_wmi_sensors *sensor_data = dev_get_drvdata(dev);
-	struct asus_wmi_ec_info *ec = &sensor_data->ec;
-	int ret, sidx, info_index;
-	long value = 0;
-
-	sidx = asus_wmi_ec_find_sensor_index(ec, type, channel);
-	if (sidx < 0)
-		return sidx;
-
-	ret = asus_wmi_ec_get_cached_value_or_update(sensor_data,

sidx, &value);

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -5
-	if (ret)
-		return ret;
-
-	info_index = ec->sensors[sidx].info_index;
-	*val = asus_wmi_ec_scale_sensor_value(value,

known_ec_sensors[info_index].type); -

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -5
-	return ret;
-}
-
-static int asus_wmi_ec_hwmon_read_string(struct device *dev,
-					 enum hwmon_sensor_types

type, u32 attr,

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-					 int channel, const char

**str) -{

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -5
-	struct asus_wmi_sensors *sensor_data = dev_get_drvdata(dev);
-	struct asus_wmi_ec_info *ec = &sensor_data->ec;
-	int sensor_index;
-
-	sensor_index = asus_wmi_ec_find_sensor_index(ec, type,

channel);

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-	*str =

known_ec_sensors[ec->sensors[sensor_index].info_index].label; -

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -5
-	return 0;
-}
-
-static umode_t asus_wmi_ec_hwmon_is_visible(const void *drvdata,
-					    enum hwmon_sensor_types

type, u32 attr,

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -12
-					    int channel)
-{
-	const struct asus_wmi_sensors *sensor_data = drvdata;
-	const struct asus_wmi_ec_info *ec = &sensor_data->ec;
-	int index;
-
-	index = asus_wmi_ec_find_sensor_index(ec, type, channel);
-
-	return index < 0 ? 0 : 0444;
-}
-
-static int asus_wmi_hwmon_add_chan_info(struct hwmon_channel_info

*asus_wmi_hwmon_chan,

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -2
-					struct device *dev, int num,
-					enum hwmon_sensor_types

type, u32 config) -{

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -25
-	u32 *cfg;
-
-	cfg = devm_kcalloc(dev, num + 1, sizeof(*cfg), GFP_KERNEL);
-	if (!cfg)
-		return -ENOMEM;
-
-	asus_wmi_hwmon_chan->type = type;
-	asus_wmi_hwmon_chan->config = cfg;
-	memset32(cfg, config, num);
-
-	return 0;
-}
-
-static const struct hwmon_ops asus_wmi_ec_hwmon_ops = {
-	.is_visible = asus_wmi_ec_hwmon_is_visible,
-	.read = asus_wmi_ec_hwmon_read,
-	.read_string = asus_wmi_ec_hwmon_read_string,
-};
-
-static struct hwmon_chip_info asus_wmi_ec_chip_info = {
-	.ops = &asus_wmi_ec_hwmon_ops,
-};
-
-static int asus_wmi_ec_configure_sensor_setup(struct device *dev,
-					      const enum

known_ec_sensor *bsi) -{

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -32
-	struct asus_wmi_sensors *sensor_data = dev_get_drvdata(dev);
-	struct asus_wmi_ec_info *ec = &sensor_data->ec;
-	struct hwmon_channel_info *asus_wmi_hwmon_chan;
-	const struct hwmon_channel_info **asus_wmi_ci;
-	int nr_count[hwmon_max] = {}, nr_types = 0;
-	const struct hwmon_chip_info *chip_info;
-	const struct ec_sensor_info *si;
-	enum hwmon_sensor_types type;
-	struct device *hwdev;
-	int i, ret;
-
-	ret = asus_wmi_ec_fill_board_sensors(ec, bsi);
-	if (ret)
-		return ret;
-
-	if (!sensor_data->ec.nr_sensors)
-		return -ENODEV;
-
-	for (i = 0; i < ec->nr_sensors; i++) {
-		si = &known_ec_sensors[ec->sensors[i].info_index];
-		if (!nr_count[si->type])
-			nr_types++;
-		nr_count[si->type]++;
-	}
-
-	if (nr_count[hwmon_temp]) {
-		nr_count[hwmon_chip]++;
-		nr_types++;
-	}
-
-	/*
-	 * If we can get values for all the registers in a single

query,

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -5
-	 * the query will not change from call to call.
-	 */
-	asus_wmi_ec_make_block_read_query(ec);
-
-	asus_wmi_hwmon_chan = devm_kcalloc(dev, nr_types,

sizeof(*asus_wmi_hwmon_chan),

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -5
-					   GFP_KERNEL);
-	if (!asus_wmi_hwmon_chan)
-		return -ENOMEM;
-
-	asus_wmi_ci = devm_kcalloc(dev, nr_types + 1,

sizeof(*asus_wmi_ci), GFP_KERNEL);

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -11
-	if (!asus_wmi_ci)
-		return -ENOMEM;
-
-	asus_wmi_ec_chip_info.info = asus_wmi_ci;
-	chip_info = &asus_wmi_ec_chip_info;
-
-	for (type = 0; type < hwmon_max; type++) {
-		if (!nr_count[type])
-			continue;
-
-		ret =

asus_wmi_hwmon_add_chan_info(asus_wmi_hwmon_chan, dev,

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-						   nr_count[type],

type,
-
hwmon_attributes[type]);

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -7
-		if (ret)
-			return ret;
-
-		*asus_wmi_ci++ = asus_wmi_hwmon_chan++;
-	}
-
-	dev_dbg(dev, "board has %d EC sensors that span %d

registers",

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -3
-		ec->nr_sensors, ec->nr_registers);
-
-	hwdev = devm_hwmon_device_register_with_info(dev,

"asus_wmi_ec_sensors",

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -1
-						     sensor_data,

chip_info, NULL); -

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -4
-	return PTR_ERR_OR_ZERO(hwdev);
-}
-
-static int asus_wmi_probe(struct wmi_device *wdev, const void

*context) -{

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -14
-	struct asus_wmi_sensors *sensor_data;
-	struct asus_wmi_data *board_sensors;
-	const struct dmi_system_id *dmi_id;
-	const enum known_ec_sensor *bsi;
-	struct device *dev = &wdev->dev;
-
-	dmi_id = dmi_first_match(asus_wmi_ec_dmi_table);
-	if (!dmi_id)
-		return -ENODEV;
-
-	board_sensors = dmi_id->driver_data;
-	bsi = board_sensors->known_board_sensors;
-
-	sensor_data = devm_kzalloc(dev, sizeof(*sensor_data),

GFP_KERNEL);

drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -18
-	if (!sensor_data)
-		return -ENOMEM;
-
-	mutex_init(&sensor_data->lock);
-
-	dev_set_drvdata(dev, sensor_data);
-
-	return asus_wmi_ec_configure_sensor_setup(dev, bsi);
-}
-
-static const struct wmi_device_id asus_ec_wmi_id_table[] = {
-	{ ASUSWMI_MONITORING_GUID, NULL },
-	{ }
-};
-
-static struct wmi_driver asus_sensors_wmi_driver = {
-	.driver = {
-		.name = "asus_wmi_ec_sensors",

drivers/hwmon/asus_wmi_ec_sensors.c line 621

Quoted 10 lines
drivers/hwmon/asus_wmi_ec_sensors.c deleted +0 -10
-	},
-	.id_table = asus_ec_wmi_id_table,
-	.probe = asus_wmi_probe,
-};
-module_wmi_driver(asus_sensors_wmi_driver);
-
-MODULE_AUTHOR("Ed Brindley <[email protected]>");
-MODULE_AUTHOR("Eugene Shalygin <[email protected]>");
-MODULE_DESCRIPTION("Asus WMI Sensors Driver");
-MODULE_LICENSE("GPL");

Best regards,
Denis.

#4 lore raw
In reply to Eugene Shalygin
Quoted 9 lines · Eugene Shalygin

This driver provides the same data as the asus_wmi_ec_sensors driver (and gets it from the same source) but does not use WMI, polling the ACPI EC directly.

That provides two enhancements: sensor reading became quicker (on some systems or kernel configuration it took almost a full second to read all the sensors, that transfers less than 15 bytes of data), the driver became more fexible. The driver now relies on ACPI mutex to lock access

flexible

Quoted 1 line

to the EC, in the same way as the WMI DSDT code does.

How do you know that this way there is no race with any of ACPI code?

...

drivers/hwmon/Kconfig config SENSORS_ASUS_WMI_EC

Quoted 4 lines
drivers/hwmon/Kconfig +3 -0
+config SENSORS_ASUS_EC
+       tristate "ASUS EC Sensors"
 
+       depends on ACPI

No need to duplicate. See (1) below.

drivers/hwmon/Kconfig config SENSORS_ASUS_WMI_EC · line 2268

Quoted 10 lines
drivers/hwmon/Kconfig +9 -0
+       help
+         If you say yes here you get support for the ACPI embedded controller
+         hardware monitoring interface found in ASUS motherboards. The driver
+         currently supports B550/X570 boards, although other ASUS boards might
+         provide this monitoring interface as well.
+
+         This driver can also be built as a module. If so, the module
+         will be called asus_ec_sensors.
+
 endif # ACPI

(1)

...

Quoted 3 lines

+/*
+ * HWMON driver for ASUS motherboards that publish some sensor values
+ * via the embedded controller registers

Missed grammatical period.

Quoted 3 lines

+ *

+ */

...

Quoted 1 line

+#define ASUS_EC_BANK_REGISTER 0xff /* Writing to this EC register switches EC bank */

Can you put comment before the definition?

...

Quoted 1 line

+#define SENSOR_LABEL_LEN 0x10

Why in hex?

Missed blank line here.

Quoted 4 lines

+/*
+ * Arbitrary set max. allowed bank number. Required for sorting banks and
+ * currently is overkill with just 2 banks used at max, but for the sake
+ * of alignment let's set it to a higher value

Check grammar everywhere, again missed period (at least).

Quoted 1 line

+ */

...

Quoted 1 line

+#define ACPI_DELAY_MSEC_LOCK 500 /* Wait for 0.5 s max. to acquire the lock */

_LOCK_DELAY_MS and drop useless comment

I think I gave the very same comments before. Maybe you can check the reviews of another driver?

...

drivers/hwmon/asus-ec-sensors.c line 66

Quoted 3 lines
drivers/hwmon/asus-ec-sensors.c new file +3 -0
+#define MAKE_SENSOR_ADDRESS(size, bank, index)                                 \
+       {                                                                      \
+               .value = (size << 16) + (bank << 8) + index                    \

Leave comma here and everywhere else in the structure entries.

Quoted 1 line

+ }

Besides that, would it be better to have it defined as a compound literal?

...

drivers/hwmon/asus-ec-sensors.c line 101

Quoted 13 lines
drivers/hwmon/asus-ec-sensors.c new file +13 -0
+enum known_ec_sensor {
+       SENSOR_TEMP_CHIPSET     = 1 <<  0, /* chipset temperature [℃] */
+       SENSOR_TEMP_CPU         = 1 <<  1, /* CPU temperature [℃] */
+       SENSOR_TEMP_MB          = 1 <<  2, /* motherboard temperature [℃] */
+       SENSOR_TEMP_T_SENSOR    = 1 <<  3, /* "T_Sensor" temperature sensor reading [℃] */
+       SENSOR_TEMP_VRM         = 1 <<  4, /* VRM temperature [℃] */
+       SENSOR_FAN_CPU_OPT      = 1 <<  5, /* CPU_Opt fan [RPM] */
+       SENSOR_FAN_VRM_HS       = 1 <<  6, /* VRM heat sink fan [RPM] */
+       SENSOR_FAN_CHIPSET      = 1 <<  7, /* chipset fan [RPM] */
+       SENSOR_FAN_WATER_FLOW   = 1 <<  8, /* water flow sensor reading [RPM] */
+       SENSOR_CURR_CPU         = 1 <<  9, /* CPU current [A] */
+       SENSOR_TEMP_WATER_IN    = 1 << 10, /* "Water_In" temperature sensor reading [℃] */
+       SENSOR_TEMP_WATER_OUT   = 1 << 11, /* "Water_Out" temperature sensor reading [℃] */

Perhaps kernel doc and use of BIT()?

Quoted 2 lines
(quoted diff) +2 -0
+       SENSOR_END
+};

...

drivers/hwmon/asus-ec-sensors.c line 120

Quoted 13 lines
drivers/hwmon/asus-ec-sensors.c new file +13 -0
+static const struct ec_sensor_info known_ec_sensors[] = {
+       EC_SENSOR("Chipset", hwmon_temp, 1, 0x00, 0x3a), /* SENSOR_TEMP_CHIPSET */
+       EC_SENSOR("CPU", hwmon_temp, 1, 0x00, 0x3b), /* SENSOR_TEMP_CPU */
+       EC_SENSOR("Motherboard", hwmon_temp, 1, 0x00, 0x3c), /* SENSOR_TEMP_MB */
+       EC_SENSOR("T_Sensor", hwmon_temp, 1, 0x00, 0x3d), /* SENSOR_TEMP_T_SENSOR */
+       EC_SENSOR("VRM", hwmon_temp, 1, 0x00, 0x3e), /* SENSOR_TEMP_VRM */
+       EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xb0), /* SENSOR_FAN_CPU_OPT */
+       EC_SENSOR("VRM HS", hwmon_fan, 2, 0x00, 0xb2), /* SENSOR_FAN_VRM_HS */
+       EC_SENSOR("Chipset", hwmon_fan, 2, 0x00, 0xb4), /* SENSOR_FAN_CHIPSET */
+       EC_SENSOR("Water_Flow", hwmon_fan, 2, 0x00, 0xbc), /* SENSOR_FAN_WATER_FLOW */
+       EC_SENSOR("CPU", hwmon_curr, 1, 0x00, 0xf4), /* SENSOR_CURR_CPU */
+       EC_SENSOR("Water_In", hwmon_temp, 1, 0x01, 0x00), /* SENSOR_TEMP_WATER_IN */
+       EC_SENSOR("Water_Out", hwmon_temp, 1, 0x01, 0x01), /* SENSOR_TEMP_WATER_OUT */

Instead of comments, use form of

[FOO] = BAR(...),

Quoted 1 line

+};

...

drivers/hwmon/asus-ec-sensors.c line 130

Quoted 3 lines
drivers/hwmon/asus-ec-sensors.c new file +3 -0
+static struct asus_ec_board_info board_P_X570_P = {
+       .sensors = SENSOR_TEMP_CHIPSET | SENSOR_TEMP_CPU | SENSOR_TEMP_MB | SENSOR_TEMP_VRM
+                | SENSOR_FAN_CHIPSET,

It's a bit long and better to leave ' |' on the previous line(s).

Quoted 1 line

+ .acpi_mutex_path = ASUS_HW_ACCESS_MUTEX_ASMX

+ Comma.

Quoted 1 line

+};

Ditto for all other similar cases.

...

drivers/hwmon/asus-ec-sensors.c line 212

Quoted 6 lines
drivers/hwmon/asus-ec-sensors.c new file +6 -0
+#define DMI_EXACT_MATCH_BOARD(vendor, name, sensors) {                         \
+               .matches = {                                                   \
+                       DMI_EXACT_MATCH(DMI_BOARD_VENDOR, vendor),             \
+                       DMI_EXACT_MATCH(DMI_BOARD_NAME, name),                 \
+               },                                                             \
+               .driver_data = sensors                                         \

+ Comma.

Quoted 1 line

+ }

...

Quoted 5 lines
drivers/hwmon/asus-ec-sensors.c new file +5 -0
+struct ec_sensors_data {
+       const struct asus_ec_board_info *board;
+       struct ec_sensor *sensors;
+       /* EC registers to read from */
+       u16 *registers;

drivers/hwmon/asus-ec-sensors.c line 258

Quoted 10 lines
drivers/hwmon/asus-ec-sensors.c new file +10 -0
+       u8 *read_buffer;
+       /* sorted list of unique register banks */
+       u8 banks[ASUS_EC_MAX_BANK];
+       unsigned long last_updated; /* in jiffies */
+       acpi_handle aml_mutex;
+       u8 nr_sensors; /* number of board EC sensors */
+       /* number of EC registers to read (sensor might span more than 1 register) */
+       u8 nr_registers;
+       u8 nr_banks; /* number of unique register banks */
+};

Kernel doc?

...

drivers/hwmon/asus-ec-sensors.c line 262

Quoted 3 lines
drivers/hwmon/asus-ec-sensors.c new file +3 -0
+static u8 register_bank(u16 reg)
+{
+       return (reg & 0xff00) >> 8;

' & 0xff00' part is redundant.

Quoted 1 line

+}

...

drivers/hwmon/asus-ec-sensors.c line 268

Quoted 4 lines
drivers/hwmon/asus-ec-sensors.c new file +4 -0
+static struct ec_sensors_data *get_sensor_data(struct device *pdev)
+{
+       return dev_get_drvdata(pdev);
+}

Useless wrapper. It adds no value.

...

drivers/hwmon/asus-ec-sensors.c line 285

Quoted 8 lines
drivers/hwmon/asus-ec-sensors.c new file +7 -0
+       unsigned int i;
+
+       for (i = 0; i < ec->nr_sensors; ++i) {
+               if (get_sensor_info(ec, i)->type == type) {
+                       if (channel == 0)
+                               return i;
 
+                       --channel;

What's wrong with post-decrement, and I think I already commented on this. So, I stopped here until you go and enforce all comments given against previous incarnation of this driver.

Quoted 4 lines
drivers/hwmon/asus-ec-sensors.c new file +4 -0
+               }
+       }
+       return -ENOENT;
+}

...

drivers/hwmon/asus-ec-sensors.c line 313

Quoted 3 lines
drivers/hwmon/asus-ec-sensors.c new file +3 -0
+       for (i = 1; i < SENSOR_END; i <<= 1) {
+               if ((i & ec->board->sensors) == 0
+                       continue;

Interesting way of NIH for_each_set_bit().

...

Quoted 1 line

+ for (j = 0; j < si->addr.components.size; ++j, ++register_idx) {

Why pre-increments?

Quoted 6 lines
drivers/hwmon/asus-ec-sensors.c new file +6 -0
+                       ec->registers[register_idx] =
+                               (si->addr.components.bank << 8) +
+                               si->addr.components.index + j;
+               }
+       }
+}

...

drivers/hwmon/asus-ec-sensors.c line 360

Quoted 4 lines
drivers/hwmon/asus-ec-sensors.c new file +3 -0
+       acpi_handle res;
 
+       acpi_status status = acpi_get_handle(
+               NULL, (acpi_string)state->board->acpi_mutex_path, &res);

It looks awful (indentation), Have you run checkpatch?

Quoted 4 lines
drivers/hwmon/asus-ec-sensors.c new file +4 -0
+       if (ACPI_FAILURE(status)) {
+               dev_err(dev, "Could not get hardware access guard mutex: error %d", status);
+               return NULL;
+       }

...

drivers/hwmon/asus-ec-sensors.c line 583

Quoted 4 lines
drivers/hwmon/asus-ec-sensors.c new file +3 -0
+static struct hwmon_chip_info asus_wmi_chip_info = {
+       .ops = &asus_ec_hwmon_ops,
 
+       .info = NULL,

Redundant.

Quoted 1 line

+};

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

Hi Eugene,

Have you found some issues with idea of usage ACPI WMI methods as failback solution, like in case when ASUS will release some BIOS with different mutex path or different motherboard where will be same WMI methods but fully different internal logic?

Quoted 307 lines · On Thu, 16 Dec 2021 23:27:52 +0200 Andy Shevchenko <[email protected]>…
Quoted 10 lines · Eugene Shalygin

This driver provides the same data as the asus_wmi_ec_sensors driver (and gets it from the same source) but does not use WMI, polling the ACPI EC directly.

That provides two enhancements: sensor reading became quicker (on some systems or kernel configuration it took almost a full second to read all the sensors, that transfers less than 15 bytes of data), the driver became more fexible. The driver now relies on ACPI mutex to lock access

flexible

Quoted 1 line

to the EC, in the same way as the WMI DSDT code does.

How do you know that this way there is no race with any of ACPI code?

...

drivers/hwmon/Kconfig config SENSORS_ASUS_WMI_EC

Quoted 4 lines
drivers/hwmon/Kconfig +3 -0
+config SENSORS_ASUS_EC
+       tristate "ASUS EC Sensors"  
 
+       depends on ACPI  

No need to duplicate. See (1) below.

Quoted 11 lines
(quoted diff) +2 -0
+       help
+         If you say yes here you get support for the ACPI embedded

controller
+ hardware monitoring interface found in ASUS motherboards.
The driver
+ currently supports B550/X570 boards, although other ASUS
boards might

drivers/hwmon/Kconfig +3 -0
+         provide this monitoring interface as well.
+
+         This driver can also be built as a module. If so, the

module

drivers/hwmon/Kconfig config SENSORS_ASUS_WMI_EC · line 2268

Quoted 3 lines
drivers/hwmon/Kconfig +2 -0
+         will be called asus_ec_sensors.
+
 endif # ACPI  

(1)

...

Quoted 4 lines

+/*
+ * HWMON driver for ASUS motherboards that publish some sensor values
+ * via the embedded controller registers

Missed grammatical period.

Quoted 3 lines

+ *

+ */

...

Quoted 2 lines

+#define ASUS_EC_BANK_REGISTER 0xff /* Writing to this EC register switches EC bank */

Can you put comment before the definition?

...

Quoted 1 line

+#define SENSOR_LABEL_LEN 0x10

Why in hex?

Missed blank line here.

Quoted 6 lines

+/*
+ * Arbitrary set max. allowed bank number. Required for sorting banks and
+ * currently is overkill with just 2 banks used at max, but for the sake
+ * of alignment let's set it to a higher value

Check grammar everywhere, again missed period (at least).

Quoted 1 line

+ */

...

Quoted 2 lines

+#define ACPI_DELAY_MSEC_LOCK 500 /* Wait for 0.5 s max. to
acquire the lock */

_LOCK_DELAY_MS and drop useless comment

I think I gave the very same comments before. Maybe you can check the reviews of another driver?

...

Review

Quoted 6 lines
(quoted diff) +3 -0
+#define MAKE_SENSOR_ADDRESS(size, bank, index)
            \
+       {
           \
+               .value = (size << 16) + (bank << 8) + index
           \  

Leave comma here and everywhere else in the structure entries.

Quoted 1 line

+ }

Besides that, would it be better to have it defined as a compound literal?

...

Quoted 17 lines
(quoted diff) +2 -0
+enum known_ec_sensor {
+       SENSOR_TEMP_CHIPSET     = 1 <<  0, /* chipset temperature

[℃] */

(quoted diff) +2 -0
+       SENSOR_TEMP_CPU         = 1 <<  1, /* CPU temperature [℃] */
+       SENSOR_TEMP_MB          = 1 <<  2, /* motherboard

temperature [℃] */
+ SENSOR_TEMP_T_SENSOR = 1 << 3, /* "T_Sensor"
temperature sensor reading [℃] */

drivers/hwmon/asus-ec-sensors.c new file +3 -0
+       SENSOR_TEMP_VRM         = 1 <<  4, /* VRM temperature [℃] */
+       SENSOR_FAN_CPU_OPT      = 1 <<  5, /* CPU_Opt fan [RPM] */
+       SENSOR_FAN_VRM_HS       = 1 <<  6, /* VRM heat sink fan

[RPM] */

(quoted diff) +2 -0
+       SENSOR_FAN_CHIPSET      = 1 <<  7, /* chipset fan [RPM] */
+       SENSOR_FAN_WATER_FLOW   = 1 <<  8, /* water flow sensor

reading [RPM] */

(quoted diff) +2 -0
+       SENSOR_CURR_CPU         = 1 <<  9, /* CPU current [A] */
+       SENSOR_TEMP_WATER_IN    = 1 << 10, /* "Water_In"
Quoted 3 lines

temperature sensor reading [℃] */
+ SENSOR_TEMP_WATER_OUT = 1 << 11, /* "Water_Out"
temperature sensor reading [℃] */

Perhaps kernel doc and use of BIT()?

Quoted 2 lines
(quoted diff) +2 -0
+       SENSOR_END
+};  

...

Quoted 17 lines
(quoted diff) +2 -0
+static const struct ec_sensor_info known_ec_sensors[] = {
+       EC_SENSOR("Chipset", hwmon_temp, 1, 0x00, 0x3a), /*

SENSOR_TEMP_CHIPSET */
+ EC_SENSOR("CPU", hwmon_temp, 1, 0x00, 0x3b), /*
SENSOR_TEMP_CPU */
+ EC_SENSOR("Motherboard", hwmon_temp, 1, 0x00, 0x3c), /*
SENSOR_TEMP_MB */
+ EC_SENSOR("T_Sensor", hwmon_temp, 1, 0x00, 0x3d), /*
SENSOR_TEMP_T_SENSOR */
+ EC_SENSOR("VRM", hwmon_temp, 1, 0x00, 0x3e), /*
SENSOR_TEMP_VRM */
+ EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xb0), /*
SENSOR_FAN_CPU_OPT */
+ EC_SENSOR("VRM HS", hwmon_fan, 2, 0x00, 0xb2), /*
SENSOR_FAN_VRM_HS */
+ EC_SENSOR("Chipset", hwmon_fan, 2, 0x00, 0xb4), /*
SENSOR_FAN_CHIPSET */

Quoted 8 lines

+ EC_SENSOR("Water_Flow", hwmon_fan, 2, 0x00, 0xbc), /*
SENSOR_FAN_WATER_FLOW */
+ EC_SENSOR("CPU", hwmon_curr, 1, 0x00, 0xf4), /*
SENSOR_CURR_CPU */
+ EC_SENSOR("Water_In", hwmon_temp, 1, 0x01, 0x00), /*
SENSOR_TEMP_WATER_IN */
+ EC_SENSOR("Water_Out", hwmon_temp, 1, 0x01, 0x01), /*
SENSOR_TEMP_WATER_OUT */

Instead of comments, use form of

[FOO] = BAR(...),

Quoted 1 line

+};

...

Quoted 4 lines
(quoted diff) +2 -0
+static struct asus_ec_board_info board_P_X570_P = {
+       .sensors = SENSOR_TEMP_CHIPSET | SENSOR_TEMP_CPU |

SENSOR_TEMP_MB | SENSOR_TEMP_VRM
+ | SENSOR_FAN_CHIPSET,

It's a bit long and better to leave ' |' on the previous line(s).

Quoted 1 line

+ .acpi_mutex_path = ASUS_HW_ACCESS_MUTEX_ASMX

+ Comma.

Quoted 1 line

+};

Ditto for all other similar cases.

...

Review

Quoted 12 lines
(quoted diff) +6 -0
+#define DMI_EXACT_MATCH_BOARD(vendor, name, sensors) {
            \
+               .matches = {
           \
+                       DMI_EXACT_MATCH(DMI_BOARD_VENDOR, vendor),
           \
+                       DMI_EXACT_MATCH(DMI_BOARD_NAME, name),
           \
+               },
           \
+               .driver_data = sensors
           \  

+ Comma.

Quoted 1 line

+ }

...

Quoted 13 lines
drivers/hwmon/asus-ec-sensors.c new file +12 -0
+struct ec_sensors_data {
+       const struct asus_ec_board_info *board;
+       struct ec_sensor *sensors;
+       /* EC registers to read from */
+       u16 *registers;
+       u8 *read_buffer;
+       /* sorted list of unique register banks */
+       u8 banks[ASUS_EC_MAX_BANK];
+       unsigned long last_updated; /* in jiffies */
+       acpi_handle aml_mutex;
+       u8 nr_sensors; /* number of board EC sensors */
+       /* number of EC registers to read (sensor might span more

than 1 register) */

drivers/hwmon/asus-ec-sensors.c line 258

Quoted 3 lines
drivers/hwmon/asus-ec-sensors.c new file +3 -0
+       u8 nr_registers;
+       u8 nr_banks; /* number of unique register banks */
+};  

Kernel doc?

...

drivers/hwmon/asus-ec-sensors.c line 262

Quoted 3 lines
drivers/hwmon/asus-ec-sensors.c new file +3 -0
+static u8 register_bank(u16 reg)
+{
+       return (reg & 0xff00) >> 8;  

' & 0xff00' part is redundant.

Quoted 1 line

+}

...

drivers/hwmon/asus-ec-sensors.c line 268

Quoted 4 lines
drivers/hwmon/asus-ec-sensors.c new file +4 -0
+static struct ec_sensors_data *get_sensor_data(struct device *pdev)
+{
+       return dev_get_drvdata(pdev);
+}  

Useless wrapper. It adds no value.

...

drivers/hwmon/asus-ec-sensors.c line 285

Quoted 8 lines
drivers/hwmon/asus-ec-sensors.c new file +7 -0
+       unsigned int i;
+
+       for (i = 0; i < ec->nr_sensors; ++i) {
+               if (get_sensor_info(ec, i)->type == type) {
+                       if (channel == 0)
+                               return i;  
 
+                       --channel;  

What's wrong with post-decrement, and I think I already commented on this. So, I stopped here until you go and enforce all comments given against previous incarnation of this driver.

Quoted 4 lines
drivers/hwmon/asus-ec-sensors.c new file +4 -0
+               }
+       }
+       return -ENOENT;
+}  

...

drivers/hwmon/asus-ec-sensors.c line 313

Quoted 3 lines
drivers/hwmon/asus-ec-sensors.c new file +3 -0
+       for (i = 1; i < SENSOR_END; i <<= 1) {
+               if ((i & ec->board->sensors) == 0
+                       continue;  

Interesting way of NIH for_each_set_bit().

...

Quoted 2 lines

+ for (j = 0; j < si->addr.components.size; ++j,
++register_idx) {

Why pre-increments?

Quoted 6 lines
drivers/hwmon/asus-ec-sensors.c new file +6 -0
+                       ec->registers[register_idx] =
+                               (si->addr.components.bank << 8) +
+                               si->addr.components.index + j;
+               }
+       }
+}  

...

Quoted 5 lines
drivers/hwmon/asus-ec-sensors.c new file +3 -0
+       acpi_handle res;  
 
+       acpi_status status = acpi_get_handle(
+               NULL, (acpi_string)state->board->acpi_mutex_path,

&res);

It looks awful (indentation), Have you run checkpatch?

Review

Quoted 5 lines
(quoted diff) +2 -0
+       if (ACPI_FAILURE(status)) {
+               dev_err(dev, "Could not get hardware access guard

mutex: error %d", status);

(quoted diff) +2 -0
+               return NULL;
+       }  
Quoted 11 lines

...

drivers/hwmon/asus-ec-sensors.c line 583

Quoted 4 lines
drivers/hwmon/asus-ec-sensors.c new file +3 -0
+static struct hwmon_chip_info asus_wmi_chip_info = {
+       .ops = &asus_ec_hwmon_ops,  
 
+       .info = NULL,  

Redundant.

Quoted 1 line

+};

Best regards,
Denis.

author maintainer
#6 lore raw

Hi Denis,

Quoted 7 lines · Denis Pauk

Hi Eugene,

Have you found some issues with idea of usage ACPI WMI methods as failback solution, like in case when ASUS will release some BIOS with different mutex path or different motherboard where will be same WMI methods but fully different internal logic?

Not direct ones, but yes. First of all, I still don't understand what causes the big slowdown in ec_read() calls. I learned that Fedora and Arch kernel configs result in the slowdown, while my custom minimal kernel does not (well, it is still slow but nevertheless). I tried to unload all the modules I do not have in my custom kernel, I tried to disable every option which is related to ACPI in the Fedora config, but the slowdown did not disappear. Then it is not that simple to gather information from other users, because one needs the ec_sys module to measure ec_read() performance, but it is not available in many distribution kernels it seems.

Instead of that I've changed data structures for board description to include the mutex path there, so that we can handle various paths or version dependent paths for each motherboard. I can add code to select the mutex path based on the BIOS version for the next iteration. Also considering adding a module parameter to override that path. I think that will be maintainable and give users a way for a local fix while waiting for kernel update. Would you agree?

That way, I believe, the WMI fallback is rendered barely useful and I decided to drop it.

Best regards,
Eugene

#7 lore raw

Hi Eugene,

I see. Thank you.

Quoted 30 lines · On Thu, 16 Dec 2021 23:58:40 +0100 Eugene Shalygin <[email protected]>…

Hi Denis,

Quoted 7 lines · Denis Pauk

Hi Eugene,

Have you found some issues with idea of usage ACPI WMI methods as failback solution, like in case when ASUS will release some BIOS with different mutex path or different motherboard where will be same WMI methods but fully different internal logic?

Not direct ones, but yes. First of all, I still don't understand what causes the big slowdown in ec_read() calls. I learned that Fedora and Arch kernel configs result in the slowdown, while my custom minimal kernel does not (well, it is still slow but nevertheless). I tried to unload all the modules I do not have in my custom kernel, I tried to disable every option which is related to ACPI in the Fedora config, but the slowdown did not disappear. Then it is not that simple to gather information from other users, because one needs the ec_sys module to measure ec_read() performance, but it is not available in many distribution kernels it seems.

Instead of that I've changed data structures for board description to include the mutex path there, so that we can handle various paths or version dependent paths for each motherboard. I can add code to select the mutex path based on the BIOS version for the next iteration. Also considering adding a module parameter to override that path. I think that will be maintainable and give users a way for a local fix while waiting for kernel update. Would you agree?

Quoted 5 lines

That way, I believe, the WMI fallback is rendered barely useful and I decided to drop it.

Best regards,
Eugene

Best regards,
Denis.

author maintainer
#8 lore raw
In reply to Andy Shevchenko
Quoted 3 lines · Andy Shevchenko
Quoted 1 line

to the EC, in the same way as the WMI DSDT code does.

How do you know that this way there is no race with any of ACPI code?

Because this mutex is exactly what the ACPI code uses to avoid races.

Quoted 4 lines

_LOCK_DELAY_MS and drop useless comment

I think I gave the very same comments before. Maybe you can check the reviews of another driver?

I understand your frustration, sorry. In all those similar reviews I must have missed some emails. I'll fix what I can.

Quoted 14 lines

drivers/hwmon/asus-ec-sensors.c line 120

Quoted 13 lines
drivers/hwmon/asus-ec-sensors.c new file +13 -0
+static const struct ec_sensor_info known_ec_sensors[] = {
+       EC_SENSOR("Chipset", hwmon_temp, 1, 0x00, 0x3a), /* SENSOR_TEMP_CHIPSET */
+       EC_SENSOR("CPU", hwmon_temp, 1, 0x00, 0x3b), /* SENSOR_TEMP_CPU */
+       EC_SENSOR("Motherboard", hwmon_temp, 1, 0x00, 0x3c), /* SENSOR_TEMP_MB */
+       EC_SENSOR("T_Sensor", hwmon_temp, 1, 0x00, 0x3d), /* SENSOR_TEMP_T_SENSOR */
+       EC_SENSOR("VRM", hwmon_temp, 1, 0x00, 0x3e), /* SENSOR_TEMP_VRM */
+       EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xb0), /* SENSOR_FAN_CPU_OPT */
+       EC_SENSOR("VRM HS", hwmon_fan, 2, 0x00, 0xb2), /* SENSOR_FAN_VRM_HS */
+       EC_SENSOR("Chipset", hwmon_fan, 2, 0x00, 0xb4), /* SENSOR_FAN_CHIPSET */
+       EC_SENSOR("Water_Flow", hwmon_fan, 2, 0x00, 0xbc), /* SENSOR_FAN_WATER_FLOW */
+       EC_SENSOR("CPU", hwmon_curr, 1, 0x00, 0xf4), /* SENSOR_CURR_CPU */
+       EC_SENSOR("Water_In", hwmon_temp, 1, 0x01, 0x00), /* SENSOR_TEMP_WATER_IN */
+       EC_SENSOR("Water_Out", hwmon_temp, 1, 0x01, 0x01), /* SENSOR_TEMP_WATER_OUT */
Quoted 3 lines

Instead of comments, use form of

[FOO] = BAR(...),

Was unable do that because the SENSOR_ enum is a flag enum. But given this suggestion and the one about bit foreach loop, I will convert the enum to bitmap.

Quoted 3 lines

What's wrong with post-decrement, and I think I already commented on this. So, I stopped here until you go and enforce all comments given against previous incarnation of this driver.

I missed these ones, sorry.

Quoted 5 lines

drivers/hwmon/asus-ec-sensors.c line 313

Quoted 3 lines
drivers/hwmon/asus-ec-sensors.c new file +3 -0
+       for (i = 1; i < SENSOR_END; i <<= 1) {
+               if ((i & ec->board->sensors) == 0
+                       continue;

Interesting way of NIH for_each_set_bit().

Will convert to bitmap.

Quoted 4 lines

drivers/hwmon/asus-ec-sensors.c line 360

Quoted 2 lines
drivers/hwmon/asus-ec-sensors.c new file +2 -0
+       acpi_status status = acpi_get_handle(
+               NULL, (acpi_string)state->board->acpi_mutex_path, &res);

It looks awful (indentation), Have you run checkpatch?

Yes, but some warnings remained.

Thanks,
Eugene

#9 lore raw
In reply to Eugene Shalygin
I love your patch! Perhaps something to improve:

Hi Eugene,

I love your patch! Perhaps something to improve:

[auto build test WARNING on groeck-staging/hwmon-next]
[also build test WARNING on next-20211215]
[cannot apply to v5.16-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Eugene-Shalygin/hwmon-asus-ec-sensors-add-driver-for-ASUS-EC/20211217-045428
base:   https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
config: ia64-allyesconfig (https://download.01.org/0day-ci/archive/20211217/202112171205.FwhZfLkY-lkp(a)intel.com/config)
compiler: ia64-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/27e7f47121cb02208740ed895a4cf4c7ab5bee63
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Eugene-Shalygin/hwmon-asus-ec-sensors-add-driver-for-ASUS-EC/20211217-045428 git checkout 27e7f47121cb02208740ed895a4cf4c7ab5bee63
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/hwmon/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

drivers/hwmon/asus-ec-sensors.c: In function 'asus_ec_probe':

>> drivers/hwmon/asus-ec-sensors.c:690:26: warning: ordered comparison of pointer with integer zero [-Wextra]
     690 |         if (state->board < 0) {
         |                          ^

vim +690 drivers/hwmon/asus-ec-sensors.c

685
686 static int asus_ec_probe(struct platform_device *pdev)
687 {
688 struct ec_sensors_data *state = platform_get_drvdata(pdev);
689

 > 690		if (state->board < 0) {

691 return -ENODEV;
692 }
693
694 return 0;
695 }
696

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]