From patchwork Tue Apr 18 08:30:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 675538 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E494BC77B71 for ; Tue, 18 Apr 2023 08:31:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231295AbjDRIbP (ORCPT ); Tue, 18 Apr 2023 04:31:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230499AbjDRIbN (ORCPT ); Tue, 18 Apr 2023 04:31:13 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FFAD19A5 for ; Tue, 18 Apr 2023 01:31:09 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id ay3-20020a05600c1e0300b003f17289710aso3032729wmb.5 for ; Tue, 18 Apr 2023 01:31:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681806667; x=1684398667; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Pcig8VWar3G5dNsmApdG18M9MAPyuIPGXofGInx53Fg=; b=g2S5d/HeWPAdNYl1qFPhx4O40BSCwl4YAIagip7ReJgv5xvJxihhXrqU30Om/BdWz7 JpwAAgQEmgcUJwQ2Di7nd4DsQisg2IwZKnjKKEpo9iBw05gsmZx3b3Ul+gf0gcRAAWD+ hllfvyXiUam1WzRcE03xIl1r+BgeZgW3Hmz7Vyre+84wYFggP9KOs76KuJhu7RDQzjUK XFs7NRm3pTCg4QaMC/pzunrEGHDUHtCZd52iYTnOFo8woc5oiNuRsYVrc+7LR/IXzb9e CIZWpLxncyrrwn+lMZy6rhU2N7xUZLltFBzCgBwlwDFqnTRHj1pmfU4CQ+WyRmSJv9Dx VZ1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681806667; x=1684398667; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Pcig8VWar3G5dNsmApdG18M9MAPyuIPGXofGInx53Fg=; b=gVgC6hGM2Q68z4alyZANlrtWKar4aj/xHXuLwY10DGaFKLUX3QgmSHurUuS6387FFq uQ+b9k8ouycxZjl+nJYVU77bOfGXGHH5mGzZIogeeVeQNyc38C5pfmSfi5uLl1x1LIEk p0OM2DN9deaNVcLayAjUKv71wUoUZ5kkei1o/SunByLgVgc63NhVMKw5eyFH2QJxhbhl sADNoLbchyj1PeCAWzHtLIS2BoIirPKdwAWbtwXtH8pb+kQs7HOQ2UruHQZ6ShWFCmCy 5y0GMhuvY+b0INoqwYM56z9rMftvZVCTVycx6fDapSlUxj39KpD4+0CC8Cbk19jWvWXA 8oDA== X-Gm-Message-State: AAQBX9ec+80rtQmzq9dbN6ee7VkXxujSIYnLpDv2qTgTJHoh0TwzDXod cmPOR4YWlrahlN3Wwz8RfSaSqA== X-Google-Smtp-Source: AKy350ZrzCLPJOpvmcPDApu6vy1EK6sWJSgztBmGgVwAYOxV/ZvwxvZ0PaW8EsaEU1vbzMW4btLIsQ== X-Received: by 2002:a05:600c:253:b0:3f1:733d:f3c0 with SMTP id 19-20020a05600c025300b003f1733df3c0mr4622805wmj.14.1681806667613; Tue, 18 Apr 2023 01:31:07 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:c25b:18d5:815a:e12b]) by smtp.gmail.com with ESMTPSA id l37-20020a05600c1d2500b003f1738d0d13sm1805978wms.1.2023.04.18.01.31.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 01:31:07 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, thierry.reding@gmail.com Subject: [PATCH v1 1/3] thermal/core: Hardening the self-encapsulation Date: Tue, 18 Apr 2023 10:30:53 +0200 Message-Id: <20230418083055.3611721-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230418083055.3611721-1-daniel.lezcano@linaro.org> References: <20230418083055.3611721-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The thermal private header has leaked all around the drivers which interacted with the core internals. The thermal zone structure which was part of the exported header led also to a leakage of the fields into the different drivers, making very difficult to improve the core code without having to change the drivers. Now we fixed how the thermal drivers were interacting with the thermal zones (actually fixed how they should not interact). The thermal zone structure has been moved to the private thermal core header. This header has been removed from the different drivers and must belong to the core code only. In order to prevent this private header to be included again in the drivers, make explicit only the core code can include this header by defining a THERMAL_CORE_SUBSYS macro. The private header will contain a check against this macro. The Tegra SoCtherm driver needs to access thermal_core.h to have the get_thermal_instance() function definition. It is the only one remaining driver which need to access the thermal_core.h header, so the check will emit a warning at compilation time. Thierry Reding is reworking the driver to get rid of this function [1] and thus when the changes will be merged, the compilation warning will be converted to a compilation error, closing definitively the door to the drivers willing to play with the thermal zone device internals. [1] https://lore.kernel.org/all/20230414125721.1043589-1-thierry.reding@gmail.com/ Cc: Thierry Reding Signed-off-by: Daniel Lezcano --- drivers/thermal/gov_bang_bang.c | 1 + drivers/thermal/gov_fair_share.c | 1 + drivers/thermal/gov_power_allocator.c | 1 + drivers/thermal/gov_step_wise.c | 1 + drivers/thermal/gov_user_space.c | 1 + drivers/thermal/thermal_acpi.c | 1 + drivers/thermal/thermal_core.c | 1 + drivers/thermal/thermal_core.h | 4 ++++ drivers/thermal/thermal_helpers.c | 1 + drivers/thermal/thermal_hwmon.c | 1 + drivers/thermal/thermal_netlink.c | 1 + drivers/thermal/thermal_of.c | 1 + drivers/thermal/thermal_sysfs.c | 1 + drivers/thermal/thermal_trip.c | 1 + 14 files changed, 17 insertions(+) diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_bang.c index 1b121066521f..752c627075ba 100644 --- a/drivers/thermal/gov_bang_bang.c +++ b/drivers/thermal/gov_bang_bang.c @@ -11,6 +11,7 @@ #include +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" static int thermal_zone_trip_update(struct thermal_zone_device *tz, int trip_id) diff --git a/drivers/thermal/gov_fair_share.c b/drivers/thermal/gov_fair_share.c index 03c2daeb6ee8..108cb5074594 100644 --- a/drivers/thermal/gov_fair_share.c +++ b/drivers/thermal/gov_fair_share.c @@ -13,6 +13,7 @@ #include #include "thermal_trace.h" +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" /** diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index 8642f1096b91..d1c6ad92e5b4 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -14,6 +14,7 @@ #define CREATE_TRACE_POINTS #include "thermal_trace_ipa.h" +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" #define INVALID_TRIP -1 diff --git a/drivers/thermal/gov_step_wise.c b/drivers/thermal/gov_step_wise.c index 3d3067804df2..bfc9adf882d6 100644 --- a/drivers/thermal/gov_step_wise.c +++ b/drivers/thermal/gov_step_wise.c @@ -14,6 +14,7 @@ #include #include "thermal_trace.h" +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" /* diff --git a/drivers/thermal/gov_user_space.c b/drivers/thermal/gov_user_space.c index 8bc1c22aaf03..8883c9ca930f 100644 --- a/drivers/thermal/gov_user_space.c +++ b/drivers/thermal/gov_user_space.c @@ -13,6 +13,7 @@ #include #include +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" static int user_space_bind(struct thermal_zone_device *tz) diff --git a/drivers/thermal/thermal_acpi.c b/drivers/thermal/thermal_acpi.c index 0e5698818f69..556c9f0cc40d 100644 --- a/drivers/thermal/thermal_acpi.c +++ b/drivers/thermal/thermal_acpi.c @@ -9,6 +9,7 @@ #include #include +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" /* diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 842f678c1c3e..6bca97e27d59 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -24,6 +24,7 @@ #define CREATE_TRACE_POINTS #include "thermal_trace.h" +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" #include "thermal_hwmon.h" diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 5eacbcd10a40..feb02c48beba 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -14,6 +14,10 @@ #include "thermal_netlink.h" +#ifndef THERMAL_CORE_SUBSYS +#warning This header can only be included by the thermal core code +#endif + /* Default Thermal Governor */ #if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE) #define DEFAULT_THERMAL_GOVERNOR "step_wise" diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c index cfba0965a22d..164c4627949e 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -19,6 +19,7 @@ #include #include +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" #include "thermal_trace.h" diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c index fbe55509e307..3401258e55c6 100644 --- a/drivers/thermal/thermal_hwmon.c +++ b/drivers/thermal/thermal_hwmon.c @@ -17,6 +17,7 @@ #include #include "thermal_hwmon.h" +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" /* hwmon sys I/F */ diff --git a/drivers/thermal/thermal_netlink.c b/drivers/thermal/thermal_netlink.c index 08bc46c3ec7b..f3ac6432bf5f 100644 --- a/drivers/thermal/thermal_netlink.c +++ b/drivers/thermal/thermal_netlink.c @@ -11,6 +11,7 @@ #include #include +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" static const struct genl_multicast_group thermal_genl_mcgrps[] = { diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 33c5be929ad5..40faabb59183 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -17,6 +17,7 @@ #include #include +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" /*** functions parsing device tree nodes ***/ diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index 7ad1e40397e3..7fb24d1e2fad 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -19,6 +19,7 @@ #include #include +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" /* sys I/F for thermal zone */ diff --git a/drivers/thermal/thermal_trip.c b/drivers/thermal/thermal_trip.c index e1539e1d96e6..a12980a8bac5 100644 --- a/drivers/thermal/thermal_trip.c +++ b/drivers/thermal/thermal_trip.c @@ -7,6 +7,7 @@ * * Thermal trips handling */ +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" static const char * const trip_types[] = { From patchwork Tue Apr 18 08:30:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 674940 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EB7FC77B76 for ; Tue, 18 Apr 2023 08:31:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231222AbjDRIbQ (ORCPT ); Tue, 18 Apr 2023 04:31:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231216AbjDRIbO (ORCPT ); Tue, 18 Apr 2023 04:31:14 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CCC144AD for ; Tue, 18 Apr 2023 01:31:10 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-2f917585b26so1732333f8f.0 for ; Tue, 18 Apr 2023 01:31:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681806668; x=1684398668; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R4A6OpstqdNieOolGqqfs3dJZeBWURomNlQRfM9+VC0=; b=Cy3Wr2WKfWULNqyX0qg6/HCM9vISkkbv8/UnNAgM8nqb24jM9DjY9bODwDrQLg5+jX PlIxkG23AEggmzoD2NqnHcqPtYsyhUIJ19K4eTQGQw7ZaLLHGWuJWr5o8EP1siTvvGBv VIvMrVA710J+ij1OpVlBRc5hUWszpZ7ccaL2KiRVTmvTRAf93K8jnfQPA6S9gx5qybaL vXYr4xxX17TTvOkzAKAYQ6h8N8+G9WGYjWoNMbibrZA/OkmZxerTSBwT9KTaR4ytXd3s q3ILtS5kYmLWpGZ+91qBCzZTvOwvarbwNmdLjwA9/PWKDfvKU4ayWwTuUI/08Ux6pc/v w4cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681806668; x=1684398668; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R4A6OpstqdNieOolGqqfs3dJZeBWURomNlQRfM9+VC0=; b=fqmksiZbPemTlBWgyxjrOyR8Ii69p7/tOkTb4txIrGCAthfpozQ6SeXvpu+kUGSYDI Qgfdlh96MfhH5TAiSXdiNjsI6I6ZLCWVWkBhT0XfUiIyFsMTuYnmux+KRRpCN7QjAwSn /oTeSSiCpfk8b4zWQu37f+9g2YMa+GnFELuLCNL8GV2VvFpLhFqkvpOGkosSFi8tmAK4 yr5E+Z7Vl3u/4bZIFz4qQ0Hno1UpIinq66haRcaJLq2BjZajP0hp3Iwkn0N3tQCZjNwQ rNztOEQrCklyCJ9Hh57MfWFUBJtNV9D818kRyTDjFUirkqcDxmMiI/pmNiM0MgriC3r6 OCjg== X-Gm-Message-State: AAQBX9cr7ajfz21rMwrSxgL2qICVlf0ndrhSXSjMbUoO/wl07SOUa5yy A2DtZGCCjS+RvYO7JWCpbrxqew== X-Google-Smtp-Source: AKy350Zpzk7u1ICgOITr28oZA+/Uu3ha+VSToHCZOlLguvgp7G+l7PyN574H7c77blf5Ikgf5SKO/A== X-Received: by 2002:adf:fc90:0:b0:2ef:b4a9:202f with SMTP id g16-20020adffc90000000b002efb4a9202fmr1293915wrr.69.1681806668432; Tue, 18 Apr 2023 01:31:08 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:c25b:18d5:815a:e12b]) by smtp.gmail.com with ESMTPSA id l37-20020a05600c1d2500b003f1738d0d13sm1805978wms.1.2023.04.18.01.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 01:31:07 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, thierry.reding@gmail.com Subject: [PATCH v1 2/3] thermal/core: Reorder the headers inclusion Date: Tue, 18 Apr 2023 10:30:54 +0200 Message-Id: <20230418083055.3611721-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230418083055.3611721-1-daniel.lezcano@linaro.org> References: <20230418083055.3611721-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The next changes will move the thermal device structure inside the thermal core code. Consequently, the traces must be included after thermal_core.h as this one contains the thermal zone device structure definition the traces need. Reorder the inclusions. Signed-off-by: Daniel Lezcano --- drivers/thermal/gov_power_allocator.c | 6 +++--- drivers/thermal/thermal_core.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index d1c6ad92e5b4..6056ed15460b 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -11,12 +11,12 @@ #include #include -#define CREATE_TRACE_POINTS -#include "thermal_trace_ipa.h" - #define THERMAL_CORE_SUBSYS #include "thermal_core.h" +#define CREATE_TRACE_POINTS +#include "thermal_trace_ipa.h" + #define INVALID_TRIP -1 #define FRAC_BITS 10 diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 6bca97e27d59..afcd4197babd 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -21,13 +21,13 @@ #include #include -#define CREATE_TRACE_POINTS -#include "thermal_trace.h" - #define THERMAL_CORE_SUBSYS #include "thermal_core.h" #include "thermal_hwmon.h" +#define CREATE_TRACE_POINTS +#include "thermal_trace.h" + static DEFINE_IDA(thermal_tz_ida); static DEFINE_IDA(thermal_cdev_ida); From patchwork Tue Apr 18 08:30:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 675537 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3857C77B75 for ; Tue, 18 Apr 2023 08:31:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231302AbjDRIbS (ORCPT ); Tue, 18 Apr 2023 04:31:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231334AbjDRIbQ (ORCPT ); Tue, 18 Apr 2023 04:31:16 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB52C4EE9 for ; Tue, 18 Apr 2023 01:31:10 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id o29-20020a05600c511d00b003f1739de43cso2662768wms.4 for ; Tue, 18 Apr 2023 01:31:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681806669; x=1684398669; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Dxd4s2C5sMKfjUufqyKegiNsjshtUcEOvXHcUf8vktQ=; b=rQhdsjfVrvCeOAYpxDOsF1But51g+urZZc1NTbbOXKX45dY9SiXOio7uIAoVH5f7En /83VoIYgx1Zn+JyiYGBkkSJYbXLfzAeCnSngc1wLwN7TioZ4Da0TloLC6qwqTucHwUWq 4BgXQF57/fROxpulXp968tI+JAGoX3NJg9TVjtTAb2bzxOGXS/RRyevHcAAoXOstq7iZ eZTK6K5iMrhwDBNw+/G7gr9kfjC1x3prD1yNsrMpDIjZ03MANPVeHdEqwYkJcQBKPfmr kgfkLZ7gqQ8w/b+OpLrVJF+tf+SwrDA337b+pMZOOw7oT0uSAmkLk/RTZhq0hPzLVZ1w MOQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681806669; x=1684398669; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dxd4s2C5sMKfjUufqyKegiNsjshtUcEOvXHcUf8vktQ=; b=Lp+DaMArMuGjmzC+0FWV3FAZJsi1MjbRNazHThfwYtBiW8kk24nbRGqQyS3BkUvT3f +Drhe6RAjItUbXZ8z2OBT0hskhZ/RHEDPJjW32sFhL04b020GK0tsTAKeZvmxUCBp1pF 8oHCnb8ozpQCuVyDRiQzg/XTnn9x8f4lg3e41ij+Z40jTYq3RH6YaOymDRSur3WktbbA XMg55bO531JcNKW4zmEIbRLKe4+qdvb59Ggiw1mqJg4sM5A/g/K0Y8OBCjC0GNVSJR4k ALwSyTaj6l15Z4ztu5QPBOO3FuF46XYd4/RWyjYQCyDbcbGP9Gq2WmjaNGM232CsfU5U yBdA== X-Gm-Message-State: AAQBX9fWVpNsIB9juRvkwWDiDyFp5mDR4o8ECJYRQ7tRLIcXfbjpb4rZ gKTXfXOIT4C4jDb9dgYJp6slTg== X-Google-Smtp-Source: AKy350aD6rwNgLE5Xe+x6fNCr5L+7fPbeEjOgKxDuQpJX130OXB24T3V8Ezo7RNwTZ3vxg2nxpjAUw== X-Received: by 2002:a1c:790f:0:b0:3f1:72e3:576b with SMTP id l15-20020a1c790f000000b003f172e3576bmr5701930wme.26.1681806669232; Tue, 18 Apr 2023 01:31:09 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:c25b:18d5:815a:e12b]) by smtp.gmail.com with ESMTPSA id l37-20020a05600c1d2500b003f1738d0d13sm1805978wms.1.2023.04.18.01.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 01:31:08 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, thierry.reding@gmail.com Subject: [PATCH v1 3/3] thermal/core: Move the thermal zone structure to the private core header Date: Tue, 18 Apr 2023 10:30:55 +0200 Message-Id: <20230418083055.3611721-4-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230418083055.3611721-1-daniel.lezcano@linaro.org> References: <20230418083055.3611721-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The code in the different drivers have been sanitized and they no longer access the thermal zone structure internals. This one is just a pointer passed around to the thermal core code as a handler. Move the structure definition to the private core code header to self-encapsulate the core code. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.h | 75 ++++++++++++++++++++++++++++++++++ include/linux/thermal.h | 75 ---------------------------------- 2 files changed, 75 insertions(+), 75 deletions(-) diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index feb02c48beba..e55d1eaa8bdb 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -18,6 +18,81 @@ #warning This header can only be included by the thermal core code #endif +/** + * struct thermal_zone_device - structure for a thermal zone + * @id: unique id number for each thermal zone + * @type: the thermal zone device type + * @device: &struct device for this thermal zone + * @trip_temp_attrs: attributes for trip points for sysfs: trip temperature + * @trip_type_attrs: attributes for trip points for sysfs: trip type + * @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis + * @mode: current mode of this thermal zone + * @devdata: private pointer for device private data + * @trips: an array of struct thermal_trip + * @num_trips: number of trip points the thermal zone supports + * @trips_disabled; bitmap for disabled trips + * @passive_delay_jiffies: number of jiffies to wait between polls when + * performing passive cooling. + * @polling_delay_jiffies: number of jiffies to wait between polls when + * checking whether trip points have been crossed (0 for + * interrupt driven systems) + * @temperature: current temperature. This is only for core code, + * drivers should use thermal_zone_get_temp() to get the + * current temperature + * @last_temperature: previous temperature read + * @emul_temperature: emulated temperature when using CONFIG_THERMAL_EMULATION + * @passive: 1 if you've crossed a passive trip point, 0 otherwise. + * @prev_low_trip: the low current temperature if you've crossed a passive + trip point. + * @prev_high_trip: the above current temperature if you've crossed a + passive trip point. + * @need_update: if equals 1, thermal_zone_device_update needs to be invoked. + * @ops: operations this &thermal_zone_device supports + * @tzp: thermal zone parameters + * @governor: pointer to the governor for this thermal zone + * @governor_data: private pointer for governor data + * @thermal_instances: list of &struct thermal_instance of this thermal zone + * @ida: &struct ida to generate unique id for this zone's cooling + * devices + * @lock: lock to protect thermal_instances list + * @node: node in thermal_tz_list (in thermal_core.c) + * @poll_queue: delayed work for polling + * @notify_event: Last notification event + */ +struct thermal_zone_device { + int id; + char type[THERMAL_NAME_LENGTH]; + struct device device; + struct attribute_group trips_attribute_group; + struct thermal_attr *trip_temp_attrs; + struct thermal_attr *trip_type_attrs; + struct thermal_attr *trip_hyst_attrs; + enum thermal_device_mode mode; + void *devdata; + struct thermal_trip *trips; + int num_trips; + unsigned long trips_disabled; /* bitmap for disabled trips */ + unsigned long passive_delay_jiffies; + unsigned long polling_delay_jiffies; + int temperature; + int last_temperature; + int emul_temperature; + int passive; + int prev_low_trip; + int prev_high_trip; + atomic_t need_update; + struct thermal_zone_device_ops *ops; + struct thermal_zone_params *tzp; + struct thermal_governor *governor; + void *governor_data; + struct list_head thermal_instances; + struct ida ida; + struct mutex lock; + struct list_head node; + struct delayed_work poll_queue; + enum thermal_notify_event notify_event; +}; + /* Default Thermal Governor */ #if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE) #define DEFAULT_THERMAL_GOVERNOR "step_wise" diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 87837094d549..3e8bedb21755 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -112,81 +112,6 @@ struct thermal_cooling_device { struct list_head node; }; -/** - * struct thermal_zone_device - structure for a thermal zone - * @id: unique id number for each thermal zone - * @type: the thermal zone device type - * @device: &struct device for this thermal zone - * @trip_temp_attrs: attributes for trip points for sysfs: trip temperature - * @trip_type_attrs: attributes for trip points for sysfs: trip type - * @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis - * @mode: current mode of this thermal zone - * @devdata: private pointer for device private data - * @trips: an array of struct thermal_trip - * @num_trips: number of trip points the thermal zone supports - * @trips_disabled; bitmap for disabled trips - * @passive_delay_jiffies: number of jiffies to wait between polls when - * performing passive cooling. - * @polling_delay_jiffies: number of jiffies to wait between polls when - * checking whether trip points have been crossed (0 for - * interrupt driven systems) - * @temperature: current temperature. This is only for core code, - * drivers should use thermal_zone_get_temp() to get the - * current temperature - * @last_temperature: previous temperature read - * @emul_temperature: emulated temperature when using CONFIG_THERMAL_EMULATION - * @passive: 1 if you've crossed a passive trip point, 0 otherwise. - * @prev_low_trip: the low current temperature if you've crossed a passive - trip point. - * @prev_high_trip: the above current temperature if you've crossed a - passive trip point. - * @need_update: if equals 1, thermal_zone_device_update needs to be invoked. - * @ops: operations this &thermal_zone_device supports - * @tzp: thermal zone parameters - * @governor: pointer to the governor for this thermal zone - * @governor_data: private pointer for governor data - * @thermal_instances: list of &struct thermal_instance of this thermal zone - * @ida: &struct ida to generate unique id for this zone's cooling - * devices - * @lock: lock to protect thermal_instances list - * @node: node in thermal_tz_list (in thermal_core.c) - * @poll_queue: delayed work for polling - * @notify_event: Last notification event - */ -struct thermal_zone_device { - int id; - char type[THERMAL_NAME_LENGTH]; - struct device device; - struct attribute_group trips_attribute_group; - struct thermal_attr *trip_temp_attrs; - struct thermal_attr *trip_type_attrs; - struct thermal_attr *trip_hyst_attrs; - enum thermal_device_mode mode; - void *devdata; - struct thermal_trip *trips; - int num_trips; - unsigned long trips_disabled; /* bitmap for disabled trips */ - unsigned long passive_delay_jiffies; - unsigned long polling_delay_jiffies; - int temperature; - int last_temperature; - int emul_temperature; - int passive; - int prev_low_trip; - int prev_high_trip; - atomic_t need_update; - struct thermal_zone_device_ops *ops; - struct thermal_zone_params *tzp; - struct thermal_governor *governor; - void *governor_data; - struct list_head thermal_instances; - struct ida ida; - struct mutex lock; - struct list_head node; - struct delayed_work poll_queue; - enum thermal_notify_event notify_event; -}; - /** * struct thermal_governor - structure that holds thermal governor information * @name: name of the governor