thermal/core: Use the thermal zone 'devdata' accessor in thermal located drivers
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Wed, 1 Mar 2023 20:14:30 +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>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> #R-Car
Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> #MediaTek auxadc and lvts
Reviewed-by: Balsam CHIHI <bchihi@baylibre.com> #Mediatek lvts
Reviewed-by: Adam Ward <DLG-Adam.Ward.opensource@dm.renesas.com> #da9062
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com> #spread
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> #sun8i_thermal
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com> #Broadcom
Reviewed-by: Dhruva Gole <d-gole@ti.com> # K3 bandgap
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Heiko Stuebner <heiko@sntech.de> #rockchip
Reviewed-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> #uniphier
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
48 files changed:
drivers/thermal/amlogic_thermal.c
drivers/thermal/armada_thermal.c
drivers/thermal/broadcom/bcm2711_thermal.c
drivers/thermal/broadcom/bcm2835_thermal.c
drivers/thermal/broadcom/brcmstb_thermal.c
drivers/thermal/broadcom/ns-thermal.c
drivers/thermal/broadcom/sr-thermal.c
drivers/thermal/da9062-thermal.c
drivers/thermal/db8500_thermal.c
drivers/thermal/dove_thermal.c
drivers/thermal/hisi_thermal.c
drivers/thermal/imx8mm_thermal.c
drivers/thermal/imx_sc_thermal.c
drivers/thermal/imx_thermal.c
drivers/thermal/intel/int340x_thermal/int3400_thermal.c
drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
drivers/thermal/intel/intel_pch_thermal.c
drivers/thermal/intel/intel_quark_dts_thermal.c
drivers/thermal/intel/intel_soc_dts_iosf.c
drivers/thermal/intel/x86_pkg_temp_thermal.c
drivers/thermal/k3_bandgap.c
drivers/thermal/k3_j72xx_bandgap.c
drivers/thermal/kirkwood_thermal.c
drivers/thermal/max77620_thermal.c
drivers/thermal/mediatek/auxadc_thermal.c
drivers/thermal/mediatek/lvts_thermal.c
drivers/thermal/qcom/qcom-spmi-adc-tm5.c
drivers/thermal/qcom/qcom-spmi-temp-alarm.c
drivers/thermal/qcom/tsens.c
drivers/thermal/qoriq_thermal.c
drivers/thermal/rcar_gen3_thermal.c
drivers/thermal/rcar_thermal.c
drivers/thermal/rockchip_thermal.c
drivers/thermal/rzg2l_thermal.c
drivers/thermal/samsung/exynos_tmu.c
drivers/thermal/spear_thermal.c
drivers/thermal/sprd_thermal.c
drivers/thermal/st/st_thermal.c
drivers/thermal/st/stm_thermal.c
drivers/thermal/sun8i_thermal.c
drivers/thermal/tegra/soctherm.c
drivers/thermal/tegra/tegra-bpmp-thermal.c
drivers/thermal/tegra/tegra30-tsensor.c
drivers/thermal/thermal-generic-adc.c
drivers/thermal/thermal_mmio.c
drivers/thermal/ti-soc-thermal/ti-thermal-common.c
drivers/thermal/uniphier_thermal.c

