thermal: Add a thermal zone id accessor
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Wed, 1 Mar 2023 20:14:40 +0000 (21:14 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 3 Mar 2023 19:45:02 +0000 (20:45 +0100)
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>
drivers/acpi/thermal.c
drivers/hwmon/scmi-hwmon.c
drivers/thermal/thermal_core.c
include/linux/thermal.h

index 392b73b3e26959754b6601e11fce9b03f041dd5b..255efa73ed70ae5570c263e23e7ec70d13de36d6 100644 (file)
@@ -842,7 +842,7 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
                goto acpi_bus_detach;
 
        dev_info(&tz->device->dev, "registered as thermal_zone%d\n",
-                tz->thermal_zone->id);
+                thermal_zone_device_id(tz->thermal_zone));
 
        return 0;
 
index 046ac157749d1fcd5a3a3f8b96b1418be1c17bda..364199b332c0a3feadbd1753598d0f94b27877d7 100644 (file)
@@ -220,7 +220,7 @@ static int scmi_thermal_sensor_register(struct device *dev,
                        sensor->name);
        } else {
                dev_dbg(dev, "Sensor '%s' attached to thermal zone ID:%d\n",
-                       sensor->name, tzd->id);
+                       sensor->name, thermal_zone_device_id(tzd));
        }
 
        return 0;
index fa1c175290185ca4f589fd0bc49df9841f07020b..5ae72f314683e004ec0bd9767c83ee25ae8034d2 100644 (file)
@@ -1389,6 +1389,12 @@ const char *thermal_zone_device_type(struct thermal_zone_device *tzd)
 }
 EXPORT_SYMBOL_GPL(thermal_zone_device_type);
 
+int thermal_zone_device_id(struct thermal_zone_device *tzd)
+{
+       return tzd->id;
+}
+EXPORT_SYMBOL_GPL(thermal_zone_device_id);
+
 /**
  * thermal_zone_device_unregister - removes the registered thermal zone device
  * @tz: the thermal zone device to remove
index 21686e676b3d35f767ec7098f56c73eeb74edb14..eb80cee4f64fab535c381af089a79539efbe720c 100644 (file)
@@ -367,6 +367,7 @@ thermal_zone_device_register_with_trips(const char *, struct thermal_trip *, int
 
 void *thermal_zone_device_priv(struct thermal_zone_device *tzd);
 const char *thermal_zone_device_type(struct thermal_zone_device *tzd);
+int thermal_zone_device_id(struct thermal_zone_device *tzd);
 
 int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int,
                                     struct thermal_cooling_device *,
@@ -449,6 +450,11 @@ static inline const char *thermal_zone_device_type(struct thermal_zone_device *t
        return NULL;
 }
 
+static inline int thermal_zone_device_id(struct thermal_zone_device *tzd)
+{
+       return -ENODEV;
+}
+
 static inline int thermal_zone_device_enable(struct thermal_zone_device *tz)
 { return -ENODEV; }