Re: [PATCH v1 10/10] ACPI: fan: Use more suitable cooling device data
From: Armin Wolf
Date: Fri Sep 11 2026 - 17:28:11 EST
Am 11.09.26 um 15:07 schrieb Rafael J. Wysocki:
From: "Rafael J. Wysocki" <rafael.j.wysocki@xxxxxxxxx>
Instead of passing an ACPI device object pointer as devdata to
thermal_cooling_device_create(), make acpi_fan_probe() pass a pointer
to struct acpi_fan to it, which allows the callback functions in
fan_cooling_ops to be simplified.
Also avoid using acpi_driver_data() in two functions invoked by the
cooling device callbacks by passing struct acpi_fan pointers instead
of struct acpi_device pointers to them.
No intentional functional impact.
Reviewed-by: Armin Wolf <W_Armin@xxxxxx>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
---
drivers/acpi/fan_core.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/drivers/acpi/fan_core.c b/drivers/acpi/fan_core.c
index 8b20b8a55c13..5ad65975fbb4 100644
--- a/drivers/acpi/fan_core.c
+++ b/drivers/acpi/fan_core.c
@@ -54,8 +54,7 @@ MODULE_DEVICE_TABLE(acpi, fan_device_ids);
static int fan_get_max_state(struct thermal_cooling_device *cdev, unsigned long
*state)
{
- struct acpi_device *device = cdev->devdata;
- struct acpi_fan *fan = acpi_driver_data(device);
+ struct acpi_fan *fan = cdev->devdata;
if (fan->acpi4) {
if (fan->fif.fine_grain_ctrl)
@@ -105,9 +104,9 @@ int acpi_fan_get_fst(acpi_handle handle, struct acpi_fan_fst *fst)
return ret;
}
-static int fan_get_state_acpi4(struct acpi_device *device, unsigned long *state)
+static int fan_get_state_acpi4(struct acpi_fan *fan, unsigned long *state)
{
- struct acpi_fan *fan = acpi_driver_data(device);
+ struct acpi_device *device = fan->adev;
struct acpi_fan_fst fst;
int status, i;
@@ -159,13 +158,12 @@ static int fan_get_state(struct acpi_device *device, unsigned long *state)
static int fan_get_cur_state(struct thermal_cooling_device *cdev, unsigned long
*state)
{
- struct acpi_device *device = cdev->devdata;
- struct acpi_fan *fan = acpi_driver_data(device);
+ struct acpi_fan *fan = cdev->devdata;
if (fan->acpi4)
- return fan_get_state_acpi4(device, state);
+ return fan_get_state_acpi4(fan, state);
else
- return fan_get_state(device, state);
+ return fan_get_state(fan->adev, state);
}
static int fan_set_state(struct acpi_device *device, unsigned long state)
@@ -177,9 +175,9 @@ static int fan_set_state(struct acpi_device *device, unsigned long state)
state ? ACPI_STATE_D0 : ACPI_STATE_D3_COLD);
}
-static int fan_set_state_acpi4(struct acpi_device *device, unsigned long state)
+static int fan_set_state_acpi4(struct acpi_fan *fan, unsigned long state)
{
- struct acpi_fan *fan = acpi_driver_data(device);
+ struct acpi_device *device = fan->adev;
acpi_status status;
u64 value = state;
int max_state;
@@ -213,13 +211,12 @@ static int fan_set_state_acpi4(struct acpi_device *device, unsigned long state)
static int
fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
{
- struct acpi_device *device = cdev->devdata;
- struct acpi_fan *fan = acpi_driver_data(device);
+ struct acpi_fan *fan = cdev->devdata;
if (fan->acpi4)
- return fan_set_state_acpi4(device, state);
+ return fan_set_state_acpi4(fan, state);
else
- return fan_set_state(device, state);
+ return fan_set_state(fan->adev, state);
}
static const struct thermal_cooling_device_ops fan_cooling_ops = {
@@ -565,7 +562,7 @@ static int acpi_fan_probe(struct platform_device *pdev)
else
name = acpi_device_bid(device);
- cdev = thermal_cooling_device_create(&pdev->dev, name, device, &fan_cooling_ops);
+ cdev = thermal_cooling_device_create(&pdev->dev, name, fan, &fan_cooling_ops);
if (IS_ERR(cdev)) {
result = PTR_ERR(cdev);
goto err_end;