@@ -498,7 +498,7 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
static int thermal_get_temp(struct thermal_zone_device *thermal, int *temp)
{
- struct acpi_thermal *tz = thermal->devdata;
+ struct acpi_thermal *tz = thermal_zone_device_get_data(thermal);
int result;
if (!tz)
@@ -516,7 +516,7 @@ static int thermal_get_temp(struct thermal_zone_device *thermal, int *temp)
static int thermal_get_trip_type(struct thermal_zone_device *thermal,
int trip, enum thermal_trip_type *type)
{
- struct acpi_thermal *tz = thermal->devdata;
+ struct acpi_thermal *tz = thermal_zone_device_get_data(thermal);
int i;
if (!tz || trip < 0)
@@ -560,7 +560,7 @@ static int thermal_get_trip_type(struct thermal_zone_device *thermal,
static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
int trip, int *temp)
{
- struct acpi_thermal *tz = thermal->devdata;
+ struct acpi_thermal *tz = thermal_zone_device_get_data(thermal);
int i;
if (!tz || trip < 0)
@@ -613,7 +613,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
static int thermal_get_crit_temp(struct thermal_zone_device *thermal,
int *temperature)
{
- struct acpi_thermal *tz = thermal->devdata;
+ struct acpi_thermal *tz = thermal_zone_device_get_data(thermal);
if (tz->trips.critical.flags.valid) {
*temperature = deci_kelvin_to_millicelsius_with_offset(
@@ -628,7 +628,7 @@ static int thermal_get_crit_temp(struct thermal_zone_device *thermal,
static int thermal_get_trend(struct thermal_zone_device *thermal,
int trip, enum thermal_trend *trend)
{
- struct acpi_thermal *tz = thermal->devdata;
+ struct acpi_thermal *tz = thermal_zone_device_get_data(thermal);
enum thermal_trip_type type;
int i;
@@ -670,7 +670,7 @@ static int thermal_get_trend(struct thermal_zone_device *thermal,
static void acpi_thermal_zone_device_hot(struct thermal_zone_device *thermal)
{
- struct acpi_thermal *tz = thermal->devdata;
+ struct acpi_thermal *tz = thermal_zone_device_get_data(thermal);
acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
dev_name(&tz->device->dev),
@@ -679,7 +679,7 @@ static void acpi_thermal_zone_device_hot(struct thermal_zone_device *thermal)
static void acpi_thermal_zone_device_critical(struct thermal_zone_device *thermal)
{
- struct acpi_thermal *tz = thermal->devdata;
+ struct acpi_thermal *tz = thermal_zone_device_get_data(thermal);
acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
dev_name(&tz->device->dev),
@@ -693,7 +693,7 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
bool bind)
{
struct acpi_device *device = cdev->devdata;
- struct acpi_thermal *tz = thermal->devdata;
+ struct acpi_thermal *tz = thermal_zone_device_get_data(thermal);
struct acpi_device *dev;
acpi_handle handle;
int i;
@@ -418,7 +418,7 @@ static int __sata_ahci_read_temperature(void *dev, int *temp)
static int sata_ahci_read_temperature(struct thermal_zone_device *tz, int *temp)
{
- return __sata_ahci_read_temperature(tz->devdata, temp);
+ return __sata_ahci_read_temperature(thermal_zone_device_get_data(tz), temp);
}
static ssize_t sata_ahci_show_temp(struct device *dev,
@@ -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_get_data(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_get_data(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;
@@ -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_get_data(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);
@@ -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_get_data(tz);
ret = scmi_hwmon_read_scaled_value(th_sensor->ph, th_sensor->info,
&value);
@@ -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_get_data(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];
@@ -414,7 +414,7 @@ static int sun4i_gpadc_runtime_resume(struct device *dev)
static int sun4i_gpadc_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct sun4i_gpadc_iio *info = tz->devdata;
+ struct sun4i_gpadc_iio *info = thermal_zone_device_get_data(tz);
int val, scale, offset;
if (sun4i_gpadc_temp_read(info->indio_dev, &val))
@@ -194,7 +194,7 @@ static int sun4i_get_temp(const struct sun4i_ts_data *ts, int *temp)
static int sun4i_get_tz_temp(struct thermal_zone_device *tz, int *temp)
{
- return sun4i_get_temp(tz->devdata, temp);
+ return sun4i_get_temp(thermal_zone_device_get_data(tz), temp);
}
static const struct thermal_zone_device_ops sun4i_ts_tz_ops = {
@@ -12,7 +12,7 @@
static int cxgb4_thermal_get_temp(struct thermal_zone_device *tzdev,
int *temp)
{
- struct adapter *adap = tzdev->devdata;
+ struct adapter *adap = thermal_zone_device_get_data(tzdev);
u32 param, val;
int ret;
@@ -201,7 +201,7 @@ mlxsw_thermal_module_trips_update(struct device *dev, struct mlxsw_core *core,
static int mlxsw_thermal_bind(struct thermal_zone_device *tzdev,
struct thermal_cooling_device *cdev)
{
- struct mlxsw_thermal *thermal = tzdev->devdata;
+ struct mlxsw_thermal *thermal = thermal_zone_device_get_data(tzdev);
struct device *dev = thermal->bus_info->dev;
int i, err;
@@ -227,7 +227,7 @@ static int mlxsw_thermal_bind(struct thermal_zone_device *tzdev,
static int mlxsw_thermal_unbind(struct thermal_zone_device *tzdev,
struct thermal_cooling_device *cdev)
{
- struct mlxsw_thermal *thermal = tzdev->devdata;
+ struct mlxsw_thermal *thermal = thermal_zone_device_get_data(tzdev);
struct device *dev = thermal->bus_info->dev;
int i;
int err;
@@ -249,7 +249,7 @@ static int mlxsw_thermal_unbind(struct thermal_zone_device *tzdev,
static int mlxsw_thermal_get_temp(struct thermal_zone_device *tzdev,
int *p_temp)
{
- struct mlxsw_thermal *thermal = tzdev->devdata;
+ struct mlxsw_thermal *thermal = thermal_zone_device_get_data(tzdev);
struct device *dev = thermal->bus_info->dev;
char mtmp_pl[MLXSW_REG_MTMP_LEN];
int temp;
@@ -281,7 +281,7 @@ static struct thermal_zone_device_ops mlxsw_thermal_ops = {
static int mlxsw_thermal_module_bind(struct thermal_zone_device *tzdev,
struct thermal_cooling_device *cdev)
{
- struct mlxsw_thermal_module *tz = tzdev->devdata;
+ struct mlxsw_thermal_module *tz = thermal_zone_device_get_data(tzdev);
struct mlxsw_thermal *thermal = tz->parent;
int i, j, err;
@@ -310,7 +310,7 @@ static int mlxsw_thermal_module_bind(struct thermal_zone_device *tzdev,
static int mlxsw_thermal_module_unbind(struct thermal_zone_device *tzdev,
struct thermal_cooling_device *cdev)
{
- struct mlxsw_thermal_module *tz = tzdev->devdata;
+ struct mlxsw_thermal_module *tz = thermal_zone_device_get_data(tzdev);
struct mlxsw_thermal *thermal = tz->parent;
int i;
int err;
@@ -356,7 +356,7 @@ mlxsw_thermal_module_temp_and_thresholds_get(struct mlxsw_core *core,
static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev,
int *p_temp)
{
- struct mlxsw_thermal_module *tz = tzdev->devdata;
+ struct mlxsw_thermal_module *tz = thermal_zone_device_get_data(tzdev);
struct mlxsw_thermal *thermal = tz->parent;
int temp, crit_temp, emerg_temp;
struct device *dev;
@@ -391,7 +391,7 @@ static struct thermal_zone_device_ops mlxsw_thermal_module_ops = {
static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev,
int *p_temp)
{
- struct mlxsw_thermal_module *tz = tzdev->devdata;
+ struct mlxsw_thermal_module *tz = thermal_zone_device_get_data(tzdev);
struct mlxsw_thermal *thermal = tz->parent;
char mtmp_pl[MLXSW_REG_MTMP_LEN];
u16 index;
@@ -615,7 +615,7 @@ int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm)
static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
int *temperature)
{
- struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;
+ struct iwl_mvm *mvm = thermal_zone_device_get_data(device);
int ret;
int temp;
@@ -641,7 +641,7 @@ static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
int trip, int temp)
{
- struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;
+ struct iwl_mvm *mvm = thermal_zone_device_get_data(device);
struct iwl_mvm_thermal_device *tzone;
int ret;
@@ -1142,7 +1142,7 @@ static int power_supply_read_temp(struct thermal_zone_device *tzd,
int ret;
WARN_ON(tzd == NULL);
- psy = tzd->devdata;
+ psy = thermal_zone_device_get_data(tzd);
ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_TEMP, &val);
if (ret)
return ret;
@@ -436,7 +436,7 @@ static int max8973_init_dcdc(struct max8973_chip *max,
static int max8973_thermal_read_temp(struct thermal_zone_device *tz, int *temp)
{
- struct max8973_chip *mchip = tz->devdata;
+ struct max8973_chip *mchip = thermal_zone_device_get_data(tz);
unsigned int val;
int ret;
@@ -398,7 +398,7 @@ static int armada_read_sensor(struct armada_thermal_priv *priv, int *temp)
static int armada_get_temp_legacy(struct thermal_zone_device *thermal,
int *temp)
{
- struct armada_thermal_priv *priv = thermal->devdata;
+ struct armada_thermal_priv *priv = thermal_zone_device_get_data(thermal);
int ret;
/* Valid check */
@@ -420,7 +420,7 @@ static struct thermal_zone_device_ops legacy_ops = {
static int armada_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct armada_thermal_sensor *sensor = tz->devdata;
+ struct armada_thermal_sensor *sensor = thermal_zone_device_get_data(tz);
struct armada_thermal_priv *priv = sensor->priv;
int ret;
@@ -33,7 +33,7 @@ struct bcm2711_thermal_priv {
static int bcm2711_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct bcm2711_thermal_priv *priv = tz->devdata;
+ struct bcm2711_thermal_priv *priv = thermal_zone_device_get_data(tz);
int slope = thermal_zone_get_slope(tz);
int offset = thermal_zone_get_offset(tz);
u32 val;
@@ -90,7 +90,7 @@ static int bcm2835_thermal_temp2adc(int temp, int offset, int slope)
static int bcm2835_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct bcm2835_thermal_data *data = tz->devdata;
+ struct bcm2835_thermal_data *data = thermal_zone_device_get_data(tz);
u32 val = readl(data->regs + BCM2835_TS_TSENSSTAT);
if (!(val & BCM2835_TS_TSENSSTAT_VALID))
@@ -152,7 +152,7 @@ static inline u32 avs_tmon_temp_to_code(struct brcmstb_thermal_priv *priv,
static int brcmstb_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct brcmstb_thermal_priv *priv = tz->devdata;
+ struct brcmstb_thermal_priv *priv = thermal_zone_device_get_data(tz);
u32 val;
long t;
@@ -262,7 +262,7 @@ static irqreturn_t brcmstb_tmon_irq_thread(int irq, void *data)
static int brcmstb_set_trips(struct thermal_zone_device *tz, int low, int high)
{
- struct brcmstb_thermal_priv *priv = tz->devdata;
+ struct brcmstb_thermal_priv *priv = thermal_zone_device_get_data(tz);
dev_dbg(priv->dev, "set trips %d <--> %d\n", low, high);
@@ -16,7 +16,7 @@
static int ns_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
{
- void __iomem *pvtmon = tz->devdata;
+ void __iomem *pvtmon = thermal_zone_device_get_data(tz);
int offset = thermal_zone_get_offset(tz);
int slope = thermal_zone_get_slope(tz);
u32 val;
@@ -32,7 +32,7 @@ struct sr_thermal {
static int sr_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct sr_tmon *tmon = tz->devdata;
+ struct sr_tmon *tmon = thermal_zone_device_get_data(tz);
struct sr_thermal *sr_thermal = tmon->priv;
*temp = readl(sr_thermal->regs + SR_TMON_TEMP_BASE(tmon->tmon_id));
@@ -123,7 +123,7 @@ static irqreturn_t da9062_thermal_irq_handler(int irq, void *data)
static int da9062_thermal_get_temp(struct thermal_zone_device *z,
int *temp)
{
- struct da9062_thermal *thermal = z->devdata;
+ struct da9062_thermal *thermal = thermal_zone_device_get_data(z);
mutex_lock(&thermal->lock);
*temp = thermal->temperature;
@@ -87,7 +87,7 @@ static int dove_get_temp(struct thermal_zone_device *thermal,
int *temp)
{
unsigned long reg;
- struct dove_thermal_priv *priv = thermal->devdata;
+ struct dove_thermal_priv *priv = thermal_zone_device_get_data(thermal);
/* Valid check */
reg = readl_relaxed(priv->control + PMU_TEMP_DIOD_CTRL1_REG);
@@ -431,7 +431,7 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data)
static int hisi_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct hisi_thermal_sensor *sensor = tz->devdata;
+ struct hisi_thermal_sensor *sensor = thermal_zone_device_get_data(tz);
struct hisi_thermal_data *data = sensor->data;
*temp = data->ops->get_temp(sensor);
@@ -141,7 +141,7 @@ static int imx8mp_tmu_get_temp(void *data, int *temp)
static int tmu_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct tmu_sensor *sensor = tz->devdata;
+ struct tmu_sensor *sensor = thermal_zone_device_get_data(tz);
struct imx8mm_tmu *tmu = sensor->priv;
return tmu->socdata->get_temp(sensor, temp);
@@ -46,7 +46,7 @@ static int imx_sc_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
{
struct imx_sc_msg_misc_get_temp msg;
struct imx_sc_rpc_msg *hdr = &msg.hdr;
- struct imx_sc_sensor *sensor = tz->devdata;
+ struct imx_sc_sensor *sensor = thermal_zone_device_get_data(tz);
int ret;
msg.data.req.resource_id = sensor->resource_id;
@@ -252,7 +252,7 @@ static void imx_set_alarm_temp(struct imx_thermal_data *data,
static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct imx_thermal_data *data = tz->devdata;
+ struct imx_thermal_data *data = thermal_zone_device_get_data(tz);
const struct thermal_soc_data *soc_data = data->socdata;
struct regmap *map = data->tempmon;
unsigned int n_meas;
@@ -311,7 +311,7 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
static int imx_change_mode(struct thermal_zone_device *tz,
enum thermal_device_mode mode)
{
- struct imx_thermal_data *data = tz->devdata;
+ struct imx_thermal_data *data = thermal_zone_device_get_data(tz);
if (mode == THERMAL_DEVICE_ENABLED) {
pm_runtime_get(data->dev);
@@ -342,7 +342,7 @@ static int imx_get_crit_temp(struct thermal_zone_device *tz, int *temp)
static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip,
int temp)
{
- struct imx_thermal_data *data = tz->devdata;
+ struct imx_thermal_data *data = thermal_zone_device_get_data(tz);
int ret;
ret = pm_runtime_resume_and_get(data->dev);
@@ -119,7 +119,7 @@ static int pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd, int trip)
static int pch_thermal_get_temp(struct thermal_zone_device *tzd, int *temp)
{
- struct pch_thermal_device *ptd = tzd->devdata;
+ struct pch_thermal_device *ptd = thermal_zone_device_get_data(tzd);
*temp = GET_WPT_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP));
return 0;
@@ -54,7 +54,7 @@ static int sys_get_trip_temp(struct thermal_zone_device *tzd, int trip,
struct intel_soc_dts_sensor_entry *dts;
struct intel_soc_dts_sensors *sensors;
- dts = tzd->devdata;
+ dts = thermal_zone_device_get_data(tzd);
sensors = dts->sensors;
mutex_lock(&sensors->dts_update_lock);
status = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ,
@@ -168,7 +168,7 @@ static int update_trip_temp(struct intel_soc_dts_sensor_entry *dts,
static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
int temp)
{
- struct intel_soc_dts_sensor_entry *dts = tzd->devdata;
+ struct intel_soc_dts_sensor_entry *dts = thermal_zone_device_get_data(tzd);
struct intel_soc_dts_sensors *sensors = dts->sensors;
int status;
@@ -176,7 +176,7 @@ static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
return -EINVAL;
mutex_lock(&sensors->dts_update_lock);
- status = update_trip_temp(tzd->devdata, trip, temp,
+ status = update_trip_temp(dts, trip, temp,
dts->trip_types[trip]);
mutex_unlock(&sensors->dts_update_lock);
@@ -186,9 +186,7 @@ static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
static int sys_get_trip_type(struct thermal_zone_device *tzd,
int trip, enum thermal_trip_type *type)
{
- struct intel_soc_dts_sensor_entry *dts;
-
- dts = tzd->devdata;
+ struct intel_soc_dts_sensor_entry *dts = thermal_zone_device_get_data(tzd);
*type = dts->trip_types[trip];
@@ -200,11 +198,10 @@ static int sys_get_curr_temp(struct thermal_zone_device *tzd,
{
int status;
u32 out;
- struct intel_soc_dts_sensor_entry *dts;
+ struct intel_soc_dts_sensor_entry *dts = thermal_zone_device_get_data(tzd);
struct intel_soc_dts_sensors *sensors;
unsigned long raw;
- dts = tzd->devdata;
sensors = dts->sensors;
status = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ,
SOC_DTS_OFFSET_TEMP, &out);
@@ -107,7 +107,7 @@ static struct zone_device *pkg_temp_thermal_get_dev(unsigned int cpu)
static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp)
{
- struct zone_device *zonedev = tzd->devdata;
+ struct zone_device *zonedev = thermal_zone_device_get_data(tzd);
int val;
val = intel_tcc_get_temp(zonedev->cpu, true);
@@ -122,7 +122,7 @@ static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp)
static int
sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp)
{
- struct zone_device *zonedev = tzd->devdata;
+ struct zone_device *zonedev = thermal_zone_device_get_data(tzd);
u32 l, h, mask, shift, intr;
int tj_max, ret;
@@ -141,7 +141,7 @@ static int k3_bgp_read_temp(struct k3_thermal_data *devdata,
static int k3_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct k3_thermal_data *data = tz->devdata;
+ struct k3_thermal_data *data = thermal_zone_device_get_data(tz);
int ret = 0;
ret = k3_bgp_read_temp(data, temp);
@@ -248,7 +248,7 @@ static inline int k3_bgp_read_temp(struct k3_thermal_data *devdata,
/* Get temperature callback function for thermal zone */
static int k3_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
{
- return k3_bgp_read_temp(tz->devdata, temp);
+ return k3_bgp_read_temp(thermal_zone_device_get_data(tz), temp);
}
static const struct thermal_zone_device_ops k3_of_thermal_ops = {
@@ -27,7 +27,7 @@ static int kirkwood_get_temp(struct thermal_zone_device *thermal,
int *temp)
{
unsigned long reg;
- struct kirkwood_thermal_priv *priv = thermal->devdata;
+ struct kirkwood_thermal_priv *priv = thermal_zone_device_get_data(thermal);
reg = readl_relaxed(priv->sensor);
@@ -46,7 +46,7 @@ struct max77620_therm_info {
static int max77620_thermal_read_temp(struct thermal_zone_device *tz, int *temp)
{
- struct max77620_therm_info *mtherm = tz->devdata;
+ struct max77620_therm_info *mtherm = thermal_zone_device_get_data(tz);
unsigned int val;
int ret;
@@ -763,7 +763,7 @@ static int mtk_thermal_bank_temperature(struct mtk_thermal_bank *bank)
static int mtk_read_temp(struct thermal_zone_device *tz, int *temperature)
{
- struct mtk_thermal *mt = tz->devdata;
+ struct mtk_thermal *mt = thermal_zone_device_get_data(tz);
int i;
int tempmax = INT_MIN;
@@ -252,7 +252,7 @@ static u32 lvts_temp_to_raw(int temperature)
static int lvts_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct lvts_sensor *lvts_sensor = tz->devdata;
+ struct lvts_sensor *lvts_sensor = thermal_zone_device_get_data(tz);
void __iomem *msr = lvts_sensor->msr;
u32 value;
@@ -290,7 +290,7 @@ static int lvts_get_temp(struct thermal_zone_device *tz, int *temp)
static int lvts_set_trips(struct thermal_zone_device *tz, int low, int high)
{
- struct lvts_sensor *lvts_sensor = tz->devdata;
+ struct lvts_sensor *lvts_sensor = thermal_zone_device_get_data(tz);
void __iomem *base = lvts_sensor->base;
u32 raw_low = lvts_temp_to_raw(low);
u32 raw_high = lvts_temp_to_raw(high);
@@ -360,7 +360,7 @@ static irqreturn_t adc_tm5_gen2_isr(int irq, void *data)
static int adc_tm5_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct adc_tm5_channel *channel = tz->devdata;
+ struct adc_tm5_channel *channel = thermal_zone_device_get_data(tz);
int ret;
if (!channel || !channel->iio)
@@ -642,7 +642,7 @@ static int adc_tm5_gen2_configure(struct adc_tm5_channel *channel, int low, int
static int adc_tm5_set_trips(struct thermal_zone_device *tz, int low, int high)
{
- struct adc_tm5_channel *channel = tz->devdata;
+ struct adc_tm5_channel *channel = thermal_zone_device_get_data(tz);
struct adc_tm5_chip *chip;
int ret;
@@ -187,7 +187,7 @@ static int qpnp_tm_update_temp_no_adc(struct qpnp_tm_chip *chip)
static int qpnp_tm_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct qpnp_tm_chip *chip = tz->devdata;
+ struct qpnp_tm_chip *chip = thermal_zone_device_get_data(tz);
int ret, mili_celsius;
if (!temp)
@@ -265,7 +265,7 @@ static int qpnp_tm_update_critical_trip_temp(struct qpnp_tm_chip *chip,
static int qpnp_tm_set_trip_temp(struct thermal_zone_device *tz, int trip_id, int temp)
{
- struct qpnp_tm_chip *chip = tz->devdata;
+ struct qpnp_tm_chip *chip = thermal_zone_device_get_data(tz);
struct thermal_trip trip;
int ret;
@@ -83,7 +83,7 @@ static struct qoriq_tmu_data *qoriq_sensor_to_data(struct qoriq_sensor *s)
static int tmu_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct qoriq_sensor *qsensor = tz->devdata;
+ struct qoriq_sensor *qsensor = thermal_zone_device_get_data(tz);
struct qoriq_tmu_data *qdata = qoriq_sensor_to_data(qsensor);
u32 val;
/*
@@ -167,7 +167,7 @@ static int rcar_gen3_thermal_round(int temp)
static int rcar_gen3_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct rcar_gen3_thermal_tsc *tsc = tz->devdata;
+ struct rcar_gen3_thermal_tsc *tsc = thermal_zone_device_get_data(tz);
int mcelsius, val;
int reg;
@@ -206,7 +206,7 @@ static int rcar_gen3_thermal_mcelsius_to_temp(struct rcar_gen3_thermal_tsc *tsc,
static int rcar_gen3_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)
{
- struct rcar_gen3_thermal_tsc *tsc = tz->devdata;
+ struct rcar_gen3_thermal_tsc *tsc = thermal_zone_device_get_data(tz);
u32 irqmsk = 0;
if (low != -INT_MAX) {
@@ -101,7 +101,6 @@ struct rcar_thermal_priv {
list_for_each_entry(pos, &common->head, list)
#define MCELSIUS(temp) ((temp) * 1000)
-#define rcar_zone_to_priv(zone) ((zone)->devdata)
#define rcar_priv_to_dev(priv) ((priv)->common->dev)
#define rcar_has_irq_support(priv) ((priv)->common->base)
#define rcar_id_to_shift(priv) ((priv)->id * 8)
@@ -273,7 +272,7 @@ static int rcar_thermal_get_current_temp(struct rcar_thermal_priv *priv,
static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
{
- struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+ struct rcar_thermal_priv *priv = thermal_zone_device_get_data(zone);
return rcar_thermal_get_current_temp(priv, temp);
}
@@ -1213,7 +1213,7 @@ static irqreturn_t rockchip_thermal_alarm_irq_thread(int irq, void *dev)
static int rockchip_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)
{
- struct rockchip_thermal_sensor *sensor = tz->devdata;
+ struct rockchip_thermal_sensor *sensor = thermal_zone_device_get_data(tz);
struct rockchip_thermal_data *thermal = sensor->thermal;
const struct rockchip_tsadc_chip *tsadc = thermal->chip;
@@ -1226,7 +1226,7 @@ static int rockchip_thermal_set_trips(struct thermal_zone_device *tz, int low, i
static int rockchip_thermal_get_temp(struct thermal_zone_device *tz, int *out_temp)
{
- struct rockchip_thermal_sensor *sensor = tz->devdata;
+ struct rockchip_thermal_sensor *sensor = thermal_zone_device_get_data(tz);
struct rockchip_thermal_data *thermal = sensor->thermal;
const struct rockchip_tsadc_chip *tsadc = sensor->thermal->chip;
int retval;
@@ -75,7 +75,7 @@ static inline void rzg2l_thermal_write(struct rzg2l_thermal_priv *priv, u32 reg,
static int rzg2l_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct rzg2l_thermal_priv *priv = tz->devdata;
+ struct rzg2l_thermal_priv *priv = thermal_zone_device_get_data(tz);
u32 result = 0, dsensor, ts_code_ave;
int val, i;
@@ -645,7 +645,7 @@ static void exynos7_tmu_control(struct platform_device *pdev, bool on)
static int exynos_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct exynos_tmu_data *data = tz->devdata;
+ struct exynos_tmu_data *data = thermal_zone_device_get_data(tz);
int value, ret = 0;
if (!data || !data->tmu_read)
@@ -723,7 +723,7 @@ static void exynos4412_tmu_set_emulation(struct exynos_tmu_data *data,
static int exynos_tmu_set_emulation(struct thermal_zone_device *tz, int temp)
{
- struct exynos_tmu_data *data = tz->devdata;
+ struct exynos_tmu_data *data = thermal_zone_device_get_data(tz);
int ret = -EINVAL;
if (data->soc == SOC_ARCH_EXYNOS4210)
@@ -31,7 +31,7 @@ struct spear_thermal_dev {
static inline int thermal_get_temp(struct thermal_zone_device *thermal,
int *temp)
{
- struct spear_thermal_dev *stdev = thermal->devdata;
+ struct spear_thermal_dev *stdev = thermal_zone_device_get_data(thermal);
/*
* Data are ready to be read after 628 usec from POWERDOWN signal
@@ -48,7 +48,7 @@ static struct thermal_zone_device_ops ops = {
static int __maybe_unused spear_thermal_suspend(struct device *dev)
{
struct thermal_zone_device *spear_thermal = dev_get_drvdata(dev);
- struct spear_thermal_dev *stdev = spear_thermal->devdata;
+ struct spear_thermal_dev *stdev = thermal_zone_device_get_data(spear_thermal);
unsigned int actual_mask = 0;
/* Disable SPEAr Thermal Sensor */
@@ -64,7 +64,7 @@ static int __maybe_unused spear_thermal_suspend(struct device *dev)
static int __maybe_unused spear_thermal_resume(struct device *dev)
{
struct thermal_zone_device *spear_thermal = dev_get_drvdata(dev);
- struct spear_thermal_dev *stdev = spear_thermal->devdata;
+ struct spear_thermal_dev *stdev = thermal_zone_device_get_data(spear_thermal);
unsigned int actual_mask = 0;
int ret = 0;
@@ -154,7 +154,7 @@ static int spear_thermal_exit(struct platform_device *pdev)
{
unsigned int actual_mask = 0;
struct thermal_zone_device *spear_thermal = platform_get_drvdata(pdev);
- struct spear_thermal_dev *stdev = spear_thermal->devdata;
+ struct spear_thermal_dev *stdev = thermal_zone_device_get_data(spear_thermal);
thermal_zone_device_unregister(spear_thermal);
@@ -206,7 +206,7 @@ static int sprd_thm_temp_to_rawdata(int temp, struct sprd_thermal_sensor *sen)
static int sprd_thm_read_temp(struct thermal_zone_device *tz, int *temp)
{
- struct sprd_thermal_sensor *sen = tz->devdata;
+ struct sprd_thermal_sensor *sen = thermal_zone_device_get_data(tz);
u32 data;
data = readl(sen->data->base + SPRD_THM_TEMP(sen->id)) &
@@ -110,7 +110,7 @@ static int sun50i_h5_calc_temp(struct ths_device *tmdev,
static int sun8i_ths_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct tsensor *s = tz->devdata;
+ struct tsensor *s = thermal_zone_device_get_data(tz);
struct ths_device *tmdev = s->tmdev;
int val = 0;
@@ -62,12 +62,14 @@ static int __tegra_bpmp_thermal_get_temp(struct tegra_bpmp_thermal_zone *zone,
static int tegra_bpmp_thermal_get_temp(struct thermal_zone_device *tz, int *out_temp)
{
- return __tegra_bpmp_thermal_get_temp(tz->devdata, out_temp);
+ struct tegra_bpmp_thermal_zone *zone = thermal_zone_device_get_data(tz);
+
+ return __tegra_bpmp_thermal_get_temp(zone, out_temp);
}
static int tegra_bpmp_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)
{
- struct tegra_bpmp_thermal_zone *zone = tz->devdata;
+ struct tegra_bpmp_thermal_zone *zone = thermal_zone_device_get_data(tz);
struct mrq_thermal_host_to_bpmp_request req;
struct tegra_bpmp_message msg;
int err;
@@ -160,7 +160,7 @@ static void devm_tegra_tsensor_hw_disable(void *data)
static int tegra_tsensor_get_temp(struct thermal_zone_device *tz, int *temp)
{
- const struct tegra_tsensor_channel *tsc = tz->devdata;
+ const struct tegra_tsensor_channel *tsc = thermal_zone_device_get_data(tz);
const struct tegra_tsensor *ts = tsc->ts;
int err, c1, c2, c3, c4, counter;
u32 val;
@@ -218,7 +218,7 @@ static int tegra_tsensor_temp_to_counter(const struct tegra_tsensor *ts, int tem
static int tegra_tsensor_set_trips(struct thermal_zone_device *tz, int low, int high)
{
- const struct tegra_tsensor_channel *tsc = tz->devdata;
+ const struct tegra_tsensor_channel *tsc = thermal_zone_device_get_data(tz);
const struct tegra_tsensor *ts = tsc->ts;
u32 val;
@@ -54,7 +54,7 @@ static int gadc_thermal_adc_to_temp(struct gadc_thermal_info *gti, int val)
static int gadc_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
{
- struct gadc_thermal_info *gti = tz->devdata;
+ struct gadc_thermal_info *gti = thermal_zone_device_get_data(tz);
int val;
int ret;
@@ -1378,6 +1378,12 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type, int n
}
EXPORT_SYMBOL_GPL(thermal_zone_device_register);
+void *thermal_zone_device_get_data(struct thermal_zone_device *tzd)
+{
+ return tzd->devdata;
+}
+EXPORT_SYMBOL_GPL(thermal_zone_device_get_data);
+
/**
* thermal_zone_device_unregister - removes the registered thermal zone device
* @tz: the thermal zone device to remove
@@ -23,7 +23,7 @@ static u32 thermal_mmio_readb(void __iomem *mmio_base)
static int thermal_mmio_get_temperature(struct thermal_zone_device *tz, int *temp)
{
int t;
- struct thermal_mmio *sensor = tz->devdata;
+ struct thermal_mmio *sensor = thermal_zone_device_get_data(tz);
t = sensor->read_mmio(sensor->mmio_base) & sensor->mask;
t *= sensor->factor;
@@ -68,7 +68,7 @@ static inline int ti_thermal_hotspot_temperature(int t, int s, int c)
static inline int __ti_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
{
struct thermal_zone_device *pcb_tz = NULL;
- struct ti_thermal_data *data = tz->devdata;
+ struct ti_thermal_data *data = thermal_zone_device_get_data(tz);
struct ti_bandgap *bgp;
const struct ti_temp_sensor *s;
int ret, tmp, slope, constant;
@@ -109,7 +109,7 @@ static inline int __ti_thermal_get_temp(struct thermal_zone_device *tz, int *tem
static int __ti_thermal_get_trend(struct thermal_zone_device *tz, int trip, enum thermal_trend *trend)
{
- struct ti_thermal_data *data = tz->devdata;
+ struct ti_thermal_data *data = thermal_zone_device_get_data(tz);
struct ti_bandgap *bgp;
int id, tr, ret = 0;
@@ -187,7 +187,7 @@ static void uniphier_tm_disable_sensor(struct uniphier_tm_dev *tdev)
static int uniphier_tm_get_temp(struct thermal_zone_device *tz, int *out_temp)
{
- struct uniphier_tm_dev *tdev = tz->devdata;
+ struct uniphier_tm_dev *tdev = thermal_zone_device_get_data(tz);
struct regmap *map = tdev->regmap;
int ret;
u32 temp;
@@ -365,6 +365,8 @@ thermal_zone_device_register_with_trips(const char *, struct thermal_trip *, int
void *, struct thermal_zone_device_ops *,
struct thermal_zone_params *, int, int);
+void *thermal_zone_device_get_data(struct thermal_zone_device *tzd);
+
int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int,
struct thermal_cooling_device *,
unsigned long, unsigned long,
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. Provide an accessor to the 'devdata' structure and make use of it in the different drivers. No functional changes intended. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> --- drivers/acpi/thermal.c | 16 ++++++++-------- drivers/ata/ahci_imx.c | 2 +- drivers/hwmon/hwmon.c | 4 ++-- drivers/hwmon/pmbus/pmbus_core.c | 2 +- drivers/hwmon/scmi-hwmon.c | 2 +- drivers/hwmon/scpi-hwmon.c | 2 +- drivers/iio/adc/sun4i-gpadc-iio.c | 2 +- drivers/input/touchscreen/sun4i-ts.c | 2 +- .../net/ethernet/chelsio/cxgb4/cxgb4_thermal.c | 2 +- .../net/ethernet/mellanox/mlxsw/core_thermal.c | 14 +++++++------- drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 4 ++-- drivers/power/supply/power_supply_core.c | 2 +- drivers/regulator/max8973-regulator.c | 2 +- drivers/thermal/armada_thermal.c | 4 ++-- drivers/thermal/broadcom/bcm2711_thermal.c | 2 +- drivers/thermal/broadcom/bcm2835_thermal.c | 2 +- drivers/thermal/broadcom/brcmstb_thermal.c | 4 ++-- drivers/thermal/broadcom/ns-thermal.c | 2 +- drivers/thermal/broadcom/sr-thermal.c | 2 +- drivers/thermal/da9062-thermal.c | 2 +- drivers/thermal/dove_thermal.c | 2 +- drivers/thermal/hisi_thermal.c | 2 +- drivers/thermal/imx8mm_thermal.c | 2 +- drivers/thermal/imx_sc_thermal.c | 2 +- drivers/thermal/imx_thermal.c | 6 +++--- drivers/thermal/intel/intel_pch_thermal.c | 2 +- drivers/thermal/intel/intel_soc_dts_iosf.c | 13 +++++-------- drivers/thermal/intel/x86_pkg_temp_thermal.c | 4 ++-- drivers/thermal/k3_bandgap.c | 2 +- drivers/thermal/k3_j72xx_bandgap.c | 2 +- drivers/thermal/kirkwood_thermal.c | 2 +- drivers/thermal/max77620_thermal.c | 2 +- drivers/thermal/mediatek/auxadc_thermal.c | 2 +- drivers/thermal/mediatek/lvts_thermal.c | 4 ++-- drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 4 ++-- drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 4 ++-- drivers/thermal/qoriq_thermal.c | 2 +- drivers/thermal/rcar_gen3_thermal.c | 4 ++-- drivers/thermal/rcar_thermal.c | 3 +-- drivers/thermal/rockchip_thermal.c | 4 ++-- drivers/thermal/rzg2l_thermal.c | 2 +- drivers/thermal/samsung/exynos_tmu.c | 4 ++-- drivers/thermal/spear_thermal.c | 8 ++++---- drivers/thermal/sprd_thermal.c | 2 +- drivers/thermal/sun8i_thermal.c | 2 +- drivers/thermal/tegra/tegra-bpmp-thermal.c | 6 ++++-- drivers/thermal/tegra/tegra30-tsensor.c | 4 ++-- drivers/thermal/thermal-generic-adc.c | 2 +- drivers/thermal/thermal_core.c | 6 ++++++ drivers/thermal/thermal_mmio.c | 2 +- .../thermal/ti-soc-thermal/ti-thermal-common.c | 4 ++-- drivers/thermal/uniphier_thermal.c | 2 +- include/linux/thermal.h | 2 ++ 53 files changed, 97 insertions(+), 91 deletions(-)