mirror of https://github.com/torvalds/linux.git
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>
This commit is contained in:
parent
0670b9ad4d
commit
3d4ca76369
|
|
@ -56,6 +56,9 @@ struct acpi_fan {
|
||||||
struct acpi_fan_fif fif;
|
struct acpi_fan_fif fif;
|
||||||
struct acpi_fan_fps *fps;
|
struct acpi_fan_fps *fps;
|
||||||
int fps_count;
|
int fps_count;
|
||||||
|
#if IS_REACHABLE(CONFIG_HWMON)
|
||||||
|
struct device *hdev;
|
||||||
|
#endif
|
||||||
struct thermal_cooling_device *cdev;
|
struct thermal_cooling_device *cdev;
|
||||||
struct device_attribute fst_speed;
|
struct device_attribute fst_speed;
|
||||||
struct device_attribute fine_grain_control;
|
struct device_attribute fine_grain_control;
|
||||||
|
|
@ -99,8 +102,10 @@ void acpi_fan_delete_attributes(struct acpi_device *device);
|
||||||
|
|
||||||
#if IS_REACHABLE(CONFIG_HWMON)
|
#if IS_REACHABLE(CONFIG_HWMON)
|
||||||
int devm_acpi_fan_create_hwmon(struct device *dev);
|
int devm_acpi_fan_create_hwmon(struct device *dev);
|
||||||
|
void acpi_fan_notify_hwmon(struct device *dev);
|
||||||
#else
|
#else
|
||||||
static inline int devm_acpi_fan_create_hwmon(struct device *dev) { return 0; };
|
static inline int devm_acpi_fan_create_hwmon(struct device *dev) { return 0; };
|
||||||
|
static inline void acpi_fan_notify_hwmon(struct device *dev) { };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -326,6 +326,7 @@ static void acpi_fan_notify_handler(acpi_handle handle, u32 event, void *context
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
dev_err(dev, "Error retrieving current fan status: %d\n", ret);
|
dev_err(dev, "Error retrieving current fan status: %d\n", ret);
|
||||||
|
|
||||||
|
acpi_fan_notify_hwmon(dev);
|
||||||
acpi_bus_generate_netlink_event("fan", dev_name(dev), event, 0);
|
acpi_bus_generate_netlink_event("fan", dev_name(dev), event, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -162,12 +162,19 @@ static const struct hwmon_chip_info acpi_fan_hwmon_chip_info = {
|
||||||
.info = acpi_fan_hwmon_info,
|
.info = acpi_fan_hwmon_info,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void acpi_fan_notify_hwmon(struct device *dev)
|
||||||
|
{
|
||||||
|
struct acpi_fan *fan = dev_get_drvdata(dev);
|
||||||
|
|
||||||
|
hwmon_notify_event(fan->hdev, hwmon_fan, hwmon_fan_input, 0);
|
||||||
|
}
|
||||||
|
|
||||||
int devm_acpi_fan_create_hwmon(struct device *dev)
|
int devm_acpi_fan_create_hwmon(struct device *dev)
|
||||||
{
|
{
|
||||||
struct acpi_fan *fan = dev_get_drvdata(dev);
|
struct acpi_fan *fan = dev_get_drvdata(dev);
|
||||||
struct device *hdev;
|
|
||||||
|
|
||||||
hdev = devm_hwmon_device_register_with_info(dev, "acpi_fan", fan, &acpi_fan_hwmon_chip_info,
|
fan->hdev = devm_hwmon_device_register_with_info(dev, "acpi_fan", fan,
|
||||||
NULL);
|
&acpi_fan_hwmon_chip_info, NULL);
|
||||||
return PTR_ERR_OR_ZERO(hdev);
|
|
||||||
|
return PTR_ERR_OR_ZERO(fan->hdev);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue