···176176177177 if (crit_temp > emerg_temp) {178178 dev_warn(dev, "%s : Critical threshold %d is above emergency threshold %d\n",179179- tz->tzdev->type, crit_temp, emerg_temp);179179+ thermal_zone_device_type(tz->tzdev), crit_temp, emerg_temp);180180 return 0;181181 }182182···200200static int mlxsw_thermal_bind(struct thermal_zone_device *tzdev,201201 struct thermal_cooling_device *cdev)202202{203203- struct mlxsw_thermal *thermal = tzdev->devdata;203203+ struct mlxsw_thermal *thermal = thermal_zone_device_priv(tzdev);204204 struct device *dev = thermal->bus_info->dev;205205 int i, err;206206···226226static int mlxsw_thermal_unbind(struct thermal_zone_device *tzdev,227227 struct thermal_cooling_device *cdev)228228{229229- struct mlxsw_thermal *thermal = tzdev->devdata;229229+ struct mlxsw_thermal *thermal = thermal_zone_device_priv(tzdev);230230 struct device *dev = thermal->bus_info->dev;231231 int i;232232 int err;···248248static int mlxsw_thermal_get_temp(struct thermal_zone_device *tzdev,249249 int *p_temp)250250{251251- struct mlxsw_thermal *thermal = tzdev->devdata;251251+ struct mlxsw_thermal *thermal = thermal_zone_device_priv(tzdev);252252 struct device *dev = thermal->bus_info->dev;253253 char mtmp_pl[MLXSW_REG_MTMP_LEN];254254 int temp;···280280static int mlxsw_thermal_module_bind(struct thermal_zone_device *tzdev,281281 struct thermal_cooling_device *cdev)282282{283283- struct mlxsw_thermal_module *tz = tzdev->devdata;283283+ struct mlxsw_thermal_module *tz = thermal_zone_device_priv(tzdev);284284 struct mlxsw_thermal *thermal = tz->parent;285285 int i, j, err;286286···309309static int mlxsw_thermal_module_unbind(struct thermal_zone_device *tzdev,310310 struct thermal_cooling_device *cdev)311311{312312- struct mlxsw_thermal_module *tz = tzdev->devdata;312312+ struct mlxsw_thermal_module *tz = thermal_zone_device_priv(tzdev);313313 struct mlxsw_thermal *thermal = tz->parent;314314 int i;315315 int err;···355355static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev,356356 int *p_temp)357357{358358- struct mlxsw_thermal_module *tz = tzdev->devdata;358358+ struct mlxsw_thermal_module *tz = thermal_zone_device_priv(tzdev);359359 struct mlxsw_thermal *thermal = tz->parent;360360 int temp, crit_temp, emerg_temp;361361 struct device *dev;···390390static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev,391391 int *p_temp)392392{393393- struct mlxsw_thermal_module *tz = tzdev->devdata;393393+ struct mlxsw_thermal_module *tz = thermal_zone_device_priv(tzdev);394394 struct mlxsw_thermal *thermal = tz->parent;395395 char mtmp_pl[MLXSW_REG_MTMP_LEN];396396 u16 index;
+2-2
drivers/net/wireless/intel/iwlwifi/mvm/tt.c
···615615static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,616616 int *temperature)617617{618618- struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;618618+ struct iwl_mvm *mvm = thermal_zone_device_priv(device);619619 int ret;620620 int temp;621621···641641static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,642642 int trip, int temp)643643{644644- struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;644644+ struct iwl_mvm *mvm = thermal_zone_device_priv(device);645645 struct iwl_mvm_thermal_device *tzone;646646 int ret;647647
+3-16
drivers/platform/x86/acerhdf.c
···7979static unsigned int fanstate = ACERHDF_FAN_AUTO;8080static char force_bios[16];8181static char force_product[16];8282-static unsigned int prev_interval;8382static struct thermal_zone_device *thz_dev;8483static struct thermal_cooling_device *cl_dev;8584static struct platform_device *acerhdf_dev;···345346 trips[0].temperature = fanon;346347 trips[0].hysteresis = fanon - fanoff;347348348348- if (kernelmode && prev_interval != interval) {349349+ if (kernelmode) {349350 if (interval > ACERHDF_MAX_INTERVAL) {350351 pr_err("interval too high, set to %d\n",351352 ACERHDF_MAX_INTERVAL);352353 interval = ACERHDF_MAX_INTERVAL;353354 }355355+354356 if (verbose)355357 pr_notice("interval changed to: %d\n", interval);356356-357357- if (thermal)358358- thermal->polling_delay_jiffies =359359- round_jiffies(msecs_to_jiffies(interval * 1000));360360-361361- prev_interval = interval;362358 }363359}364360···691697 if (ret)692698 return ret;693699694694- if (strcmp(thz_dev->governor->name,695695- acerhdf_zone_params.governor_name)) {696696- pr_err("Didn't get thermal governor %s, perhaps not compiled into thermal subsystem.\n",697697- acerhdf_zone_params.governor_name);698698- return -EINVAL;699699- }700700-701700 return 0;702701}703702···788801 .get = param_get_uint,789802};790803791791-module_param_cb(interval, &interval_ops, &interval, 0600);804804+module_param_cb(interval, &interval_ops, &interval, 0000);792805MODULE_PARM_DESC(interval, "Polling interval of temperature check");
+1-1
drivers/power/supply/power_supply_core.c
···11421142 int ret;1143114311441144 WARN_ON(tzd == NULL);11451145- psy = tzd->devdata;11451145+ psy = thermal_zone_device_priv(tzd);11461146 ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_TEMP, &val);11471147 if (ret)11481148 return ret;
+1-1
drivers/regulator/max8973-regulator.c
···436436437437static int max8973_thermal_read_temp(struct thermal_zone_device *tz, int *temp)438438{439439- struct max8973_chip *mchip = tz->devdata;439439+ struct max8973_chip *mchip = thermal_zone_device_priv(tz);440440 unsigned int val;441441 int ret;442442
+2-2
drivers/thermal/amlogic_thermal.c
···181181static int amlogic_thermal_get_temp(struct thermal_zone_device *tz, int *temp)182182{183183 unsigned int tval;184184- struct amlogic_thermal *pdata = tz->devdata;184184+ struct amlogic_thermal *pdata = thermal_zone_device_priv(tz);185185186186 if (!pdata)187187 return -EINVAL;···285285 return ret;286286 }287287288288- if (devm_thermal_add_hwmon_sysfs(pdata->tzd))288288+ if (devm_thermal_add_hwmon_sysfs(&pdev->dev, pdata->tzd))289289 dev_warn(&pdev->dev, "Failed to add hwmon sysfs attributes\n");290290291291 ret = amlogic_thermal_initialize(pdata);
+4-10
drivers/thermal/armada_thermal.c
···360360 * we must absolutely wait for the sensor validity bit to ensure we read361361 * actual data.362362 */363363- if (armada_wait_sensor_validity(priv)) {364364- dev_err(priv->dev,365365- "Temperature sensor reading not valid\n");363363+ if (armada_wait_sensor_validity(priv))366364 return -EIO;367367- }368365369366 return 0;370367}···395398static int armada_get_temp_legacy(struct thermal_zone_device *thermal,396399 int *temp)397400{398398- struct armada_thermal_priv *priv = thermal->devdata;401401+ struct armada_thermal_priv *priv = thermal_zone_device_priv(thermal);399402 int ret;400403401404 /* Valid check */402402- if (!armada_is_valid(priv)) {403403- dev_err(priv->dev,404404- "Temperature sensor reading not valid\n");405405+ if (!armada_is_valid(priv))405406 return -EIO;406406- }407407408408 /* Do the actual reading */409409 ret = armada_read_sensor(priv, temp);···414420415421static int armada_get_temp(struct thermal_zone_device *tz, int *temp)416422{417417- struct armada_thermal_sensor *sensor = tz->devdata;423423+ struct armada_thermal_sensor *sensor = thermal_zone_device_priv(tz);418424 struct armada_thermal_priv *priv = sensor->priv;419425 int ret;420426
+1-2
drivers/thermal/broadcom/bcm2711_thermal.c
···33333434static int bcm2711_get_temp(struct thermal_zone_device *tz, int *temp)3535{3636- struct bcm2711_thermal_priv *priv = tz->devdata;3636+ struct bcm2711_thermal_priv *priv = thermal_zone_device_priv(tz);3737 int slope = thermal_zone_get_slope(tz);3838 int offset = thermal_zone_get_offset(tz);3939 u32 val;···98989999 priv->thermal = thermal;100100101101- thermal->tzp->no_hwmon = false;102101 return thermal_add_hwmon_sysfs(thermal);103102}104103
+1-2
drivers/thermal/broadcom/bcm2835_thermal.c
···90909191static int bcm2835_thermal_get_temp(struct thermal_zone_device *tz, int *temp)9292{9393- struct bcm2835_thermal_data *data = tz->devdata;9393+ struct bcm2835_thermal_data *data = thermal_zone_device_priv(tz);9494 u32 val = readl(data->regs + BCM2835_TS_TSENSSTAT);95959696 if (!(val & BCM2835_TS_TSENSSTAT_VALID))···267267 * Thermal_zone doesn't enable hwmon as default,268268 * enable it here269269 */270270- tz->tzp->no_hwmon = false;271270 err = thermal_add_hwmon_sysfs(tz);272271 if (err)273272 goto err_tz;
+3-5
drivers/thermal/broadcom/brcmstb_thermal.c
···152152153153static int brcmstb_get_temp(struct thermal_zone_device *tz, int *temp)154154{155155- struct brcmstb_thermal_priv *priv = tz->devdata;155155+ struct brcmstb_thermal_priv *priv = thermal_zone_device_priv(tz);156156 u32 val;157157 long t;158158159159 val = __raw_readl(priv->tmon_base + AVS_TMON_STATUS);160160161161- if (!(val & AVS_TMON_STATUS_valid_msk)) {162162- dev_err(priv->dev, "reading not valid\n");161161+ if (!(val & AVS_TMON_STATUS_valid_msk))163162 return -EIO;164164- }165163166164 val = (val & AVS_TMON_STATUS_data_msk) >> AVS_TMON_STATUS_data_shift;167165···260262261263static int brcmstb_set_trips(struct thermal_zone_device *tz, int low, int high)262264{263263- struct brcmstb_thermal_priv *priv = tz->devdata;265265+ struct brcmstb_thermal_priv *priv = thermal_zone_device_priv(tz);264266265267 dev_dbg(priv->dev, "set trips %d <--> %d\n", low, high);266268
+1-1
drivers/thermal/broadcom/ns-thermal.c
···16161717static int ns_thermal_get_temp(struct thermal_zone_device *tz, int *temp)1818{1919- void __iomem *pvtmon = tz->devdata;1919+ void __iomem *pvtmon = thermal_zone_device_priv(tz);2020 int offset = thermal_zone_get_offset(tz);2121 int slope = thermal_zone_get_slope(tz);2222 u32 val;
···41414242#define DA9062_MILLI_CELSIUS(t) ((t) * 1000)43434444+static unsigned int pp_tmp = DA9062_DEFAULT_POLLING_MS_PERIOD;4545+4446struct da9062_thermal_config {4547 const char *name;4648};···9795 thermal_zone_device_update(thermal->zone,9896 THERMAL_EVENT_UNSPECIFIED);9997100100- delay = thermal->zone->passive_delay_jiffies;9898+ /*9999+ * pp_tmp is between 1s and 10s, so we can round the jiffies100100+ */101101+ delay = round_jiffies(msecs_to_jiffies(pp_tmp));101102 queue_delayed_work(system_freezable_wq, &thermal->work, delay);102103 return;103104 }···128123static int da9062_thermal_get_temp(struct thermal_zone_device *z,129124 int *temp)130125{131131- struct da9062_thermal *thermal = z->devdata;126126+ struct da9062_thermal *thermal = thermal_zone_device_priv(z);132127133128 mutex_lock(&thermal->lock);134129 *temp = thermal->temperature;···160155{161156 struct da9062 *chip = dev_get_drvdata(pdev->dev.parent);162157 struct da9062_thermal *thermal;163163- unsigned int pp_tmp = DA9062_DEFAULT_POLLING_MS_PERIOD;164158 const struct of_device_id *match;165159 int ret = 0;166160···212208 }213209214210 dev_dbg(&pdev->dev,215215- "TJUNC temperature polling period set at %d ms\n",216216- jiffies_to_msecs(thermal->zone->passive_delay_jiffies));211211+ "TJUNC temperature polling period set at %d ms\n", pp_tmp);217212218213 ret = platform_get_irq_byname(pdev, "THERMAL");219214 if (ret < 0)
+1-1
drivers/thermal/db8500_thermal.c
···6060/* Callback to get current temperature */6161static int db8500_thermal_get_temp(struct thermal_zone_device *tz, int *temp)6262{6363- struct db8500_thermal_zone *th = tz->devdata;6363+ struct db8500_thermal_zone *th = thermal_zone_device_priv(tz);64646565 /*6666 * TODO: There is no PRCMU interface to get temperature data currently,
+2-5
drivers/thermal/dove_thermal.c
···8787 int *temp)8888{8989 unsigned long reg;9090- struct dove_thermal_priv *priv = thermal->devdata;9090+ struct dove_thermal_priv *priv = thermal_zone_device_priv(thermal);91919292 /* Valid check */9393 reg = readl_relaxed(priv->control + PMU_TEMP_DIOD_CTRL1_REG);9494- if ((reg & PMU_TDC1_TEMP_VALID_MASK) == 0x0) {9595- dev_err(&thermal->device,9696- "Temperature sensor reading not valid\n");9494+ if ((reg & PMU_TDC1_TEMP_VALID_MASK) == 0x0)9795 return -EIO;9898- }999610097 /*10198 * Calculate temperature. According to Marvell internal
···120120static int soc_dts_enable(struct thermal_zone_device *tzd)121121{122122 u32 out;123123- struct soc_sensor_entry *aux_entry = tzd->devdata;123123+ struct soc_sensor_entry *aux_entry = thermal_zone_device_priv(tzd);124124 int ret;125125126126 ret = iosf_mbi_read(QRK_MBI_UNIT_RMU, MBI_REG_READ,···148148static int soc_dts_disable(struct thermal_zone_device *tzd)149149{150150 u32 out;151151- struct soc_sensor_entry *aux_entry = tzd->devdata;151151+ struct soc_sensor_entry *aux_entry = thermal_zone_device_priv(tzd);152152 int ret;153153154154 ret = iosf_mbi_read(QRK_MBI_UNIT_RMU, MBI_REG_READ,···250250static inline int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,251251 int temp)252252{253253- return update_trip_temp(tzd->devdata, trip, temp);253253+ return update_trip_temp(thermal_zone_device_priv(tzd), trip, temp);254254}255255256256static int sys_get_curr_temp(struct thermal_zone_device *tzd,
+5-8
drivers/thermal/intel/intel_soc_dts_iosf.c
···5454 struct intel_soc_dts_sensor_entry *dts;5555 struct intel_soc_dts_sensors *sensors;56565757- dts = tzd->devdata;5757+ dts = thermal_zone_device_priv(tzd);5858 sensors = dts->sensors;5959 mutex_lock(&sensors->dts_update_lock);6060 status = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ,···168168static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,169169 int temp)170170{171171- struct intel_soc_dts_sensor_entry *dts = tzd->devdata;171171+ struct intel_soc_dts_sensor_entry *dts = thermal_zone_device_priv(tzd);172172 struct intel_soc_dts_sensors *sensors = dts->sensors;173173 int status;174174···176176 return -EINVAL;177177178178 mutex_lock(&sensors->dts_update_lock);179179- status = update_trip_temp(tzd->devdata, trip, temp,179179+ status = update_trip_temp(dts, trip, temp,180180 dts->trip_types[trip]);181181 mutex_unlock(&sensors->dts_update_lock);182182···186186static int sys_get_trip_type(struct thermal_zone_device *tzd,187187 int trip, enum thermal_trip_type *type)188188{189189- struct intel_soc_dts_sensor_entry *dts;190190-191191- dts = tzd->devdata;189189+ struct intel_soc_dts_sensor_entry *dts = thermal_zone_device_priv(tzd);192190193191 *type = dts->trip_types[trip];194192···198200{199201 int status;200202 u32 out;201201- struct intel_soc_dts_sensor_entry *dts;203203+ struct intel_soc_dts_sensor_entry *dts = thermal_zone_device_priv(tzd);202204 struct intel_soc_dts_sensors *sensors;203205 unsigned long raw;204206205205- dts = tzd->devdata;206207 sensors = dts->sensors;207208 status = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ,208209 SOC_DTS_OFFSET_TEMP, &out);
+7-5
drivers/thermal/intel/x86_pkg_temp_thermal.c
···107107108108static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp)109109{110110- struct zone_device *zonedev = tzd->devdata;110110+ struct zone_device *zonedev = thermal_zone_device_priv(tzd);111111 int val;112112113113 val = intel_tcc_get_temp(zonedev->cpu, true);···122122static int123123sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp)124124{125125- struct zone_device *zonedev = tzd->devdata;125125+ struct zone_device *zonedev = thermal_zone_device_priv(tzd);126126 u32 l, h, mask, shift, intr;127127- int tj_max, ret;127127+ int tj_max, val, ret;128128129129 tj_max = intel_tcc_get_tjmax(zonedev->cpu);130130 if (tj_max < 0)131131 return tj_max;132132 tj_max *= 1000;133133134134- if (trip >= MAX_NUMBER_OF_TRIPS || temp >= tj_max)134134+ val = (tj_max - temp)/1000;135135+136136+ if (trip >= MAX_NUMBER_OF_TRIPS || val < 0 || val > 0x7f)135137 return -EINVAL;136138137139 ret = rdmsr_on_cpu(zonedev->cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT,···158156 if (!temp) {159157 l &= ~intr;160158 } else {161161- l |= (tj_max - temp)/1000 << shift;159159+ l |= val << shift;162160 l |= intr;163161 }164162
+2-2
drivers/thermal/k3_bandgap.c
···141141142142static int k3_thermal_get_temp(struct thermal_zone_device *tz, int *temp)143143{144144- struct k3_thermal_data *data = tz->devdata;144144+ struct k3_thermal_data *data = thermal_zone_device_priv(tz);145145 int ret = 0;146146147147 ret = k3_bgp_read_temp(data, temp);···222222 goto err_alloc;223223 }224224225225- if (devm_thermal_add_hwmon_sysfs(data[id].tzd))225225+ if (devm_thermal_add_hwmon_sysfs(dev, data[id].tzd))226226 dev_warn(dev, "Failed to add hwmon sysfs attributes\n");227227 }228228
+1-1
drivers/thermal/k3_j72xx_bandgap.c
···248248/* Get temperature callback function for thermal zone */249249static int k3_thermal_get_temp(struct thermal_zone_device *tz, int *temp)250250{251251- return k3_bgp_read_temp(tz->devdata, temp);251251+ return k3_bgp_read_temp(thermal_zone_device_priv(tz), temp);252252}253253254254static const struct thermal_zone_device_ops k3_of_thermal_ops = {
+2-5
drivers/thermal/kirkwood_thermal.c
···2727 int *temp)2828{2929 unsigned long reg;3030- struct kirkwood_thermal_priv *priv = thermal->devdata;3030+ struct kirkwood_thermal_priv *priv = thermal_zone_device_priv(thermal);31313232 reg = readl_relaxed(priv->sensor);33333434 /* Valid check */3535 if (!((reg >> KIRKWOOD_THERMAL_VALID_OFFSET) &3636- KIRKWOOD_THERMAL_VALID_MASK)) {3737- dev_err(&thermal->device,3838- "Temperature sensor reading not valid\n");3636+ KIRKWOOD_THERMAL_VALID_MASK))3937 return -EIO;4040- }41384239 /*4340 * Calculate temperature. According to Marvell internal
+2-4
drivers/thermal/max77620_thermal.c
···46464747static int max77620_thermal_read_temp(struct thermal_zone_device *tz, int *temp)4848{4949- struct max77620_therm_info *mtherm = tz->devdata;4949+ struct max77620_therm_info *mtherm = thermal_zone_device_priv(tz);5050 unsigned int val;5151 int ret;52525353 ret = regmap_read(mtherm->rmap, MAX77620_REG_STATLBT, &val);5454- if (ret < 0) {5555- dev_err(mtherm->dev, "Failed to read STATLBT: %d\n", ret);5454+ if (ret < 0)5655 return ret;5757- }58565957 if (val & MAX77620_IRQ_TJALRM2_MASK)6058 *temp = MAX77620_TJALARM2_TEMP;
+2-2
drivers/thermal/mediatek/auxadc_thermal.c
···763763764764static int mtk_read_temp(struct thermal_zone_device *tz, int *temperature)765765{766766- struct mtk_thermal *mt = tz->devdata;766766+ struct mtk_thermal *mt = thermal_zone_device_priv(tz);767767 int i;768768 int tempmax = INT_MIN;769769···12101210 goto err_disable_clk_peri_therm;12111211 }1212121212131213- ret = devm_thermal_add_hwmon_sysfs(tzdev);12131213+ ret = devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev);12141214 if (ret)12151215 dev_warn(&pdev->dev, "error in thermal_add_hwmon_sysfs");12161216
+6-4
drivers/thermal/mediatek/lvts_thermal.c
···252252253253static int lvts_get_temp(struct thermal_zone_device *tz, int *temp)254254{255255- struct lvts_sensor *lvts_sensor = tz->devdata;255255+ struct lvts_sensor *lvts_sensor = thermal_zone_device_priv(tz);256256 void __iomem *msr = lvts_sensor->msr;257257 u32 value;258258···290290291291static int lvts_set_trips(struct thermal_zone_device *tz, int low, int high)292292{293293- struct lvts_sensor *lvts_sensor = tz->devdata;293293+ struct lvts_sensor *lvts_sensor = thermal_zone_device_priv(tz);294294 void __iomem *base = lvts_sensor->base;295295 u32 raw_low = lvts_temp_to_raw(low);296296 u32 raw_high = lvts_temp_to_raw(high);···305305 * 14-0 : Raw temperature for threshold306306 */307307 if (low != -INT_MAX) {308308- dev_dbg(&tz->device, "Setting low limit temperature interrupt: %d\n", low);308308+ pr_debug("%s: Setting low limit temperature interrupt: %d\n",309309+ thermal_zone_device_type(tz), low);309310 writel(raw_low, LVTS_H2NTHRE(base));310311 }311312···319318 *320319 * 14-0 : Raw temperature for threshold321320 */322322- dev_dbg(&tz->device, "Setting high limit temperature interrupt: %d\n", high);321321+ pr_debug("%s: Setting high limit temperature interrupt: %d\n",322322+ thermal_zone_device_type(tz), high);323323 writel(raw_high, LVTS_HTHRE(base));324324325325 return 0;
+3-3
drivers/thermal/qcom/qcom-spmi-adc-tm5.c
···360360361361static int adc_tm5_get_temp(struct thermal_zone_device *tz, int *temp)362362{363363- struct adc_tm5_channel *channel = tz->devdata;363363+ struct adc_tm5_channel *channel = thermal_zone_device_priv(tz);364364 int ret;365365366366 if (!channel || !channel->iio)···642642643643static int adc_tm5_set_trips(struct thermal_zone_device *tz, int low, int high)644644{645645- struct adc_tm5_channel *channel = tz->devdata;645645+ struct adc_tm5_channel *channel = thermal_zone_device_priv(tz);646646 struct adc_tm5_chip *chip;647647 int ret;648648···689689 return PTR_ERR(tzd);690690 }691691 adc_tm->channels[i].tzd = tzd;692692- if (devm_thermal_add_hwmon_sysfs(tzd))692692+ if (devm_thermal_add_hwmon_sysfs(adc_tm->dev, tzd))693693 dev_warn(adc_tm->dev,694694 "Failed to add hwmon sysfs attributes\n");695695 }
+3-3
drivers/thermal/qcom/qcom-spmi-temp-alarm.c
···187187188188static int qpnp_tm_get_temp(struct thermal_zone_device *tz, int *temp)189189{190190- struct qpnp_tm_chip *chip = tz->devdata;190190+ struct qpnp_tm_chip *chip = thermal_zone_device_priv(tz);191191 int ret, mili_celsius;192192193193 if (!temp)···265265266266static int qpnp_tm_set_trip_temp(struct thermal_zone_device *tz, int trip_id, int temp)267267{268268- struct qpnp_tm_chip *chip = tz->devdata;268268+ struct qpnp_tm_chip *chip = thermal_zone_device_priv(tz);269269 struct thermal_trip trip;270270 int ret;271271···459459 return ret;460460 }461461462462- if (devm_thermal_add_hwmon_sysfs(chip->tz_dev))462462+ if (devm_thermal_add_hwmon_sysfs(&pdev->dev, chip->tz_dev))463463 dev_warn(&pdev->dev,464464 "Failed to add hwmon sysfs attributes\n");465465
+3-3
drivers/thermal/qcom/tsens.c
···673673674674static int tsens_set_trips(struct thermal_zone_device *tz, int low, int high)675675{676676- struct tsens_sensor *s = tz->devdata;676676+ struct tsens_sensor *s = thermal_zone_device_priv(tz);677677 struct tsens_priv *priv = s->priv;678678 struct device *dev = priv->dev;679679 struct tsens_irq_data d;···1057105710581058static int tsens_get_temp(struct thermal_zone_device *tz, int *temp)10591059{10601060- struct tsens_sensor *s = tz->devdata;10601060+ struct tsens_sensor *s = thermal_zone_device_priv(tz);10611061 struct tsens_priv *priv = s->priv;1062106210631063 return priv->ops->get_temp(s, temp);···11891189 if (priv->ops->enable)11901190 priv->ops->enable(priv, i);1191119111921192- if (devm_thermal_add_hwmon_sysfs(tzd))11921192+ if (devm_thermal_add_hwmon_sysfs(priv->dev, tzd))11931193 dev_warn(priv->dev,11941194 "Failed to add hwmon sysfs attributes\n");11951195 }
+2-2
drivers/thermal/qoriq_thermal.c
···83838484static int tmu_get_temp(struct thermal_zone_device *tz, int *temp)8585{8686- struct qoriq_sensor *qsensor = tz->devdata;8686+ struct qoriq_sensor *qsensor = thermal_zone_device_priv(tz);8787 struct qoriq_tmu_data *qdata = qoriq_sensor_to_data(qsensor);8888 u32 val;8989 /*···157157 return ret;158158 }159159160160- if (devm_thermal_add_hwmon_sysfs(tzd))160160+ if (devm_thermal_add_hwmon_sysfs(dev, tzd))161161 dev_warn(dev,162162 "Failed to add hwmon sysfs attributes\n");163163
+2-3
drivers/thermal/rcar_gen3_thermal.c
···167167168168static int rcar_gen3_thermal_get_temp(struct thermal_zone_device *tz, int *temp)169169{170170- struct rcar_gen3_thermal_tsc *tsc = tz->devdata;170170+ struct rcar_gen3_thermal_tsc *tsc = thermal_zone_device_priv(tz);171171 int mcelsius, val;172172 int reg;173173···206206207207static int rcar_gen3_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)208208{209209- struct rcar_gen3_thermal_tsc *tsc = tz->devdata;209209+ struct rcar_gen3_thermal_tsc *tsc = thermal_zone_device_priv(tz);210210 u32 irqmsk = 0;211211212212 if (low != -INT_MAX) {···527527 }528528 tsc->zone = zone;529529530530- tsc->zone->tzp->no_hwmon = false;531530 ret = thermal_add_hwmon_sysfs(tsc->zone);532531 if (ret)533532 goto error_unregister;
+1-7
drivers/thermal/rcar_thermal.c
···101101 list_for_each_entry(pos, &common->head, list)102102103103#define MCELSIUS(temp) ((temp) * 1000)104104-#define rcar_zone_to_priv(zone) ((zone)->devdata)105104#define rcar_priv_to_dev(priv) ((priv)->common->dev)106105#define rcar_has_irq_support(priv) ((priv)->common->base)107106#define rcar_id_to_shift(priv) ((priv)->id * 8)···272273273274static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)274275{275275- struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);276276+ struct rcar_thermal_priv *priv = thermal_zone_device_priv(zone);276277277278 return rcar_thermal_get_current_temp(priv, temp);278279}···509510 }510511511512 if (chip->use_of_thermal) {512512- /*513513- * thermal_zone doesn't enable hwmon as default,514514- * but, enable it here to keep compatible515515- */516516- priv->zone->tzp->no_hwmon = false;517513 ret = thermal_add_hwmon_sysfs(priv->zone);518514 if (ret)519515 goto error_unregister;
+2-6
drivers/thermal/rockchip_thermal.c
···1213121312141214static int rockchip_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)12151215{12161216- struct rockchip_thermal_sensor *sensor = tz->devdata;12161216+ struct rockchip_thermal_sensor *sensor = thermal_zone_device_priv(tz);12171217 struct rockchip_thermal_data *thermal = sensor->thermal;12181218 const struct rockchip_tsadc_chip *tsadc = thermal->chip;12191219···1226122612271227static int rockchip_thermal_get_temp(struct thermal_zone_device *tz, int *out_temp)12281228{12291229- struct rockchip_thermal_sensor *sensor = tz->devdata;12291229+ struct rockchip_thermal_sensor *sensor = thermal_zone_device_priv(tz);12301230 struct rockchip_thermal_data *thermal = sensor->thermal;12311231 const struct rockchip_tsadc_chip *tsadc = sensor->thermal->chip;12321232 int retval;1233123312341234 retval = tsadc->get_temp(&tsadc->table,12351235 sensor->id, thermal->regs, out_temp);12361236- dev_dbg(&thermal->pdev->dev, "sensor %d - temp: %d, retval: %d\n",12371237- sensor->id, *out_temp, retval);12381238-12391236 return retval;12401237}12411238···1451145414521455 for (i = 0; i < thermal->chip->chn_num; i++) {14531456 rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);14541454- thermal->sensors[i].tzd->tzp->no_hwmon = false;14551457 error = thermal_add_hwmon_sysfs(thermal->sensors[i].tzd);14561458 if (error)14571459 dev_warn(&pdev->dev,
+1-2
drivers/thermal/rzg2l_thermal.c
···75757676static int rzg2l_thermal_get_temp(struct thermal_zone_device *tz, int *temp)7777{7878- struct rzg2l_thermal_priv *priv = tz->devdata;7878+ struct rzg2l_thermal_priv *priv = thermal_zone_device_priv(tz);7979 u32 result = 0, dsensor, ts_code_ave;8080 int val, i;8181···216216 }217217218218 priv->zone = zone;219219- priv->zone->tzp->no_hwmon = false;220219 ret = thermal_add_hwmon_sysfs(priv->zone);221220 if (ret)222221 goto err;
+2-2
drivers/thermal/samsung/exynos_tmu.c
···645645646646static int exynos_get_temp(struct thermal_zone_device *tz, int *temp)647647{648648- struct exynos_tmu_data *data = tz->devdata;648648+ struct exynos_tmu_data *data = thermal_zone_device_priv(tz);649649 int value, ret = 0;650650651651 if (!data || !data->tmu_read)···723723724724static int exynos_tmu_set_emulation(struct thermal_zone_device *tz, int temp)725725{726726- struct exynos_tmu_data *data = tz->devdata;726726+ struct exynos_tmu_data *data = thermal_zone_device_priv(tz);727727 int ret = -EINVAL;728728729729 if (data->soc == SOC_ARCH_EXYNOS4210)
+5-5
drivers/thermal/spear_thermal.c
···3131static inline int thermal_get_temp(struct thermal_zone_device *thermal,3232 int *temp)3333{3434- struct spear_thermal_dev *stdev = thermal->devdata;3434+ struct spear_thermal_dev *stdev = thermal_zone_device_priv(thermal);35353636 /*3737 * Data are ready to be read after 628 usec from POWERDOWN signal···4848static int __maybe_unused spear_thermal_suspend(struct device *dev)4949{5050 struct thermal_zone_device *spear_thermal = dev_get_drvdata(dev);5151- struct spear_thermal_dev *stdev = spear_thermal->devdata;5151+ struct spear_thermal_dev *stdev = thermal_zone_device_priv(spear_thermal);5252 unsigned int actual_mask = 0;53535454 /* Disable SPEAr Thermal Sensor */···6464static int __maybe_unused spear_thermal_resume(struct device *dev)6565{6666 struct thermal_zone_device *spear_thermal = dev_get_drvdata(dev);6767- struct spear_thermal_dev *stdev = spear_thermal->devdata;6767+ struct spear_thermal_dev *stdev = thermal_zone_device_priv(spear_thermal);6868 unsigned int actual_mask = 0;6969 int ret = 0;7070···137137138138 platform_set_drvdata(pdev, spear_thermal);139139140140- dev_info(&spear_thermal->device, "Thermal Sensor Loaded at: 0x%p.\n",140140+ dev_info(&pdev->dev, "Thermal Sensor Loaded at: 0x%p.\n",141141 stdev->thermal_base);142142143143 return 0;···154154{155155 unsigned int actual_mask = 0;156156 struct thermal_zone_device *spear_thermal = platform_get_drvdata(pdev);157157- struct spear_thermal_dev *stdev = spear_thermal->devdata;157157+ struct spear_thermal_dev *stdev = thermal_zone_device_priv(spear_thermal);158158159159 thermal_zone_device_unregister(spear_thermal);160160
+1-1
drivers/thermal/sprd_thermal.c
···206206207207static int sprd_thm_read_temp(struct thermal_zone_device *tz, int *temp)208208{209209- struct sprd_thermal_sensor *sen = tz->devdata;209209+ struct sprd_thermal_sensor *sen = thermal_zone_device_priv(tz);210210 u32 data;211211212212 data = readl(sen->data->base + SPRD_THM_TEMP(sen->id)) &
+1-4
drivers/thermal/st/st_thermal.c
···108108/* Callback to get temperature from HW*/109109static int st_thermal_get_temp(struct thermal_zone_device *th, int *temperature)110110{111111- struct st_thermal_sensor *sensor = th->devdata;112112- struct device *dev = sensor->dev;111111+ struct st_thermal_sensor *sensor = thermal_zone_device_priv(th);113112 unsigned int temp;114113 unsigned int overflow;115114 int ret;···125126126127 temp += sensor->cdata->temp_adjust_val;127128 temp = mcelsius(temp);128128-129129- dev_dbg(dev, "temperature: %d\n", temp);130129131130 *temperature = temp;132131
+2-2
drivers/thermal/st/stm_thermal.c
···303303304304static int stm_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)305305{306306- struct stm_thermal_sensor *sensor = tz->devdata;306306+ struct stm_thermal_sensor *sensor = thermal_zone_device_priv(tz);307307 u32 itr1, th;308308 int ret;309309···351351/* Callback to get temperature from HW */352352static int stm_thermal_get_temp(struct thermal_zone_device *tz, int *temp)353353{354354- struct stm_thermal_sensor *sensor = tz->devdata;354354+ struct stm_thermal_sensor *sensor = thermal_zone_device_priv(tz);355355 u32 periods;356356 int freqM, ret;357357
+2-2
drivers/thermal/sun8i_thermal.c
···110110111111static int sun8i_ths_get_temp(struct thermal_zone_device *tz, int *temp)112112{113113- struct tsensor *s = tz->devdata;113113+ struct tsensor *s = thermal_zone_device_priv(tz);114114 struct ths_device *tmdev = s->tmdev;115115 int val = 0;116116···475475 if (IS_ERR(tmdev->sensor[i].tzd))476476 return PTR_ERR(tmdev->sensor[i].tzd);477477478478- if (devm_thermal_add_hwmon_sysfs(tmdev->sensor[i].tzd))478478+ if (devm_thermal_add_hwmon_sysfs(tmdev->dev, tmdev->sensor[i].tzd))479479 dev_warn(tmdev->dev,480480 "Failed to add hwmon sysfs attributes\n");481481 }
+3-3
drivers/thermal/tegra/soctherm.c
···423423424424static int tegra_thermctl_get_temp(struct thermal_zone_device *tz, int *out_temp)425425{426426- struct tegra_thermctl_zone *zone = tz->devdata;426426+ struct tegra_thermctl_zone *zone = thermal_zone_device_priv(tz);427427 u32 val;428428429429 val = readl(zone->reg);···584584585585static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip_id, int temp)586586{587587- struct tegra_thermctl_zone *zone = tz->devdata;587587+ struct tegra_thermctl_zone *zone = thermal_zone_device_priv(tz);588588 struct tegra_soctherm *ts = zone->ts;589589 struct thermal_trip trip;590590 const struct tegra_tsensor_group *sg = zone->sg;···658658659659static int tegra_thermctl_set_trips(struct thermal_zone_device *tz, int lo, int hi)660660{661661- struct tegra_thermctl_zone *zone = tz->devdata;661661+ struct tegra_thermctl_zone *zone = thermal_zone_device_priv(tz);662662 u32 r;663663664664 thermal_irq_disable(zone);
+4-2
drivers/thermal/tegra/tegra-bpmp-thermal.c
···62626363static int tegra_bpmp_thermal_get_temp(struct thermal_zone_device *tz, int *out_temp)6464{6565- return __tegra_bpmp_thermal_get_temp(tz->devdata, out_temp);6565+ struct tegra_bpmp_thermal_zone *zone = thermal_zone_device_priv(tz);6666+6767+ return __tegra_bpmp_thermal_get_temp(zone, out_temp);6668}67696870static int tegra_bpmp_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)6971{7070- struct tegra_bpmp_thermal_zone *zone = tz->devdata;7272+ struct tegra_bpmp_thermal_zone *zone = thermal_zone_device_priv(tz);7173 struct mrq_thermal_host_to_bpmp_request req;7274 struct tegra_bpmp_message msg;7375 int err;
+17-14
drivers/thermal/tegra/tegra30-tsensor.c
···160160161161static int tegra_tsensor_get_temp(struct thermal_zone_device *tz, int *temp)162162{163163- const struct tegra_tsensor_channel *tsc = tz->devdata;163163+ const struct tegra_tsensor_channel *tsc = thermal_zone_device_priv(tz);164164 const struct tegra_tsensor *ts = tsc->ts;165165 int err, c1, c2, c3, c4, counter;166166 u32 val;···218218219219static int tegra_tsensor_set_trips(struct thermal_zone_device *tz, int low, int high)220220{221221- const struct tegra_tsensor_channel *tsc = tz->devdata;221221+ const struct tegra_tsensor_channel *tsc = thermal_zone_device_priv(tz);222222 const struct tegra_tsensor *ts = tsc->ts;223223 u32 val;224224···359359360360 tegra_tsensor_get_hw_channel_trips(tzd, &hot_trip, &crit_trip);361361362362- /* prevent potential racing with tegra_tsensor_set_trips() */363363- mutex_lock(&tzd->lock);364364-365362 dev_info_once(ts->dev, "ch%u: PMC emergency shutdown trip set to %dC\n",366363 id, DIV_ROUND_CLOSEST(crit_trip, 1000));367364···400403 val |= FIELD_PREP(TSENSOR_SENSOR0_CONFIG0_INTR_HW_FREQ_DIV_EN, 1);401404 val |= FIELD_PREP(TSENSOR_SENSOR0_CONFIG0_INTR_THERMAL_RST_EN, 1);402405 writel_relaxed(val, tsc->regs + TSENSOR_SENSOR0_CONFIG0);403403-404404- mutex_unlock(&tzd->lock);405406406407 err = thermal_zone_device_enable(tzd);407408 if (err) {···523528 return 0;524529 }525530526526- if (devm_thermal_add_hwmon_sysfs(tsc->tzd))531531+ if (devm_thermal_add_hwmon_sysfs(ts->dev, tsc->tzd))527532 dev_warn(ts->dev, "failed to add hwmon sysfs attributes\n");528533529534 return 0;···580585 return err;581586 }582587588588+ /*589589+ * Enable the channels before setting the interrupt so590590+ * set_trips() can not be called while we are setting up the591591+ * register TSENSOR_SENSOR0_CONFIG1. With this we close a592592+ * potential race window where we are setting up the TH2 and593593+ * the temperature hits TH1 resulting to an update of the594594+ * TSENSOR_SENSOR0_CONFIG1 register in the ISR.595595+ */596596+ for (i = 0; i < ARRAY_SIZE(ts->ch); i++) {597597+ err = tegra_tsensor_enable_hw_channel(ts, i);598598+ if (err)599599+ return err;600600+ }601601+583602 err = devm_request_threaded_irq(&pdev->dev, irq, NULL,584603 tegra_tsensor_isr, IRQF_ONESHOT,585604 "tegra_tsensor", ts);586605 if (err)587606 return dev_err_probe(&pdev->dev, err,588607 "failed to request interrupt\n");589589-590590- for (i = 0; i < ARRAY_SIZE(ts->ch); i++) {591591- err = tegra_tsensor_enable_hw_channel(ts, i);592592- if (err)593593- return err;594594- }595608596609 return 0;597610}
+3-4
drivers/thermal/thermal-generic-adc.c
···54545555static int gadc_thermal_get_temp(struct thermal_zone_device *tz, int *temp)5656{5757- struct gadc_thermal_info *gti = tz->devdata;5757+ struct gadc_thermal_info *gti = thermal_zone_device_priv(tz);5858 int val;5959 int ret;60606161 ret = iio_read_channel_processed(gti->channel, &val);6262- if (ret < 0) {6363- dev_err(gti->dev, "IIO channel read failed %d\n", ret);6262+ if (ret < 0)6463 return ret;6565- }6464+6665 *temp = gadc_thermal_adc_to_temp(gti, val);67666867 return 0;
+18
drivers/thermal/thermal_core.c
···14671467}14681468EXPORT_SYMBOL_GPL(thermal_zone_device_register);1469146914701470+void *thermal_zone_device_priv(struct thermal_zone_device *tzd)14711471+{14721472+ return tzd->devdata;14731473+}14741474+EXPORT_SYMBOL_GPL(thermal_zone_device_priv);14751475+14761476+const char *thermal_zone_device_type(struct thermal_zone_device *tzd)14771477+{14781478+ return tzd->type;14791479+}14801480+EXPORT_SYMBOL_GPL(thermal_zone_device_type);14811481+14821482+int thermal_zone_device_id(struct thermal_zone_device *tzd)14831483+{14841484+ return tzd->id;14851485+}14861486+EXPORT_SYMBOL_GPL(thermal_zone_device_id);14871487+14701488/**14711489 * thermal_zone_device_unregister - removes the registered thermal zone device14721490 * @tz: the thermal zone device to remove