From patchwork Fri Jul 7 20:37:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 700291 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 8316CC001DF for ; Fri, 7 Jul 2023 20:38:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232314AbjGGUiA (ORCPT ); Fri, 7 Jul 2023 16:38:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232322AbjGGUhy (ORCPT ); Fri, 7 Jul 2023 16:37:54 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D27261FF9 for ; Fri, 7 Jul 2023 13:37:52 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-313f1085ac2so2332331f8f.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=j8Gso6sdhjtbVLw4FRPz9OI3GZ5DzXB6lgCzZyA1+km1D0oOyOspA6VPKT8GagbEwG NSLNUOE3tOeLdwheaTjLKKISVLMzBBsoxWA/uVmDdHVrNrcZEGPL6/lwWJzXR9tu2/Pr tfGKCI1kBYY+/50XWunyXk751q4SQhsDpuHgeGHkf5l7Ir4j80lXmTPF8AE7fVDUHUgi byZzcmCvLohdImoDqhKxmUML8RWDgHxwATz/Dnyz6OTXqZo7cBjVyoTSltWYXCOvPwNk uNYI1Y3XjYS+XJgv+eRD8acS3jBuJm1qeBTN1A03jfZCKLSircRLLPdIjixYOzzHSQmZ 75xQ== X-Gm-Message-State: ABy/qLb3AJlSFMLuyOgDgnGE9y9E5//GTfBt0c64r9ECnUzCPZCAAe9T DO3Juygk02Bfqv3pfZnVJU98LA== 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 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. No functional changes intended. [1] https://lore.kernel.org/all/20230414125721.1043589-1-thierry.reding@gmail.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_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 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" +#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 17c1bbed734d..2f58eb9854ff 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 c3ae44659b81..ba2ae5be0c23 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 6fb14e521197..0f2aca2d1dea 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 6c20c9f90a05..ccda2579ae82 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 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" int __for_each_thermal_trip(struct thermal_zone_device *tz, From patchwork Fri Jul 7 20:37:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 700768 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 7234FC001DC for ; Fri, 7 Jul 2023 20:38:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232409AbjGGUiB (ORCPT ); Fri, 7 Jul 2023 16:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232408AbjGGUhz (ORCPT ); Fri, 7 Jul 2023 16:37:55 -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 81A541986 for ; Fri, 7 Jul 2023 13:37:53 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fbdfda88f4so24784625e9.1 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=TBSmF2NBjHa32hy+baOE/s4DRb4If1rt3nLNV6kL6imMllMtzpyOH0boppcnQ9Rbon 6LwywgccgV0/Q+L9LZq+Hi/sUUkwJnyat1qvqmw3hmo8XTBAi+2nDURFICbTO36kDshC imjakNUPCKT0DYMkRYBlU5cyfT3nG1dF+4YCDh5U0x4/rCt1SVYwGGsootQF3UHAaIs8 JckJgGVgKHQuSTHoy6/pfmIz769m9BjjED1WJAV6jEOYnQkz/v7lFgGlemsVdT+6iteN jWY/H1FbZVwnh48hngdWV/sA+gDJclAhNzU3e57QacMxT+l8EYNG9Z30Dr8MulfsiMYy fLeg== X-Gm-Message-State: ABy/qLbghh1Kvxtxlktbd4b72/Q2oVzG/kGLE+fCnnyOzg8XApIKIPyo t3OWc72Jx2EFWltOlOObQGdo4H7zzGZf7ufCF3k= 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 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. 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_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 Fri Jul 7 20:37:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 700290 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 230B2C04A6A for ; Fri, 7 Jul 2023 20:38:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232282AbjGGUiB (ORCPT ); Fri, 7 Jul 2023 16:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232467AbjGGUh4 (ORCPT ); Fri, 7 Jul 2023 16:37:56 -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 1301F1FEB for ; Fri, 7 Jul 2023 13:37:55 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fc02a92dcfso5692735e9.0 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=Y/r4ptv6DwBi1XAuTnUrxucJ8sh3oUDviK8UHDNjic+DTfbA6RGwfHNpxvRHmWvnYA Ot5hYZoGSeZHb8vC4NxmPF2vKbBj4jRxnzOhiw0YCkhGGpYe+TC4srueDET6RIsU/P/N I6ldl5ZH7YCTKq/HTuuXi2BlSyDqSArsyfgGP78EWj6Xk61jEy1iRLmun91+n5DDS1Zl BZAQwj311G5nUgEsM32lOn/WbFiKvALrI2YFJjn0pPmzh7Kd2o0Z8hNfF3WrUefFrc7D pZmt2Yx1Rg1Q+GO9M4VpOPBBVpcewYlN7Sw2vEyd/JW9Q5QptcI0VRxvZeVbTqbPPD3m MluA== X-Gm-Message-State: ABy/qLYyazDrhrZWIk06yi+suw8def69cqjE0DS98O6oghk8vsbiWUXl /4hKPfxB0PV7J1ejG/EyQ0fc0g== 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_S=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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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/drivers/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 */ enum int3400_thermal_uuid { INT3400_THERMAL_ACTIVE = 0, @@ -453,6 +454,7 @@ static void int3400_notify(acpi_handle handle, void *data) { struct int3400_thermal_priv *priv = data; + struct device *dev; char *thermal_prop[5]; int therm_event; @@ -475,12 +477,14 @@ static void int3400_notify(acpi_handle handle, return; } - thermal_prop[0] = kasprintf(GFP_KERNEL, "NAME=%s", priv->thermal->type); - thermal_prop[1] = kasprintf(GFP_KERNEL, "TEMP=%d", priv->thermal->temperature); + dev = thermal_zone_device(priv->thermal); + + thermal_prop[0] = kasprintf(GFP_KERNEL, "NAME=%s", thermal_zone_device_type(priv->thermal)); + thermal_prop[1] = kasprintf(GFP_KERNEL, "TEMP=%d", INT3400_FAKE_TEMP); thermal_prop[2] = kasprintf(GFP_KERNEL, "TRIP="); thermal_prop[3] = kasprintf(GFP_KERNEL, "EVENT=%d", therm_event); thermal_prop[4] = 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 = 20 * 1000; /* faked temp sensor with 20C */ + *temp = INT3400_FAKE_TEMP; return 0; } From patchwork Fri Jul 7 20:37:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 700769 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 16CC0EB64DA for ; Fri, 7 Jul 2023 20:38:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230145AbjGGUh7 (ORCPT ); Fri, 7 Jul 2023 16:37:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232560AbjGGUh5 (ORCPT ); Fri, 7 Jul 2023 16:37:57 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A350A1994 for ; Fri, 7 Jul 2023 13:37:56 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3fbf1b82dc7so25040295e9.2 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=g+24SGwWVUaC3UkQQYj23wUWhkhhcomEcPg0qnrKZBBmjX01csqGGGtV+jQb/zufGb 8ug9EKOJWcp4epO4u5K6sZ8oDKRjwX827102RltCpp3ajGTERsMmAE8rWnGIpbYxBBiE iZvfQM7OQuRGsiau32up9ae+Fs4e0jbL6XhDZVwXzPN7hmEU9QTJkYGdDVXTNhhNUGot 7dQUUQlBN3GUj5e7fc4p+5rPBCQsWycc4qHC/VSINne/9ILM0EdQByjHGFIr8MbXKmKn hN+S+s8j4HuD0AYY/zWsl4ogrv28vUk1rCg9Juo33vgc0zQ/lXGkboSfOmYl2v3LFFSb v4Ag== X-Gm-Message-State: ABy/qLbRadVAO1RMPfBzJqAywtb8as3VU/VRGnhI2oE171tIBhOcei9v F3XwGYvmpglUhjBR4j33GYW75Q== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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/drivers/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 = thermal_zone_device_priv(thermal); int result = 0; + int enabled; if (!priv) return -EINVAL; - if (mode != thermal->mode) { - int enabled; + enabled = mode == THERMAL_DEVICE_ENABLED; - enabled = mode == THERMAL_DEVICE_ENABLED; - - if (priv->os_uuid_mask) { - if (!enabled) { - priv->os_uuid_mask = 0; - result = set_os_uuid_mask(priv, priv->os_uuid_mask); - } - goto eval_odvp; + if (priv->os_uuid_mask) { + if (!enabled) { + priv->os_uuid_mask = 0; + result = set_os_uuid_mask(priv, priv->os_uuid_mask); } - - if (priv->current_uuid_index < 0 || - priv->current_uuid_index >= INT3400_THERMAL_MAXIMUM_UUID) - return -EINVAL; - - result = int3400_thermal_run_osc(priv->adev->handle, - int3400_thermal_uuids[priv->current_uuid_index], - &enabled); + goto eval_odvp; } + if (priv->current_uuid_index < 0 || + priv->current_uuid_index >= INT3400_THERMAL_MAXIMUM_UUID) + return -EINVAL; + + result = int3400_thermal_run_osc(priv->adev->handle, + int3400_thermal_uuids[priv->current_uuid_index], + &enabled); eval_odvp: evaluate_odvp(priv);