2023-02-28 11:23:00

by Daniel Lezcano

[permalink] [raw]
Subject: [PATCH v4 00/19] Self-encapsulate the thermal zone device structure

The exported thermal headers expose the thermal core structure while those
should be private to the framework. The initial idea was the thermal sensor
drivers use the thermal zone device structure pointer to pass it around from
the ops to the thermal framework API like a handler.

Unfortunately, different drivers are using and abusing the internals of this
structure to hook the associated struct device, read the internals values, take
the lock, etc ...

In order to fix this situation, let's encapsulate the structure leaking the
more in the different drivers: the thermal_zone_device structure.

This series revisit the existing drivers using the thermal zone private
structure internals to change the access to something else. For instance, the
get_temp() ops is using the tz->dev to write a debug trace. Despite the trace
is not helpful, we can check the return value for the get_temp() ops in the
call site and show the message in this place.

With this set of changes, the thermal_zone_device is almost self-encapsulated.
As usual, the acpi driver needs a more complex changes, so that will come in a
separate series along with the structure moved the private core headers.

Changelog:
- V4:
- Collected more tags
- Fixed a typo therma_zone_device_priv() for db8500
- Remove traces patch [20/20] to be submitted separetely
- V3:
- Split the first patch into three to reduce the number of
recipients per change
- Collected more tags
- Added missing changes for ->devdata in some drivers
- Added a 'type' accessor
- Replaced the 'type' to 'id' changes by the 'type' accessor
- Used the 'type' accessor in the drivers
- V2:
- Collected tags
- Added missing changes for ->devdata for the tsens driver
- Renamed thermal_zone_device_get_data() to thermal_zone_priv()
- Added stubs when CONFIG_THERMAL is not set
- Dropped hwmon change where we remove the tz->lock usage

Thank you all for your comments

Cc: "Rafael J. Wysocki" <[email protected]>
Cc: Zhang Rui <[email protected]>
Cc: Len Brown <[email protected]>
Cc: Damien Le Moal <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: NXP Linux Team <[email protected]>
Cc: Jean Delvare <[email protected]>
Cc: Guenter Roeck <[email protected]>
Cc: Jonathan Cameron <[email protected]>
Cc: Lars-Peter Clausen <[email protected]>
Cc: Chen-Yu Tsai <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Samuel Holland <[email protected]>
Cc: Dmitry Torokhov <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Paolo Abeni <[email protected]>
Cc: Ido Schimmel <[email protected]>
Cc: Petr Machata <[email protected]>
Cc: Gregory Greenman <[email protected]>
Cc: Kalle Valo <[email protected]>
Cc: Sebastian Reichel <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Miquel Raynal <[email protected]>
Cc: Daniel Lezcano <[email protected]>
Cc: Amit Kucheria <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Broadcom internal kernel review list <[email protected]>
Cc: Ray Jui <[email protected]>
Cc: Scott Branden <[email protected]>
Cc: Markus Mayer <[email protected]>
Cc: Support Opensource <[email protected]>
Cc: Andy Gross <[email protected]>
Cc: Bjorn Andersson <[email protected]>
Cc: Konrad Dybcio <[email protected]>
Cc: Thara Gopinath <[email protected]>
Cc: "Niklas Söderlund" <[email protected]>
Cc: Heiko Stuebner <[email protected]>
Cc: Bartlomiej Zolnierkiewicz <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Alim Akhtar <[email protected]>
Cc: Orson Zhai <[email protected]>
Cc: Baolin Wang <[email protected]>
Cc: Chunyan Zhang <[email protected]>
Cc: Vasily Khoruzhick <[email protected]>
Cc: Yangtao Li <[email protected]>
Cc: Thierry Reding <[email protected]>
Cc: Jonathan Hunter <[email protected]>
Cc: Talel Shenhar <[email protected]>
Cc: Eduardo Valentin <[email protected]>
Cc: Keerthy <[email protected]>
Cc: Kunihiko Hayashi <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Matthias Brugger <[email protected]>
Cc: AngeloGioacchino Del Regno <[email protected]>
Cc: Stefan Wahren <[email protected]>
Cc: Zheng Yongjun <[email protected]>
Cc: Yang Li <[email protected]>
Cc: Srinivas Pandruvada <[email protected]>
Cc: Daniel Golle <[email protected]>
Cc: Balsam CHIHI <[email protected]>
Cc: Mikko Perttunen <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

