hwmon: (acer-aspire14-ec) Add driver for Acer Aspire 14 52MT and 52M fan
Subsystems (3)
PATCH 1/1 hwmon: (acer-aspire14-ec) Add driver for Acer Aspire 14 52MT and 52M fan
The Aspire A14-52M and A14-52MT expose fan speed through an I2C HID embedded controller that also serves the keyboard. The same product id is used by other Acer keyboards, so the driver binds only when DMI matches these two models.
--- Documentation/hwmon/acer-aspire14-ec.rst | 38 ++++ Documentation/hwmon/index.rst | 1 + MAINTAINERS | 8 + drivers/hwmon/Kconfig | 20 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/acer-aspire14-ec.c | 270 +++++++++++++++++++++++ 6 files changed, 338 insertions(+) create mode 100644 Documentation/hwmon/acer-aspire14-ec.rst create mode 100644 drivers/hwmon/acer-aspire14-ec.c
Documentation/hwmon/acer-aspire14-ec.rst new file +38 -0
@@ -0,0 +1,38 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Kernel driver acer-aspire14-ec +============================== + +Supported chips: + + * Acer Aspire 14 AI 52MT/52M embedded controller + + Prefix: 'aspire14_ec' + + Addresses scanned: none + + Datasheet: unavailable + +Author: Ethan Jimmy <[email protected]> + +Description +----------- + +This driver monitors the fan on the Acer Aspire 14 AI (Aspire A14-52M +and A14-52MT). The embedded controller is an I2C HID device (vendor +0x1025, product 0x174b) that also provides the keyboard. + +The device is autodetected on those models. The same product id is used +by other Acer keyboards; those machines stay with hid-generic. On the +Aspire A14-52M and A14-52MT this driver provides both the keyboard and +the fan sensor. + +Fan speed is reported in RPM through the standard hwmon attribute +``fan1_input``. The driver does not change fan speed. + +Sysfs entries +------------- + +======================= ====================================================== +fan1_input Fan speed in RPM +======================= ======================================================
Documentation/hwmon/index.rst +1 -0
@@ -22,6 +22,7 @@ Hardware Monitoring Kernel Drivers abituguru abituguru3 acbel-fsg032 + acer-aspire14-ec acpi_power_meter ad7314 adc128d818
MAINTAINERS +8 -0
@@ -262,6 +262,14 @@ L: [email protected] S: Maintained F: drivers/gpio/gpio-pcie-idio-24.c +ACER ASPIRE 14 AI (A14-52M, A14-52MT) EC FAN DRIVER +M: Ethan Jimmy <[email protected]> +L: [email protected] +L: [email protected] +S: Maintained +F: Documentation/hwmon/acer-aspire14-ec.rst +F: drivers/hwmon/acer-aspire14-ec.c + ACER ASPIRE ONE TEMPERATURE AND FAN DRIVER M: Peter Kaestle <[email protected]> L: [email protected]
drivers/hwmon/Kconfig +20 -0
@@ -67,6 +67,26 @@ config SENSORS_ABITUGURU3 This driver can also be built as a module. If so, the module will be called abituguru3. +config SENSORS_ACER_ASPIRE14_EC + tristate "Acer Aspire 14 AI EC fan sensor" + depends on HID + depends on X86 || COMPILE_TEST + depends on DMI || COMPILE_TEST + depends on I2C_HID_ACPI || I2C_HID_OF || COMPILE_TEST + help + If you say yes here you get support for reading the fan + speed from the embedded controller on the Acer Aspire 14 AI + (Aspire A14-52M and A14-52MT). The controller is an I2C HID + device (vendor 0x1025, product 0x174b) that also provides the + keyboard. Fan speed is read-only. + + The same product id is used by other Acer keyboards. This driver + registers only on the Aspire A14-52M and A14-52MT, where it also + provides the keyboard. Other machines stay with hid-generic. + + This driver can also be built as a module. If so, the module + will be called acer-aspire14-ec. + config SENSORS_SMPRO tristate "Ampere's Altra SMpro hardware monitoring driver" depends on MFD_SMPRO
drivers/hwmon/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_SENSORS_W83791D) += w83791d.o obj-$(CONFIG_SENSORS_ABITUGURU) += abituguru.o obj-$(CONFIG_SENSORS_ABITUGURU3)+= abituguru3.o +obj-$(CONFIG_SENSORS_ACER_ASPIRE14_EC) += acer-aspire14-ec.o obj-$(CONFIG_SENSORS_AD7314) += ad7314.o obj-$(CONFIG_SENSORS_AD7414) += ad7414.o obj-$(CONFIG_SENSORS_AD7418) += ad7418.o
drivers/hwmon/acer-aspire14-ec.c new file +270 -0
270 lines not on this page · raw message
Signature · 1 line
2.56.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] hwmon: architectural violation of HID layering rules --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] hwmon: architectural violation of HID layering rules
--
commit fa48d917bd5280e6dd85fd709932750623717a15
Author: Ethan Jimmy <[email protected]>
Subject: hwmon: (acer-aspire14-ec) Add driver for Acer Aspire 14 52MT and 52M fan
This commit introduces a new hardware monitoring driver for the Acer Aspire 14 AI series (A14-52M and A14-52MT). It reads the fan speed via an I2C HID embedded controller that also serves as the system keyboard.
drivers/hwmon/acer-aspire14-ec.c new file +0 -0
[ ... ]
Review
Quoted 9 lines
(quoted diff) +9
-0+static const struct hid_device_id acer_aspire14_id_table[] = { + { HID_I2C_DEVICE(ACER_ASPIRE14_VID, ACER_ASPIRE14_PID) }, + { } +}; + +static struct hid_driver acer_aspire14_driver = { + .name = "acer-aspire14-ec", + .id_table = acer_aspire14_id_table, + .probe = acer_aspire14_probe,
[Severity: Medium]
Does this driver architecture bypass the HID subsystem layering?
The hardware monitoring subsystem guidelines state that if the main functionality of a chip is not hardware monitoring (such as a system keyboard EC), its primary driver should reside in its respective subsystem directory (e.g., drivers/hid/). The hardware monitoring functionality should then be implemented as an auxiliary device driver residing in drivers/hwmon/.
By defining and registering a complete hid_driver directly within the hwmon directory, this bypasses the HID subsystem maintainer review for the transport layer integration. Could the primary hid_driver be placed in drivers/hid/ to spawn an auxiliary_device, allowing an auxiliary_driver in drivers/hwmon/ to bind to the fan monitoring feature?
Quoted 5 lines
(quoted diff) +5
-0+ .remove = acer_aspire14_remove, + .reset_resume = acer_aspire14_reset_resume, +}; + +static int __init acer_aspire14_init(void)
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Guenter Roeck
maintainerQuoted 141 lines · Ethan Jimmy
The Aspire A14-52M and A14-52MT expose fan speed through an I2C HID embedded controller that also serves the keyboard. The same product id is used by other Acer keyboards, so the driver binds only when DMI matches these two models.
Signed-off-by Ethan Jimmy <[email protected]>--- Documentation/hwmon/acer-aspire14-ec.rst | 38 ++++ Documentation/hwmon/index.rst | 1 + MAINTAINERS | 8 + drivers/hwmon/Kconfig | 20 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/acer-aspire14-ec.c | 270 +++++++++++++++++++++++ 6 files changed, 338 insertions(+) create mode 100644 Documentation/hwmon/acer-aspire14-ec.rst create mode 100644 drivers/hwmon/acer-aspire14-ec.cDocumentation/hwmon/acer-aspire14-ec.rst new file +38
-0@@ -0,0 +1,38 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Kernel driver acer-aspire14-ec +============================== + +Supported chips: + + * Acer Aspire 14 AI 52MT/52M embedded controller + + Prefix: 'aspire14_ec' + + Addresses scanned: none + + Datasheet: unavailable + +Author: Ethan Jimmy <[email protected]> + +Description +----------- + +This driver monitors the fan on the Acer Aspire 14 AI (Aspire A14-52M +and A14-52MT). The embedded controller is an I2C HID device (vendor +0x1025, product 0x174b) that also provides the keyboard. + +The device is autodetected on those models. The same product id is used +by other Acer keyboards; those machines stay with hid-generic. On the +Aspire A14-52M and A14-52MT this driver provides both the keyboard and +the fan sensor. + +Fan speed is reported in RPM through the standard hwmon attribute +``fan1_input``. The driver does not change fan speed. + +Sysfs entries +------------- + +======================= ====================================================== +fan1_input Fan speed in RPM +======================= ======================================================Documentation/hwmon/index.rst +1
-0@@ -22,6 +22,7 @@ Hardware Monitoring Kernel Drivers abituguru abituguru3 acbel-fsg032 + acer-aspire14-ec acpi_power_meter ad7314 adc128d818MAINTAINERS +8
-0@@ -262,6 +262,14 @@ L: [email protected] S: Maintained F: drivers/gpio/gpio-pcie-idio-24.c +ACER ASPIRE 14 AI (A14-52M, A14-52MT) EC FAN DRIVER +M: Ethan Jimmy <[email protected]> +L: [email protected] +L: [email protected] +S: Maintained +F: Documentation/hwmon/acer-aspire14-ec.rst +F: drivers/hwmon/acer-aspire14-ec.c + ACER ASPIRE ONE TEMPERATURE AND FAN DRIVER M: Peter Kaestle <[email protected]> L: [email protected]drivers/hwmon/Kconfig +20
-0@@ -67,6 +67,26 @@ config SENSORS_ABITUGURU3 This driver can also be built as a module. If so, the module will be called abituguru3. +config SENSORS_ACER_ASPIRE14_EC + tristate "Acer Aspire 14 AI EC fan sensor" + depends on HID + depends on X86 || COMPILE_TEST + depends on DMI || COMPILE_TEST + depends on I2C_HID_ACPI || I2C_HID_OF || COMPILE_TEST + help + If you say yes here you get support for reading the fan + speed from the embedded controller on the Acer Aspire 14 AI + (Aspire A14-52M and A14-52MT). The controller is an I2C HID + device (vendor 0x1025, product 0x174b) that also provides the + keyboard. Fan speed is read-only. + + The same product id is used by other Acer keyboards. This driver + registers only on the Aspire A14-52M and A14-52MT, where it also + provides the keyboard. Other machines stay with hid-generic. + + This driver can also be built as a module. If so, the module + will be called acer-aspire14-ec. + config SENSORS_SMPRO tristate "Ampere's Altra SMpro hardware monitoring driver" depends on MFD_SMPROdrivers/hwmon/Makefile +1
-0@@ -27,6 +27,7 @@ obj-$(CONFIG_SENSORS_W83791D) += w83791d.o obj-$(CONFIG_SENSORS_ABITUGURU) += abituguru.o obj-$(CONFIG_SENSORS_ABITUGURU3)+= abituguru3.o +obj-$(CONFIG_SENSORS_ACER_ASPIRE14_EC) += acer-aspire14-ec.o obj-$(CONFIG_SENSORS_AD7314) += ad7314.o obj-$(CONFIG_SENSORS_AD7414) += ad7414.o obj-$(CONFIG_SENSORS_AD7418) += ad7418.odrivers/hwmon/acer-aspire14-ec.c new file +0
-0
drivers/hwmon/acer-aspire14-ec.c line 10
Quoted 10 lines
drivers/hwmon/acer-aspire14-ec.c new file +10
-0@@ -0,0 +1,270 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Hwmon driver for the Acer Aspire 14 AI embedded controller. +* +* Author: Ethan Jimmy <[email protected]> +* +* On the Aspire A14-52M and A14-52MT the EC is an I2C HID device +* (vendor 0x1025, product 0x174b) that also serves the keyboard. The same +* product id is used by other Acer keyboards. The HID driver is registered +* only when DMI matches these models, so those machines stay with hid-generic.
Doees this impact the actual keyboard functionality ?
Quoted 17 lines
drivers/hwmon/acer-aspire14-ec.c new file +17
-0+* +* Fan speed is read with one feature report: A0 00 A0 08 00 02 02. The +* reply carries a little-endian status word, command id, and RPM. +*/ + +#include <linux/dmi.h> +#include <linux/hid.h> +#include <linux/hwmon.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/string.h> +#include <linux/unaligned.h> + +#define ACER_ASPIRE14_VID 0x1025 +#define ACER_ASPIRE14_PID 0x174b +#define ACER_ASPIRE14_REPORT_ID 0xa0 +#define ACER_ASPIRE14_PREFIX 0xa0
drivers/hwmon/acer-aspire14-ec.c line 37
Quoted 10 lines
drivers/hwmon/acer-aspire14-ec.c new file +10
-0+#define ACER_ASPIRE14_CMD_MARK 0x02 +#define ACER_ASPIRE14_RPM_OFFSET 8 +#define ACER_ASPIRE14_MIN_REPLY (ACER_ASPIRE14_RPM_OFFSET + sizeof(u16)) +#define ACER_ASPIRE14_STATUS_OK 0xe000 +#define ACER_ASPIRE14_CMD_FAN_RPM 0x0008 + +struct acer_aspire14_data { +struct hid_device *hdev; +struct device *hwmon_dev; +struct mutex lock;/* protects buf across feature report I/O */
There is no asynchronous call, meaning the lock is unnecessary since requests are already serialised by the hwmon subsystem.
Quoted 14 lines
drivers/hwmon/acer-aspire14-ec.c new file +14
-0+u8 *buf; +u32 report_len; +}; + +static int acer_aspire14_fan_rpm (struct acer_aspire14_data *data,long *val) +{ +u16 status, command_id; +int ret; + +mutex_lock (&data->lock); + +memset (data->buf,0 , data->report_len); + data->buf[0 ] =ACER_ASPIRE14_REPORT_ID ; + data->buf[2 ] =ACER_ASPIRE14_PREFIX ;
drivers/hwmon/acer-aspire14-ec.c line 61
Quoted 10 lines
drivers/hwmon/acer-aspire14-ec.c new file +10
-0+put_unaligned_le16 (ACER_ASPIRE14_CMD_FAN_RPM , &data->buf[3 ]); + data->buf[5 ] =ACER_ASPIRE14_CMD_MARK ; + data->buf[6 ] =ACER_ASPIRE14_CMD_MARK ; + + ret =hid_hw_raw_request (data->hdev,ACER_ASPIRE14_REPORT_ID , + data->buf, data->report_len, +HID_FEATURE_REPORT ,HID_REQ_SET_REPORT ); +if (ret <0 ) + goto unlock; +if (!ret) {
Shouldn't that check for a specific length, such as data->report_len ?
Quoted 29 lines
drivers/hwmon/acer-aspire14-ec.c new file +29
-0+ ret = -EIO ; + goto unlock; + } + +memset (data->buf,0 , data->report_len); + data->buf[0 ] =ACER_ASPIRE14_REPORT_ID ; + ret =hid_hw_raw_request (data->hdev,ACER_ASPIRE14_REPORT_ID , + data->buf, data->report_len, +HID_FEATURE_REPORT ,HID_REQ_GET_REPORT ); +if (ret <0 ) + goto unlock; +if (ret <ACER_ASPIRE14_MIN_REPLY ) { + ret = -EIO ; + goto unlock; + } + + status =get_unaligned_le16 (&data->buf[1 ]); + command_id =get_unaligned_le16 (&data->buf[3 ]); +if (status !=ACER_ASPIRE14_STATUS_OK || + command_id !=ACER_ASPIRE14_CMD_FAN_RPM ) { + ret = -EIO ; + goto unlock; + } + + *val =get_unaligned_le16 (&data->buf[ACER_ASPIRE14_RPM_OFFSET ]); + ret =0 ; + +unlock: +mutex_unlock (&data->lock);
drivers/hwmon/acer-aspire14-ec.c line 100
Quoted 10 lines
drivers/hwmon/acer-aspire14-ec.c new file +10
-0+return ret; +} + +static int acer_aspire14_read (struct device *dev,enum hwmon_sensor_types type, +u32 attr,int channel,long *val) +{ +struct acer_aspire14_data *data =dev_get_drvdata (dev); + +if (type != hwmon_fan || attr != hwmon_fan_input || channel !=0 ) +return -EOPNOTSUPP ;
Unnecessary check.
drivers/hwmon/acer-aspire14-ec.c line 111
Quoted 11 lines
drivers/hwmon/acer-aspire14-ec.c new file +11
-0+ +return acer_aspire14_fan_rpm (data, val); +} + +static umode_t acer_aspire14_is_visible (const void *drvdata, +enum hwmon_sensor_types type, +u32 attr,int channel) +{ +if (type == hwmon_fan && attr == hwmon_fan_input && channel ==0 ) +return 0444 ; +
Unnecessary check. Just return 0444.
Quoted 94 lines
drivers/hwmon/acer-aspire14-ec.c new file +94
-0+return 0 ; +} + +static const struct hwmon_channel_info *const acer_aspire14_info[] = { +HWMON_CHANNEL_INFO (fan,HWMON_F_INPUT ), +NULL +}; + +static const struct hwmon_ops acer_aspire14_ops = { + .is_visible = acer_aspire14_is_visible, + .read = acer_aspire14_read, +}; + +static const struct hwmon_chip_info acer_aspire14_chip_info = { + .ops = &acer_aspire14_ops, + .info = acer_aspire14_info, +}; + +static const struct dmi_system_id acer_aspire14_dmi_table[] = { + { + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Acer" ), +DMI_EXACT_MATCH (DMI_PRODUCT_NAME ,"Aspire A14-52M" ), + }, + }, + { + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Acer" ), +DMI_EXACT_MATCH (DMI_PRODUCT_NAME ,"Aspire A14-52MT" ), + }, + }, + { } +}; +MODULE_DEVICE_TABLE (dmi, acer_aspire14_dmi_table); + +static u32 acer_aspire14_fan_report_len (struct hid_device *hdev) +{ +struct hid_report *report; +u32 len; + + report = hdev->report_enum[HID_FEATURE_REPORT ].report_id_hash[ACER_ASPIRE14_REPORT_ID ]; +if (!report) +return 0 ; + + len =hid_report_len (report); +if (len <ACER_ASPIRE14_MIN_REPLY || len >HID_MAX_BUFFER_SIZE ) +return 0 ; + +return len; +} + +static int acer_aspire14_probe (struct hid_device *hdev, +const struct hid_device_id *id) +{ +struct acer_aspire14_data *data; +struct device *hwmon_dev; +long rpm; +u32 report_len; +int ret; + + hdev->quirks |=HID_QUIRK_INPUT_PER_APP ; + + ret =hid_parse (hdev); +if (ret) +return ret; + + ret =hid_hw_start (hdev,HID_CONNECT_DEFAULT |HID_CONNECT_DRIVER ); +if (ret) +return ret; + + report_len =acer_aspire14_fan_report_len (hdev); +if (!report_len) +return 0 ; + + data =devm_kzalloc (&hdev->dev,sizeof (*data),GFP_KERNEL ); +if (!data) +return 0 ; + + data->buf =devm_kzalloc (&hdev->dev, report_len,GFP_KERNEL ); +if (!data->buf) +return 0 ; + data->report_len = report_len; + + ret =devm_mutex_init (&hdev->dev, &data->lock); +if (ret) { +hid_warn (hdev,"failed to init mutex: %d\n" , ret); +return 0 ; + } + + data->hdev = hdev; +hid_set_drvdata (hdev, data); + + ret =acer_aspire14_fan_rpm (data, &rpm); +if (ret)
drivers/hwmon/acer-aspire14-ec.c line 215
Quoted 10 lines
drivers/hwmon/acer-aspire14-ec.c new file +10
-0+hid_dbg (hdev,"fan report failed: %d\n" , ret); + else + hid_dbg(hdev, "initial fan speed %ld RPM\n", rpm); + + hwmon_dev =hwmon_device_register_with_info (&hdev->dev,"aspire14_ec" , + data, &acer_aspire14_chip_info, +NULL ); +if (IS_ERR (hwmon_dev)) { +hid_warn (hdev,"failed to register hwmon: %pe\n" , hwmon_dev); +return 0 ;
That is a problem. Something is wrong here: If the driver fails to instantiate the hwmon device, it should return an error. Same for all other "return 0" instances above.
Quoted 55 lines
drivers/hwmon/acer-aspire14-ec.c new file +55
-0+ } + data->hwmon_dev = hwmon_dev; + +return 0 ; +} + +static void acer_aspire14_remove (struct hid_device *hdev) +{ +struct acer_aspire14_data *data =hid_get_drvdata (hdev); + +if (data && data->hwmon_dev) +hwmon_device_unregister (data->hwmon_dev); +hid_hw_stop (hdev); +} + +static int acer_aspire14_reset_resume (struct hid_device *hdev) +{ +if (hdev->claimed &HID_CLAIMED_INPUT ) +hidinput_reset_resume (hdev); + +return 0 ; +} + +static const struct hid_device_id acer_aspire14_id_table[] = { + {HID_I2C_DEVICE (ACER_ASPIRE14_VID ,ACER_ASPIRE14_PID ) }, + { } +}; + +static struct hid_driver acer_aspire14_driver = { + .name ="acer-aspire14-ec" , + .id_table = acer_aspire14_id_table, + .probe = acer_aspire14_probe, + .remove = acer_aspire14_remove, + .reset_resume = acer_aspire14_reset_resume, +}; + +static int __init acer_aspire14_init (void ) +{ +if (!dmi_check_system (acer_aspire14_dmi_table)) +return -ENODEV ; + +return hid_register_driver (&acer_aspire14_driver); +} + +static void __exit acer_aspire14_exit(void) +{ +hid_unregister_driver (&acer_aspire14_driver); +} + +module_init (acer_aspire14_init); +module_exit (acer_aspire14_exit); + +MODULE_AUTHOR ("Ethan Jimmy <[email protected]>" ); +MODULE_DESCRIPTION ("Acer Aspire 14 AI EC fan driver" ); +MODULE_LICENSE ("GPL" );
PATCH v2 1/1 hwmon: (acer-aspire14-ec) Add driver for Acer Aspire 14 52MT and 52M fan
The Aspire A14-52M and A14-52MT expose fan speed through an I2C HID embedded controller that also serves the keyboard. The same product id is used by other Acer keyboards, so the driver binds only when DMI matches these two models.
---
Changes in v2:
- Removed mutex.
- Probe returns the error when the fan report is missing, an allocation fails, or hwmon registration fails, and stops the HID device.
- Remove type/attr/channel checks in read() and is_visible(). is_visible() always returns 0444.
- Reject a SET_REPORT whose transferred length is not the feature report length.
The keyboard path is unchanged from v1. On the Aspire A14-52M and A14-52MT, hid_hw_start() is called with HID_CONNECT_DEFAULT | HID_CONNECT_DRIVER, so the HID keyboard stays connected. Other machines with product id 0x174b do not match the DMI table and stay with hid-generic.
v1: https://lore.kernel.org/linux-hwmon/[email protected]/
Documentation/hwmon/acer-aspire14-ec.rst | 38 ++++ Documentation/hwmon/index.rst | 1 + MAINTAINERS | 8 + drivers/hwmon/Kconfig | 20 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/acer-aspire14-ec.c | 255 +++++++++++++++++++++++ 6 files changed, 323 insertions(+) create mode 100644 Documentation/hwmon/acer-aspire14-ec.rst create mode 100644 drivers/hwmon/acer-aspire14-ec.c
Documentation/hwmon/acer-aspire14-ec.rst new file +38 -0
@@ -0,0 +1,38 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Kernel driver acer-aspire14-ec +============================== + +Supported chips: + + * Acer Aspire 14 AI 52MT/52M embedded controller + + Prefix: 'aspire14_ec' + + Addresses scanned: none + + Datasheet: unavailable + +Author: Ethan Jimmy <[email protected]> + +Description +----------- + +This driver monitors the fan on the Acer Aspire 14 AI (Aspire A14-52M +and A14-52MT). The embedded controller is an I2C HID device (vendor +0x1025, product 0x174b) that also provides the keyboard. + +The device is autodetected on those models. The same product id is used +by other Acer keyboards; those machines stay with hid-generic. On the +Aspire A14-52M and A14-52MT this driver provides both the keyboard and +the fan sensor. + +Fan speed is reported in RPM through the standard hwmon attribute +``fan1_input``. The driver does not change fan speed. + +Sysfs entries +------------- + +======================= ====================================================== +fan1_input Fan speed in RPM +======================= ======================================================
Documentation/hwmon/index.rst +1 -0
@@ -22,6 +22,7 @@ Hardware Monitoring Kernel Drivers abituguru abituguru3 acbel-fsg032 + acer-aspire14-ec acpi_power_meter ad7314 adc128d818
MAINTAINERS +8 -0
@@ -262,6 +262,14 @@ L: [email protected] S: Maintained F: drivers/gpio/gpio-pcie-idio-24.c +ACER ASPIRE 14 AI (A14-52M, A14-52MT) EC FAN DRIVER +M: Ethan Jimmy <[email protected]> +L: [email protected] +L: [email protected] +S: Maintained +F: Documentation/hwmon/acer-aspire14-ec.rst +F: drivers/hwmon/acer-aspire14-ec.c + ACER ASPIRE ONE TEMPERATURE AND FAN DRIVER M: Peter Kaestle <[email protected]> L: [email protected]
drivers/hwmon/Kconfig +20 -0
@@ -67,6 +67,26 @@ config SENSORS_ABITUGURU3 This driver can also be built as a module. If so, the module will be called abituguru3. +config SENSORS_ACER_ASPIRE14_EC + tristate "Acer Aspire 14 AI EC fan sensor" + depends on HID + depends on X86 || COMPILE_TEST + depends on DMI || COMPILE_TEST + depends on I2C_HID_ACPI || I2C_HID_OF || COMPILE_TEST + help + If you say yes here you get support for reading the fan + speed from the embedded controller on the Acer Aspire 14 AI + (Aspire A14-52M and A14-52MT). The controller is an I2C HID + device (vendor 0x1025, product 0x174b) that also provides the + keyboard. Fan speed is read-only. + + The same product id is used by other Acer keyboards. This driver + registers only on the Aspire A14-52M and A14-52MT, where it also + provides the keyboard. Other machines stay with hid-generic. + + This driver can also be built as a module. If so, the module + will be called acer-aspire14-ec. + config SENSORS_SMPRO tristate "Ampere's Altra SMpro hardware monitoring driver" depends on MFD_SMPRO
drivers/hwmon/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_SENSORS_W83791D) += w83791d.o obj-$(CONFIG_SENSORS_ABITUGURU) += abituguru.o obj-$(CONFIG_SENSORS_ABITUGURU3)+= abituguru3.o +obj-$(CONFIG_SENSORS_ACER_ASPIRE14_EC) += acer-aspire14-ec.o obj-$(CONFIG_SENSORS_AD7314) += ad7314.o obj-$(CONFIG_SENSORS_AD7414) += ad7414.o obj-$(CONFIG_SENSORS_AD7418) += ad7418.o
drivers/hwmon/acer-aspire14-ec.c new file +255 -0
255 lines not on this page · raw message
base-commit: e1b3c2630d5b8bc755fe4ba86d20d08c734eb504
Signature · 1 line
2.56.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] hwmon: (acer-aspire14-ec) module_init() fails when driver is built-in --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] hwmon: (acer-aspire14-ec) module_init() fails when driver is built-in --
commit 7f4ea74f303f12662cc63822a17eaf3d1e0e84bf
Author: Ethan Jimmy <[email protected]>
hwmon: (acer-aspire14-ec) Add driver for Acer Aspire 14 52MT and 52M fan
This commit adds a hwmon driver for the Acer Aspire 14 AI (A14-52M and A14-52MT) fan sensor, which is exposed via an I2C HID embedded controller.
Quoted 5 lines
drivers/hwmon/acer-aspire14-ec.c new file +0
-0
[ ... ]
Quoted 5 lines
drivers/hwmon/acer-aspire14-ec.c new file +5
-0+static int __init acer_aspire14_init (void ) +{ +if (!dmi_check_system (acer_aspire14_dmi_table)) +return -ENODEV ; +
drivers/hwmon/acer-aspire14-ec.c line 251
Quoted 10 lines
drivers/hwmon/acer-aspire14-ec.c new file +10
-0+return hid_register_driver (&acer_aspire14_driver); +} + +static void __exit acer_aspire14_exit(void) +{ +hid_unregister_driver (&acer_aspire14_driver); +} + +module_init (acer_aspire14_init); +module_exit (acer_aspire14_exit);
[Severity: High]
Does acer_aspire14_init() fail when CONFIG_SENSORS_ACER_ASPIRE14_EC=y and CONFIG_HID=y are built into the kernel?
In drivers/Makefile, drivers/hwmon/ is linked before drivers/hid/:
obj-$(CONFIG_HWMON) += hwmon/ ... obj-$(CONFIG_HID_SUPPORT) += hid/
Because both acer_aspire14_init() and hid_init() in drivers/hid/hid-core.c use module_init() (which expands to device_initcall() when built-in), acer_aspire14_init() runs before hid_init() registers hid_bus_type.
On matching DMI systems, the registration call chain:
acer_aspire14_init()
hid_register_driver(&acer_aspire14_driver)
__hid_register_driver()
driver_register()reaches driver_register() in drivers/base/driver.c before the HID bus is initialized:
if (!bus_is_registered(drv->bus)) {
pr_err("Driver '%s' was unable to register with bus_type '%s' because the bus was not initialized.\n",
drv->name, drv->bus->name);
return -EINVAL;
}Should this use late_initcall(acer_aspire14_init) like the other HID drivers in drivers/hwmon/ (such as corsair-psu.c, corsair-cpro.c, and nzxt-kraken2.c) so that driver registration happens after hid_init()?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Guenter Roeck
maintainerEthan,
Quoted 66 lines · On 10/30/26 14:09, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] hwmon: (acer-aspire14-ec)module_init()fails when driver is built-in --commit
7f4ea74f303f12662cc63822a17eaf3d1e0e84bf
Author: Ethan Jimmy <[email protected]>hwmon: (acer-aspire14-ec) Add driver for Acer Aspire 14 52MT and 52M fan
This commit adds a hwmon driver for the Acer Aspire 14 AI (A14-52M and A14-52MT) fan sensor, which is exposed via an I2C HID embedded controller.
Quoted 5 lines
drivers/hwmon/acer-aspire14-ec.c new file +0
-0[ ... ]
Quoted 5 lines
drivers/hwmon/acer-aspire14-ec.c new file +5
-0+static int __init acer_aspire14_init (void ) +{ +if (!dmi_check_system (acer_aspire14_dmi_table)) +return -ENODEV ; +drivers/hwmon/acer-aspire14-ec.c line 251
Quoted 10 lines
drivers/hwmon/acer-aspire14-ec.c new file +10
-0+return hid_register_driver (&acer_aspire14_driver); +} + +static void __exit acer_aspire14_exit(void) +{ +hid_unregister_driver (&acer_aspire14_driver); +} + +module_init (acer_aspire14_init); +module_exit (acer_aspire14_exit);[Severity: High]
Doesacer_aspire14_init()fail whenCONFIG_SENSORS_ACER_ASPIRE14_EC=yandCONFIG_HID=yare built into the kernel?In
drivers/Makefile,drivers/hwmon/is linked beforedrivers/hid/:obj-$(CONFIG_HWMON) += hwmon/ ... obj-$(CONFIG_HID_SUPPORT) += hid/Because both
acer_aspire14_init()andhid_init()indrivers/hid/hid-core.cusemodule_init()(which expands todevice_initcall()when built-in),acer_aspire14_init()runs beforehid_init()registershid_bus_type.On matching DMI systems, the registration call chain:
acer_aspire14_init() hid_register_driver(&acer_aspire14_driver) __hid_register_driver() driver_register()reaches
driver_register()indrivers/base/driver.cbefore the HID bus is initialized:if (!bus_is_registered(drv->bus)) { pr_err("Driver '%s' was unable to register with bus_type '%s' because the bus was not initialized.\n", drv->name, drv->bus->name); return -EINVAL; }
Quoted 4 lines
Should this use
late_initcall(acer_aspire14_init)like the other HID drivers indrivers/hwmon/(such ascorsair-psu.c,corsair-cpro.c, andnzxt-kraken2.c) so that driver registration happens afterhid_init()?
That seems to be a real problem. Please fix, or explain why it is a false positive.
Thanks,
Guenter
PATCH v3 1/1 hwmon: (acer-aspire14-ec) Add driver for Acer Aspire 14 52MT and 52M fan
The Aspire A14-52M and A14-52MT expose fan speed through an I2C HID embedded controller that also serves the keyboard. The same product id is used by other Acer keyboards, so the driver binds only when DMI matches these two models.
---
Changes in v3:
- Register with late_initcall() so a built-in driver runs after hid_init(). module_init() is device_initcall(), and drivers/hwmon/ is linked before drivers/hid/, so hid_register_driver() returned -EINVAL when the DMI table matched.
Changes in v2:
- Removed mutex.
- Probe returns the error when the fan report is missing, an allocation fails, or hwmon registration fails, and stops the HID device.
- Remove type/attr/channel checks in read() and is_visible(). is_visible() always returns 0444.
- Reject a SET_REPORT whose transferred length is not the feature report length.
On the Aspire A14-52M and A14-52MT, hid_hw_start() is called with HID_CONNECT_DEFAULT | HID_CONNECT_DRIVER, so the HID keyboard stays connected. Other machines with product id 0x174b do not match the DMI table and stay with hid-generic.
v2: https://lore.kernel.org/linux-hwmon/[email protected]/
v1: https://lore.kernel.org/linux-hwmon/[email protected]/
Documentation/hwmon/acer-aspire14-ec.rst | 38 ++++ Documentation/hwmon/index.rst | 1 + MAINTAINERS | 8 + drivers/hwmon/Kconfig | 20 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/acer-aspire14-ec.c | 255 +++++++++++++++++++++++ 6 files changed, 323 insertions(+) create mode 100644 Documentation/hwmon/acer-aspire14-ec.rst create mode 100644 drivers/hwmon/acer-aspire14-ec.c
Documentation/hwmon/acer-aspire14-ec.rst new file +38 -0
@@ -0,0 +1,38 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Kernel driver acer-aspire14-ec +============================== + +Supported chips: + + * Acer Aspire 14 AI 52MT/52M embedded controller + + Prefix: 'aspire14_ec' + + Addresses scanned: none + + Datasheet: unavailable + +Author: Ethan Jimmy <[email protected]> + +Description +----------- + +This driver monitors the fan on the Acer Aspire 14 AI (Aspire A14-52M +and A14-52MT). The embedded controller is an I2C HID device (vendor +0x1025, product 0x174b) that also provides the keyboard. + +The device is autodetected on those models. The same product id is used +by other Acer keyboards; those machines stay with hid-generic. On the +Aspire A14-52M and A14-52MT this driver provides both the keyboard and +the fan sensor. + +Fan speed is reported in RPM through the standard hwmon attribute +``fan1_input``. The driver does not change fan speed. + +Sysfs entries +------------- + +======================= ====================================================== +fan1_input Fan speed in RPM +======================= ======================================================
Documentation/hwmon/index.rst +1 -0
@@ -22,6 +22,7 @@ Hardware Monitoring Kernel Drivers abituguru abituguru3 acbel-fsg032 + acer-aspire14-ec acpi_power_meter ad7314 adc128d818
MAINTAINERS +8 -0
@@ -262,6 +262,14 @@ L: [email protected] S: Maintained F: drivers/gpio/gpio-pcie-idio-24.c +ACER ASPIRE 14 AI (A14-52M, A14-52MT) EC FAN DRIVER +M: Ethan Jimmy <[email protected]> +L: [email protected] +L: [email protected] +S: Maintained +F: Documentation/hwmon/acer-aspire14-ec.rst +F: drivers/hwmon/acer-aspire14-ec.c + ACER ASPIRE ONE TEMPERATURE AND FAN DRIVER M: Peter Kaestle <[email protected]> L: [email protected]
drivers/hwmon/Kconfig +20 -0
@@ -67,6 +67,26 @@ config SENSORS_ABITUGURU3 This driver can also be built as a module. If so, the module will be called abituguru3. +config SENSORS_ACER_ASPIRE14_EC + tristate "Acer Aspire 14 AI EC fan sensor" + depends on HID + depends on X86 || COMPILE_TEST + depends on DMI || COMPILE_TEST + depends on I2C_HID_ACPI || I2C_HID_OF || COMPILE_TEST + help + If you say yes here you get support for reading the fan + speed from the embedded controller on the Acer Aspire 14 AI + (Aspire A14-52M and A14-52MT). The controller is an I2C HID + device (vendor 0x1025, product 0x174b) that also provides the + keyboard. Fan speed is read-only. + + The same product id is used by other Acer keyboards. This driver + registers only on the Aspire A14-52M and A14-52MT, where it also + provides the keyboard. Other machines stay with hid-generic. + + This driver can also be built as a module. If so, the module + will be called acer-aspire14-ec. + config SENSORS_SMPRO tristate "Ampere's Altra SMpro hardware monitoring driver" depends on MFD_SMPRO
drivers/hwmon/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_SENSORS_W83791D) += w83791d.o obj-$(CONFIG_SENSORS_ABITUGURU) += abituguru.o obj-$(CONFIG_SENSORS_ABITUGURU3)+= abituguru3.o +obj-$(CONFIG_SENSORS_ACER_ASPIRE14_EC) += acer-aspire14-ec.o obj-$(CONFIG_SENSORS_AD7314) += ad7314.o obj-$(CONFIG_SENSORS_AD7414) += ad7414.o obj-$(CONFIG_SENSORS_AD7418) += ad7418.o
drivers/hwmon/acer-aspire14-ec.c new file +255 -0
255 lines not on this page · raw message
Signature · 1 line
2.56.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 6 lines
The Aspire A14-52M and A14-52MT expose fan speed through an I2C HID embedded controller that also serves the keyboard. The same product id is used by other Acer keyboards, so the driver binds only when DMI matches these two models.
Signed-off-by Ethan Jimmy <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 6 lines · Ethan Jimmy
The Aspire A14-52M and A14-52MT expose fan speed through an I2C HID embedded controller that also serves the keyboard. The same product id is used by other Acer keyboards, so the driver binds only when DMI matches these two models.
Signed-off-by Ethan Jimmy <[email protected]>
Applied.
Thanks,
Guenter
A message that is not in the archive (sent off-list or not yet received): CAOS5+2Gd1Sn1Wd9GY=ghzWmpWViXiz6hLaZChAYJYNs6E+hyrw@mail.gmail.com
Guenter Roeck
maintainerQuoted 4 lines · Ethan Jimmy
Hi Guenter,
Thanks! Is this headed for 7.5 or 7.4?
7.5
Guenter