[PATCH v1 06/10] ACPI: fan: Use thermal_cooling_device_create()
From: Rafael J. Wysocki
Date: Fri Sep 11 2026 - 09:11:29 EST
From: "Rafael J. Wysocki" <rafael.j.wysocki@xxxxxxxxx>
Instead of using thermal_cooling_device_register() for
registering a cooling device in the ACPI fan driver, make it use
thermal_cooling_device_create() and pass a pointer to the platform
device representing the given fan to that function as the cooling
device's parent. That will cause the cooling device's sysfs directory
to be created under the parent's sysfs directory (among other things).
Since creating a class device under a parent causes a "device" symbolic
link from the sysfs directory of the class device to the sysfs directory
of the parent to appear automatically, remove the code creating that
symbolic link manually.
Moreover, since the cooling device is now located in sysfs under its
parent and it can be easily identified as a cooling device, there is
no need to create a "thermal_cooling" symbolic link from its parent
to it. Accordingly, also remove the code creating that symbolic link.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
---
drivers/acpi/fan_core.c | 24 +-----------------------
1 file changed, 1 insertion(+), 23 deletions(-)
diff --git a/drivers/acpi/fan_core.c b/drivers/acpi/fan_core.c
index a31d7beca5d0..29ca97503deb 100644
--- a/drivers/acpi/fan_core.c
+++ b/drivers/acpi/fan_core.c
@@ -564,8 +564,7 @@ static int acpi_fan_probe(struct platform_device *pdev)
else
name = acpi_device_bid(device);
- cdev = thermal_cooling_device_register(name, device,
- &fan_cooling_ops);
+ cdev = thermal_cooling_device_create(&pdev->dev, name, device, &fan_cooling_ops);
if (IS_ERR(cdev)) {
result = PTR_ERR(cdev);
goto err_end;
@@ -574,28 +573,9 @@ static int acpi_fan_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "registered as cooling_device%d\n", cdev->id);
fan->cdev = cdev;
- result = sysfs_create_link(&pdev->dev.kobj,
- &cdev->device.kobj,
- "thermal_cooling");
- if (result) {
- dev_err(&pdev->dev, "Failed to create sysfs link 'thermal_cooling'\n");
- goto err_unregister;
- }
-
- result = sysfs_create_link(&cdev->device.kobj,
- &pdev->dev.kobj,
- "device");
- if (result) {
- dev_err(&pdev->dev, "Failed to create sysfs link 'device'\n");
- goto err_remove_link;
- }
return 0;
-err_remove_link:
- sysfs_remove_link(&pdev->dev.kobj, "thermal_cooling");
-err_unregister:
- thermal_cooling_device_unregister(cdev);
err_end:
if (fan->has_fst)
acpi_fan_delete_attributes(device);
@@ -612,8 +592,6 @@ static void acpi_fan_remove(struct platform_device *pdev)
acpi_fan_delete_attributes(device);
}
- sysfs_remove_link(&pdev->dev.kobj, "thermal_cooling");
- sysfs_remove_link(&fan->cdev->device.kobj, "device");
thermal_cooling_device_unregister(fan->cdev);
}
--
2.51.0