Daniel Lezcano (19):
thermal/core: Add a thermal zone 'devdata' accessor
thermal/core: Use the thermal zone 'devdata' accessor in thermal
located drivers
thermal/core: Use the thermal zone 'devdata' accessor in hwmon located
drivers
thermal/core: Use the thermal zone 'devdata' accessor in remaining
drivers
thermal/core: Show a debug message when get_temp() fails
thermal: Remove debug or error messages in get_temp() ops
thermal/hwmon: Do not set no_hwmon before calling
thermal_add_hwmon_sysfs()
thermal/hwmon: Use the right device for devm_thermal_add_hwmon_sysfs()
thermal: Don't use 'device' internal thermal zone structure field
thermal/core: Add thermal_zone_device structure 'type' accessor
thermal/drivers/spear: Don't use tz->device but pdev->dev
thermal: Add a thermal zone id accessor
thermal: Use thermal_zone_device_type() accessor
thermal/drivers/da9062: Don't access the thermal zone device fields
thermal/hwmon: Use the thermal_core.h header
thermal/drivers/tegra: Remove unneeded lock when setting a trip point
thermal/tegra: Do not enable the thermal zone, it is already enabled
thermal/drivers/acerhdf: Make interval setting only at module load
time
thermal/drivers/acerhdf: Remove pointless governor test

drivers/acpi/thermal.c | 18 +++----
drivers/ata/ahci_imx.c | 2 +-
drivers/hwmon/hwmon.c | 4 +-
drivers/hwmon/pmbus/pmbus_core.c | 2 +-
drivers/hwmon/scmi-hwmon.c | 4 +-
drivers/hwmon/scpi-hwmon.c | 2 +-
drivers/iio/adc/sun4i-gpadc-iio.c | 2 +-
drivers/input/touchscreen/sun4i-ts.c | 2 +-
.../ethernet/chelsio/cxgb4/cxgb4_thermal.c | 2 +-
.../ethernet/mellanox/mlxsw/core_thermal.c | 16 +++----
drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 4 +-
drivers/platform/x86/acerhdf.c | 19 ++------
drivers/power/supply/power_supply_core.c | 2 +-
drivers/regulator/max8973-regulator.c | 2 +-
drivers/thermal/amlogic_thermal.c | 4 +-
drivers/thermal/armada_thermal.c | 14 ++----
drivers/thermal/broadcom/bcm2711_thermal.c | 3 +-
drivers/thermal/broadcom/bcm2835_thermal.c | 3 +-
drivers/thermal/broadcom/brcmstb_thermal.c | 8 ++--
drivers/thermal/broadcom/ns-thermal.c | 2 +-
drivers/thermal/broadcom/sr-thermal.c | 2 +-
drivers/thermal/da9062-thermal.c | 13 +++--
drivers/thermal/db8500_thermal.c | 2 +-
drivers/thermal/dove_thermal.c | 7 +--
drivers/thermal/hisi_thermal.c | 5 +-
drivers/thermal/imx8mm_thermal.c | 4 +-
drivers/thermal/imx_sc_thermal.c | 9 ++--
drivers/thermal/imx_thermal.c | 47 +++++--------------
.../intel/int340x_thermal/int3400_thermal.c | 2 +-
.../int340x_thermal/int340x_thermal_zone.c | 4 +-
.../processor_thermal_device_pci.c | 4 +-
drivers/thermal/intel/intel_pch_thermal.c | 2 +-
.../thermal/intel/intel_quark_dts_thermal.c | 6 +--
drivers/thermal/intel/intel_soc_dts_iosf.c | 13 ++---
drivers/thermal/intel/x86_pkg_temp_thermal.c | 4 +-
drivers/thermal/k3_bandgap.c | 4 +-
drivers/thermal/k3_j72xx_bandgap.c | 2 +-
drivers/thermal/kirkwood_thermal.c | 7 +--
drivers/thermal/max77620_thermal.c | 6 +--
drivers/thermal/mediatek/auxadc_thermal.c | 4 +-
drivers/thermal/mediatek/lvts_thermal.c | 10 ++--
drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 6 +--
drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 6 +--
drivers/thermal/qcom/tsens.c | 6 +--
drivers/thermal/qoriq_thermal.c | 4 +-
drivers/thermal/rcar_gen3_thermal.c | 5 +-
drivers/thermal/rcar_thermal.c | 8 +---
drivers/thermal/rockchip_thermal.c | 8 +---
drivers/thermal/rzg2l_thermal.c | 3 +-
drivers/thermal/samsung/exynos_tmu.c | 4 +-
drivers/thermal/spear_thermal.c | 10 ++--
drivers/thermal/sprd_thermal.c | 2 +-
drivers/thermal/st/st_thermal.c | 5 +-
drivers/thermal/st/stm_thermal.c | 4 +-
drivers/thermal/sun8i_thermal.c | 4 +-
drivers/thermal/tegra/soctherm.c | 6 +--
drivers/thermal/tegra/tegra-bpmp-thermal.c | 6 ++-
drivers/thermal/tegra/tegra30-tsensor.c | 31 ++++++------
drivers/thermal/thermal-generic-adc.c | 7 ++-
drivers/thermal/thermal_core.c | 18 +++++++
drivers/thermal/thermal_helpers.c | 3 ++
drivers/thermal/thermal_hwmon.c | 9 ++--
drivers/thermal/thermal_hwmon.h | 4 +-
drivers/thermal/thermal_mmio.c | 2 +-
.../ti-soc-thermal/ti-thermal-common.c | 10 ++--
drivers/thermal/uniphier_thermal.c | 2 +-
include/linux/thermal.h | 19 ++++++++
67 files changed, 217 insertions(+), 247 deletions(-)

