From nobody Sun Apr 19 10:42:38 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 05FE2C43334 for ; Sun, 3 Jul 2022 18:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232571AbiGCSbc (ORCPT ); Sun, 3 Jul 2022 14:31:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231909AbiGCSb3 (ORCPT ); Sun, 3 Jul 2022 14:31:29 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0E623886 for ; Sun, 3 Jul 2022 11:31:28 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id c131-20020a1c3589000000b003a19b2bce36so1123499wma.4 for ; Sun, 03 Jul 2022 11:31:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lYiarM6ryCuSTp2tU29BbcCVirvvghP4xAIxJ7FKWQI=; b=X1DjKI+m1eU/WtbCOKdkKYpTrI92MOgpcrTaKGWVrqwoRuT7SV+0OAyxJE79WtEmq7 BUoYGsWeRJ3J95S53ewFuYGYF1N48wTly80F6st20feP7pDAIMXNkT/iOrTKu48IZbwH SG5Aa9RHuPG2PssE7gZgj7h0KScuYUMSyzSmAcBTXXIlF7jNXhLwr0WsrcK0EWKP2sTC 28fxD2dnvOv04h8MUzSUmzyCAUznzbpyNiL6zi3nsQ9l9zLRLoP6w1jx0wncKSHCFpy2 GG/MhL1sFRiz612ygQTmW52cmS2/VeCMbO/oo10qEJGRpRSwxlF0vWQbYmVqgHM7vN3Z PAjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lYiarM6ryCuSTp2tU29BbcCVirvvghP4xAIxJ7FKWQI=; b=3YFVqUbBPEPtHbh761LCqzFN4Ffa/jiKfrh9Km/3gl+UqKSyOIyoD+mgb7JV/Inxh8 xLsXfdXFZ4k68EonZ09XI5tEJcelJNkt1NWMplkge23h0rE1/DTuULM4P/YM0Q20Zifg 8Re2H8Da0JtEnc1o/44nAV+UuEW7fBKDgyxjDEz6ZxDLkagH1rsJErqS2OVN2WMbXCjE zT5vG3OTfId3BuJKqjsF5nmI5IiHff9BgKEqeHtAHRFMK9BIIUVtgytx5GjfgV8+2Q/X NdpWaiVED4ycXfi2sV2pJG+ucPdWE03B6NItPSom6Nz5ojif5CGuMpcHFBOfk/XUjk1e hl9g== X-Gm-Message-State: AJIora/qs22kAerSw+q7in/UkQZvMHtLIMVYM8yVFEU6I2cOlag1JkaV JFXqg9m7lxQ8CHANjmGchdOsHA== X-Google-Smtp-Source: AGRyM1tS3mlJ0wfgPTJPXoEoze0T1T/T81PmNi9tH11k/td1lmaFNTG1MFHvsG87l/i3VEht0vhrPg== X-Received: by 2002:a05:600c:2207:b0:3a0:4659:a0b0 with SMTP id z7-20020a05600c220700b003a04659a0b0mr29806674wml.48.1656873087286; Sun, 03 Jul 2022 11:31:27 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id x10-20020a5d54ca000000b0021b85664636sm27504258wrv.16.2022.07.03.11.31.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 11:31:27 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, Amit Kucheria , Zhang Rui Subject: [PATCH v3 01/12] thermal/core: Remove duplicate information when an error occurs Date: Sun, 3 Jul 2022 20:30:48 +0200 Message-Id: <20220703183059.4133659-2-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703183059.4133659-1-daniel.lezcano@linexp.org> References: <20220703183059.4133659-1-daniel.lezcano@linexp.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 pr_err already tells it is an error, it is pointless to add the 'Error:' string in the messages. Remove them. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano Reviewed-by: Lukasz Luba --- drivers/thermal/thermal_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index cdc0552e8c42..e22e7d939c54 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1198,23 +1198,23 @@ thermal_zone_device_register(const char *type, int = trips, int mask, struct thermal_governor *governor; =20 if (!type || strlen(type) =3D=3D 0) { - pr_err("Error: No thermal zone type defined\n"); + pr_err("No thermal zone type defined\n"); return ERR_PTR(-EINVAL); } =20 if (type && strlen(type) >=3D THERMAL_NAME_LENGTH) { - pr_err("Error: Thermal zone name (%s) too long, should be under %d chars= \n", + pr_err("Thermal zone name (%s) too long, should be under %d chars\n", type, THERMAL_NAME_LENGTH); return ERR_PTR(-EINVAL); } =20 if (trips > THERMAL_MAX_TRIPS || trips < 0 || mask >> trips) { - pr_err("Error: Incorrect number of thermal trips\n"); + pr_err("Incorrect number of thermal trips\n"); return ERR_PTR(-EINVAL); } =20 if (!ops) { - pr_err("Error: Thermal zone device ops not defined\n"); + pr_err("Thermal zone device ops not defined\n"); return ERR_PTR(-EINVAL); } =20 --=20 2.25.1 From nobody Sun Apr 19 10:42:38 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 A480CC43334 for ; Sun, 3 Jul 2022 18:31:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232686AbiGCSbg (ORCPT ); Sun, 3 Jul 2022 14:31:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232280AbiGCSbb (ORCPT ); Sun, 3 Jul 2022 14:31:31 -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 B2C092DE4 for ; Sun, 3 Jul 2022 11:31:29 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id l68so4194676wml.3 for ; Sun, 03 Jul 2022 11:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0c9qHlWoBwCGs7JGuVHwAzNgwf4Be2qCjsOeezEPK2c=; b=UlEcX9eTZYXVEmQ/yq54/rTJFbnHWDcSzcSJW8KW4S6Nu5lJKppccNEcxt/crItNCo c4PQW59ZNDz/EvkXTrN0GmuY1kFx0Fxxia37q/mKl5KAHZZxwEVZibmvFUKW0107y6PW fyuvOIAptFakGOW+L2qmSNTV6iXVFNxG70UzhpvzE3L7c0kbQFhp6JCFf3HjC/t3bzSZ hZzAk1HSJFGEicCjxYGcYmPscb1Ry5x2LSBFX3XcU8pRRmakFZoc5mektURNSfpB3Ftl x2D+5YAND3MuBMM5QfXXA0e3yK8F1Y1IuDof0DLaRwWA5jcFkLchfTko88wqHxMLmXxe x/9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0c9qHlWoBwCGs7JGuVHwAzNgwf4Be2qCjsOeezEPK2c=; b=6Hn4D6VTw4giBbYMzzYst+hJt+jblLCBnaq8GEU4+/Ft2WTDzmU9q6TKqNuMA8emOI mRshcl2hSEKRPjfpvIB/UIIfFDK6NVmeg+94vuooJ8KeAqzL9USB9az/XvZGt11kegwK gza2R8gZakHfWYsJzNxV4qvWeITFIHTip/30DTnVPK1+YV94Ha/HHHIG3lRSXWS488jO my5QY/MmWnYoB9ciy/yJh/7kJpbtPHTH7Nz5KAE9Lu2mb7puoo3o8uSRadpvO2yp+wjG 0VZP3yl4IANoFXwEmu5I8OSPpXw++lRlAbdxE0/yR8feF1nMYDv7b1oBRq7bMd2KSsBH ygGQ== X-Gm-Message-State: AJIora8yLwCFiCCDOaMzdzMjtb+ph6fMuqUsdTIRFJof3FOsgVncq1+D GTgilBRd54C0HLDQTZup2rPzMQ== X-Google-Smtp-Source: AGRyM1sHAXyRoZ4WaNasYPMScPdXHnvDVvw/BvEPRGJZ4aaeVV60ziTVH8KT1SJHG1FzLH5NmzqXTg== X-Received: by 2002:a05:600c:27cd:b0:3a1:8b8c:b156 with SMTP id l13-20020a05600c27cd00b003a18b8cb156mr15358093wmb.156.1656873088277; Sun, 03 Jul 2022 11:31:28 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id x10-20020a5d54ca000000b0021b85664636sm27504258wrv.16.2022.07.03.11.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 11:31:28 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, Amit Kucheria , Zhang Rui Subject: [PATCH v3 02/12] thermal/of: Replace device node match with device node search Date: Sun, 3 Jul 2022 20:30:49 +0200 Message-Id: <20220703183059.4133659-3-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703183059.4133659-1-daniel.lezcano@linexp.org> References: <20220703183059.4133659-1-daniel.lezcano@linexp.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_of code builds a trip array associated with the node pointer in order to compare the trip point phandle with the list. The thermal trip is a thermal zone property and should be moved there. If some sensors have hardcoded trip points, they should use the exported structure instead of redefining again and again their own structure and data to describe exactly the same things. In order to move this to the thermal.h header and allow more cleanup, we need to remove the node pointer from the structure. Instead of building storing the device node, we search directly in the device tree the corresponding node. That results in a simplification of the code and allows to move the structure to thermal.h Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 62 ++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index b65d435cb92f..04c910ca8623 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -671,6 +671,35 @@ EXPORT_SYMBOL_GPL(devm_thermal_zone_of_sensor_unregist= er); =20 /*** functions parsing device tree nodes ***/ =20 +static int of_find_trip_id(struct device_node *np, struct device_node *tri= p) +{ + struct device_node *trips; + struct device_node *t; + int i =3D 0; + + trips =3D of_get_child_by_name(np, "trips"); + if (!trips) { + pr_err("Failed to find 'trips' node\n"); + return -EINVAL; + } + + /* + * Find the trip id point associated with the cooling device map + */ + for_each_child_of_node(trips, t) { + + if (t =3D=3D trip) + goto out; + i++; + } + + i =3D -ENXIO; +out:=09 + of_node_put(trips); + + return i; +} + /** * thermal_of_populate_bind_params - parse and fill cooling map data * @np: DT node containing a cooling-map node @@ -686,14 +715,13 @@ EXPORT_SYMBOL_GPL(devm_thermal_zone_of_sensor_unregis= ter); * Return: 0 on success, proper error code otherwise */ static int thermal_of_populate_bind_params(struct device_node *np, - struct __thermal_bind_params *__tbp, - struct thermal_trip *trips, - int ntrips) + struct __thermal_bind_params *__tbp) { struct of_phandle_args cooling_spec; struct __thermal_cooling_bind_param *__tcbp; struct device_node *trip; int ret, i, count; + int trip_id; u32 prop; =20 /* Default weight. Usage is optional */ @@ -708,18 +736,14 @@ static int thermal_of_populate_bind_params(struct dev= ice_node *np, return -ENODEV; } =20 - /* match using device_node */ - for (i =3D 0; i < ntrips; i++) - if (trip =3D=3D trips[i].np) { - __tbp->trip_id =3D i; - break; - } - - if (i =3D=3D ntrips) { - ret =3D -ENODEV; + trip_id =3D of_find_trip_id(np, trip); + if (trip_id < 0) { + ret =3D trip_id; goto end; } =20 + __tbp->trip_id =3D trip_id; +=09 count =3D of_count_phandle_with_args(np, "cooling-device", "#cooling-cells"); if (count <=3D 0) { @@ -868,6 +892,7 @@ static struct __thermal_zone __init *thermal_of_build_thermal_zone(struct device_node *np) { struct device_node *child =3D NULL, *gchild; + struct device_node *trips; struct __thermal_zone *tz; int ret, i; u32 prop, coef[2]; @@ -910,13 +935,13 @@ __init *thermal_of_build_thermal_zone(struct device_n= ode *np) } =20 /* trips */ - child =3D of_get_child_by_name(np, "trips"); + trips =3D of_get_child_by_name(np, "trips"); =20 /* No trips provided */ - if (!child) + if (!trips) goto finish; =20 - tz->ntrips =3D of_get_child_count(child); + tz->ntrips =3D of_get_child_count(trips); if (tz->ntrips =3D=3D 0) /* must have at least one child */ goto finish; =20 @@ -927,14 +952,12 @@ __init *thermal_of_build_thermal_zone(struct device_n= ode *np) } =20 i =3D 0; - for_each_child_of_node(child, gchild) { + for_each_child_of_node(trips, gchild) { ret =3D thermal_of_populate_trip(gchild, &tz->trips[i++]); if (ret) goto free_trips; } =20 - of_node_put(child); - /* cooling-maps */ child =3D of_get_child_by_name(np, "cooling-maps"); =20 @@ -954,8 +977,7 @@ __init *thermal_of_build_thermal_zone(struct device_nod= e *np) =20 i =3D 0; for_each_child_of_node(child, gchild) { - ret =3D thermal_of_populate_bind_params(gchild, &tz->tbps[i++], - tz->trips, tz->ntrips); + ret =3D thermal_of_populate_bind_params(gchild, &tz->tbps[i++]); if (ret) goto free_tbps; } --=20 2.25.1 From nobody Sun Apr 19 10:42:38 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 EF627CCA47F for ; Sun, 3 Jul 2022 18:31:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232634AbiGCSbi (ORCPT ); Sun, 3 Jul 2022 14:31:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232388AbiGCSbb (ORCPT ); Sun, 3 Jul 2022 14:31:31 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3FD23886 for ; Sun, 3 Jul 2022 11:31:30 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id t17-20020a1c7711000000b003a0434b0af7so4478706wmi.0 for ; Sun, 03 Jul 2022 11:31:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uMdWj+8IX41ropCzCvRKN6v1pic3BDCL4i5ocfz1lDQ=; b=auMA2wBPakeBvAHe93TzS3VT6myP+ZZKn8tvCarChohy1lKOzaNh+dFaw9G9VOLluf Y/Q1UI8ooK8fWfkdC5D+jvMxmI1xcDYv24xQ4oiLRwXYnmJFpDXWvN/3ftfLagm5lhJV 1rfTNuNZNmNE9se7QFr/ivrwEz9+XrVRPDmrhfD7WSlU+oXM3JnA03MrNK9mbQqfStDT AtXAwh7BgXK2ypeWTSNp7KEBZV8DUlT1o8jtqbvplA7Wt8hk12P1AoYtza68hvcLWJ2j vB7DqGnAr2IaDfygH1QZw3SUV9UQ/HBvjFUtE4fiiPhi3tyvoXykYeBAffgSmqQjpWXY YxEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uMdWj+8IX41ropCzCvRKN6v1pic3BDCL4i5ocfz1lDQ=; b=vH7AJVj4AmY/gScAgD6CxNTGkFZFIn5BN7gl0x1MVlabgHTw5MLWz3eGmUZt+mbOzB XFiFwc4TL2Cd16/bPhjOm94MhFnkDuut73xkNgbuNMQjMt7jfSu7Ar6R6qpTcePejCMP Gr4ucFQY3PfC7T8JcUb5KiHSxTS4OdTdDKtJA2590Og0raI7wu20tmtWIMt0xQ0aiQ7z Ee7hIb8vGbYkPCc8RYPdUEdGUMtjZqp5zLgbvdkC78syL4zSlBixzJWeYMqa9FErkrL5 Sd8jVL4YtZX+Vh976WaVAlTbnJ1BaEFP3CW0b1ctchL0UXcSD2sx2qJID4XTjRwwPVtf f+dQ== X-Gm-Message-State: AJIora+7RBKIAEL9OZeZYZMO/C3Kbran8/d2OSq1fXBANBnXcI+vd7aJ 5hxlndNRUAkqk55DPzbpY+l8TOefjzPC7A== X-Google-Smtp-Source: AGRyM1sTfvIvVlyecJ5qq2G1Twupk2XWDNGZjmSewsOGJOQCu6HcnIbiWfakmM/a3FkCZpwj+pKAbA== X-Received: by 2002:a05:600c:1c0d:b0:3a0:503a:9c9c with SMTP id j13-20020a05600c1c0d00b003a0503a9c9cmr27120260wms.2.1656873089358; Sun, 03 Jul 2022 11:31:29 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id x10-20020a5d54ca000000b0021b85664636sm27504258wrv.16.2022.07.03.11.31.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 11:31:29 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, Amit Kucheria , Zhang Rui Subject: [PATCH v3 03/12] thermal/of: Remove the device node pointer for thermal_trip Date: Sun, 3 Jul 2022 20:30:50 +0200 Message-Id: <20220703183059.4133659-4-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703183059.4133659-1-daniel.lezcano@linexp.org> References: <20220703183059.4133659-1-daniel.lezcano@linexp.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 device node pointer is no longer needed in the thermal trip structure, remove it. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano Reviewed-by: Lukasz Luba --- drivers/thermal/thermal_core.h | 2 -- drivers/thermal/thermal_of.c | 8 -------- 2 files changed, 10 deletions(-) diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 726e327b4205..ff10cdda056c 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -70,13 +70,11 @@ void __thermal_cdev_update(struct thermal_cooling_devic= e *cdev); =20 /** * struct thermal_trip - representation of a point in temperature domain - * @np: pointer to struct device_node that this trip point was created from * @temperature: temperature value in miliCelsius * @hysteresis: relative hysteresis in miliCelsius * @type: trip point type */ struct thermal_trip { - struct device_node *np; int temperature; int hysteresis; enum thermal_trip_type type; diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 04c910ca8623..16eb18c24430 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -867,10 +867,6 @@ static int thermal_of_populate_trip(struct device_node= *np, return ret; } =20 - /* Required for cooling map matching */ - trip->np =3D np; - of_node_get(np); - return 0; } =20 @@ -1000,8 +996,6 @@ __init *thermal_of_build_thermal_zone(struct device_no= de *np) =20 kfree(tz->tbps); free_trips: - for (i =3D 0; i < tz->ntrips; i++) - of_node_put(tz->trips[i].np); kfree(tz->trips); of_node_put(gchild); free_tz: @@ -1026,8 +1020,6 @@ static __init void of_thermal_free_zone(struct __ther= mal_zone *tz) } =20 kfree(tz->tbps); - for (i =3D 0; i < tz->ntrips; i++) - of_node_put(tz->trips[i].np); kfree(tz->trips); kfree(tz); } --=20 2.25.1 From nobody Sun Apr 19 10:42:38 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 3FC3EC43334 for ; Sun, 3 Jul 2022 18:31:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232775AbiGCSbn (ORCPT ); Sun, 3 Jul 2022 14:31:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232607AbiGCSbd (ORCPT ); Sun, 3 Jul 2022 14:31:33 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7EE52DE4 for ; Sun, 3 Jul 2022 11:31:31 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id l68so4194709wml.3 for ; Sun, 03 Jul 2022 11:31:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A2z3qfhbQ3zSDbb76Qqm6EAs5xwOzGA7CqbEOdCxb6g=; b=XhQSb87XVVI3luZ32GWskOiupZ5bhwPz1YAQE1fY5hOjVny3ZZB1mQzM8xqwA0WF1y xMTEgCUd9wKgfrskPUemcvxiDbjBMl20XafSGYnRkaGdW0RHnqngtJcmKp+PKjb8Wj6n 523eScii7Q0p3lIUlL7j+fS5Hn6e7lVa+9+d1tDWfs6sYDpvnrhJxO2I3Uh7uFygTSxt cOSHNOJmdYwgyI7X+uhvUVlLc5Ti5bznfVzKFMu9sec8a8OEzwA3ra4rfsJMA7A0CcMk reD/hlq2YxY8pGJKTh5n9MY/6/JiK6N+B8LO1CqfBx8mlfOJ3bR0iDZ8FMSQBMK5Abn3 scCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A2z3qfhbQ3zSDbb76Qqm6EAs5xwOzGA7CqbEOdCxb6g=; b=sBv7jaXpdg0MSSZDsJnxjSTeX3K58LFsGw0ihCnhIq35L8P5f4SP87Hn5uEIqenaId KVJlw1XmCW0bBL9ZOjbG8J1cz8XeaOSloA4dk90nzI/l3znuDQbcmyeCPeUIQweXa+sg CRoV5VePlX6J4Fe0w2EcnQXkteLMOzkfiVhidStLjWlS0rQecP0KW64yIZniWrBcba+C pGHG2JVN6VEZudosQ48kyU+j2c6KKIg8BNCx01vlKm0pFjE29BqarjoOZwkUDaLNsZNu QiICPxWy4yAtlPg3sNcS+dpneXv0R3XXMuab8Whk3zG1/LoH+x3B/y9eWOVtz9z6umyh iOGw== X-Gm-Message-State: AJIora9xGe7epx1lggJUYOb/F/489C/lAKS5bCeb84b4m5NY/a2gSjDJ G/g049qUPkpmFbELz+KSmq+i4w== X-Google-Smtp-Source: AGRyM1tuvMijgjcSMj9tFddYyj2ScVNEALBCowAqot6wGPssoHDtk7EBqcmWdK5tMba5E15kDXmXJQ== X-Received: by 2002:a05:600c:1c93:b0:3a0:579e:9f44 with SMTP id k19-20020a05600c1c9300b003a0579e9f44mr27474122wms.82.1656873090393; Sun, 03 Jul 2022 11:31:30 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id x10-20020a5d54ca000000b0021b85664636sm27504258wrv.16.2022.07.03.11.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 11:31:30 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, Amit Kucheria , Zhang Rui Subject: [PATCH v3 04/12] thermal/of: Move thermal_trip structure to thermal.h Date: Sun, 3 Jul 2022 20:30:51 +0200 Message-Id: <20220703183059.4133659-5-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703183059.4133659-1-daniel.lezcano@linexp.org> References: <20220703183059.4133659-1-daniel.lezcano@linexp.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 structure thermal_trip is now generic and will be usable by the different sensor drivers in place of their own structure. Move its definition to thermal.h to make it accessible. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano Reviewed-by: Lukasz Luba --- drivers/thermal/thermal_core.h | 12 ------------ include/linux/thermal.h | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index ff10cdda056c..60844e2d59bb 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -68,18 +68,6 @@ static inline bool cdev_is_power_actor(struct thermal_co= oling_device *cdev) void thermal_cdev_update(struct thermal_cooling_device *); void __thermal_cdev_update(struct thermal_cooling_device *cdev); =20 -/** - * struct thermal_trip - representation of a point in temperature domain - * @temperature: temperature value in miliCelsius - * @hysteresis: relative hysteresis in miliCelsius - * @type: trip point type - */ -struct thermal_trip { - int temperature; - int hysteresis; - enum thermal_trip_type type; -}; - int get_tz_trend(struct thermal_zone_device *tz, int trip); =20 struct thermal_instance * diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 365733b428d8..6289b0bb1c97 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -80,6 +80,18 @@ struct thermal_zone_device_ops { void (*critical)(struct thermal_zone_device *); }; =20 +/** + * struct thermal_trip - representation of a point in temperature domain + * @temperature: temperature value in miliCelsius + * @hysteresis: relative hysteresis in miliCelsius + * @type: trip point type + */ +struct thermal_trip { + int temperature; + int hysteresis; + enum thermal_trip_type type; +}; + struct thermal_cooling_device_ops { int (*get_max_state) (struct thermal_cooling_device *, unsigned long *); int (*get_cur_state) (struct thermal_cooling_device *, unsigned long *); --=20 2.25.1 From nobody Sun Apr 19 10:42:38 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 CC73BC43334 for ; Sun, 3 Jul 2022 18:31:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232766AbiGCSbq (ORCPT ); Sun, 3 Jul 2022 14:31:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232699AbiGCSbh (ORCPT ); Sun, 3 Jul 2022 14:31:37 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C97FE3898 for ; Sun, 3 Jul 2022 11:31:32 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id e28so10480077wra.0 for ; Sun, 03 Jul 2022 11:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T7tkBePSX5yj0NYkrN882NXSd6Nnb35TSjkjDJbwv98=; b=OON/Z7AAVnyojhsr41KEKcatST2zK4gWTUcHL1cZ/7LMyF0HO36KXoI8zqlqrmomcq hvFKBGqufPChB65qZ5rc+IK/KXhwyKE6U6e9W8IAaSf4w602kjXp+esQxUZXdCaThAft OtsUAhD8B06Xow+9XQtSgpTaXeoZYfUTHuFcC3X2Kj6Lisk1i+9cOyMVmNMxU21EqQL0 U5kSlzER5281yybwwkF/FXoCuREZbOz6b3YvQ+omlP9wPpNiAeqXJiWmbwcb33ZbTsgc KkHQmyxcg4hFcmcz514grNq0xTxx+e94IvdxZvNx2Rxx160DP6hEm2XF+QcbbiyQmB5z 5Gyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T7tkBePSX5yj0NYkrN882NXSd6Nnb35TSjkjDJbwv98=; b=OnEC/X2yFycKqbQMnOWWUJjwEvxmLf/AaK7pkfhna66DIjnNwyarbAAGzYHeTYvDql 1lculgsGn8Yk0zrJFZqEyKHuOczgXeyUvg2WEiIUb2t2VgVru83AQgN/bw169lnPtKbf MOcYaMpkC2eWS/W0dg2zs/ZvJCUKBgKT5KMpjQD/cQsps33b8Ocyd62L/tvuajvSASE2 Fp3nJFZME/w4A1jYWSNjM3fuyILL2qy0hIt+uKUB1X3fvuAoFpJtuJsA3NZwxkML/7E4 7APdgyU/ojVUSu3qyOUF7jLNdWUot+cyOPFaJP3W1JTInIvvDbq0GonqYqFuLi8yYnbM Wj6Q== X-Gm-Message-State: AJIora+6liKADD5jZ6dJR/6f5GzPbqVU3ZGE80xq0DNnjALFje2EG+qE jLT+hcWoF7vM5nNhkZ4BMd3vPw== X-Google-Smtp-Source: AGRyM1vQL3HGL0Vws9udKWsxWTNMjoaqHFdx81oodzRiBuGENGX+2oa2qUlISSQdiYlH03PGZqXPsQ== X-Received: by 2002:adf:9d82:0:b0:21a:3906:59cc with SMTP id p2-20020adf9d82000000b0021a390659ccmr23609554wre.289.1656873091448; Sun, 03 Jul 2022 11:31:31 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id x10-20020a5d54ca000000b0021b85664636sm27504258wrv.16.2022.07.03.11.31.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 11:31:31 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, Amit Kucheria , Zhang Rui Subject: [PATCH v3 05/12] thermal/core: Remove unneeded EXPORT_SYMBOLS Date: Sun, 3 Jul 2022 20:30:52 +0200 Message-Id: <20220703183059.4133659-6-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703183059.4133659-1-daniel.lezcano@linexp.org> References: <20220703183059.4133659-1-daniel.lezcano@linexp.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" Different functions are exporting the symbols but are actually only used by the thermal framework internals. Remove these EXPORT_SYMBOLS. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_helpers.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_he= lpers.c index 3edd047e144f..f4c1e87ef040 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -39,7 +39,6 @@ int get_tz_trend(struct thermal_zone_device *tz, int trip) =20 return trend; } -EXPORT_SYMBOL(get_tz_trend); =20 struct thermal_instance * get_thermal_instance(struct thermal_zone_device *tz, @@ -228,7 +227,6 @@ void thermal_cdev_update(struct thermal_cooling_device = *cdev) } mutex_unlock(&cdev->lock); } -EXPORT_SYMBOL(thermal_cdev_update); =20 /** * thermal_zone_get_slope - return the slope attribute of the thermal zone --=20 2.25.1 From nobody Sun Apr 19 10:42:38 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 51E88C433EF for ; Sun, 3 Jul 2022 18:31:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232824AbiGCSbt (ORCPT ); Sun, 3 Jul 2022 14:31:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232723AbiGCSbh (ORCPT ); Sun, 3 Jul 2022 14:31:37 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDE7D5580 for ; Sun, 3 Jul 2022 11:31:33 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id r81-20020a1c4454000000b003a0297a61ddso6716930wma.2 for ; Sun, 03 Jul 2022 11:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=raVjxKqEErh+B2L67+xqA5bMSQyms2haK6UW0czdPBo=; b=x3xuFSbyzWpkII3FF3+X2kRzXrRCTeSq/nism1nI8JQx0uo+wtA3nTCC91UoBd33Cz oESvVBEalCTWXvJsvUsy8YIcNeO8V2QRoqHwN058K5JIfNRH8Ozk5+iXqDVb93KRcdB5 ONmG/PNKOTOwuolb6R1CDOy5A2f1jSXGWMdI2w+UmZGA6fl0BOaIHiDGkyxzWIZmWc5r a9m/nPJfRphMYoQNn/Olo8Agt0KsNpHux/PtiBNV1EC+BC7Qv0LCavgELgZhnf3ZRQyQ UY9v4vns82XB/SIizXJ4NJIB9KBv3E5yIgU3vCGAejprMKThk1aeQL+/qQlCzPH9FhpA ozWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=raVjxKqEErh+B2L67+xqA5bMSQyms2haK6UW0czdPBo=; b=HofhU2Ef2U+8Vn6Jr+aZ5xsggiorjJfxm/E+0nQgnUfT9O4Oab4VNKOwZ3gDCQMAuF owA4Lmr9MNhSX4Nszkwykp6wAyezevGK2fbxZf18fcrmNNhdhhGkwG5PiZsOHTOaFgc3 ln9tA2kx0u/+NpakC2up1T0FrKpVnAMk80Ud0Q0BQZg1VlUx4ERuZRjzRv3Id014w61G H5HDdpMBX27oU70HZLnvamXhtki5Kzqxd87gp4aWtkU1PEV44aBTluithGehWjHsUM2y Xmz4yCPXpvXp9QxMVSkgV5XgkpJr1elYKvSoR7J94X58G1hkqArH1uFcNAcwfMML61Sn ye5w== X-Gm-Message-State: AJIora9n+gbOzV9fVqrNrbG3racUznd7s3jAf5PjjettAmhX5CDbewUO LkJGwTfdhPNZUW5h/bGZjYi8HL4b4IkqUA== X-Google-Smtp-Source: AGRyM1tUz5gLMmIs7wbe3dm4z8qkP4CmQflxr31boSetvZ6qf5tAb2zcGYWDFJ2Gd1PNCfkyjdJItA== X-Received: by 2002:a05:600c:3847:b0:3a1:db24:b7c9 with SMTP id s7-20020a05600c384700b003a1db24b7c9mr1786489wmr.24.1656873092493; Sun, 03 Jul 2022 11:31:32 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id x10-20020a5d54ca000000b0021b85664636sm27504258wrv.16.2022.07.03.11.31.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 11:31:32 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, Amit Kucheria , Zhang Rui Subject: [PATCH v3 06/12] thermal/core: Move thermal_set_delay_jiffies to static Date: Sun, 3 Jul 2022 20:30:53 +0200 Message-Id: <20220703183059.4133659-7-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703183059.4133659-1-daniel.lezcano@linexp.org> References: <20220703183059.4133659-1-daniel.lezcano@linexp.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 function 'thermal_set_delay_jiffies' is only used in thermal_core.c but it is defined and implemented in a separate file. Move the function to thermal_core.c and make it static. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano Reviewed-by: Lukasz Luba --- drivers/thermal/thermal_core.c | 7 +++++++ drivers/thermal/thermal_core.h | 1 - drivers/thermal/thermal_helpers.c | 7 ------- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index e22e7d939c54..a8b1628937c6 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1159,6 +1159,13 @@ static void bind_tz(struct thermal_zone_device *tz) mutex_unlock(&thermal_list_lock); } =20 +static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int de= lay_ms) +{ + *delay_jiffies =3D msecs_to_jiffies(delay_ms); + if (delay_ms > 1000) + *delay_jiffies =3D round_jiffies(*delay_jiffies); +} + /** * thermal_zone_device_register() - register a new thermal zone device * @type: the thermal zone device type diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 60844e2d59bb..c991bb290512 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -112,7 +112,6 @@ int thermal_build_list_of_policies(char *buf); =20 /* Helpers */ void thermal_zone_set_trips(struct thermal_zone_device *tz); -void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms); =20 /* sysfs I/F */ int thermal_zone_create_device_groups(struct thermal_zone_device *, int); diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_he= lpers.c index f4c1e87ef040..60bfda1a1db7 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -174,13 +174,6 @@ void thermal_zone_set_trips(struct thermal_zone_device= *tz) mutex_unlock(&tz->lock); } =20 -void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms) -{ - *delay_jiffies =3D msecs_to_jiffies(delay_ms); - if (delay_ms > 1000) - *delay_jiffies =3D round_jiffies(*delay_jiffies); -} - static void thermal_cdev_set_cur_state(struct thermal_cooling_device *cdev, int target) { --=20 2.25.1 From nobody Sun Apr 19 10:42:38 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 B01B0CCA473 for ; Sun, 3 Jul 2022 18:31:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232901AbiGCSb4 (ORCPT ); Sun, 3 Jul 2022 14:31:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232790AbiGCSbo (ORCPT ); Sun, 3 Jul 2022 14:31:44 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FE7A5F64 for ; Sun, 3 Jul 2022 11:31:38 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id u12-20020a05600c210c00b003a02b16d2b8so4456449wml.2 for ; Sun, 03 Jul 2022 11:31:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CTpHzS2InsEWdha/c7ASsHGBaisNa75ZXdZy4b4WI+4=; b=2EadyHsJvNm65+YS2KL+xBAk+PCF1L/e6v574Uu0YCSpIyUy4xIMBXweSnV0SZaKmE Y1kK3UhounA03x+SIaMhfLZetS+lEyxkTzd0C4HVVtH8Rg6CIf3ALkDLEgy9phsbwTuq L6wIWk5nAubGUWIATkt30EHDwJ1FUryx/lMKAO7/m/uUkIKqldYDj2pq8VYPjrjRRJKz YBHJubTCtDRMHlnjhx8q2maMcVPCGmzyQxkgnUmGiXRH49s0/TqDPB6tEsY5T56kmmkK YkZxZKftJ6kH1CcBdViYJ38kJkQ8F87WXzCe7bEO9PPgunNs1TTU3u4fevxvo4O3WcUZ ehUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CTpHzS2InsEWdha/c7ASsHGBaisNa75ZXdZy4b4WI+4=; b=WMtSKxbaiHGf0kIN5R/THyV9xnbbpw93H4Pcc04PkA6+sFw3elgSy+U+iVQBUDideQ 1srJFl5xFF8C/Qsyog/7ySvL43pNR23mYz1Xhe4MrT4DmZ+U7EeGnApQjdGHy+uylRB8 kgWK3F9RzEe9ZJ8cMjefKDDzK5lScu440g35W8HLM0hs9MV1qiD/EOXmY1UaK2t6JYrI TjTyLgwDN5DJa3QXVDfbVG1Bm1MqSIw+chholsFLCmLFCQK6c0kK85MR4kYxOmDeYACY TU40YXtcXR3AMaaEIzPkAc/n9NL6q2oP7V45urnnYeNrOzd7Xa8SG2j+J96TzdY0sRKh Ei6g== X-Gm-Message-State: AJIora+a4jp1msIhCXKMxkAuQnpehqABXMbg4WRG4Tex9tdNO+AMQ4Ph FUthAbHSO8LVOxmcF03sCTd64g== X-Google-Smtp-Source: AGRyM1tDnvOT6xrVItMTP7jF/4I+x/UzBGDrWoWaPH/ATP1N4Z/M50Q24AQj+9aIuamNWas5F4kvzQ== X-Received: by 2002:a05:600c:a42:b0:39c:9166:5a55 with SMTP id c2-20020a05600c0a4200b0039c91665a55mr26996235wmq.141.1656873097939; Sun, 03 Jul 2022 11:31:37 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id x10-20020a5d54ca000000b0021b85664636sm27504258wrv.16.2022.07.03.11.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 11:31:37 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, Amit Kucheria , Zhang Rui , Lukasz Luba , Thierry Reding , Jonathan Hunter , Dmitry Osipenko , linux-tegra@vger.kernel.org (open list:TEGRA ARCHITECTURE SUPPORT) Subject: [PATCH v3 07/12] thermal/core: Rename trips to ntrips Date: Sun, 3 Jul 2022 20:30:54 +0200 Message-Id: <20220703183059.4133659-8-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703183059.4133659-1-daniel.lezcano@linexp.org> References: <20220703183059.4133659-1-daniel.lezcano@linexp.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" In order to use thermal trips defined in the thermal structure, rename the 'trips' field to 'ntrips' to have the 'trips' field containing the thermal trip points. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/gov_fair_share.c | 6 +++--- drivers/thermal/gov_power_allocator.c | 4 ++-- drivers/thermal/tegra/tegra30-tsensor.c | 2 +- drivers/thermal/thermal_core.c | 20 ++++++++++---------- drivers/thermal/thermal_helpers.c | 4 ++-- drivers/thermal/thermal_netlink.c | 2 +- drivers/thermal/thermal_sysfs.c | 22 +++++++++++----------- include/linux/thermal.h | 2 +- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/thermal/gov_fair_share.c b/drivers/thermal/gov_fair_sh= are.c index 1e5abf4822be..5d23bb5c39ea 100644 --- a/drivers/thermal/gov_fair_share.c +++ b/drivers/thermal/gov_fair_share.c @@ -25,10 +25,10 @@ static int get_trip_level(struct thermal_zone_device *t= z) int trip_temp; enum thermal_trip_type trip_type; =20 - if (tz->trips =3D=3D 0 || !tz->ops->get_trip_temp) + if (tz->ntrips =3D=3D 0 || !tz->ops->get_trip_temp) return 0; =20 - for (count =3D 0; count < tz->trips; count++) { + for (count =3D 0; count < tz->ntrips; count++) { tz->ops->get_trip_temp(tz, count, &trip_temp); if (tz->temperature < trip_temp) break; @@ -53,7 +53,7 @@ static long get_target_state(struct thermal_zone_device *= tz, =20 cdev->ops->get_max_state(cdev, &max_state); =20 - return (long)(percentage * level * max_state) / (100 * tz->trips); + return (long)(percentage * level * max_state) / (100 * tz->ntrips); } =20 /** diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_po= wer_allocator.c index 13e375751d22..c9f4eb12b0c4 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -527,7 +527,7 @@ static void get_governor_trips(struct thermal_zone_devi= ce *tz, last_active =3D INVALID_TRIP; last_passive =3D INVALID_TRIP; =20 - for (i =3D 0; i < tz->trips; i++) { + for (i =3D 0; i < tz->ntrips; i++) { enum thermal_trip_type type; int ret; =20 @@ -668,7 +668,7 @@ static int power_allocator_bind(struct thermal_zone_dev= ice *tz) =20 get_governor_trips(tz, params); =20 - if (tz->trips > 0) { + if (tz->ntrips > 0) { ret =3D tz->ops->get_trip_temp(tz, params->trip_max_desired_temperature, &control_temp); diff --git a/drivers/thermal/tegra/tegra30-tsensor.c b/drivers/thermal/tegr= a/tegra30-tsensor.c index 9b6b693cbcf8..8ffd3dcfdb53 100644 --- a/drivers/thermal/tegra/tegra30-tsensor.c +++ b/drivers/thermal/tegra/tegra30-tsensor.c @@ -316,7 +316,7 @@ static void tegra_tsensor_get_hw_channel_trips(struct t= hermal_zone_device *tzd, *hot_trip =3D 85000; *crit_trip =3D 90000; =20 - for (i =3D 0; i < tzd->trips; i++) { + for (i =3D 0; i < tzd->ntrips; i++) { enum thermal_trip_type type; int trip_temp; =20 diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index a8b1628937c6..434a675da245 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -505,7 +505,7 @@ void thermal_zone_device_update(struct thermal_zone_dev= ice *tz, =20 tz->notify_event =3D event; =20 - for (count =3D 0; count < tz->trips; count++) + for (count =3D 0; count < tz->ntrips; count++) handle_thermal_trip(tz, count); } EXPORT_SYMBOL_GPL(thermal_zone_device_update); @@ -630,7 +630,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zon= e_device *tz, unsigned long max_state; int result, ret; =20 - if (trip >=3D tz->trips || trip < 0) + if (trip >=3D tz->ntrips || trip < 0) return -EINVAL; =20 list_for_each_entry(pos1, &thermal_tz_list, node) { @@ -811,7 +811,7 @@ static void __bind(struct thermal_zone_device *tz, int = mask, { int i, ret; =20 - for (i =3D 0; i < tz->trips; i++) { + for (i =3D 0; i < tz->ntrips; i++) { if (mask & (1 << i)) { unsigned long upper, lower; =20 @@ -1057,7 +1057,7 @@ static void __unbind(struct thermal_zone_device *tz, = int mask, { int i; =20 - for (i =3D 0; i < tz->trips; i++) + for (i =3D 0; i < tz->ntrips; i++) if (mask & (1 << i)) thermal_zone_unbind_cooling_device(tz, i, cdev); } @@ -1169,7 +1169,7 @@ static void thermal_set_delay_jiffies(unsigned long *= delay_jiffies, int delay_ms /** * thermal_zone_device_register() - register a new thermal zone device * @type: the thermal zone device type - * @trips: the number of trip points the thermal zone support + * @ntrips: the number of trip points the thermal zone support * @mask: a bit string indicating the writeablility of trip points * @devdata: private device data * @ops: standard thermal zone device callbacks @@ -1191,7 +1191,7 @@ static void thermal_set_delay_jiffies(unsigned long *= delay_jiffies, int delay_ms * IS_ERR*() helpers. */ struct thermal_zone_device * -thermal_zone_device_register(const char *type, int trips, int mask, +thermal_zone_device_register(const char *type, int ntrips, int mask, void *devdata, struct thermal_zone_device_ops *ops, struct thermal_zone_params *tzp, int passive_delay, int polling_delay) @@ -1215,7 +1215,7 @@ thermal_zone_device_register(const char *type, int tr= ips, int mask, return ERR_PTR(-EINVAL); } =20 - if (trips > THERMAL_MAX_TRIPS || trips < 0 || mask >> trips) { + if (ntrips > THERMAL_MAX_TRIPS || ntrips < 0 || mask >> ntrips) { pr_err("Incorrect number of thermal trips\n"); return ERR_PTR(-EINVAL); } @@ -1225,7 +1225,7 @@ thermal_zone_device_register(const char *type, int tr= ips, int mask, return ERR_PTR(-EINVAL); } =20 - if (trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp)) + if (ntrips > 0 && (!ops->get_trip_type || !ops->get_trip_temp)) return ERR_PTR(-EINVAL); =20 tz =3D kzalloc(sizeof(*tz), GFP_KERNEL); @@ -1255,7 +1255,7 @@ thermal_zone_device_register(const char *type, int tr= ips, int mask, tz->tzp =3D tzp; tz->device.class =3D &thermal_class; tz->devdata =3D devdata; - tz->trips =3D trips; + tz->ntrips =3D ntrips; =20 thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay); thermal_set_delay_jiffies(&tz->polling_delay_jiffies, polling_delay); @@ -1273,7 +1273,7 @@ thermal_zone_device_register(const char *type, int tr= ips, int mask, if (result) goto release_device; =20 - for (count =3D 0; count < trips; count++) { + for (count =3D 0; count < ntrips; count++) { if (tz->ops->get_trip_type(tz, count, &trip_type) || tz->ops->get_trip_temp(tz, count, &trip_temp) || !trip_temp) diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_he= lpers.c index 60bfda1a1db7..c6bb8c7638da 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -89,7 +89,7 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz,= int *temp) ret =3D tz->ops->get_temp(tz, temp); =20 if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) { - for (count =3D 0; count < tz->trips; count++) { + for (count =3D 0; count < tz->ntrips; count++) { ret =3D tz->ops->get_trip_type(tz, count, &type); if (!ret && type =3D=3D THERMAL_TRIP_CRITICAL) { ret =3D tz->ops->get_trip_temp(tz, count, @@ -137,7 +137,7 @@ void thermal_zone_set_trips(struct thermal_zone_device = *tz) if (!tz->ops->set_trips || !tz->ops->get_trip_hyst) goto exit; =20 - for (i =3D 0; i < tz->trips; i++) { + for (i =3D 0; i < tz->ntrips; i++) { int trip_low; =20 tz->ops->get_trip_temp(tz, i, &trip_temp); diff --git a/drivers/thermal/thermal_netlink.c b/drivers/thermal/thermal_ne= tlink.c index 32fea5174cc0..122552937353 100644 --- a/drivers/thermal/thermal_netlink.c +++ b/drivers/thermal/thermal_netlink.c @@ -469,7 +469,7 @@ static int thermal_genl_cmd_tz_get_trip(struct param *p) =20 mutex_lock(&tz->lock); =20 - for (i =3D 0; i < tz->trips; i++) { + for (i =3D 0; i < tz->ntrips; i++) { =20 enum thermal_trip_type type; int temp, hyst =3D 0; diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysf= s.c index 1c4aac8464a7..e12f35eee0e8 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -416,15 +416,15 @@ static int create_trip_attrs(struct thermal_zone_devi= ce *tz, int mask) int indx; =20 /* This function works only for zones with at least one trip */ - if (tz->trips <=3D 0) + if (tz->ntrips <=3D 0) return -EINVAL; =20 - tz->trip_type_attrs =3D kcalloc(tz->trips, sizeof(*tz->trip_type_attrs), + tz->trip_type_attrs =3D kcalloc(tz->ntrips, sizeof(*tz->trip_type_attrs), GFP_KERNEL); if (!tz->trip_type_attrs) return -ENOMEM; =20 - tz->trip_temp_attrs =3D kcalloc(tz->trips, sizeof(*tz->trip_temp_attrs), + tz->trip_temp_attrs =3D kcalloc(tz->ntrips, sizeof(*tz->trip_temp_attrs), GFP_KERNEL); if (!tz->trip_temp_attrs) { kfree(tz->trip_type_attrs); @@ -432,7 +432,7 @@ static int create_trip_attrs(struct thermal_zone_device= *tz, int mask) } =20 if (tz->ops->get_trip_hyst) { - tz->trip_hyst_attrs =3D kcalloc(tz->trips, + tz->trip_hyst_attrs =3D kcalloc(tz->ntrips, sizeof(*tz->trip_hyst_attrs), GFP_KERNEL); if (!tz->trip_hyst_attrs) { @@ -442,7 +442,7 @@ static int create_trip_attrs(struct thermal_zone_device= *tz, int mask) } } =20 - attrs =3D kcalloc(tz->trips * 3 + 1, sizeof(*attrs), GFP_KERNEL); + attrs =3D kcalloc(tz->ntrips * 3 + 1, sizeof(*attrs), GFP_KERNEL); if (!attrs) { kfree(tz->trip_type_attrs); kfree(tz->trip_temp_attrs); @@ -451,7 +451,7 @@ static int create_trip_attrs(struct thermal_zone_device= *tz, int mask) return -ENOMEM; } =20 - for (indx =3D 0; indx < tz->trips; indx++) { + for (indx =3D 0; indx < tz->ntrips; indx++) { /* create trip type attribute */ snprintf(tz->trip_type_attrs[indx].name, THERMAL_NAME_LENGTH, "trip_point_%d_type", indx); @@ -478,7 +478,7 @@ static int create_trip_attrs(struct thermal_zone_device= *tz, int mask) tz->trip_temp_attrs[indx].attr.store =3D trip_point_temp_store; } - attrs[indx + tz->trips] =3D &tz->trip_temp_attrs[indx].attr.attr; + attrs[indx + tz->ntrips] =3D &tz->trip_temp_attrs[indx].attr.attr; =20 /* create Optional trip hyst attribute */ if (!tz->ops->get_trip_hyst) @@ -496,10 +496,10 @@ static int create_trip_attrs(struct thermal_zone_devi= ce *tz, int mask) tz->trip_hyst_attrs[indx].attr.store =3D trip_point_hyst_store; } - attrs[indx + tz->trips * 2] =3D + attrs[indx + tz->ntrips * 2] =3D &tz->trip_hyst_attrs[indx].attr.attr; } - attrs[tz->trips * 3] =3D NULL; + attrs[tz->ntrips * 3] =3D NULL; =20 tz->trips_attribute_group.attrs =3D attrs; =20 @@ -540,7 +540,7 @@ int thermal_zone_create_device_groups(struct thermal_zo= ne_device *tz, for (i =3D 0; i < size - 2; i++) groups[i] =3D thermal_zone_attribute_groups[i]; =20 - if (tz->trips) { + if (tz->ntrips) { result =3D create_trip_attrs(tz, mask); if (result) { kfree(groups); @@ -561,7 +561,7 @@ void thermal_zone_destroy_device_groups(struct thermal_= zone_device *tz) if (!tz) return; =20 - if (tz->trips) + if (tz->ntrips) destroy_trip_attrs(tz); =20 kfree(tz->device.groups); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 6289b0bb1c97..3a57878a2a6c 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -165,7 +165,7 @@ struct thermal_zone_device { struct thermal_attr *trip_hyst_attrs; enum thermal_device_mode mode; void *devdata; - int trips; + int ntrips; unsigned long trips_disabled; /* bitmap for disabled trips */ unsigned long passive_delay_jiffies; unsigned long polling_delay_jiffies; --=20 2.25.1 From nobody Sun Apr 19 10:42:38 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 5890DC43334 for ; Sun, 3 Jul 2022 18:32:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232774AbiGCScA (ORCPT ); Sun, 3 Jul 2022 14:32:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232801AbiGCSbp (ORCPT ); Sun, 3 Jul 2022 14:31:45 -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 7704D62D4 for ; Sun, 3 Jul 2022 11:31:39 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id l68so4194849wml.3 for ; Sun, 03 Jul 2022 11:31:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ytk6hZOc5k3XFHtzqogPt/m0wTJUPnrDdEaPU5N3m1I=; b=hlAaqbH6ItL1iLN4ikMGRagc4T4JnVFXvMOzDusKYjf/mf1kJ7erKSoSVP763gF9JQ fgBnKpoSMuTDgbtxYzO3qgqJyeHupWvNoWjim22brZDIzfJw9+S7pPJy5nAcufl8h/OA DyxIznZYtNs71l1kpyhFQehkSJ2Cm41aI6TZc57t4SiyV2Qx2Qx/DqqmXCWB6HruQ5Zx ikuc66nJfKk87Tpe1rSer+Y0Wireku1mAgTl/58XdJeYk0dmLiiqW9eynxm2mFnUi6OU dcOlfdqBpzrTUBH7ch2Wd+ShssewDANeJbDgSi6i0uHUsa+27d3U5uwpkp/2iRVDhvW1 /thA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ytk6hZOc5k3XFHtzqogPt/m0wTJUPnrDdEaPU5N3m1I=; b=M+w1KVT8Fwtc/v04LSqm2DI2Zv0sw+gmf4BE8f1tllm2Y6BzNXb0oQG+MIvMD5EbPv BgxlvNLf+w6/U2oTGx61pNjjfTV4ivOTY/CWAiDajoqj291YpUXYMxdkM3u8FybNj3lG 5Ksfm+/dO3id7BCuVsIpPN57amVLBuib4yklnPTIMrKZ4vfHrp8H6G0IXofG9wlrr+rJ qI0EWybt/LWGhHczCx3HMcduD6WC4oegb/eSrUgObImo9pUPvgG/4/3oxmGY2Kyo2cxE 51vnESwgNJQKUg+suxFlAu6wPHUO2sQGYDfagD29PwYR1Lvb7ZrJk+23yNrClgfvfJoJ h5lw== X-Gm-Message-State: AJIora+oVj8bkd859/aQUkz8QgHlnWNFPdhE7Xa0LXdgFt2hoOCAnLrs 36N9tdky0vR8c5ATcadttZbXxw== X-Google-Smtp-Source: AGRyM1uL6+KaT79e11hlLOr5QXnKWuwMgKMFI1Hpw+ifJdlmHhg4BGK1vNNxZ3Sd+n2v98ew3iQwdw== X-Received: by 2002:a05:600c:3ac3:b0:3a0:45b6:7efb with SMTP id d3-20020a05600c3ac300b003a045b67efbmr28626507wms.183.1656873099008; Sun, 03 Jul 2022 11:31:39 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id x10-20020a5d54ca000000b0021b85664636sm27504258wrv.16.2022.07.03.11.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 11:31:38 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, Amit Kucheria , Zhang Rui Subject: [PATCH v3 08/12] thermal/core: Add thermal_trip in thermal_zone Date: Sun, 3 Jul 2022 20:30:55 +0200 Message-Id: <20220703183059.4133659-9-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703183059.4133659-1-daniel.lezcano@linexp.org> References: <20220703183059.4133659-1-daniel.lezcano@linexp.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 trip points are properties of a thermal zone and the different sub systems should be able to save them in the thermal zone structure instead of having their own definition. Give the opportunity to the drivers to create a thermal zone with thermal trips which will be accessible directly from the thermal core framework. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.h | 10 ++++++++++ include/linux/thermal.h | 1 + 2 files changed, 11 insertions(+) diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index c991bb290512..84e341c1e0fc 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -113,6 +113,16 @@ int thermal_build_list_of_policies(char *buf); /* Helpers */ void thermal_zone_set_trips(struct thermal_zone_device *tz); =20 +static inline struct thermal_trip *thermal_zone_get_trips(struct thermal_z= one *tz) +{ + return tz->trips; +} + +static inline int thermal_zone_get_ntrips(struct thermal_zone *tz) +{ + return tz->ntrips; +} + /* sysfs I/F */ int thermal_zone_create_device_groups(struct thermal_zone_device *, int); void thermal_zone_destroy_device_groups(struct thermal_zone_device *); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 3a57878a2a6c..3733e23b6359 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -179,6 +179,7 @@ struct thermal_zone_device { struct thermal_zone_device_ops *ops; struct thermal_zone_params *tzp; struct thermal_governor *governor; + struct thermal_trip *trips; void *governor_data; struct list_head thermal_instances; struct ida ida; --=20 2.25.1 From nobody Sun Apr 19 10:42:38 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 01B2DC43334 for ; Sun, 3 Jul 2022 18:32:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232926AbiGCScE (ORCPT ); Sun, 3 Jul 2022 14:32:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232827AbiGCSbx (ORCPT ); Sun, 3 Jul 2022 14:31:53 -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 78DC962D7 for ; Sun, 3 Jul 2022 11:31:40 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id r14so4636736wrg.1 for ; Sun, 03 Jul 2022 11:31:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i9mswFSfgMMM6ctVTcRkTgkPmngepr2InY7YT4YdepQ=; b=yoQeAMMTd8L47frAw4UAzn/FQT7aw8xf/eMgJ/708OBhtdQYEB4Rrj+E1aCUTl7wMb 6lSJrTiOZEGR1W3e1vkdHIqz1TX+xqDHjdqWnyweTKZBqRcyrw48sRSEPd6OKGXQoXPG EYgJvfIiyATP/eiOQSC5tWRzCDevFEHPfr4L+CTE+Pn88SzFxjsbcFy4+EK1Neq8iQH6 wRMtSz7+T5gkI3cXYDCoAlTI6mWJTckwZoF6L1DJVU/xY8r9XxrGyS7Je3m+gh5ek1yv I5X3Fuc3fjH6PvQZVTLBCoHdJ5OmQteTdov/vDk5aFV3sN89bk+6iTyEwURZkmYv8z4b a1og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i9mswFSfgMMM6ctVTcRkTgkPmngepr2InY7YT4YdepQ=; b=MUF74PvgU3JIMxMT3yEO2hwOkvR8kC2KIRWtDI4P0ZiMYl5L2onIQfTvw9XDNtM9F2 Vmqe6v5Sp31ViSRNqImA8msgArd0PoCEneHOZI2HaytIJ18vvB7l5awemKzknWXRseHz YAR/gGXtLAMEVzjXyQYRCIBhZHDqL1MJRAbkxvHs0+5jz8Puqk7Ji+rqIoSh1+ZmUcKd R7rocIP3h9esSOyBvXnQ8f8V+CPAFfTKE3Bj2RWDvpP3VmcOlHfTPt77NSRbtDWmx5oK Ak1J7gdjJcv6I0oFinTD8xGod8ZsI90H/xz+YCLeMMZWL8KmJuhGN3kFdceN0zfZKCZw 26TQ== X-Gm-Message-State: AJIora9j7a+fxV2Rdcf6m9FmkqU/jzdAjGAOGwFnMFzVmKHXfn0u1jFf DKOQZtWbn+/Uz8ZH5dAHtefCucJaG3rsuw== X-Google-Smtp-Source: AGRyM1uWq03QG4qLCjV81TKgYhFJCWXNcBZMBTYUY/AyPFu3UpZhMH/AeiJFTNnRfuvnZfQSKKjdKw== X-Received: by 2002:adf:f047:0:b0:21d:64cb:b34f with SMTP id t7-20020adff047000000b0021d64cbb34fmr4737918wro.506.1656873100103; Sun, 03 Jul 2022 11:31:40 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id x10-20020a5d54ca000000b0021b85664636sm27504258wrv.16.2022.07.03.11.31.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 11:31:39 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, Amit Kucheria , Zhang Rui Subject: [PATCH v3 09/12] thermal/core: Register with the trip points Date: Sun, 3 Jul 2022 20:30:56 +0200 Message-Id: <20220703183059.4133659-10-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703183059.4133659-1-daniel.lezcano@linexp.org> References: <20220703183059.4133659-1-daniel.lezcano@linexp.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" As we added the thermal trip points structure in the thermal zone, let's extend the thermal zone register function to have the thermal trip structures as a parameter and store it in the 'trips' field of the thermal zone structure. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 22 +++++++++++++++++----- drivers/thermal/thermal_core.h | 4 ++-- include/linux/thermal.h | 6 ++++++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 434a675da245..e865c41d2320 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1167,8 +1167,9 @@ static void thermal_set_delay_jiffies(unsigned long *= delay_jiffies, int delay_ms } =20 /** - * thermal_zone_device_register() - register a new thermal zone device + * thermal_zone_device_register_with_trips() - register a new thermal zone= device * @type: the thermal zone device type + * @trips: a pointer to an array of thermal trips * @ntrips: the number of trip points the thermal zone support * @mask: a bit string indicating the writeablility of trip points * @devdata: private device data @@ -1191,10 +1192,10 @@ static void thermal_set_delay_jiffies(unsigned long= *delay_jiffies, int delay_ms * IS_ERR*() helpers. */ struct thermal_zone_device * -thermal_zone_device_register(const char *type, int ntrips, int mask, - void *devdata, struct thermal_zone_device_ops *ops, - struct thermal_zone_params *tzp, int passive_delay, - int polling_delay) +thermal_zone_device_register_with_trips(const char *type, struct thermal_t= rip *trips, int ntrips, int mask, + void *devdata, struct thermal_zone_device_ops *ops, + struct thermal_zone_params *tzp, int passive_delay, + int polling_delay) { struct thermal_zone_device *tz; enum thermal_trip_type trip_type; @@ -1256,6 +1257,7 @@ thermal_zone_device_register(const char *type, int nt= rips, int mask, tz->device.class =3D &thermal_class; tz->devdata =3D devdata; tz->ntrips =3D ntrips; + tz->trips =3D trips; =20 thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay); thermal_set_delay_jiffies(&tz->polling_delay_jiffies, polling_delay); @@ -1331,6 +1333,16 @@ thermal_zone_device_register(const char *type, int n= trips, int mask, kfree(tz); return ERR_PTR(result); } + +struct thermal_zone_device *thermal_zone_device_register(const char *type,= int ntrips, int mask, + void *devdata, struct thermal_zone_device_ops *ops, + struct thermal_zone_params *tzp, int passive_delay, + int polling_delay) +{ + return thermal_zone_device_register_with_trips(type, NULL, ntrips, mask, + devdata, ops, tzp, + passive_delay, polling_delay); +} EXPORT_SYMBOL_GPL(thermal_zone_device_register); =20 /** diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 84e341c1e0fc..bbe3ec26d12e 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -113,12 +113,12 @@ int thermal_build_list_of_policies(char *buf); /* Helpers */ void thermal_zone_set_trips(struct thermal_zone_device *tz); =20 -static inline struct thermal_trip *thermal_zone_get_trips(struct thermal_z= one *tz) +static inline struct thermal_trip *thermal_zone_get_trips(struct thermal_z= one_device *tz) { return tz->trips; } =20 -static inline int thermal_zone_get_ntrips(struct thermal_zone *tz) +static inline int thermal_zone_get_ntrips(struct thermal_zone_device *tz) { return tz->ntrips; } diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 3733e23b6359..8cbe237a92d0 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -379,8 +379,14 @@ void devm_thermal_zone_of_sensor_unregister(struct dev= ice *dev, struct thermal_zone_device *thermal_zone_device_register(const char *, int= , int, void *, struct thermal_zone_device_ops *, struct thermal_zone_params *, int, int); + void thermal_zone_device_unregister(struct thermal_zone_device *); =20 +struct thermal_zone_device * +thermal_zone_device_register_with_trips(const char *, struct thermal_trip = *, int, int, + void *, struct thermal_zone_device_ops *, + struct thermal_zone_params *, int, int); + int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int, struct thermal_cooling_device *, unsigned long, unsigned long, --=20 2.25.1 From nobody Sun Apr 19 10:42:38 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 AD997CCA47F for ; Sun, 3 Jul 2022 18:32:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233038AbiGCScL (ORCPT ); Sun, 3 Jul 2022 14:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232844AbiGCSby (ORCPT ); Sun, 3 Jul 2022 14:31:54 -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 BD8E362F5 for ; Sun, 3 Jul 2022 11:31:42 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id l40-20020a05600c1d2800b003a18adff308so4436767wms.5 for ; Sun, 03 Jul 2022 11:31:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/isKFt1lkIfXPaTIWoygw+joVoVDkhVdKtPDc/SYGmc=; b=5zlSSXg40gmUFuNbxcAEOwBNQkHZB4kmYiGD4Bd9gCcjsWxcnjO3tEstj4MwSgnTqv Lf0Wr47+H4IhPoDtc9D6rPevNlUvmkzlA7ZuJCA4R+sWmYco2hpNxf478cGYF1BCr4yv E65msi7Y+mc9EHr/yWKAbw+njy5paJ5HYL1u6ne77h+MCBmVWwMGiajto/ZI1JgjT4R8 3XnP+Q5VZr8EbyqonSO1FhiDpcuT26NN4Is7P7aUegqGdvb28G+A55+Ljo7WlHP2sPEW 2SM2oJxkE4+vC7CkwZcI2EbR/fe7A56tObiTU2CyPPimQIMQ/eZtSZg48bkFBnEKglAo 2GJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/isKFt1lkIfXPaTIWoygw+joVoVDkhVdKtPDc/SYGmc=; b=hpWx4lH/132baR3rO/einNi5oTjxkkvXFfDSHIS3mWHrIjyYqO15/3pDAdUuTfcoXS Glx2nKVAMy1lePC2RP3KFxHw9A40WgxSFqSzxFJKgTCXIiDrUhFNlINCg9ZRFRWEhnLF c2oUSpJ34aVZx0KH+v68wcgQjW/Xlxyspd39m/jmUSY5k9NZgV6FC5gH4mSv91UGaXwB MubWlM2LG6c0dFtvsMkfEgF6g8SjhXHkqqcbg4YPwnG4Dy9unYmHDiQSLNb05QdRdPE9 Wub44UdEsiLYWCCbpYw8ckm13FzIweSX85Yz20vX1kALaaJFu2DeRSHCt7AvssH+yxkV 9+Og== X-Gm-Message-State: AJIora+sYNg1CzIubb2P+4Ag3y/pWJg9BO9BTkjnd2uOkgtiY6S5qSGY BHEmVjVxjSYPMM5zHzVU9vkt9w== X-Google-Smtp-Source: AGRyM1vAm8lGX92tqiwhEsCF2DAKJfnkdL+4nCSpCUOCudpy3LFHR9Lr32QoS33qS/w63bMxNktu8A== X-Received: by 2002:a05:600c:3553:b0:3a0:519b:4b96 with SMTP id i19-20020a05600c355300b003a0519b4b96mr26662033wmq.61.1656873101083; Sun, 03 Jul 2022 11:31:41 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id x10-20020a5d54ca000000b0021b85664636sm27504258wrv.16.2022.07.03.11.31.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 11:31:40 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, Amit Kucheria , Zhang Rui Subject: [PATCH v3 10/12] thermal/of: Store the trips in the thermal zone Date: Sun, 3 Jul 2022 20:30:57 +0200 Message-Id: <20220703183059.4133659-11-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703183059.4133659-1-daniel.lezcano@linexp.org> References: <20220703183059.4133659-1-daniel.lezcano@linexp.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" As the thermal zone contains the trip point, we can store them directly in the when registering the thermal zone. That will allow another step forward to remove the duplicate thermal zone structure we find in the thermal_of code. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 16eb18c24430..16b6b90a2390 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -1117,11 +1117,9 @@ int __init of_parse_thermal_zones(void) tzp->slope =3D tz->slope; tzp->offset =3D tz->offset; =20 - zone =3D thermal_zone_device_register(child->name, tz->ntrips, - mask, tz, - ops, tzp, - tz->passive_delay, - tz->polling_delay); + zone =3D thermal_zone_device_register_with_trips(child->name, tz->trips,= tz->ntrips, + mask, tz, ops, tzp, tz->passive_delay, + tz->polling_delay); if (IS_ERR(zone)) { pr_err("Failed to build %pOFn zone %ld\n", child, PTR_ERR(zone)); --=20 2.25.1 From nobody Sun Apr 19 10:42:38 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 802E6C43334 for ; Sun, 3 Jul 2022 18:32:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232717AbiGCScP (ORCPT ); Sun, 3 Jul 2022 14:32:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232795AbiGCSbz (ORCPT ); Sun, 3 Jul 2022 14:31:55 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B89B355B6 for ; Sun, 3 Jul 2022 11:31:43 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id z12so818162wrq.7 for ; Sun, 03 Jul 2022 11:31:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=igJaz5Xt/+d7nGudD2jGwH6ZHxfxarZoPjKAaCPJvZE=; b=0OGrfuFHbEacgs7IB/4qdSQVFUJOoB329OhFBXD8zJtblB0VPgWLRD81v8s9qKZ/1i JCBYsr9vfzoaIKTFkYNPSOWmQoSXA52MvIYZEn9GVh9piTEPbCqj+5Y+oKpA7zFhArjj rLleGOELYJfP5eyiqEZs3iFPiycMOmm5YLh1na/8X4M677Y4jvParw4MgkUJYVdrUCUD 5OOUnrIf1W9i8Ez4k3m4WROL7BSMtZog85mnAuT5nq0KF5MUP19kPKWtkLxH+dC/PcmA kFwGeIqq88kgd/iRwcImuXkz21Max3HA3eCG0t248G3BHTHIfJdvofpnAg8vLntOa4wC 3qqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=igJaz5Xt/+d7nGudD2jGwH6ZHxfxarZoPjKAaCPJvZE=; b=vX7ermh1eClxBwsjt3Ay7Y5Zl10290qn9j63H4+STCrL43o/P/CFzsl+A3lB93g3Dr Fd1aR7xBBDl8zxeu2Tye8ICBkGYTbQnnZ8qUIMQY5kumir7JInuYwbONPFnvXgTZPLmx 8LAMKjx2NK/g2s09+IGTN3PHDqrz8SKYq4qF1TbiHCMlwD6fpcc2i42SiPCm8hgYg7KE D9qbBsGvGf2JOMP8WTep2JXP6Q3pnap4lChtIw0cMk9Bg9HXTl0ehX8Nf7J3JqkFDo16 3j8g4K1VvtM+JlZOOv1FKBGKHGGDTgxrJKDPf0n5jrVEZi78/SgpZ+IgxHp+GiSaSgZ6 B2AQ== X-Gm-Message-State: AJIora9ivi4drn2m/ML8q1mnonFvRk66gguIwjJDTnGJeakBxnZ1LoHg tYfV1P9enwuH4a7fSb9M3l3Yig== X-Google-Smtp-Source: AGRyM1tIA1l3oX2jqbAbbffxhOY3rRe9LEjUbWoNiOgdFqvA0iv9jCagX04lvepV7pdbCIjSPNVqbA== X-Received: by 2002:a5d:4205:0:b0:21b:89ea:b5e3 with SMTP id n5-20020a5d4205000000b0021b89eab5e3mr21887921wrq.103.1656873102109; Sun, 03 Jul 2022 11:31:42 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id x10-20020a5d54ca000000b0021b85664636sm27504258wrv.16.2022.07.03.11.31.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 11:31:41 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, Amit Kucheria , Zhang Rui Subject: [PATCH v3 11/12] thermal/of: Use thermal trips stored in the thermal zone Date: Sun, 3 Jul 2022 20:30:58 +0200 Message-Id: <20220703183059.4133659-12-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703183059.4133659-1-daniel.lezcano@linexp.org> References: <20220703183059.4133659-1-daniel.lezcano@linexp.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" Now that we have the thermal trip stored in the thermal zone in a generic way, we can rely on them and remove one indirection we found in the thermal_of code and do one more step forward the removal of the duplicated structures. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 53 +++++++++++------------------------- 1 file changed, 16 insertions(+), 37 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 16b6b90a2390..bc885729bf23 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -118,12 +118,7 @@ static int of_thermal_set_trips(struct thermal_zone_de= vice *tz, */ int of_thermal_get_ntrips(struct thermal_zone_device *tz) { - struct __thermal_zone *data =3D tz->devdata; - - if (!data || IS_ERR(data)) - return -ENODEV; - - return data->ntrips; + return tz->ntrips; } EXPORT_SYMBOL_GPL(of_thermal_get_ntrips); =20 @@ -139,9 +134,7 @@ EXPORT_SYMBOL_GPL(of_thermal_get_ntrips); */ bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, int trip) { - struct __thermal_zone *data =3D tz->devdata; - - if (!data || trip >=3D data->ntrips || trip < 0) + if (trip >=3D tz->ntrips || trip < 0) return false; =20 return true; @@ -161,12 +154,7 @@ EXPORT_SYMBOL_GPL(of_thermal_is_trip_valid); const struct thermal_trip * of_thermal_get_trip_points(struct thermal_zone_device *tz) { - struct __thermal_zone *data =3D tz->devdata; - - if (!data) - return NULL; - - return data->trips; + return tz->trips; } EXPORT_SYMBOL_GPL(of_thermal_get_trip_points); =20 @@ -281,12 +269,10 @@ static int of_thermal_unbind(struct thermal_zone_devi= ce *thermal, static int of_thermal_get_trip_type(struct thermal_zone_device *tz, int tr= ip, enum thermal_trip_type *type) { - struct __thermal_zone *data =3D tz->devdata; - - if (trip >=3D data->ntrips || trip < 0) + if (trip >=3D tz->ntrips || trip < 0) return -EDOM; =20 - *type =3D data->trips[trip].type; + *type =3D tz->trips[trip].type; =20 return 0; } @@ -294,12 +280,10 @@ static int of_thermal_get_trip_type(struct thermal_zo= ne_device *tz, int trip, static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int tr= ip, int *temp) { - struct __thermal_zone *data =3D tz->devdata; - - if (trip >=3D data->ntrips || trip < 0) + if (trip >=3D tz->ntrips || trip < 0) return -EDOM; =20 - *temp =3D data->trips[trip].temperature; + *temp =3D tz->trips[trip].temperature; =20 return 0; } @@ -309,7 +293,7 @@ static int of_thermal_set_trip_temp(struct thermal_zone= _device *tz, int trip, { struct __thermal_zone *data =3D tz->devdata; =20 - if (trip >=3D data->ntrips || trip < 0) + if (trip >=3D tz->ntrips || trip < 0) return -EDOM; =20 if (data->ops && data->ops->set_trip_temp) { @@ -321,7 +305,7 @@ static int of_thermal_set_trip_temp(struct thermal_zone= _device *tz, int trip, } =20 /* thermal framework should take care of data->mask & (1 << trip) */ - data->trips[trip].temperature =3D temp; + tz->trips[trip].temperature =3D temp; =20 return 0; } @@ -329,12 +313,10 @@ static int of_thermal_set_trip_temp(struct thermal_zo= ne_device *tz, int trip, static int of_thermal_get_trip_hyst(struct thermal_zone_device *tz, int tr= ip, int *hyst) { - struct __thermal_zone *data =3D tz->devdata; - - if (trip >=3D data->ntrips || trip < 0) + if (trip >=3D tz->ntrips || trip < 0) return -EDOM; =20 - *hyst =3D data->trips[trip].hysteresis; + *hyst =3D tz->trips[trip].hysteresis; =20 return 0; } @@ -342,13 +324,11 @@ static int of_thermal_get_trip_hyst(struct thermal_zo= ne_device *tz, int trip, static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int tr= ip, int hyst) { - struct __thermal_zone *data =3D tz->devdata; - - if (trip >=3D data->ntrips || trip < 0) + if (trip >=3D tz->ntrips || trip < 0) return -EDOM; =20 /* thermal framework should take care of data->mask & (1 << trip) */ - data->trips[trip].hysteresis =3D hyst; + tz->trips[trip].hysteresis =3D hyst; =20 return 0; } @@ -356,12 +336,11 @@ static int of_thermal_set_trip_hyst(struct thermal_zo= ne_device *tz, int trip, static int of_thermal_get_crit_temp(struct thermal_zone_device *tz, int *temp) { - struct __thermal_zone *data =3D tz->devdata; int i; =20 - for (i =3D 0; i < data->ntrips; i++) - if (data->trips[i].type =3D=3D THERMAL_TRIP_CRITICAL) { - *temp =3D data->trips[i].temperature; + for (i =3D 0; i < tz->ntrips; i++) + if (tz->trips[i].type =3D=3D THERMAL_TRIP_CRITICAL) { + *temp =3D tz->trips[i].temperature; return 0; } =20 --=20 2.25.1 From nobody Sun Apr 19 10:42:38 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 A186EC43334 for ; Sun, 3 Jul 2022 18:32:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232938AbiGCScR (ORCPT ); Sun, 3 Jul 2022 14:32:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232896AbiGCSb4 (ORCPT ); Sun, 3 Jul 2022 14:31:56 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CABEA3898 for ; Sun, 3 Jul 2022 11:31:44 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id m184so4210991wme.1 for ; Sun, 03 Jul 2022 11:31:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Jk6Zu7YOAs+Rffq4qnY/9T9F1YET7fLb3BWny63zQyY=; b=zvNljsfyutvIHJIr7s846lTOdo7lNtsV8c+P0ET1m9aaS5dlkvKqLYpMfJPqfiE38P H4m34iPtH2mI9JqinWXmdSMfUntxvX26Ux60ejkdYrfQ9gNoRHTxBz82u903+rLF7yxT IitBnc3i92NGCrZ7+Tfv0tliLHcUVRr+dn8KQExFqhSFPsa8eEnMsHnzO+MulZMk3BFc 18OyWW7QisXop8xvlNlWkaxr7q/3IrykERPUiK5GwrCo6CQ5thymB/0+W5f3eDS6DtZp h+eqQvBV44qNP3KghJhNYinq4xvuhu0qe9wlu5eRkgUE0dvydIEELHNaXW/y+kTMvbaH Qjlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jk6Zu7YOAs+Rffq4qnY/9T9F1YET7fLb3BWny63zQyY=; b=4nXBKG3X7REhsd/IyYNXHg0C8kIIJXqE4JZqcvCl3jnpiLStAdNhLqyqJOZ2uo8gKP P6E+E92kPYMn7SwnfjCvnyS61mbDu2/nIF+jldKPFsYba+e3wnKDxG/q9x3fCw/8kOlM 2F4PVRVHmOttRFT14GwlpK51lYkrDTltx0yUdpUvk2nAK8xVpRotaGMgnaL2F5nKk8Zl qmIl2rb9+WOgBjmFV2M68YOKaIDxu/GnssW5LS+DQ4VMoFC6c8HhEbokDF1Tusr9brW+ v3O11yF+hEJStXPkp5UM0gni36Cqj9WrRkK0KLXz5CFoSMxXE8Lmok1kXB7q6t3WhY+1 91tA== X-Gm-Message-State: AJIora9zbQyE11RvO/vKhImmarWjHAV5K4BMDNHhGTelc7Lh9vM+/38z bMmk2Hhjww9MfwocXce237w+8g== X-Google-Smtp-Source: AGRyM1tIj4RTXx38KKeGaCcnVNxP0RuWB2ivIFi83e6UE58tH/+iDzqJowtMdqRA/bbFkFfZy8dcBg== X-Received: by 2002:a05:600c:154f:b0:3a0:54f9:4388 with SMTP id f15-20020a05600c154f00b003a054f94388mr26423001wmg.16.1656873103107; Sun, 03 Jul 2022 11:31:43 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id x10-20020a5d54ca000000b0021b85664636sm27504258wrv.16.2022.07.03.11.31.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 11:31:42 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, Amit Kucheria , Zhang Rui Subject: [PATCH v3 12/12] thermal/of: Initialize trip points separately Date: Sun, 3 Jul 2022 20:30:59 +0200 Message-Id: <20220703183059.4133659-13-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703183059.4133659-1-daniel.lezcano@linexp.org> References: <20220703183059.4133659-1-daniel.lezcano@linexp.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" Self contain the trip initialization from the device tree in a single function for the sake of making the code flow more clear. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 84 ++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 27 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index bc885729bf23..1aa52df507b6 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -693,7 +693,8 @@ static int of_find_trip_id(struct device_node *np, stru= ct device_node *trip) * * Return: 0 on success, proper error code otherwise */ -static int thermal_of_populate_bind_params(struct device_node *np, +static int thermal_of_populate_bind_params(struct device_node *tz_np, + struct device_node *np, struct __thermal_bind_params *__tbp) { struct of_phandle_args cooling_spec; @@ -715,7 +716,7 @@ static int thermal_of_populate_bind_params(struct devic= e_node *np, return -ENODEV; } =20 - trip_id =3D of_find_trip_id(np, trip); + trip_id =3D of_find_trip_id(tz_np, trip); if (trip_id < 0) { ret =3D trip_id; goto end; @@ -849,6 +850,53 @@ static int thermal_of_populate_trip(struct device_node= *np, return 0; } =20 +static struct thermal_trip *thermal_of_trips_init(struct device_node *np, = int *ntrips) +{ + struct thermal_trip *tt; + struct device_node *trips, *trip; + int ret, count; + + trips =3D of_get_child_by_name(np, "trips"); + if (!trips) { + pr_err("Failed to find 'trips' node\n"); + return ERR_PTR(-EINVAL); + } + + count =3D of_get_child_count(trips); + if (!count) { + pr_err("No trip point defined\n"); + ret =3D -EINVAL; + goto out_of_node_put; + } + + tt =3D kzalloc(sizeof(*tt) * count, GFP_KERNEL); + if (!tt) { + ret =3D -ENOMEM; + goto out_of_node_put; + } + + *ntrips =3D count; + + count =3D 0; + for_each_child_of_node(trips, trip) { + ret =3D thermal_of_populate_trip(trip, &tt[count++]); + if (ret) + goto out_kfree; + } + + of_node_put(trips); +=09 + return tt; +=09 +out_kfree: + kfree(tt); + *ntrips =3D 0; +out_of_node_put: + of_node_put(trips); + + return ERR_PTR(ret); +} + /** * thermal_of_build_thermal_zone - parse and fill one thermal zone data * @np: DT node containing a thermal zone node @@ -867,7 +915,6 @@ static struct __thermal_zone __init *thermal_of_build_thermal_zone(struct device_node *np) { struct device_node *child =3D NULL, *gchild; - struct device_node *trips; struct __thermal_zone *tz; int ret, i; u32 prop, coef[2]; @@ -909,28 +956,10 @@ __init *thermal_of_build_thermal_zone(struct device_n= ode *np) tz->offset =3D 0; } =20 - /* trips */ - trips =3D of_get_child_by_name(np, "trips"); - - /* No trips provided */ - if (!trips) - goto finish; - - tz->ntrips =3D of_get_child_count(trips); - if (tz->ntrips =3D=3D 0) /* must have at least one child */ + tz->trips =3D thermal_of_trips_init(np, &tz->ntrips); + if (IS_ERR(tz->trips)) { + ret =3D PTR_ERR(tz->trips); goto finish; - - tz->trips =3D kcalloc(tz->ntrips, sizeof(*tz->trips), GFP_KERNEL); - if (!tz->trips) { - ret =3D -ENOMEM; - goto free_tz; - } - - i =3D 0; - for_each_child_of_node(trips, gchild) { - ret =3D thermal_of_populate_trip(gchild, &tz->trips[i++]); - if (ret) - goto free_trips; } =20 /* cooling-maps */ @@ -952,9 +981,11 @@ __init *thermal_of_build_thermal_zone(struct device_no= de *np) =20 i =3D 0; for_each_child_of_node(child, gchild) { - ret =3D thermal_of_populate_bind_params(gchild, &tz->tbps[i++]); - if (ret) + ret =3D thermal_of_populate_bind_params(np, gchild, &tz->tbps[i++]); + if (ret) { + of_node_put(gchild); goto free_tbps; + } } =20 finish: @@ -976,7 +1007,6 @@ __init *thermal_of_build_thermal_zone(struct device_no= de *np) kfree(tz->tbps); free_trips: kfree(tz->trips); - of_node_put(gchild); free_tz: kfree(tz); of_node_put(child); --=20 2.25.1