Re: [PATCH v4 02/19] thermal/core: Use the thermal zone 'devdata' accessor in thermal located drivers

Gole, Dhruva
2023-03-01T16:22:37Z

On 2/28/2023 4:52 PM, Daniel Lezcano wrote:
> 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
> ---
> drivers/thermal/amlogic_thermal.c | 2 +-
> drivers/thermal/armada_thermal.c | 4 ++--
> drivers/thermal/broadcom/bcm2711_thermal.c | 2 +-
> drivers/thermal/broadcom/bcm2835_thermal.c | 2 +-
> drivers/thermal/broadcom/brcmstb_thermal.c | 4 ++--
> drivers/thermal/broadcom/ns-thermal.c | 2 +-
> drivers/thermal/broadcom/sr-thermal.c | 2 +-
> drivers/thermal/da9062-thermal.c | 2 +-
> drivers/thermal/db8500_thermal.c | 2 +-
> drivers/thermal/dove_thermal.c | 2 +-
> drivers/thermal/hisi_thermal.c | 2 +-
> drivers/thermal/imx8mm_thermal.c | 2 +-
> drivers/thermal/imx_sc_thermal.c | 2 +-
> drivers/thermal/imx_thermal.c | 6 +++---
> .../thermal/intel/int340x_thermal/int3400_thermal.c | 2 +-
> .../intel/int340x_thermal/int340x_thermal_zone.c | 4 ++--
> .../int340x_thermal/processor_thermal_device_pci.c | 4 ++--
> drivers/thermal/intel/intel_pch_thermal.c | 2 +-
> drivers/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 | 2 +-
> drivers/thermal/k3_j72xx_bandgap.c | 2 +-
> [...]
>
> diff --git a/drivers/thermal/k3_bandgap.c b/drivers/thermal/k3_bandgap.c
> index 22c9bcb899c3..b5cd2c85e0c3 100644
> --- a/drivers/thermal/k3_bandgap.c
> +++ b/drivers/thermal/k3_bandgap.c
> @@ -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);

Reviewed-by: Dhruva Gole <d-gole@ti.com>

> int ret = 0;
>
> ret = k3_bgp_read_temp(data, temp);
> diff --git a/drivers/thermal/k3_j72xx_bandgap.c b/drivers/thermal/k3_j72xx_bandgap.c
> index 031ea1091909..5be1f09eeb2c 100644
> --- a/drivers/thermal/k3_j72xx_bandgap.c
> +++ b/drivers/thermal/k3_j72xx_bandgap.c
> @@ -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 = {
> diff --git a/drivers/thermal/kirkwood_thermal.c b/drivers/thermal/kirkwood_thermal.c
> index bec7ec20e79d..92b3ce426b9d 100644
> --- a/drivers/thermal/kirkwood_thermal.c
> +++ b/drivers/thermal/kirkwood_thermal.c
> @@ -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);
>
> [...]

--
Regards,
Dhruva Gole <d-gole@ti.com>