From patchwork Tue Feb 21 18:06:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 5697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp151395wrd; Tue, 21 Feb 2023 10:10:06 -0800 (PST) X-Google-Smtp-Source: AK7set+8ES7VfaQlR0uPafz2sdlTvKd3rqdnW+iwseGYYvPAYypvUv5Ep9fgUe6IJeLeUsi6KuRg X-Received: by 2002:a17:902:d481:b0:19a:b427:230a with SMTP id c1-20020a170902d48100b0019ab427230amr7644403plg.63.1677003005787; Tue, 21 Feb 2023 10:10:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677003005; cv=none; d=google.com; s=arc-20160816; b=gewWhZkmor6yaSNX8qD/in00qkFlTz3wdICBIzF613xvBr25a8rpOcd+02IWcecC/D 0JMtUONAwYmhCJ5AtAj7s/0DBxQpXDhNxpv6/NUvT/gslpEkjVjEaJLFzHNuxdXDkA4k jZhcNLHWGlN+8tFDjueknoXwVxjzrD8gKyVByfKzyVZlhaFIBdRQu9WQpOJw0wgOws2h RRULCFEeYYHOnrziaTlAkrEiS9sACJkujYXL3YOD3HfRbl6EYhmwAoq0OTq87wV7V6rg YfdCezO0MZq/zKae9wQdketbhgJuUAdnhi/dA40Rrm9nlNE5K8FLiPVbJCexFMUCy1kH Ic3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=lfj1mZi2k757H35m25tyUr6uh3LAZ/RgBwbJZ5o+VDw=; b=z2fRMPP8OGrI45lpzTx0ZedBAEk2MajrMkdOO0OqeJfD7GZ/5a88ex812dSio4/blL rR5fj0+4ZMz2uMGV848cyIfcTjgQmEjzUmDuWGc4nQ+SeJWLRmIN9P0Etr8emAhQYhnR 7soemvRfct4+CErH1kLKh/xgrn9drMnjuhSFwG0O30Ea/XASzCtnrjG7AyCjXMcU0fIz NUZm14S+kUffPkRvmWbsuuMP4tkFX/ywvOMfRMc9vc3IHGJdSc9CMDwiDPXDNqHYeg/8 JYcVJQneBxa3otF28xBP8q4/GrMuy/wJQaoUHlL9o7dEK6bDycRVytXX11APpn++B8OB BQzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u5BJZXUa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q9-20020a170902bd8900b001990648edbbsi11464804pls.520.2023.02.21.10.09.52; Tue, 21 Feb 2023 10:10:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u5BJZXUa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231362AbjBUSHa (ORCPT + 99 others); Tue, 21 Feb 2023 13:07:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231473AbjBUSH1 (ORCPT ); Tue, 21 Feb 2023 13:07:27 -0500 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B6F530199 for ; Tue, 21 Feb 2023 10:07:20 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id l2-20020a05600c1d0200b003e1f6dff952so4270190wms.1 for ; Tue, 21 Feb 2023 10:07:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lfj1mZi2k757H35m25tyUr6uh3LAZ/RgBwbJZ5o+VDw=; b=u5BJZXUa9F8UucG23kCvceS4gRHYypGZjUrwN+WfE+iqvaVcZj2YVLk7dfg0R6Idx9 gflLanjVP35J60jBKfCJ+IyQkz0EaB8ruNLiYhhxs7s3a1U2JKpWnPGy+ZHn/LHCKaL7 XE86sPaelerMPxRmSfBtaZJpro0HKrtMQyuleg62C8adFzQPSd1SA4QNugvxeGvLns/+ 2PopsKjrjUEq1GaqquE/DM0csnoQTtYQzrGOXF5zMIHzE9Fa0B3Z022BpjasHagsBRyG XVta5BLfmxNPPmGEHIsdbbo6t5JCwjrF68GY4JncQiT8kBmNrvNzg0xpFCmBb0MXwCn0 Mexw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=lfj1mZi2k757H35m25tyUr6uh3LAZ/RgBwbJZ5o+VDw=; b=MgvIisZrvbpXT20lE4h7aMJ2nT1DecTvWDGOeUj9njjUCPgx5g/ts0djECfMMOv85h w42oMvwqS31nhegx9An2W5Q5tq9jxXAsHRI5HwizVNlqPx0ZICaskvEvOEnOWuMOf/xj oGgWlM+3sDLqGkZYj3K0HKiNCnrAJLGtcamsSG04VGek5OU5oC70Xs70DDl1sBe2QciX 44kbFWJXU39fZX21NJevy3sI/9/O2v3zJj/C0dHYyG+99zArOHxDvX93RhXIZniC6DPB hn8oI5EmXaod49fB58qp/VAd93/6CebHf8q/VXH0REsZEasOQrmdphSFVSEo2R1YBhmR fPSg== X-Gm-Message-State: AO0yUKX21ar+tnoW1geXeUGdqy5snjvNUjsAVxo8hAPZ6Xgar6MER/qO 0mhH+3xWK2JxpCn1XsARcscJyA== X-Received: by 2002:a05:600c:1caa:b0:3e1:f8af:963f with SMTP id k42-20020a05600c1caa00b003e1f8af963fmr5047535wms.3.1677002838300; Tue, 21 Feb 2023 10:07:18 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:1e9:315c:bb40:e382]) by smtp.gmail.com with ESMTPSA id c128-20020a1c3586000000b003e21558ee9dsm5107815wma.2.2023.02.21.10.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 10:07:17 -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 v2 00/17] Self-encapsulate the thermal zone device structure Date: Tue, 21 Feb 2023 19:06:54 +0100 Message-Id: <20230221180710.2781027-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758465103643018820?= X-GMAIL-MSGID: =?utf-8?q?1758465103643018820?= 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 ... rn 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: - V2: - Collected tags - Add mising change 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 (16): thermal/core: Add a thermal zone 'devdata' accessor 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/drivers/spear: Don't use tz->device but pdev->dev thermal: Add a thermal zone id accessor thermal: Do not access 'type' field, use the tz id instead 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 thermal/traces: Replace the thermal zone structure parameter with the field value 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 | 18 +++---- 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 | 2 +- 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/dove_thermal.c | 7 +-- drivers/thermal/gov_fair_share.c | 2 +- drivers/thermal/gov_power_allocator.c | 4 +- drivers/thermal/gov_step_wise.c | 2 +- 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 +++++-------------- drivers/thermal/intel/intel_pch_thermal.c | 2 +- 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 | 9 ++-- drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 6 +-- drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 6 +-- drivers/thermal/qcom/tsens.c | 2 +- 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 | 2 - drivers/thermal/sun8i_thermal.c | 4 +- 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 | 17 ++++++- 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 | 9 ++++ include/trace/events/thermal.h | 24 +++++----- .../trace/events/thermal_power_allocator.h | 12 ++--- 65 files changed, 206 insertions(+), 255 deletions(-)