Skip to content

Commit 3034f85

Browse files
dlezcanorafaeljw
authored andcommitted
thermal: Add a thermal zone id accessor
In order to get the thermal zone id but without directly accessing the thermal zone device structure, add an accessor. Use the accessor in the hwmon_scmi and acpi_thermal. No functional change intented. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Acked-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 25e4397 commit 3034f85

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

drivers/acpi/thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
842842
goto acpi_bus_detach;
843843

844844
dev_info(&tz->device->dev, "registered as thermal_zone%d\n",
845-
tz->thermal_zone->id);
845+
thermal_zone_device_id(tz->thermal_zone));
846846

847847
return 0;
848848

drivers/hwmon/scmi-hwmon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static int scmi_thermal_sensor_register(struct device *dev,
220220
sensor->name);
221221
} else {
222222
dev_dbg(dev, "Sensor '%s' attached to thermal zone ID:%d\n",
223-
sensor->name, tzd->id);
223+
sensor->name, thermal_zone_device_id(tzd));
224224
}
225225

226226
return 0;

drivers/thermal/thermal_core.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,12 @@ const char *thermal_zone_device_type(struct thermal_zone_device *tzd)
13891389
}
13901390
EXPORT_SYMBOL_GPL(thermal_zone_device_type);
13911391

1392+
int thermal_zone_device_id(struct thermal_zone_device *tzd)
1393+
{
1394+
return tzd->id;
1395+
}
1396+
EXPORT_SYMBOL_GPL(thermal_zone_device_id);
1397+
13921398
/**
13931399
* thermal_zone_device_unregister - removes the registered thermal zone device
13941400
* @tz: the thermal zone device to remove

include/linux/thermal.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ thermal_zone_device_register_with_trips(const char *, struct thermal_trip *, int
367367

368368
void *thermal_zone_device_priv(struct thermal_zone_device *tzd);
369369
const char *thermal_zone_device_type(struct thermal_zone_device *tzd);
370+
int thermal_zone_device_id(struct thermal_zone_device *tzd);
370371

371372
int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int,
372373
struct thermal_cooling_device *,
@@ -449,6 +450,11 @@ static inline const char *thermal_zone_device_type(struct thermal_zone_device *t
449450
return NULL;
450451
}
451452

453+
static inline int thermal_zone_device_id(struct thermal_zone_device *tzd)
454+
{
455+
return -ENODEV;
456+
}
457+
452458
static inline int thermal_zone_device_enable(struct thermal_zone_device *tz)
453459
{ return -ENODEV; }
454460

0 commit comments

Comments
 (0)