--
2.34.1



2023-02-28 11:23:41

by Daniel Lezcano

[permalink] [raw]
Subject: [PATCH v4 04/19] thermal/core: Use the thermal zone 'devdata' accessor in remaining drivers

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 <[email protected]>
Acked-by: Mark Brown <[email protected]>
Reviewed-by: Ido Schimmel <[email protected]> #mlxsw
Acked-by: Gregory Greenman <[email protected]> #iwlwifi
Acked-by: Sebastian Reichel <[email protected]> #power_supply
Acked-by: Damien Le Moal <[email protected]> #ahci
Acked-by: Rafael J. Wysocki <[email protected]>
---
drivers/acpi/thermal.c | 16 ++++++++--------
drivers/ata/ahci_imx.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 +-
9 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 0b4b844f9d4c..392b73b3e269 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -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_priv(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_priv(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_priv(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_priv(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_priv(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_priv(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_priv(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_priv(thermal);
struct acpi_device *dev;
acpi_handle handle;
int i;
diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c
index a950767f7948..e45e91f5e703 100644
--- a/drivers/ata/ahci_imx.c
+++ b/drivers/ata/ahci_imx.c
@@ -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_priv(tz), temp);
}

static ssize_t sata_ahci_show_temp(struct device *dev,
diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
index a6ade70dedf8..a5322550c422 100644
--- a/drivers/iio/adc/sun4i-gpadc-iio.c
+++ b/drivers/iio/adc/sun4i-gpadc-iio.c
@@ -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_priv(tz);
int val, scale, offset;

if (sun4i_gpadc_temp_read(info->indio_dev, &val))
diff --git a/drivers/input/touchscreen/sun4i-ts.c b/drivers/input/touchscreen/sun4i-ts.c
index 73eb8f80be6e..1117fba30020 100644
--- a/drivers/input/touchscreen/sun4i-ts.c
+++ b/drivers/input/touchscreen/sun4i-ts.c
@@ -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_priv(tz), temp);
}

static const struct thermal_zone_device_ops sun4i_ts_tz_ops = {
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c
index 95e1b415ba13..dea9d2907666 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c
@@ -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_priv(tzdev);
u32 param, val;
int ret;

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
index c5240d38c9db..722e4a40afef 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
@@ -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_priv(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_priv(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_priv(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_priv(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_priv(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_priv(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_priv(tzdev);
struct mlxsw_thermal *thermal = tz->parent;
char mtmp_pl[MLXSW_REG_MTMP_LEN];
u16 index;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
index 232c200af38f..354d95222b1b 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
@@ -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_priv(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_priv(device);
struct iwl_mvm_thermal_device *tzone;
int ret;

diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index 7c790c41e2fe..83fd19079d8b 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -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_priv(tzd);
ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_TEMP, &val);
if (ret)
return ret;
diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
index 7e00a45db26a..303426135276 100644
--- a/drivers/regulator/max8973-regulator.c
+++ b/drivers/regulator/max8973-regulator.c
@@ -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_priv(tz);
unsigned int val;
int ret;

--
2.34.1