From patchwork Wed Mar 1 20:14:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 13156436 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D780EC7EE23 for ; Wed, 1 Mar 2023 20:15:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=UL6jyObqEDWPkIExW0RcGcpMNbk7K85iwtzEZPEoxdA=; b=tJoqXvcceetKG+lgS4LpR2eMet ipwT4rzwUIUhee9P7ENl38PQFB40S5JbZ8uJfxNBmzCAfhj3PpL/+CCUtwyqh5hKahi0hSWb7Dl2f KF/2cuVaBofMJeUK89cjlCJjsoQDODpeXNY4sdirwW0nwnadH3sKuQHUY+asKLAdGqyoTgKdZq8+q VpzSpBs/TCEDBLJu0RI2YBKEtDiN1AnaoPwB33t0hREZxtZ4yCRHb3zCILEsMubSqTYQNVqd401lb kIM3P10kJ4h7X6VQkVZ2JHBsqyA0oYnwog8sVCuz2knS+V1YJhnBI2JnN+8BmmNUlP0ST6pyQyxFE jyUCl+5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pXSqv-00HSvy-4F; Wed, 01 Mar 2023 20:15:05 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pXSqq-00HStT-U0 for linux-mediatek@lists.infradead.org; Wed, 01 Mar 2023 20:15:03 +0000 Received: by mail-wm1-x329.google.com with SMTP id l7-20020a05600c1d0700b003eb5e6d906bso195989wms.5 for ; Wed, 01 Mar 2023 12:14:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677701695; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=UL6jyObqEDWPkIExW0RcGcpMNbk7K85iwtzEZPEoxdA=; b=LV3tqRLJ/ej99je4mDW0tARqwSA5pYbVA7Y5HNC+uUOFiOinqVIGYTkRBR9rvtr/Wm 0T/C7PvyEJKxRhUWox5zwepS1dAlTzUaccJWU0FkWphN/S9cu09ltf1pZHqlVMNaepMs VMxJ4UUmDQE98V8fnIwzIHf3gRM3XzVcAJcdQoHR2ESxh9anlXptud7g35Vlj4Bo04gT HDLS9w0DJYFZ9I4jsqlJxAOGteMkYUw+p6ukfEgzoaodyKOq8P1flOX79iwEfIPPlrl/ BB/6FgVweItWFyTL5IETuFFnEVVJinMZa6jip9PEmprLoyb+jaLZe1CnIWZO9Ut63dXp FKsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677701695; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UL6jyObqEDWPkIExW0RcGcpMNbk7K85iwtzEZPEoxdA=; b=PHflNaIY9fyQnyNdj4d+VB3MyL0viUVvWtcXvbaaACazVmcCwqKjABVlqXEg7em0c/ 9CMKO+7sgO6s/NPLuuFKt9b3Bk1f9+T1EIRDQ8bXMDM+FPR/Vs9wl4dIWeOaP+y/3L2B dFq385Qsc86tOwDSoq24vG+JYmtNnCYXdFOBGM6aUImT2yVGwozvwY+qDHH2f10Q4l2a n/eiLqBzcU8fQWUdTyMTz1AKzn0U+An2lzYz9U4SrLw3uue6WHOyhhLLmeyd00IBb96G jHrnnPyHu14RVpvubepRu01wDDW+Q9vfBQ6RQBJzLlSr2cNVuIIbngeKNQKhXOjrFGYs jDng== X-Gm-Message-State: AO0yUKVADMcz6Jol+EPVfmMrwcq77F/1tQaPGhl+qjsal5+nZCCGNC71 NtjCP+d8W1SKir6OoJT22jgGJw== X-Google-Smtp-Source: AK7set+KfD0tst2qDZWSdc/h50S9KF3GhIgTFGhpH1HtZEw4NcDC4rb9Dp0BF3xPtLF+MyJmFYpf8g== X-Received: by 2002:a05:600c:19c7:b0:3dc:40a0:3853 with SMTP id u7-20020a05600c19c700b003dc40a03853mr5873714wmq.11.1677701695517; Wed, 01 Mar 2023 12:14:55 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:6ffe:ce4f:bd31:1e6d]) by smtp.gmail.com with ESMTPSA id x16-20020a1c7c10000000b003e70a7c1b73sm576546wmc.16.2023.03.01.12.14.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Mar 2023 12:14:54 -0800 (PST) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Zhang Rui , Len Brown , Damien Le Moal , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Jean Delvare , Guenter Roeck , Jonathan Cameron , Lars-Peter Clausen , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Dmitry Torokhov , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Ido Schimmel , Petr Machata , Gregory Greenman , Kalle Valo , Sebastian Reichel , Liam Girdwood , Mark Brown , Miquel Raynal , Amit Kucheria , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Markus Mayer , Support Opensource , Andy Gross , Bjorn Andersson , Konrad Dybcio , Thara Gopinath , =?utf-8?q?Niklas_S=C3=B6derlund?= , Heiko Stuebner , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Orson Zhai , Baolin Wang , Chunyan Zhang , Vasily Khoruzhick , Yangtao Li , Thierry Reding , Jonathan Hunter , Talel Shenhar , Eduardo Valentin , Keerthy , Kunihiko Hayashi , Masami Hiramatsu , Matthias Brugger , AngeloGioacchino Del Regno , Stefan Wahren , Zheng Yongjun , Yang Li , Srinivas Pandruvada , Daniel Golle , Balsam CHIHI , Mikko Perttunen , linux-acpi@vger.kernel.org, linux-ide@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-input@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v5 00/18] Self-encapsulate the thermal zone device structure Date: Wed, 1 Mar 2023 21:14:28 +0100 Message-Id: <20230301201446.3713334-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230301_121501_001181_686B7FDE X-CRM114-Status: GOOD ( 26.21 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org 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" Cc: Zhang Rui Cc: Len Brown Cc: Damien Le Moal Cc: Shawn Guo Cc: Sascha Hauer Cc: Pengutronix Kernel Team Cc: Fabio Estevam Cc: NXP Linux Team Cc: Jean Delvare Cc: Guenter Roeck Cc: Jonathan Cameron Cc: Lars-Peter Clausen Cc: Chen-Yu Tsai Cc: Jernej Skrabec Cc: Samuel Holland Cc: Dmitry Torokhov Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Ido Schimmel Cc: Petr Machata Cc: Gregory Greenman Cc: Kalle Valo Cc: Sebastian Reichel Cc: Liam Girdwood Cc: Mark Brown Cc: Miquel Raynal Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Florian Fainelli Cc: Broadcom internal kernel review list Cc: Ray Jui Cc: Scott Branden Cc: Markus Mayer Cc: Support Opensource Cc: Andy Gross Cc: Bjorn Andersson Cc: Konrad Dybcio Cc: Thara Gopinath Cc: "Niklas Söderlund" Cc: Heiko Stuebner Cc: Bartlomiej Zolnierkiewicz Cc: Krzysztof Kozlowski Cc: Alim Akhtar Cc: Orson Zhai Cc: Baolin Wang Cc: Chunyan Zhang Cc: Vasily Khoruzhick Cc: Yangtao Li Cc: Thierry Reding Cc: Jonathan Hunter Cc: Talel Shenhar Cc: Eduardo Valentin Cc: Keerthy Cc: Kunihiko Hayashi Cc: Masami Hiramatsu Cc: Matthias Brugger Cc: AngeloGioacchino Del Regno Cc: Stefan Wahren Cc: Zheng Yongjun Cc: Yang Li Cc: Srinivas Pandruvada Cc: Daniel Golle Cc: Balsam CHIHI Cc: Mikko Perttunen Cc: linux-acpi@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-ide@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-hwmon@vger.kernel.org Cc: linux-iio@vger.kernel.org Cc: linux-sunxi@lists.linux.dev Cc: linux-input@vger.kernel.org Cc: netdev@vger.kernel.org Cc: linux-wireless@vger.kernel.org Cc: linux-pm@vger.kernel.org Cc: linux-rpi-kernel@lists.infradead.org Cc: linux-arm-msm@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org Cc: linux-rockchip@lists.infradead.org Cc: linux-samsung-soc@vger.kernel.org Cc: linux-tegra@vger.kernel.org Cc: linux-omap@vger.kernel.org Cc: linux-mediatek@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(-)