#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;
 
 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;
 
 
 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);
 
 {
        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);
 
 
 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];