Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI: fan: Add hwmon notification support

The platform firmware can notify the ACPI fan device that the fan
speed has changed. Relay this notification to the hwmon device if
present so that userspace applications can react to it.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://patch.msgid.link/20251024183824.5656-3-W_Armin@gmx.de
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Armin Wolf and committed by
Rafael J. Wysocki
3d4ca763 0670b9ad

+17 -4
+5
drivers/acpi/fan.h
··· 56 56 struct acpi_fan_fif fif; 57 57 struct acpi_fan_fps *fps; 58 58 int fps_count; 59 + #if IS_REACHABLE(CONFIG_HWMON) 60 + struct device *hdev; 61 + #endif 59 62 struct thermal_cooling_device *cdev; 60 63 struct device_attribute fst_speed; 61 64 struct device_attribute fine_grain_control; ··· 102 99 103 100 #if IS_REACHABLE(CONFIG_HWMON) 104 101 int devm_acpi_fan_create_hwmon(struct device *dev); 102 + void acpi_fan_notify_hwmon(struct device *dev); 105 103 #else 106 104 static inline int devm_acpi_fan_create_hwmon(struct device *dev) { return 0; }; 105 + static inline void acpi_fan_notify_hwmon(struct device *dev) { }; 107 106 #endif 108 107 109 108 #endif
+1
drivers/acpi/fan_core.c
··· 326 326 if (ret < 0) 327 327 dev_err(dev, "Error retrieving current fan status: %d\n", ret); 328 328 329 + acpi_fan_notify_hwmon(dev); 329 330 acpi_bus_generate_netlink_event("fan", dev_name(dev), event, 0); 330 331 break; 331 332 default:
+11 -4
drivers/acpi/fan_hwmon.c
··· 162 162 .info = acpi_fan_hwmon_info, 163 163 }; 164 164 165 + void acpi_fan_notify_hwmon(struct device *dev) 166 + { 167 + struct acpi_fan *fan = dev_get_drvdata(dev); 168 + 169 + hwmon_notify_event(fan->hdev, hwmon_fan, hwmon_fan_input, 0); 170 + } 171 + 165 172 int devm_acpi_fan_create_hwmon(struct device *dev) 166 173 { 167 174 struct acpi_fan *fan = dev_get_drvdata(dev); 168 - struct device *hdev; 169 175 170 - hdev = devm_hwmon_device_register_with_info(dev, "acpi_fan", fan, &acpi_fan_hwmon_chip_info, 171 - NULL); 172 - return PTR_ERR_OR_ZERO(hdev); 176 + fan->hdev = devm_hwmon_device_register_with_info(dev, "acpi_fan", fan, 177 + &acpi_fan_hwmon_chip_info, NULL); 178 + 179 + return PTR_ERR_OR_ZERO(fan->hdev); 173 180 }