index 9235fda4ec1eba632d545b59c25f9de9dbd4de8a..dfcc93e45cdde0009687ae903039dcfb46c7a0a1 100644 (file)
@@ -181,7 +181,7 @@ static int amlogic_thermal_disable(struct amlogic_thermal *data)
 static int amlogic_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
 {
        unsigned int tval;
-       struct amlogic_thermal *pdata = tz->devdata;
+       struct amlogic_thermal *pdata = thermal_zone_device_priv(tz);
 
        if (!pdata)
                return -EINVAL;
index 2efc222a379bb22e6f9c2c2383f77bbd5f6f1809..ebd606861a617ef54f81ffd1d7578ef0ddf64383 100644 (file)
@@ -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_priv(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_priv(tz);
        struct armada_thermal_priv *priv = sensor->priv;
        int ret;
 
index 1f8651d15160c972cf477a745b4142a2d7e938b1..fcfcbbf044a42461a2ee40e4612806046aab286c 100644 (file)
@@ -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_priv(tz);
        int slope = thermal_zone_get_slope(tz);
        int offset = thermal_zone_get_offset(tz);
        u32 val;
index 23918bb76ae649e8e223c74ad7cb9b82594c1b46..86aaf459de3710a7e1690d689f33d3d647e94b9f 100644 (file)
@@ -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_priv(tz);
        u32 val = readl(data->regs + BCM2835_TS_TSENSSTAT);
 
        if (!(val & BCM2835_TS_TSENSSTAT_VALID))
index 4d02c28331e379db536a8152f994ff4df06c0738..60173cc83c46cba07e13c64324251de25d1671f2 100644 (file)
@@ -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_priv(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_priv(tz);
 
        dev_dbg(priv->dev, "set trips %d <--> %d\n", low, high);
 
index 07a8a3f49bd0f98c5bdede4bc12d85d25b823fcd..d255aa879fc0d109c64bc38e91545d9c9f2fc54b 100644 (file)
@@ -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_priv(tz);
        int offset = thermal_zone_get_offset(tz);
        int slope = thermal_zone_get_slope(tz);
        u32 val;
index 2b93502543ff4be8254d3bee4f016d9b318deb5c..7479158900226f169520b0a1880cfc793f7f10ba 100644 (file)
@@ -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_priv(tz);
        struct sr_thermal *sr_thermal = tmon->priv;
 
        *temp = readl(sr_thermal->regs + SR_TMON_TEMP_BASE(tmon->tmon_id));
index a805a6666c4400cb774a4c531b7ad5773c34188f..e7097f35475001ced84af1ff3f103d5dc625ba30 100644 (file)
@@ -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_priv(z);
 
        mutex_lock(&thermal->lock);
        *temp = thermal->temperature;
index cb10e280681fcc027cd1a800d684a6cfaf4a2db7..c0418497520cbe0089bb10c5eb6b75ffe4dbf542 100644 (file)
@@ -60,7 +60,7 @@ struct db8500_thermal_zone {
 /* Callback to get current temperature */
 static int db8500_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
 {
-       struct db8500_thermal_zone *th = tz->devdata;
+       struct db8500_thermal_zone *th = thermal_zone_device_priv(tz);
 
        /*
         * TODO: There is no PRCMU interface to get temperature data currently,
index 056622a58d007395160ee47abf3334cfec2e3401..6db1882e822917ce7d0efa24518826256e323a91 100644 (file)
@@ -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_priv(thermal);
 
        /* Valid check */
        reg = readl_relaxed(priv->control + PMU_TEMP_DIOD_CTRL1_REG);
index 32a7c3cf073df22f09293d0960eadf74ed8319fd..f3a374266fa0e624a25364c8820e2689bf71c77d 100644 (file)
@@ -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_priv(tz);
        struct hisi_thermal_data *data = sensor->data;
 
        *temp = data->ops->get_temp(sensor);
index 72b5d6f319c1d0d9c603312c85bfea587145641f..efa1a4ffc368ae96a56a5955e3b4f61e2030c407 100644 (file)
@@ -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_priv(tz);
        struct imx8mm_tmu *tmu = sensor->priv;
 
        return tmu->socdata->get_temp(sensor, temp);
index f32e59e7462316de443531bb76c6167687a2cfc1..ddde4bdfc94a3284468bca00ace8b2f09cf89a3f 100644 (file)
@@ -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_priv(tz);
        int ret;
 
        msg.data.req.resource_id = sensor->resource_id;
index fb0d5cab70af3a9a69f071b9dab5a1801a7a599e..a22b8086a209a17720b8f55f4fc651b16d5105b9 100644 (file)
@@ -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_priv(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_priv(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_priv(tz);
        int ret;
 
        ret = pm_runtime_resume_and_get(data->dev);
index d0295123cc3e44961b0f616febf594dcbb55b75e..810231b59dcdcc7b1e2943a603b099ac40a3e33b 100644 (file)
@@ -497,7 +497,7 @@ static int int3400_thermal_get_temp(struct thermal_zone_device *thermal,
 static int int3400_thermal_change_mode(struct thermal_zone_device *thermal,
                                       enum thermal_device_mode mode)
 {
-       struct int3400_thermal_priv *priv = thermal->devdata;
+       struct int3400_thermal_priv *priv = thermal_zone_device_priv(thermal);
        int result = 0;
 
        if (!priv)
index 00665967ca521300d41fa0548b838d9246e698bd..89cf007146ead3f0ff4d7321b4b8c27b1836504b 100644 (file)
@@ -14,7 +14,7 @@
 static int int340x_thermal_get_zone_temp(struct thermal_zone_device *zone,
                                         int *temp)
 {
-       struct int34x_thermal_zone *d = zone->devdata;
+       struct int34x_thermal_zone *d = thermal_zone_device_priv(zone);
        unsigned long long tmp;
        acpi_status status;
 
@@ -41,7 +41,7 @@ static int int340x_thermal_get_zone_temp(struct thermal_zone_device *zone,
 static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone,
                                         int trip, int temp)
 {
-       struct int34x_thermal_zone *d = zone->devdata;
+       struct int34x_thermal_zone *d = thermal_zone_device_priv(zone);
        char name[] = {'P', 'A', 'T', '0' + trip, '\0'};
        acpi_status status;
 
index 40725cbc6eb0cdcf1381ad71644085d00656bd5e..0404d4db70f07ba7f953e7998be18ebeb2d6f6ad 100644 (file)
@@ -135,7 +135,7 @@ static irqreturn_t proc_thermal_irq_handler(int irq, void *devid)
 
 static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp)
 {
-       struct proc_thermal_pci *pci_info = tzd->devdata;
+       struct proc_thermal_pci *pci_info = thermal_zone_device_priv(tzd);
        u32 _temp;
 
        proc_thermal_mmio_read(pci_info, PROC_THERMAL_MMIO_PKG_TEMP, &_temp);
@@ -146,7 +146,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 proc_thermal_pci *pci_info = tzd->devdata;
+       struct proc_thermal_pci *pci_info = thermal_zone_device_priv(tzd);
        int tjmax, _temp;
 
        if (temp <= 0) {
index b855d031a855d34694a85c7d93aab44b00265762..dce50d239357bc3a05088cb077e3ff34a2630e91 100644 (file)
@@ -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_priv(tzd);
 
        *temp = GET_WPT_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP));
        return 0;
index ffdc95047838f37acc0ddc9972db7b229f129095..646ca8bd40a9859983fa0523612a6b9221fee4a0 100644 (file)
@@ -120,7 +120,7 @@ static DEFINE_MUTEX(dts_update_mutex);
 static int soc_dts_enable(struct thermal_zone_device *tzd)
 {
        u32 out;
-       struct soc_sensor_entry *aux_entry = tzd->devdata;
+       struct soc_sensor_entry *aux_entry = thermal_zone_device_priv(tzd);
        int ret;
 
        ret = iosf_mbi_read(QRK_MBI_UNIT_RMU, MBI_REG_READ,
@@ -148,7 +148,7 @@ static int soc_dts_enable(struct thermal_zone_device *tzd)
 static int soc_dts_disable(struct thermal_zone_device *tzd)
 {
        u32 out;
-       struct soc_sensor_entry *aux_entry = tzd->devdata;
+       struct soc_sensor_entry *aux_entry = thermal_zone_device_priv(tzd);
        int ret;
 
        ret = iosf_mbi_read(QRK_MBI_UNIT_RMU, MBI_REG_READ,
@@ -250,7 +250,7 @@ failed:
 static inline int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
                                int temp)
 {
-       return update_trip_temp(tzd->devdata, trip, temp);
+       return update_trip_temp(thermal_zone_device_priv(tzd), trip, temp);
 }
 
 static int sys_get_curr_temp(struct thermal_zone_device *tzd,
index 8c26f7b2316b5b844af5e197e6c563a15384479e..f99dc7e4ae893949e1fb8009982f2a922aeeb0e5 100644 (file)
@@ -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_priv(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 @@ err_restore_ptps:
 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_priv(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_priv(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_priv(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);
index 1c2de84742dfb51db7bbf09b83558d396a9c7a05..c4ec314441be5299c12b51956a24ee32fff57937 100644 (file)
@@ -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_priv(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_priv(tzd);
        u32 l, h, mask, shift, intr;
        int tj_max, ret;
 
index 22c9bcb899c37b21dde6ee48cb19b3cb93554fcb..b5cd2c85e0c391fed09c66043ecb23e61768ca60 100644 (file)
@@ -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_priv(tz);
        int ret = 0;
 
        ret = k3_bgp_read_temp(data, temp);
index 031ea1091909a78549dfb2191b9a739eef3f7248..5be1f09eeb2c3d7c14f46b2a7f0cb11c0d808620 100644 (file)
@@ -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_priv(tz), temp);
 }
 
 static const struct thermal_zone_device_ops k3_of_thermal_ops = {
index bec7ec20e79d5e86830eb1764d8baa2eca79f805..92b3ce426b9ded68f056783a76cedf41273ed1fb 100644 (file)
@@ -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_priv(thermal);
 
        reg = readl_relaxed(priv->sensor);
 
index 6451a55eb5823abdb4f0b986ef1d77f39ec2e9bc..bf1679765f1b2ee85e1978cd220ee8144b49c3c6 100644 (file)
@@ -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_priv(tz);
        unsigned int val;
        int ret;
 
index ab730f9552d0e00a0a96c59c0f6441242e769994..755baa4e5bd231791f5cc4857921c1166f83ae77 100644 (file)
@@ -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_priv(tz);
        int i;
        int tempmax = INT_MIN;
 
index 84ba65a27acf7db452af75e2ee824c638045203e..fb4b1b4db245f8c422f5a688da780a2c41c7b699 100644 (file)
@@ -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_priv(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_priv(tz);
        void __iomem *base = lvts_sensor->base;
        u32 raw_low = lvts_temp_to_raw(low);
        u32 raw_high = lvts_temp_to_raw(high);
index 31164ade2dd11379045e7f14d26493184def35e1..ed204489a9506890dfafb291406c60f410365ccf 100644 (file)
@@ -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_priv(tz);
        int ret;
 
        if (!channel || !channel->iio)
@@ -642,7 +642,7 @@ config_fail:
 
 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_priv(tz);
        struct adc_tm5_chip *chip;
        int ret;
 
index 101c75d0e13f3c6605dde08919f9ef7781909463..b196d8d0172627425e49bfc98eb3ecaa53d86b02 100644 (file)
@@ -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_priv(tz);
        int ret, mili_celsius;
 
        if (!temp)
@@ -265,7 +265,7 @@ skip:
 
 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_priv(tz);
        struct thermal_trip trip;
        int ret;
 
index 8020ead2794e99263057821af863e1fcab0a3640..6cc935379f00044b8edaeb71bf037dcc5f926ee5 100644 (file)
@@ -673,7 +673,7 @@ static irqreturn_t tsens_combined_irq_thread(int irq, void *data)
 
 static int tsens_set_trips(struct thermal_zone_device *tz, int low, int high)
 {
-       struct tsens_sensor *s = tz->devdata;
+       struct tsens_sensor *s = thermal_zone_device_priv(tz);
        struct tsens_priv *priv = s->priv;
        struct device *dev = priv->dev;
        struct tsens_irq_data d;
@@ -1057,7 +1057,7 @@ err_put_device:
 
 static int tsens_get_temp(struct thermal_zone_device *tz, int *temp)
 {
-       struct tsens_sensor *s = tz->devdata;
+       struct tsens_sensor *s = thermal_zone_device_priv(tz);
        struct tsens_priv *priv = s->priv;
 
        return priv->ops->get_temp(s, temp);
index 431c29c0898a7be0f27bce265dad3a58b2d529ba..d2dc99247f6179a50b5eefb16a2f648a086080c8 100644 (file)
@@ -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_priv(tz);
        struct qoriq_tmu_data *qdata = qoriq_sensor_to_data(qsensor);
        u32 val;
        /*
index d6b5b59c5c534623e7e64dda97905e40795a1c4d..2b7537ef141dc4351869864c29d09eadfa8b9ab5 100644 (file)
@@ -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_priv(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_priv(tz);
        u32 irqmsk = 0;
 
        if (low != -INT_MAX) {
index 436f5f9cf72999cee18f26a743b0816ccf6e4b8c..e0440f63ae77358f90a6769bd2e23fe0dafe96d4 100644 (file)
@@ -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_priv(zone);
 
        return rcar_thermal_get_current_temp(priv, temp);
 }
index 4b7c43f34d1a93130baae677cc01eccd2f1c13b0..8a51eb26e79871b4235d014672f63102a2e5a0c1 100644 (file)
@@ -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_priv(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_priv(tz);
        struct rockchip_thermal_data *thermal = sensor->thermal;
        const struct rockchip_tsadc_chip *tsadc = sensor->thermal->chip;
        int retval;
index 2e0649f3850607574ddf74a0891fe9c34a246958..7631430ce8a920e683abe75c652197148411c9c8 100644 (file)
@@ -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_priv(tz);
        u32 result = 0, dsensor, ts_code_ave;
        int val, i;
 
index 527d1eb0663a10beeef6ab24c28512d3470fd96f..45e5c840d1300d462f064042cb6db45e26c54ed3 100644 (file)
@@ -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_priv(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_priv(tz);
        int ret = -EINVAL;
 
        if (data->soc == SOC_ARCH_EXYNOS4210)
index 6a722b10d738083a5064c50df7002f759c751349..653439b965c8725eae960593e3cde05b39a7cf0a 100644 (file)
@@ -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_priv(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_priv(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_priv(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_priv(spear_thermal);
 
        thermal_zone_device_unregister(spear_thermal);
 
index ac884514f116a0f38741bd2f1c948f140a794a75..2fb90fdad76e2d17ea1c7425f8055405b2022a3b 100644 (file)
@@ -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_priv(tz);
        u32 data;
 
        data = readl(sen->data->base + SPRD_THM_TEMP(sen->id)) &
index 1009f08e64e351b5d132b8e1dfd38dd9aea63126..6ed393218eb8dd87a03bf6da2ed7dbe9c034f974 100644 (file)
@@ -108,7 +108,7 @@ static int st_thermal_calibration(struct st_thermal_sensor *sensor)
 /* Callback to get temperature from HW*/
 static int st_thermal_get_temp(struct thermal_zone_device *th, int *temperature)
 {
-       struct st_thermal_sensor *sensor = th->devdata;
+       struct st_thermal_sensor *sensor = thermal_zone_device_priv(th);
        struct device *dev = sensor->dev;
        unsigned int temp;
        unsigned int overflow;
index 735401958f01147fda2f2fd4c57aaa5df7e4e573..6f2bad8ef82fa61a06c57ecba86fa4cefc372ffa 100644 (file)
@@ -303,7 +303,7 @@ static int stm_disable_irq(struct stm_thermal_sensor *sensor)
 
 static int stm_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)
 {
-       struct stm_thermal_sensor *sensor = tz->devdata;
+       struct stm_thermal_sensor *sensor = thermal_zone_device_priv(tz);
        u32 itr1, th;
        int ret;
 
@@ -351,7 +351,7 @@ static int stm_thermal_set_trips(struct thermal_zone_device *tz, int low, int hi
 /* Callback to get temperature from HW */
 static int stm_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
 {
-       struct stm_thermal_sensor *sensor = tz->devdata;
+       struct stm_thermal_sensor *sensor = thermal_zone_device_priv(tz);
        u32 periods;
        int freqM, ret;
 
index 497beac63e5d9305f2f41aa95c0d1ecca719bebe..6b550f0f90bf96214db9c8d0dd70701f60a301ef 100644 (file)
@@ -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_priv(tz);
        struct ths_device *tmdev = s->tmdev;
        int val = 0;
 
index 220873298d776b733b0788d3a47ace860c544abc..ea66cba09e5696ac6922617a4000dcea5f3e14f5 100644 (file)
@@ -423,7 +423,7 @@ static int translate_temp(u16 val)
 
 static int tegra_thermctl_get_temp(struct thermal_zone_device *tz, int *out_temp)
 {
-       struct tegra_thermctl_zone *zone = tz->devdata;
+       struct tegra_thermctl_zone *zone = thermal_zone_device_priv(tz);
        u32 val;
 
        val = readl(zone->reg);
@@ -584,7 +584,7 @@ static int tsensor_group_thermtrip_get(struct tegra_soctherm *ts, int id)
 
 static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip_id, int temp)
 {
-       struct tegra_thermctl_zone *zone = tz->devdata;
+       struct tegra_thermctl_zone *zone = thermal_zone_device_priv(tz);
        struct tegra_soctherm *ts = zone->ts;
        struct thermal_trip trip;
        const struct tegra_tsensor_group *sg = zone->sg;
@@ -658,7 +658,7 @@ static void thermal_irq_disable(struct tegra_thermctl_zone *zn)
 
 static int tegra_thermctl_set_trips(struct thermal_zone_device *tz, int lo, int hi)
 {
-       struct tegra_thermctl_zone *zone = tz->devdata;
+       struct tegra_thermctl_zone *zone = thermal_zone_device_priv(tz);
        u32 r;
 
        thermal_irq_disable(zone);
index 0b7a1a1948cb8b2c8a825b02c4fb2b55b836604c..b1d5aaf81224ada3569ba13435b55181b4e1b5cf 100644 (file)
@@ -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_priv(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_priv(tz);
        struct mrq_thermal_host_to_bpmp_request req;
        struct tegra_bpmp_message msg;
        int err;
index b3218b71b6d976968be6bb023897fecac906d953..42c6fb494dd993c1ae66663d34d1c760bfda65c7 100644 (file)
@@ -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_priv(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_priv(tz);
        const struct tegra_tsensor *ts = tsc->ts;
        u32 val;
 
index 323e273e329824bc4fa705974ae9686498917ea4..2c283e762d8183594ce778bcba39e9e10f4455c7 100644 (file)
@@ -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_priv(tz);
        int val;
        int ret;
 
index ea616731066c21b009a906b043e20055279e5f43..6845756ad5e74977595e705ab627dfafdd40c58a 100644 (file)
@@ -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_priv(tz);
 
        t = sensor->read_mmio(sensor->mmio_base) & sensor->mask;
        t *= sensor->factor;
index 8a9055bd376ec16a0487c4d4484ac9968f3d59d5..3e998c9799bb8f8816b9547f2021eb0e1316aac7 100644 (file)
@@ -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_priv(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_priv(tz);
        struct ti_bandgap *bgp;
        int id, tr, ret = 0;
 
index 47801841b3f5d702cd424c1df962a59faea2df57..aef6119cc0040bfda8b6b0dab1ffacc62b59ffb0 100644 (file)
@@ -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_priv(tz);
        struct regmap *map = tdev->regmap;
        int ret;
        u32 temp;