Skip to content

Commit 66d39e7

Browse files
dlezcanorafaeljw
authored andcommitted
ACPI: thermal: Use thermal_zone_device()
In order to get the device associated with the thermal zone, let's use the wrapper thermal_zone_device() instead of accessing directly the content of the thermal zone device structure. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> [ rjw: Subject adjustment, removal of trailing white space ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent ba7894b commit 66d39e7

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

drivers/acpi/thermal.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ static struct thermal_zone_device_ops acpi_thermal_zone_ops = {
789789

790790
static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
791791
{
792+
struct device *tzdev;
792793
int trips = 0;
793794
int result;
794795
acpi_status status;
@@ -820,12 +821,14 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
820821
if (IS_ERR(tz->thermal_zone))
821822
return -ENODEV;
822823

824+
tzdev = thermal_zone_device(tz->thermal_zone);
825+
823826
result = sysfs_create_link(&tz->device->dev.kobj,
824-
&tz->thermal_zone->device.kobj, "thermal_zone");
827+
&tzdev->kobj, "thermal_zone");
825828
if (result)
826829
goto unregister_tzd;
827830

828-
result = sysfs_create_link(&tz->thermal_zone->device.kobj,
831+
result = sysfs_create_link(&tzdev->kobj,
829832
&tz->device->dev.kobj, "device");
830833
if (result)
831834
goto remove_tz_link;
@@ -849,7 +852,7 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
849852
acpi_bus_detach:
850853
acpi_bus_detach_private_data(tz->device->handle);
851854
remove_dev_link:
852-
sysfs_remove_link(&tz->thermal_zone->device.kobj, "device");
855+
sysfs_remove_link(&tzdev->kobj, "device");
853856
remove_tz_link:
854857
sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone");
855858
unregister_tzd:
@@ -860,8 +863,10 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
860863

861864
static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz)
862865
{
866+
struct device *tzdev = thermal_zone_device(tz->thermal_zone);
867+
863868
sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone");
864-
sysfs_remove_link(&tz->thermal_zone->device.kobj, "device");
869+
sysfs_remove_link(&tzdev->kobj, "device");
865870
thermal_zone_device_unregister(tz->thermal_zone);
866871
tz->thermal_zone = NULL;
867872
acpi_bus_detach_private_data(tz->device->handle);

0 commit comments

Comments
 (0)