thermal/core: Use the thermal zone 'devdata' accessor in hwmon located drivers
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Wed, 1 Mar 2023 20:14:31 +0000 (21:14 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 3 Mar 2023 19:45:02 +0000 (20:45 +0100)
The thermal zone device structure is exposed to the different drivers
and obviously they access the internals while that should be
restricted to the core thermal code.

In order to self-encapsulate the thermal core code, we need to prevent
the drivers accessing directly the thermal zone structure and provide
accessor functions to deal with.

Use the devdata accessor introduced in the previous patch.

No functional changes intended.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Guenter Roeck <linux@roeck-us.net> #hwmon
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/hwmon/hwmon.c
drivers/hwmon/pmbus/pmbus_core.c
drivers/hwmon/scmi-hwmon.c
drivers/hwmon/scpi-hwmon.c

index 33edb5c02f7d79d4e8ff7a75fe7ae03c84a83579..3adf5c3c75ededa656fb3dd4a2c64b1c9ba02df3 100644 (file)
@@ -154,7 +154,7 @@ static DEFINE_IDA(hwmon_ida);
 #ifdef CONFIG_THERMAL_OF
 static int hwmon_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
 {
-       struct hwmon_thermal_data *tdata = tz->devdata;
+       struct hwmon_thermal_data *tdata = thermal_zone_device_priv(tz);
        struct hwmon_device *hwdev = to_hwmon_device(tdata->dev);
        int ret;
        long t;
@@ -171,7 +171,7 @@ static int hwmon_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
 
 static int hwmon_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)
 {
-       struct hwmon_thermal_data *tdata = tz->devdata;
+       struct hwmon_thermal_data *tdata = thermal_zone_device_priv(tz);
        struct hwmon_device *hwdev = to_hwmon_device(tdata->dev);
        const struct hwmon_chip_info *chip = hwdev->chip;
        const struct hwmon_channel_info **info = chip->info;
index 95e95783972abb5c21a5f9b9504c27f00f4e8b53..e39a327ac2a145de6203ca08af02aa50e1e71f0f 100644 (file)
@@ -1272,7 +1272,7 @@ struct pmbus_thermal_data {
 
 static int pmbus_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
 {
-       struct pmbus_thermal_data *tdata = tz->devdata;
+       struct pmbus_thermal_data *tdata = thermal_zone_device_priv(tz);
        struct pmbus_sensor *sensor = tdata->sensor;
        struct pmbus_data *pmbus_data = tdata->pmbus_data;
        struct i2c_client *client = to_i2c_client(pmbus_data->dev);
index e192f0c6714654f4107f60a34f1e74a230455c8e..046ac157749d1fcd5a3a3f8b96b1418be1c17bda 100644 (file)
@@ -141,7 +141,7 @@ static int scmi_hwmon_thermal_get_temp(struct thermal_zone_device *tz,
 {
        int ret;
        long value;
-       struct scmi_thermal_sensor *th_sensor = tz->devdata;
+       struct scmi_thermal_sensor *th_sensor = thermal_zone_device_priv(tz);
 
        ret = scmi_hwmon_read_scaled_value(th_sensor->ph, th_sensor->info,
                                           &value);
index 4d75385f7d5ecfec0e0f7703f09e258c18a2e67e..121e5e9f487fb92d163e6d429666f2664b2c78d9 100644 (file)
@@ -64,7 +64,7 @@ static void scpi_scale_reading(u64 *value, struct sensor_data *sensor)
 
 static int scpi_read_temp(struct thermal_zone_device *tz, int *temp)
 {
-       struct scpi_thermal_zone *zone = tz->devdata;
+       struct scpi_thermal_zone *zone = thermal_zone_device_priv(tz);
        struct scpi_sensors *scpi_sensors = zone->scpi_sensors;
        struct scpi_ops *scpi_ops = scpi_sensors->scpi_ops;
        struct sensor_data *sensor = &scpi_sensors->data[zone->sensor_id];