[Edgecore][as4224/as4564] Modify fan driver to support sensors command#222
[Edgecore][as4224/as4564] Modify fan driver to support sensors command#222brandonchuang wants to merge 2 commits intodentproject:mainfrom
Conversation
paulmenzel
left a comment
There was a problem hiding this comment.
Thank you for the patch.
Signed-off-by: brandonchuang brandon_chuang@edge-core.com
Please fix your git setup to spell your name: Brandon Chuang.
Lastly, please amend the commit message to describe the current behavior of sensors, and how it behaves after your fix.
| char attr_name[32] = {0}; | ||
| sprintf(attr_name, fmt, fid); | ||
| return onlp_file_read_int(value, "%s%s", FAN_SYSFS_PATH, attr_name); | ||
| return onlp_file_read_int(value, "%s*%s", FAN_SYSFS_PATH, attr_name); |
There was a problem hiding this comment.
Why is the asterisk needed?
There was a problem hiding this comment.
Why is the asterisk needed?
The path is migrated under the 'hwmon' folder.
Without the asterisk, opening the file will fail.
There was a problem hiding this comment.
Excuse my ignorance, can you please give an example for the old and the new path?
There was a problem hiding this comment.
Excuse my ignorance, can you please give an example for the old and the new path?
Old path:
/sys/devices/platform/as4224_fan/
New path:
/sys/devices/platform/as4224_fan/hwmon/hwmon5/
hwmon"5" could represent any other number, such as hwmon1 or hwmon6.
The index starts from 1, and the number is determined by the order in which the driver is attached to hwmon.
c580ca3 to
9f33fed
Compare
| data->hwmon_dev = hwmon_device_register_with_info(&pdev->dev, | ||
| DRVNAME, NULL, NULL, NULL); |
There was a problem hiding this comment.
FYI passing NULL as chip_info (fourth parameter) is considered wrong in newer kernels (5.19 and later), as of commit torvalds/linux@ddaefa2. Doing so may prevent moving to newer LTS kernels or require rewriting the driver.
The old hwmon_device_register() still exists and works though as of Linux 6.4, you just need to live with the warning about the deprecated API at boot.
There was a problem hiding this comment.
FYI passing
NULLas chip_info (fourth parameter) is considered wrong in newer kernels (5.19 and later), as of commit torvalds/linux@ddaefa2. Doing so may prevent moving to newer LTS kernels or require rewriting the driver.The old
hwmon_device_register()still exists and works though as of Linux 6.4, you just need to live with the warning about the deprecated API at boot.
Just replace hwmon_device_register_with_info() with hwmon_device_register_with_groups()
Currently, fan information is not shown with the 'sensors' command. This patch will migrate the fan folder under 'hwmon', so that sensors can detect the fan and display its information. sensors output: as4224_fan-isa-0000 Adapter: ISA adapter fan1: 8587 RPM (min = 0 RPM, max = 20500 RPM) fan2: 8667 RPM (min = 0 RPM, max = 20500 RPM) fan3: 8667 RPM (min = 0 RPM, max = 20500 RPM) fan4: 8587 RPM (min = 0 RPM, max = 20500 RPM) fan5: 8746 RPM (min = 0 RPM, max = 20500 RPM) fan6: 8746 RPM (min = 0 RPM, max = 20500 RPM) as4564_fan-isa-0000 Adapter: ISA adapter fan1: 1470 RPM (min = 0 RPM, max = 10670 RPM) fan2: 1510 RPM (min = 0 RPM, max = 10670 RPM) Changes are listed below: - Add min/max fan attributes - Create sysfs attributes under hwmon folder - Modify fani.c/sysi.c accordingly Signed-off-by: Brandon Chuang <brandon_chuang@edge-core.com>
9f33fed to
6a87d05
Compare
Currently, fan information is not shown with the 'sensors' command.
This patch will migrate the fan folder under 'hwmon',
so that sensors can detect the fan and display its information.
sensors output:
as4224_fan-isa-0000
Adapter: ISA adapter
fan1: 8587 RPM (min = 0 RPM, max = 20500 RPM)
fan2: 8667 RPM (min = 0 RPM, max = 20500 RPM)
fan3: 8667 RPM (min = 0 RPM, max = 20500 RPM)
fan4: 8587 RPM (min = 0 RPM, max = 20500 RPM)
fan5: 8746 RPM (min = 0 RPM, max = 20500 RPM)
fan6: 8746 RPM (min = 0 RPM, max = 20500 RPM)
as4564_fan-isa-0000
Adapter: ISA adapter
fan1: 1470 RPM (min = 0 RPM, max = 10670 RPM)
fan2: 1510 RPM (min = 0 RPM, max = 10670 RPM)
Changes are listed below:
Signed-off-by: Brandon Chuang brandon_chuang@edge-core.com