[PATCH v5 00/18] Self-encapsulate the thermal zone device structure
Daniel Lezcano
daniel.lezcano at linaro.org
Wed Mar 1 12:14:28 PST 2023
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:
- V5:
- Dropped patch 19 : "thermal/tegra: Do not enable ... is already enabled"
- Changed the init sequence of the hw channels on tegra3 to close
the race window
- Collected more tags
- 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" <rafael at kernel.org>
Cc: Zhang Rui <rui.zhang at intel.com>
Cc: Len Brown <lenb at kernel.org>
Cc: Damien Le Moal <damien.lemoal at opensource.wdc.com>
Cc: Shawn Guo <shawnguo at kernel.org>
Cc: Sascha Hauer <s.hauer at pengutronix.de>
Cc: Pengutronix Kernel Team <kernel at pengutronix.de>
Cc: Fabio Estevam <festevam at gmail.com>
Cc: NXP Linux Team <linux-imx at nxp.com>
Cc: Jean Delvare <jdelvare at suse.com>
Cc: Guenter Roeck <linux at roeck-us.net>
Cc: Jonathan Cameron <jic23 at kernel.org>
Cc: Lars-Peter Clausen <lars at metafoo.de>
Cc: Chen-Yu Tsai <wens at csie.org>
Cc: Jernej Skrabec <jernej.skrabec at gmail.com>
Cc: Samuel Holland <samuel at sholland.org>
Cc: Dmitry Torokhov <dmitry.torokhov at gmail.com>
Cc: "David S. Miller" <davem at davemloft.net>
Cc: Eric Dumazet <edumazet at google.com>
Cc: Jakub Kicinski <kuba at kernel.org>
Cc: Paolo Abeni <pabeni at redhat.com>
Cc: Ido Schimmel <idosch at nvidia.com>
Cc: Petr Machata <petrm at nvidia.com>
Cc: Gregory Greenman <gregory.greenman at intel.com>
Cc: Kalle Valo <kvalo at kernel.org>
Cc: Sebastian Reichel <sre at kernel.org>
Cc: Liam Girdwood <lgirdwood at gmail.com>
Cc: Mark Brown <broonie at kernel.org>
Cc: Miquel Raynal <miquel.raynal at bootlin.com>
Cc: Daniel Lezcano <daniel.lezcano at linaro.org>
Cc: Amit Kucheria <amitk at kernel.org>
Cc: Florian Fainelli <f.fainelli at gmail.com>
Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list at broadcom.com>
Cc: Ray Jui <rjui at broadcom.com>
Cc: Scott Branden <sbranden at broadcom.com>
Cc: Markus Mayer <mmayer at broadcom.com>
Cc: Support Opensource <support.opensource at diasemi.com>
Cc: Andy Gross <agross at kernel.org>
Cc: Bjorn Andersson <andersson at kernel.org>
Cc: Konrad Dybcio <konrad.dybcio at linaro.org>
Cc: Thara Gopinath <thara.gopinath at gmail.com>
Cc: "Niklas Söderlund" <niklas.soderlund at ragnatech.se>
Cc: Heiko Stuebner <heiko at sntech.de>
Cc: Bartlomiej Zolnierkiewicz <bzolnier at gmail.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski at linaro.org>
Cc: Alim Akhtar <alim.akhtar at samsung.com>
Cc: Orson Zhai <orsonzhai at gmail.com>
Cc: Baolin Wang <baolin.wang at linux.alibaba.com>
Cc: Chunyan Zhang <zhang.lyra at gmail.com>
Cc: Vasily Khoruzhick <anarsoul at gmail.com>
Cc: Yangtao Li <tiny.windzz at gmail.com>
Cc: Thierry Reding <thierry.reding at gmail.com>
Cc: Jonathan Hunter <jonathanh at nvidia.com>
Cc: Talel Shenhar <talel at amazon.com>
Cc: Eduardo Valentin <edubezval at gmail.com>
Cc: Keerthy <j-keerthy at ti.com>
Cc: Kunihiko Hayashi <hayashi.kunihiko at socionext.com>
Cc: Masami Hiramatsu <mhiramat at kernel.org>
Cc: Matthias Brugger <matthias.bgg at gmail.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno at collabora.com>
Cc: Stefan Wahren <stefan.wahren at i2se.com>
Cc: Zheng Yongjun <zhengyongjun3 at huawei.com>
Cc: Yang Li <yang.lee at linux.alibaba.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada at linux.intel.com>
Cc: Daniel Golle <daniel at makrotopia.org>
Cc: Balsam CHIHI <bchihi at baylibre.com>
Cc: Mikko Perttunen <mperttunen at nvidia.com>
Cc: linux-acpi at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Cc: linux-ide at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-hwmon at vger.kernel.org
Cc: linux-iio at vger.kernel.org
Cc: linux-sunxi at lists.linux.dev
Cc: linux-input at vger.kernel.org
Cc: netdev at vger.kernel.org
Cc: linux-wireless at vger.kernel.org
Cc: linux-pm at vger.kernel.org
Cc: linux-rpi-kernel at lists.infradead.org
Cc: linux-arm-msm at vger.kernel.org
Cc: linux-renesas-soc at vger.kernel.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-tegra at vger.kernel.org
Cc: linux-omap at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Daniel Lezcano (18):
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/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, 218 insertions(+), 246 deletions(-)
--
2.34.1
More information about the Linux-mediatek
mailing list