From nobody Sat Feb 7 19:41:16 2026 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 84556C001E0 for ; Fri, 7 Jul 2023 20:38:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232322AbjGGUiB (ORCPT ); Fri, 7 Jul 2023 16:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232282AbjGGUhy (ORCPT ); Fri, 7 Jul 2023 16:37:54 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1B241FEB for ; Fri, 7 Jul 2023 13:37:52 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-313f1085ac2so2332332f8f.1 for ; Fri, 07 Jul 2023 13:37:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688762271; x=1691354271; 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=yUcFRaFpRqekh1XutoF5FSJVV/l/MywjnadXba/M7Ls=; b=N6kGPoHEYocK0GLv1K4DMPcmhTN9rJUEJYHQDBpPnfUl7IyxvK6/Ta+cmCpT9vbujb T8ySrUdHyECVCmx17VBkSNP2xyH84fTiKPMpFn/JRSzACYvPlQnUpN3eEvAWTuEek4NE Z3lzcFeqAnlPOyN6Or0QhPdZaxYXvknAIfZUBMVtEqMYAt/Qs6sRoRCd+XYxvpTa97Tq SWA4fCtMO3gUqH5BCbR1BpSspfdsaT7hzX57Lf8ZTNmZJjw+T9GNI/fcPgmMCsJNoeTM K0VryCKVNLk0E6BTgEOa5sU7t3oDtI/hGZOfeLzup+iHj1SR3LVw/uUfP3dgODdRdBrB g2vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688762271; x=1691354271; 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=yUcFRaFpRqekh1XutoF5FSJVV/l/MywjnadXba/M7Ls=; b=gFyo2TlzNs8gW1Sv71+RdUExk5y2VIbR+EK1bGw/kvXMTEwxiU8x6e0eOWP93D6+BS 74d+vENRs6RJsY5A4sjyS/1OCeTHbmyOrKRR98UuqDKw4h0pam7KEEtuD8XRNImYHw3B vcmL2UAk2QAyrR/kFxDbN282jza6QKYdLb2yGXwpbj27l77ibYddvtNlwnR7bhU5jn7C aMaLoMr7F5qY+Xg/Bo/qagADOoTi+85mY2Wz7acqzepOCtbXO/3fvF7assNNxV0RJ2cg iQFctsF1eNRgVK0HP2abNpZPoaXnG1ovA53FqYk6cwmUSaFbcuIej28dWMHpl30zSuzg M1Ug== X-Gm-Message-State: ABy/qLZoITu5JADOYUgrzbAFdHzWf5A5CVGdCW3s0JKYhgI7sBAn8ecd LaqKZ64RQqkENBeWfymY6uJOyQ== X-Google-Smtp-Source: APBJJlGUPPMDg0BAP/ewPfJ5t0eKHzjC40OAub6ONAm9mN5qz2r2Pjv2SffMR8kpntYaWX+Ue7TP8A== X-Received: by 2002:adf:ee03:0:b0:314:15b7:1fb4 with SMTP id y3-20020adfee03000000b0031415b71fb4mr4868023wrn.52.1688762271183; Fri, 07 Jul 2023 13:37:51 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id i4-20020adfefc4000000b003143be36d99sm5260674wrp.58.2023.07.07.13.37.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 13:37:50 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, thierry.reding@gmail.com, linux-kernel@vger.kernel.org, srinivas.pandruvada@linux.intel.com, Amit Kucheria , Zhang Rui , Lukasz Luba Subject: [PATCH v2 1/4] thermal/core: Hardening the self-encapsulation Date: Fri, 7 Jul 2023 22:37:28 +0200 Message-Id: <20230707203731.848188-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230707203731.848188-1-daniel.lezcano@linaro.org> References: <20230707203731.848188-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. No functional changes intended. [1] https://lore.kernel.org/all/20230414125721.1043589-1-thierry.reding@gma= il.com/ Cc: Thierry Reding Acked-by: Rafael J. Wysocki 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_ban= g.c index 1b121066521f..752c627075ba 100644 --- a/drivers/thermal/gov_bang_bang.c +++ b/drivers/thermal/gov_bang_bang.c @@ -11,6 +11,7 @@ =20 #include =20 +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" =20 static int thermal_zone_trip_update(struct thermal_zone_device *tz, int tr= ip_id) diff --git a/drivers/thermal/gov_fair_share.c b/drivers/thermal/gov_fair_sh= are.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" =20 +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" =20 /** diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_po= wer_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" =20 +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" =20 #define INVALID_TRIP -1 diff --git a/drivers/thermal/gov_step_wise.c b/drivers/thermal/gov_step_wis= e.c index 1050fb4d94c2..1c844004afe5 100644 --- a/drivers/thermal/gov_step_wise.c +++ b/drivers/thermal/gov_step_wise.c @@ -14,6 +14,7 @@ #include #include "thermal_trace.h" =20 +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" =20 /* diff --git a/drivers/thermal/gov_user_space.c b/drivers/thermal/gov_user_sp= ace.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 =20 +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" =20 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 =20 +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" =20 /* 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" =20 +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" #include "thermal_hwmon.h" =20 diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 17c1bbed734d..2f58eb9854ff 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -14,6 +14,10 @@ =20 #include "thermal_netlink.h" =20 +#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_he= lpers.c index cfba0965a22d..164c4627949e 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -19,6 +19,7 @@ #include #include =20 +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" #include "thermal_trace.h" =20 diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmo= n.c index c3ae44659b81..ba2ae5be0c23 100644 --- a/drivers/thermal/thermal_hwmon.c +++ b/drivers/thermal/thermal_hwmon.c @@ -17,6 +17,7 @@ #include =20 #include "thermal_hwmon.h" +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" =20 /* hwmon sys I/F */ diff --git a/drivers/thermal/thermal_netlink.c b/drivers/thermal/thermal_ne= tlink.c index 08bc46c3ec7b..f3ac6432bf5f 100644 --- a/drivers/thermal/thermal_netlink.c +++ b/drivers/thermal/thermal_netlink.c @@ -11,6 +11,7 @@ #include #include =20 +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" =20 static const struct genl_multicast_group thermal_genl_mcgrps[] =3D { diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 6fb14e521197..0f2aca2d1dea 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -17,6 +17,7 @@ #include #include =20 +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" =20 /*** functions parsing device tree nodes ***/ diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysf= s.c index 6c20c9f90a05..ccda2579ae82 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -19,6 +19,7 @@ #include #include =20 +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" =20 /* sys I/F for thermal zone */ diff --git a/drivers/thermal/thermal_trip.c b/drivers/thermal/thermal_trip.c index 907f3a4d7bc8..61d927c35776 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" =20 int __for_each_thermal_trip(struct thermal_zone_device *tz, --=20 2.34.1 From nobody Sat Feb 7 19:41:16 2026 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 EB313EB64D9 for ; Fri, 7 Jul 2023 20:38:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232566AbjGGUiF (ORCPT ); Fri, 7 Jul 2023 16:38:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232396AbjGGUhy (ORCPT ); Fri, 7 Jul 2023 16:37:54 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81FD61994 for ; Fri, 7 Jul 2023 13:37:53 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fbea14700bso24659505e9.3 for ; Fri, 07 Jul 2023 13:37:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688762272; x=1691354272; 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=ENiHDLKPPvczr4GZmNOm/QgQFFHwqrusGb71Hi0udCM=; b=QRM1NdL5OjilaPqxpxhrU6X8Mx+3XPL6jpnjHvu1SzNH+A+LKcgTv+eBljOPwJbRuc ty5vJO+njHunKpZ2HMJaNOx0kofqqHOm7b/aGEorWJPegsVB4GV0XkHUzl+dnyIMzS2l T/vvOorn4HVl1oQGP00+wRAAWbhursb/emOMKdOOA6RRnxaMYzky1+QjsM5Wo5x3luMT cJuwY5GUPdAr0GbwNuxfvtiVrNdr3TYuZJI5xnmmnrKqCnZ6curv8JbRgeqdYV16Tpl6 urXWb1Sr1z1NuleNJHvaoQJzEgnGCx5NoI2nb3umHw+DACVhvuerjyTceBqSp+v2hq+h /b5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688762272; x=1691354272; 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=ENiHDLKPPvczr4GZmNOm/QgQFFHwqrusGb71Hi0udCM=; b=dCEt+UObBOmz47UOdacivWdVCzT8lp8sUeCfe6ZaZnsNpLYoQsOH3pFFkHH8aBwbLq CSqsAilNl4peJtrtlvUESL7tABYbPnnOT+dE/aI69ZUrAAHtfNul5F+/DXtQtGtstOVY yn7Hgi/450xiWpA/bRRfun86h9tqY6W5KenmXIxZgfffBPCvMec+iLYCzP3TyZtUVX0G msER7DEp0TWr+htL1KVb/71IafELXJanHCLfiTUnvvdd4HgPLkQ1bbxy5NzR0RVw4wWY 2akaH2cF8Hje93KemcZdexEGvzYIbnI9yfEOl5aFhrX0hlU/Q1+X2N9hguETgIj9lxFs 81DQ== X-Gm-Message-State: ABy/qLblVhVb7gO57HBa4BzX1a28QD7vwbqHxyeaSlb9Ycx9TYTwWLkD fLlEQj99jddH1vjq5o0dsBItrA== X-Google-Smtp-Source: APBJJlEgGWfZgDLVlNwF5NENKVslAufAZE0vPYQus65Hvw2yBnMg7f21XXWxnJgkalSla75e2TIf4w== X-Received: by 2002:a05:600c:2054:b0:3fb:fea1:affa with SMTP id p20-20020a05600c205400b003fbfea1affamr2638785wmg.37.1688762272030; Fri, 07 Jul 2023 13:37:52 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id i4-20020adfefc4000000b003143be36d99sm5260674wrp.58.2023.07.07.13.37.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 13:37:51 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, thierry.reding@gmail.com, linux-kernel@vger.kernel.org, srinivas.pandruvada@linux.intel.com, Lukasz Luba , Amit Kucheria , Zhang Rui Subject: [PATCH v2 2/4] thermal/core: Reorder the headers inclusion Date: Fri, 7 Jul 2023 22:37:29 +0200 Message-Id: <20230707203731.848188-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230707203731.848188-1-daniel.lezcano@linaro.org> References: <20230707203731.848188-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. No functional changes intended. Acked-by: Rafael J. Wysocki 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_po= wer_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 =20 -#define CREATE_TRACE_POINTS -#include "thermal_trace_ipa.h" - #define THERMAL_CORE_SUBSYS #include "thermal_core.h" =20 +#define CREATE_TRACE_POINTS +#include "thermal_trace_ipa.h"=20 + #define INVALID_TRIP -1 =20 #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 =20 -#define CREATE_TRACE_POINTS -#include "thermal_trace.h" - #define THERMAL_CORE_SUBSYS #include "thermal_core.h" #include "thermal_hwmon.h" =20 +#define CREATE_TRACE_POINTS +#include "thermal_trace.h" + static DEFINE_IDA(thermal_tz_ida); static DEFINE_IDA(thermal_cdev_ida); =20 --=20 2.34.1 From nobody Sat Feb 7 19:41:16 2026 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 161A1C0015E for ; Fri, 7 Jul 2023 20:38:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232501AbjGGUiJ (ORCPT ); Fri, 7 Jul 2023 16:38:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232505AbjGGUh4 (ORCPT ); Fri, 7 Jul 2023 16:37:56 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CF111FF9 for ; Fri, 7 Jul 2023 13:37:55 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fbc59de0e2so25173055e9.3 for ; Fri, 07 Jul 2023 13:37:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688762273; x=1691354273; 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=4NdrIPZwt9L1R1mzbxg8AqWIw5JoVMckhgJN4c8/wnI=; b=lS/hWwIUxlty3HHUhlAuObfrgH4Jvwy9c3m8808D+Sa1W04cmibz+dprPxGFLRJfD5 W+wubkN7FxqE+wSeBI/DIswpWhMYf1en1KrYUdqAHKAYxrdLZyzQJT19ej4LZNwPM5y/ ZrsJ3C5koE1MLodgKLTYDAy+79K0NZPeRyY1Rj1ldBio79paAud9ZWQ5MIT0TWBdyckH bbcedRSySKXS8FsEedvn01rjtFuLfP4gUzjCTaxW2l35Z9scX7UFu3TG1V5syVOd38CX IYOkVDx18SOY/L3Wgjswx8TNv0yh3ORCSyHK2iYewJd+w5fcnGpLYVAekQ0+fQ1+LzwR 6uJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688762273; x=1691354273; 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=4NdrIPZwt9L1R1mzbxg8AqWIw5JoVMckhgJN4c8/wnI=; b=Qds8eN5Z228PCJG05h6EeItv4ZtTiF4HwYxUZDmlVCQVjmmiy8OFk7dUpq1y9negGr w8SxJ6IET10fA7YYulP3v/L+x578NCtkAQvWCeE0SB1wb/IGxiy2ZntOLzFM9zi3yMhj b6oTM8npJwjmMdBlbduieJAqKR8pg3f2/Uz0dprHUjx8bwdrhYz+y46kH0X9VJzbvE0f BFaYSBjWJPfMsWxP1eOuEw7yiBVdRs3ozm7uTQZJ2hcZGJcNQHRSM/JhqGlSAgFlYY6q RoW/aLfVXmhTbXCJ0D4NplNTT0qXp3d2f7hoRMsRHHFi9yaKeDZK4kPioGwVzEeWN34n Nvsg== X-Gm-Message-State: ABy/qLbhOlfygfZ9IWS/I14cajxZuEksnyB/46Jl1W0X9LQ0qxAVG9Ay IWtFwgWZjmBLZa0KnkRIpnvrgA== X-Google-Smtp-Source: APBJJlFKy90SQJfbzMCfQRUyEu++iSwKiRNqGMM+51YZXrEdLEoPbgj+mk7637fvbLt3uMXQa4kXQg== X-Received: by 2002:a05:600c:2252:b0:3fb:c9f4:14f3 with SMTP id a18-20020a05600c225200b003fbc9f414f3mr4828743wmm.2.1688762273628; Fri, 07 Jul 2023 13:37:53 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id i4-20020adfefc4000000b003143be36d99sm5260674wrp.58.2023.07.07.13.37.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 13:37:53 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, thierry.reding@gmail.com, linux-kernel@vger.kernel.org, srinivas.pandruvada@linux.intel.com, Amit Kucheria , Zhang Rui , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Baolin Wang , ye xingchen , "Lee, Chun-Yi" Subject: [PATCH v2 3/4] thermal/drivers/int3400: Use thermal zone device wrappers Date: Fri, 7 Jul 2023 22:37:30 +0200 Message-Id: <20230707203731.848188-4-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230707203731.848188-1-daniel.lezcano@linaro.org> References: <20230707203731.848188-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use the thermal core API to access the thermal zone "type" field instead of directly using the structure field. While here, remove access to the temperature field, as this driver is reporting fake temperature, which can be replaced with INT3400_FAKE_TEMP. Also replace hardcoded 20C with INT3400_FAKE_TEMP Acked-by: srinivas pandruvada Signed-off-by: Daniel Lezcano --- .../thermal/intel/int340x_thermal/int3400_thermal.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/driv= ers/thermal/intel/int340x_thermal/int3400_thermal.c index 5e1164226ada..72a6e28ded2e 100644 --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c @@ -15,6 +15,7 @@ #define INT3400_THERMAL_TABLE_CHANGED 0x83 #define INT3400_ODVP_CHANGED 0x88 #define INT3400_KEEP_ALIVE 0xA0 +#define INT3400_FAKE_TEMP (20 * 1000) /* faked temp sensor with 20C */ =20 enum int3400_thermal_uuid { INT3400_THERMAL_ACTIVE =3D 0, @@ -453,6 +454,7 @@ static void int3400_notify(acpi_handle handle, void *data) { struct int3400_thermal_priv *priv =3D data; + struct device *dev; char *thermal_prop[5]; int therm_event; =20 @@ -475,12 +477,14 @@ static void int3400_notify(acpi_handle handle, return; } =20 - thermal_prop[0] =3D kasprintf(GFP_KERNEL, "NAME=3D%s", priv->thermal->typ= e); - thermal_prop[1] =3D kasprintf(GFP_KERNEL, "TEMP=3D%d", priv->thermal->tem= perature); + dev =3D thermal_zone_device(priv->thermal); +=09 + thermal_prop[0] =3D kasprintf(GFP_KERNEL, "NAME=3D%s", thermal_zone_devic= e_type(priv->thermal)); + thermal_prop[1] =3D kasprintf(GFP_KERNEL, "TEMP=3D%d", INT3400_FAKE_TEMP); thermal_prop[2] =3D kasprintf(GFP_KERNEL, "TRIP=3D"); thermal_prop[3] =3D kasprintf(GFP_KERNEL, "EVENT=3D%d", therm_event); thermal_prop[4] =3D NULL; - kobject_uevent_env(&priv->thermal->device.kobj, KOBJ_CHANGE, thermal_prop= ); + kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, thermal_prop); kfree(thermal_prop[0]); kfree(thermal_prop[1]); kfree(thermal_prop[2]); @@ -490,7 +494,7 @@ static void int3400_notify(acpi_handle handle, static int int3400_thermal_get_temp(struct thermal_zone_device *thermal, int *temp) { - *temp =3D 20 * 1000; /* faked temp sensor with 20C */ + *temp =3D INT3400_FAKE_TEMP; return 0; } =20 --=20 2.34.1 From nobody Sat Feb 7 19:41:16 2026 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 A48F2EB64D9 for ; Fri, 7 Jul 2023 20:38:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232713AbjGGUiL (ORCPT ); Fri, 7 Jul 2023 16:38:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232533AbjGGUh5 (ORCPT ); Fri, 7 Jul 2023 16:37:57 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A16891986 for ; Fri, 7 Jul 2023 13:37:56 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fbc59de0e2so25173245e9.3 for ; Fri, 07 Jul 2023 13:37:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688762275; x=1691354275; 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=INi3JugwL05IgttziwnbGPvMFEJjhzc+9jyw1opOkqE=; b=ARupnTbks4h3FT95+Y36hjBDayLzdEXaLdFPPyr+ek3g+mJSB/XJYX++SAyGlBMAb/ jMfh1kQ1dMnmOwlxCYORpntRz6a6D/j5C9kxQXyv8STSihhLMggreKVFyIoh8b0QFI6j gOxVQ2XqTMrmwEybx7nUyYG67ccuGB9YL3qp9GVxZSBcGQyGqISD+h7r6O86bztPtrab woGGaQfuANLzpBnzv5Y2yTEZLYbKnJI3JxG1tsAsASUixNLJwFUMrjl9PVkTf0TvbWJe JGmMA3SmmkylQsYK1qwa6i7SVb1C0Ikl5qsXyb0wUHiBtwbOsCsL+yqIYY0wA/FdBj8E EOaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688762275; x=1691354275; 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=INi3JugwL05IgttziwnbGPvMFEJjhzc+9jyw1opOkqE=; b=eXcy/ZTgtBngMVV+YusdaKoUroaY09QgZzAAXaHWaa4ik19TaShAJueVZzTYrPztjx GznOF66iQS8c/Ie+gl6p2LDWlLd0uxIlpIsrA6ncrRcuiyT5A0oq6+T2LOjCdGwemGyS aeUUOIZjO64ApyZnbdl0Gvcm8B9pGHidjat7kgd+K3UYsfeelFatTYG1/VC0AgpbRA0M fGI2csTo7tAj9EDlNO67vY+BRz3GuP2cyBVybnSG5GBmcPKxDvr2ZaB9SwCaxi/eGhzP jrA80TMPb6rouqzM/F7TRJ5iYZjmEGwL80XCEJhfPgErgFEqfHJDXokvcllH9ZjgqLJn ngLA== X-Gm-Message-State: ABy/qLZy1yE6INNyg2vclAsyNv3pQRRu14XUdP/moeYZjfyyx/xQ9wR7 Oa/X10JVSaQF4IbkzJXAHJWdfoFMbxML8NGVD54= X-Google-Smtp-Source: APBJJlE3ves+dG+pjqCsX+JqO34D54faHcVRS3DfpFlTo0Qi/49l4OTkpixz/vyc/5OcmUfGCN7guA== X-Received: by 2002:a05:6000:887:b0:313:f4b9:99cc with SMTP id cs7-20020a056000088700b00313f4b999ccmr5156584wrb.68.1688762275135; Fri, 07 Jul 2023 13:37:55 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id i4-20020adfefc4000000b003143be36d99sm5260674wrp.58.2023.07.07.13.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 13:37:54 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, thierry.reding@gmail.com, linux-kernel@vger.kernel.org, srinivas.pandruvada@linux.intel.com, Amit Kucheria , Zhang Rui , Dhruva Gole , Heiko Stuebner , "Lee, Chun-Yi" , ye xingchen Subject: [PATCH v2 4/4] thermal/drivers/int340x: Do not check the thermal zone state Date: Fri, 7 Jul 2023 22:37:31 +0200 Message-Id: <20230707203731.848188-5-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230707203731.848188-1-daniel.lezcano@linaro.org> References: <20230707203731.848188-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The driver is accessing the thermal zone state to ensure the state is different from the one we want to set. We don't want the driver to access the thermal zone device internals. Actually, the thermal core code already checks if the thermal zone's state is different before calling this function, thus this check is duplicate. Remove it. Acked-by: srinivas pandruvada Signed-off-by: Daniel Lezcano --- .../intel/int340x_thermal/int3400_thermal.c | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/driv= ers/thermal/intel/int340x_thermal/int3400_thermal.c index 72a6e28ded2e..c40b03d6c29f 100644 --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c @@ -503,32 +503,28 @@ static int int3400_thermal_change_mode(struct thermal= _zone_device *thermal, { struct int3400_thermal_priv *priv =3D thermal_zone_device_priv(thermal); int result =3D 0; + int enabled; =20 if (!priv) return -EINVAL; =20 - if (mode !=3D thermal->mode) { - int enabled; + enabled =3D mode =3D=3D THERMAL_DEVICE_ENABLED; =20 - enabled =3D mode =3D=3D THERMAL_DEVICE_ENABLED; - - if (priv->os_uuid_mask) { - if (!enabled) { - priv->os_uuid_mask =3D 0; - result =3D set_os_uuid_mask(priv, priv->os_uuid_mask); - } - goto eval_odvp; + if (priv->os_uuid_mask) { + if (!enabled) { + priv->os_uuid_mask =3D 0; + result =3D set_os_uuid_mask(priv, priv->os_uuid_mask); } - - if (priv->current_uuid_index < 0 || - priv->current_uuid_index >=3D INT3400_THERMAL_MAXIMUM_UUID) - return -EINVAL; - - result =3D int3400_thermal_run_osc(priv->adev->handle, - int3400_thermal_uuids[priv->current_uuid_index], - &enabled); + goto eval_odvp; } =20 + if (priv->current_uuid_index < 0 || + priv->current_uuid_index >=3D INT3400_THERMAL_MAXIMUM_UUID) + return -EINVAL; + + result =3D int3400_thermal_run_osc(priv->adev->handle, + int3400_thermal_uuids[priv->current_uuid_index], + &enabled); eval_odvp: evaluate_odvp(priv); =20 --=20 2.34.1