ACPI: fan: Use more suitable cooling device data

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.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Link: https://patch.msgid.link/3631084.QJadu78ljV@rafael.j.wysocki
This commit is contained in:
Rafael J. Wysocki 2026-09-11 15:07:07 +02:00
parent 520aac33ff
commit cc695a6745

View File

@ -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;