From nobody Sat Apr 18 21:01: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 90061CCA479 for ; Sun, 10 Jul 2022 12:35:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229537AbiGJMf2 (ORCPT ); Sun, 10 Jul 2022 08:35:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbiGJMfU (ORCPT ); Sun, 10 Jul 2022 08:35:20 -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 D85BB11149 for ; Sun, 10 Jul 2022 05:35:18 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id d13-20020a05600c34cd00b003a2dc1cf0b4so1602367wmq.4 for ; Sun, 10 Jul 2022 05:35:18 -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=7UKKS5f7QbJpxlk+iXwxbcq70b7aqG7EJc4B5ZEy8YU=; b=By6v5r10L/lAATCEtUvIN9UyTUj23D9ixh8xCslWB5BV4bBLKCf97tNmLKl4p2J5Vj 6kpafYxSKNlwzHLzVTbGj5p9xVzVDeygR3U5xP3mfFDtVP2BEGhbElywcAu5HrgbS7xC 8D4h3P6DiI3v6claR6LLrOpL7js65S+5276sT/9nCckLsoyVigewZxD0QfmOW349joJs OYb58loCAq1/W6MR/TJ3OpVCRjWQZRGIq28GyyF/F3Hy1UvOBDayNJEZyHWPFLKyEsTL CgcAL6HZ62dwAUHAAFMYwVRBxae6s5xfkJb6kJSadQev7yRRo2UtztdnTNaQ49k/LW6+ tmOg== 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=7UKKS5f7QbJpxlk+iXwxbcq70b7aqG7EJc4B5ZEy8YU=; b=ZLZKII17Qkc9Vxj7vMhAgiF1vCuECMi5X64j9fwWjAFSXIbFo8CG6nLasLYJVxZIeV +tf7JZrk539i6pcdMt8vxxMuTOwOFkeNepNHMnK36cJe46IQCgWutc16ILFP0L3o/NLw cufjeRzZKl1sAgggsxhpGwBEib9CgF1YwXL46KIbmeGAEwVh50YGv6iKmkG9A940N9yl SsBxSFAoDavoLXTy9paX7ia4aG8yNW48prEqDoDyBpbZfolZ4NCLN2dNy+z9PA6OlAxK DddC/ebm9Rtc4lb/mFMih/p7Pf2UWUB9UgmMTXUxFJxzIhVCBWuBY06rZnz9gssuDlBB K7gA== X-Gm-Message-State: AJIora90ylGyT2I7LGUtZ0JoqWLm0lfnYasTZ5uhb3BZfWRWhSTydkOc sWFxUVbe24RlAzj3aOJBSJtBi6FWj73XBA== X-Google-Smtp-Source: AGRyM1tHDEsVQduYimH8r3NljPB+Kato4ADWXh8GoJ/14eVbkAq2Q7IoN4V9CC1Ml0PyvstWVl8nCw== X-Received: by 2002:a05:600c:34c2:b0:3a0:5439:1f with SMTP id d2-20020a05600c34c200b003a05439001fmr9960836wmq.179.1657456517482; Sun, 10 Jul 2022 05:35:17 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id 24-20020a05600c22d800b003a0375c4f73sm3775144wmg.44.2022.07.10.05.35.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 05:35:17 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, lukasz.luba@arm.com, Amit Kucheria Subject: [PATCH v5 01/12] thermal/core: Remove duplicate information when an error occurs Date: Sun, 10 Jul 2022 14:35:00 +0200 Message-Id: <20220710123512.1714714-2-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710123512.1714714-1-daniel.lezcano@linexp.org> References: <20220710123512.1714714-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 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 Sat Apr 18 21:01: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 69980C43334 for ; Sun, 10 Jul 2022 12:35:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229661AbiGJMfb (ORCPT ); Sun, 10 Jul 2022 08:35:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbiGJMfU (ORCPT ); Sun, 10 Jul 2022 08:35:20 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0C9011156 for ; Sun, 10 Jul 2022 05:35:19 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id h17so3892392wrx.0 for ; Sun, 10 Jul 2022 05:35:19 -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=gJpp/3sovrJilbrJccW08MiNpRgjzFnvxf+q+uGsrtg=; b=fdOU0j/PkCW1L5PFaEZiU2JGHBNKlxN+fzzi9T/M0rCMEj4wee+7IBaum4CywN8L91 UFuWh2c9YQb3pwAkW0DrNNb+RD0x/Uh9ImHuKzaAkwsyASduhb8XaLOkdg2OGNJGyA2H dY5MzdDl2rUsK/fY3XOrk2aVckzSn+x0sz1+V+Vqcd52KN23j7x/fiPFB2RgJKuinQ1X 6mL3ijG48R7A/b3Wb1YQAVaQ67XQk6NHrp4DIial9YxdUYhCI6lJA1/VsdiUrBttPT/5 YxeGLx5hGNGATI9su6/XRSJfhrF5x1k9h5hT2Nms1VlBFmHayo9EA+C0TMBH+mLmELeh 3OGA== 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=gJpp/3sovrJilbrJccW08MiNpRgjzFnvxf+q+uGsrtg=; b=2T5NilRML15oyHn+hoNDJ+TqJbc2tjtOa1DWMgo6Gj8aBVqOq0LzIi/e44SxAy2vGT TpqJsheTx9b2uG91S+38SnEAudba2RcRWjGb1h21PPVVtv194ZAI4KJW7cbY0S/5F3eZ bVxX0c3yI2lCZas5DcqRYY1fij4dEdnnJgWV0Yt44JgkwRguvWFiaQsteoaSZiIUy5sT MunEmV22a1WmdeH1xAhCqzOLmIKrrEWivdIuG7l0DrgDDHhqsDJtZacvzJM9AFhasrLA xth+9VB8E6zvroHOagW35nCp2aPWFpem82XDyMu7u1PuYqMWwYLUC2ZhIa+kNMuM6hU0 d0/Q== X-Gm-Message-State: AJIora+f6kzUDhT8e3vvw3MKoxgCLyGY9w/kV8NbiHqSNfx2uQnkD4z1 tXwAvbiA0jTuTNpe0M4tro8wXC9GWKsgfQ== X-Google-Smtp-Source: AGRyM1uav6+HaNd6GpsrfJAcqzoVS+TYxgiPl0vSM4JhuNgl8trKCXrlepwNlq9027f4agbjqnQCeA== X-Received: by 2002:adf:e187:0:b0:21d:64c6:74f0 with SMTP id az7-20020adfe187000000b0021d64c674f0mr12099785wrb.221.1657456518495; Sun, 10 Jul 2022 05:35:18 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id 24-20020a05600c22d800b003a0375c4f73sm3775144wmg.44.2022.07.10.05.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 05:35:18 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, lukasz.luba@arm.com, Amit Kucheria Subject: [PATCH v5 02/12] thermal/of: Replace device node match with device node search Date: Sun, 10 Jul 2022 14:35:01 +0200 Message-Id: <20220710123512.1714714-3-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710123512.1714714-1-daniel.lezcano@linexp.org> References: <20220710123512.1714714-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 Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 64 +++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index b65d435cb92f..7d96494ef94d 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,13 +977,13 @@ __init *thermal_of_build_thermal_zone(struct device_n= ode *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 finish: + of_node_put(trips); of_node_put(child); =20 return tz; @@ -981,6 +1004,7 @@ __init *thermal_of_build_thermal_zone(struct device_no= de *np) for (i =3D 0; i < tz->ntrips; i++) of_node_put(tz->trips[i].np); kfree(tz->trips); + of_node_put(trips); of_node_put(gchild); free_tz: kfree(tz); --=20 2.25.1 From nobody Sat Apr 18 21:01: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 3E26AC433EF for ; Sun, 10 Jul 2022 12:35:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229686AbiGJMfj (ORCPT ); Sun, 10 Jul 2022 08:35:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229616AbiGJMfX (ORCPT ); Sun, 10 Jul 2022 08:35:23 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0106E1115B for ; Sun, 10 Jul 2022 05:35:21 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id p4so1669395wms.0 for ; Sun, 10 Jul 2022 05:35:20 -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=TKRi+GmwXFnPZbvdKLtGDHFP5gB36/7lKJQI47b4ftU=; b=7FZC1XlwUeCjZH8ZSvIznIq5ec/4ZvJN7n3SWjDc+mViL4KDlcjnIgSL5NworU/YCS 6+zFq1odwL3lW3NA013zSGPEgqj33JKyMSSSF1doHNmeqTiXCy482kR5uFxqqLShC5bE GuHvCdAH8dfDEX3tA5WRb7K6L+zrhI6O4krhUc1+zafZg9YrHPLzK+BVkRvBjeAox+SI IrOX6p92xYyDEye2WlQyCPkESExe21CHv17CXpvlTHWwtyzOirCVezhrP7i2lo7zvCvV QYk2skX+WGcFrDdR5YbgCgeqjLNSks9UqQemtj7Sm/x3JYHagq4p9lrXcp+rAWNUMl73 OZBA== 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=TKRi+GmwXFnPZbvdKLtGDHFP5gB36/7lKJQI47b4ftU=; b=pV7CigYIfECDvvQ3xORIlZsGUWkznbD6srcPdUTadVIlrmtkaKxAV4iHKqaqMAl6IS yEnRECErPthFUd8ly01fcPtAFnIJkbqhGbHizLrfqKpRV9AciC1bFaravPBYXa7Xf9nJ KEOdSQPBkmalQNg59ojbiqoQ8oiW5VDAMlaZgE0X8hi+CpUwofqfv5Anm9QzCThqzR3/ GnbJhIDWS2lg+iLyelIX70u8ftuUOft1azNtZMRkP7+wQ2tPDDLEfp47ALxia2fGIyyJ J4sE0ZFBSU9hg7Te08G3cB29nnfHdrwmHxBqa8pA4vRe/AtB3HZDnpM55ddHCpL68C1w sp3w== X-Gm-Message-State: AJIora88jYm8BjZ+Tu6y7mw5JIIe48obqYVOTtvwDj7w9lUkb9NEqr3e ZxlVN1GHQas6SSSCRqv18mVm/A== X-Google-Smtp-Source: AGRyM1tpONmqIRY5diePpBSQza27Ip45mxPB+Syk8AvH+Sa8dpOESdi0d3FCZKpamr1oEnU7vJXICw== X-Received: by 2002:a05:600c:1e20:b0:3a2:e540:17ad with SMTP id ay32-20020a05600c1e2000b003a2e54017admr2751595wmb.205.1657456519575; Sun, 10 Jul 2022 05:35:19 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id 24-20020a05600c22d800b003a0375c4f73sm3775144wmg.44.2022.07.10.05.35.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 05:35:19 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, lukasz.luba@arm.com, Amit Kucheria Subject: [PATCH v5 03/12] thermal/of: Remove the device node pointer for thermal_trip Date: Sun, 10 Jul 2022 14:35:02 +0200 Message-Id: <20220710123512.1714714-4-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710123512.1714714-1-daniel.lezcano@linexp.org> References: <20220710123512.1714714-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 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 7d96494ef94d..19243c57b3f4 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 @@ -1001,8 +997,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(trips); of_node_put(gchild); @@ -1028,8 +1022,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 Sat Apr 18 21:01: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 3DCB1C433EF for ; Sun, 10 Jul 2022 12:35:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229674AbiGJMfg (ORCPT ); Sun, 10 Jul 2022 08:35:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229628AbiGJMfX (ORCPT ); Sun, 10 Jul 2022 08:35:23 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A77F1114C for ; Sun, 10 Jul 2022 05:35:22 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id n10so3848272wrc.4 for ; Sun, 10 Jul 2022 05:35:21 -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=2Cg8NIEv3M0ZsrQ6LuqyJLiJb25T+jZLIiP7PzCJ4Cg=; b=2tR83h0EGCkoEv7T2lFxnCY/aeBlHG41RKBSE4YTvKcawRtlPIjRh5M7W4XlVGevic iXa7QvAM0csp2vl+ruQGWPSoKDWIeRMJI6u8X73oMHTUcPdRWaEPD2kfx+oYciOqdtmZ kHFWzqvkIM4qtJF4MzrSjVMdjfxFl30HrRsNf8h3ibsGrYgmBDV3FYukDki+DlllaJlF 450miA1mwl/uJNuyHDMK8UUUIwf/laLUzGtFHTnbhc/IBtPaKdPQgqBkqNX4JIr62q3P xbQfMJ/b21qH7qL6UFCRnlwPi7jRVUOBIm9cMMDFuo1NDd0lD+7oRoOV5E3uOhoLrtCG +C+w== 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=2Cg8NIEv3M0ZsrQ6LuqyJLiJb25T+jZLIiP7PzCJ4Cg=; b=gkLsiMGMljESC6mhXPbl1m0/WDGKWZroJN1o5cHjgLgma1c1yXasKOne9du4a6jxMJ A1E+ra4ywtqe+czKinBZaL1y2C36TmZsuoWhp3tPJWeKPNDBbQAExTz+FIAVYdXDx9q+ 7oq1XmPxNEB95s4dlvjl2Qs4xu6JDj5RppnC5iDRXmz0k3jCvRRJklr67xjrlen/lViv NhNmbpzlI1hHpCVAr6a08WAUbS8cvVneKPFloWz37scAQWytm/4v4E9XmglZxFtPBuWn SM028FPhtHxGfVpe7wXyKiIq33zQ8toEYQ8bUYjzFT1PcwKPr0Cn5FDnutssn1/XD1pp Z43A== X-Gm-Message-State: AJIora/Qcf+AXrOJSbC/sn4wrOabMN0+4E7Fz3MhuyWlO7OPJh0P3BGV onBu4IBS2mleY+II+ny3zita0w== X-Google-Smtp-Source: AGRyM1sobN42PnLDSkquBXU5EqHk/Cwh2Bjpol+3ULi79i2Hv1oY7VLhc40TjaJsegxcH16grgMeGg== X-Received: by 2002:adf:fb03:0:b0:21d:70cb:d6b5 with SMTP id c3-20020adffb03000000b0021d70cbd6b5mr11900872wrr.548.1657456520668; Sun, 10 Jul 2022 05:35:20 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id 24-20020a05600c22d800b003a0375c4f73sm3775144wmg.44.2022.07.10.05.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 05:35:20 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, lukasz.luba@arm.com, Amit Kucheria Subject: [PATCH v5 04/12] thermal/of: Move thermal_trip structure to thermal.h Date: Sun, 10 Jul 2022 14:35:03 +0200 Message-Id: <20220710123512.1714714-5-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710123512.1714714-1-daniel.lezcano@linexp.org> References: <20220710123512.1714714-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 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 Sat Apr 18 21:01: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 182FEC43334 for ; Sun, 10 Jul 2022 12:35:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229648AbiGJMfl (ORCPT ); Sun, 10 Jul 2022 08:35:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbiGJMfY (ORCPT ); Sun, 10 Jul 2022 08:35:24 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3123B1115F for ; Sun, 10 Jul 2022 05:35:23 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id bi22-20020a05600c3d9600b003a04de22ab6so1612662wmb.1 for ; Sun, 10 Jul 2022 05:35:23 -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=K+KDnyI1rYWiKYKY6BfUNrB+RXhqQv2REJcaYGxminc=; b=cIeFBig7IbdxtGrb61XbNxVA+j6A2T94DM8apK+8AkboXuzK4lBJQ30jOJQDQVZhYA dFvBkspS+X1eTk37AGMH65QuEITTbvoKPpRlousVXsQ1AB8i+0jM1h4ZEnYCeO6A4KVy SN5UvB4ciPgJpL3ITaGMH7J+iiSFHZYhIjOwFRO2zCYO/K3SLVHPiOVC4glsoXPKo4Aa N8o8ozXpt14eaWWuNd6l6MM5pmDxrQg3YuPbD+gSYpe1FKSr+y0yams6lQJVhoey6wIX 3F3ULBfZ+4ARYiIq9IL7sCkwpqcBu1fGFAvZZTVMBEkFtomO24r/I4WdQmrZC+VrHshU TG7w== 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=K+KDnyI1rYWiKYKY6BfUNrB+RXhqQv2REJcaYGxminc=; b=hex65rwer6VKAkP+sAohfwYJyhKAKEdnuBPCewa7Y3+7mPCIhLUKlOotOwXNdFPflY r9PRHaoP3rIKqm+1cK5gZ+7J0z5ZiCneqRewz2z3QuZeslwZvZc9owL/36A3yS+t28yA zNW7pRwLWb/yzHpkjc0F16UN4utGpGwq6HDLI4qHAiZKp+J5aYM4q4vowxI7UmKUF3o/ 9W1Tr1IcAAEmpMYHTQDVwSUX2ysgh8fQW0HSNtXLdK1DZ0Y+4umgSH0nrT8FdCqxc7bw j9HYPa23vHh9/Z8OIgs1iK3XiNXJHmFHXk++ED94AFzEBEpuIEvhNXrpYwytzCXLPdFl fCqQ== X-Gm-Message-State: AJIora9T84ClXqxEL3NvCoRO4uWXxnBUwgoJsurhB7pwqb1pqpFDdS8s q1oQpacmtzAzd74qPnJFo1q3+g== X-Google-Smtp-Source: AGRyM1sSHBD5IryGyIIB5s/pP/i+ITi3z5Ljl+3aEfpZ15MxZROK6TaAMG73DQcVAnTrTEz286IOdQ== X-Received: by 2002:a05:600c:48a:b0:3a2:ce31:a150 with SMTP id d10-20020a05600c048a00b003a2ce31a150mr10100680wme.48.1657456521656; Sun, 10 Jul 2022 05:35:21 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id 24-20020a05600c22d800b003a0375c4f73sm3775144wmg.44.2022.07.10.05.35.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 05:35:21 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, lukasz.luba@arm.com, Amit Kucheria Subject: [PATCH v5 05/12] thermal/core: Remove unneeded EXPORT_SYMBOLS Date: Sun, 10 Jul 2022 14:35:04 +0200 Message-Id: <20220710123512.1714714-6-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710123512.1714714-1-daniel.lezcano@linexp.org> References: <20220710123512.1714714-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 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 Sat Apr 18 21:01: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 572A5C433EF for ; Sun, 10 Jul 2022 12:35:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229706AbiGJMfo (ORCPT ); Sun, 10 Jul 2022 08:35:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbiGJMf0 (ORCPT ); Sun, 10 Jul 2022 08:35:26 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 688C311149 for ; Sun, 10 Jul 2022 05:35:24 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id bu1so2663751wrb.9 for ; Sun, 10 Jul 2022 05:35:24 -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=m3yHMzkH3fXgNxlTdZV4uJD5eQrxfqVqNnQSzgsUY+c=; b=AG5Aeg1i4xpol5tYCRBHi0DuekQfrGEhQW5qbA7/mVmHGUBKGpw10dbzKth/aTBwqZ msjntrnvTHLVJG8wxG2J5mZtGLEtR3cDt1mX/9wbg0gUFyAmIg900ZofBBy1ye5CPNyi yKugL9uCLEoLBlWTdrTjMViwCS9UMP0WDnGwB9kRnqC/S3eOewzpZPEDJM22+Xf/wMlZ tsJ/6ZgCuDBbhC95h+r01ft1xlvtkAv81KegwANYiqRrhXwnF1fCOHoVEGHqrzNW4Vpt qHUhP1/BHpzMpNfLxdgVZNuiS1t9It8rIfsdlngua8vuHAa0wF3XNCYGJXuaD3rP+ahf 4V0Q== 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=m3yHMzkH3fXgNxlTdZV4uJD5eQrxfqVqNnQSzgsUY+c=; b=8GPoUYgMYEdPIcIcumvBGMwrZHX8Ih6iIahimrp39vHGdNDFi0k2H5AJXJ4TZmew9Z 9NUtM1+mLMO2R8WDJToSU1UGn76DnNVnRWwpRuCDs0g05ahdFiCd4Yfn+PXXEpwnpuyv 3Jnf5RewAfaXA0/2dy5NON7PpPC8cp6mY+6JDnJ8uCUzthM5k3CPoCJo7+wTswB6ErYt 49LtlA5FP+v0/4/OBfws5g4h9PFMHNCNh2ovroovJk9we1myB5U4yuquscYDDPMk4Zhk K4xM8QFmL3z63oXVyWZWEPcZGGWV2cxW3BzRrq29XEdjjL/yc5loZDuTRfgN5Lk+wee9 FatQ== X-Gm-Message-State: AJIora+usRdCow40N7xjwfg23BFwe3CeEv/ZzGCVpb9NdNCXjEcjsjH6 Uow1F1kdaRO9fJcRHTLwYyC+cg== X-Google-Smtp-Source: AGRyM1syzMQfXfRQaCMlytjrjGSsDLhKazLv0upf+0JBK63RmutM2pjSbNm1WJKaHPjJwMhfujb5tA== X-Received: by 2002:a5d:428d:0:b0:21d:7ee2:8f9e with SMTP id k13-20020a5d428d000000b0021d7ee28f9emr11842880wrq.145.1657456522781; Sun, 10 Jul 2022 05:35:22 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id 24-20020a05600c22d800b003a0375c4f73sm3775144wmg.44.2022.07.10.05.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 05:35:22 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, lukasz.luba@arm.com, Amit Kucheria Subject: [PATCH v5 06/12] thermal/core: Move thermal_set_delay_jiffies to static Date: Sun, 10 Jul 2022 14:35:05 +0200 Message-Id: <20220710123512.1714714-7-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710123512.1714714-1-daniel.lezcano@linexp.org> References: <20220710123512.1714714-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 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 Sat Apr 18 21:01: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 F1340C43334 for ; Sun, 10 Jul 2022 12:35:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229711AbiGJMfq (ORCPT ); Sun, 10 Jul 2022 08:35:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbiGJMfb (ORCPT ); Sun, 10 Jul 2022 08:35:31 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7BB911443 for ; Sun, 10 Jul 2022 05:35:28 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id a5so3822322wrx.12 for ; Sun, 10 Jul 2022 05:35: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=XDBCqCi5qpLpV3N/M8gq3K+ocUXlMKc797KB4nwKvLU=; b=T9EDchFlGT4kE8VFbio2ci9HzYc71XyBwd+huTje1aKumQMtWF2nvYLaaHzcovCqtU PchUPMJiXvD3P288if8JrBRE5YS7IqPOaNdKrO8p2D7i6E7yQUj/Sd2Oh17g+Oulyl6R 7uXF3gazDiZebiSs8OEjOck1RW3uit9PiQ6gClfYEDmp7GSrBPM443boAiKgJJh9Yhzh /F/buSf/Tdb4Odv6kfeOaCw41N1WnEjknu1TBae6T7Ki9/efUyGxg9QdPLcdubhR7glv y78vVxrElnx0ZZwm+0KpBxKeR2d1bvagWArAky5badjcTIv4DABMkEtQAJVPanwjc5mZ B23w== 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=XDBCqCi5qpLpV3N/M8gq3K+ocUXlMKc797KB4nwKvLU=; b=Pp/y9OWLm7QXiX+cE1UxVnxblA48jQuire0U3ft4IixgyXSiC/0GW3d1pWUSz43jtf RPFOl7ar9waXvD5NaGQVQMZwvbVJCfaFleBTwPqihmgarN6B8rthL9fqWZeS7ZEh2GMe 6OBjonQsFepL1BCHdIJOP79oomOHlQ76argwCPflGFfad+z6i/LUZm9BqAg26DDmC6Wq HLdybGRIWEPNuMgZdMuAHt8ulmQdPvn+seLsJyTOeukGHhyPTryBNJlY7YQ0BvBzO5LW C/L7hFkD27FzqpClomRMEXKG0vG/kInQ+Dg+4GLB9PV4pvbi1ulXhQGhw0xJcGovVWga F0PA== X-Gm-Message-State: AJIora+PnLZsBED6iwWJm5V64XGQQzqvfFirXV6wfAWrD7s98uETrUuh PMadDFZSFgjEbhdjfFrhxqpScg== X-Google-Smtp-Source: AGRyM1tRXEejFGVqxpRyRsE0/11z+sUMc9mvfhAoyrwAATIdkz4+rrRtebjinqNsHpVJLQf8MLH5+g== X-Received: by 2002:a5d:5451:0:b0:21d:2295:6a05 with SMTP id w17-20020a5d5451000000b0021d22956a05mr12204812wrv.302.1657456527458; Sun, 10 Jul 2022 05:35:27 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id 24-20020a05600c22d800b003a0375c4f73sm3775144wmg.44.2022.07.10.05.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 05:35:27 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, lukasz.luba@arm.com, Amit Kucheria , Thierry Reding , Jonathan Hunter , Dmitry Osipenko , linux-tegra@vger.kernel.org (open list:TEGRA ARCHITECTURE SUPPORT) Subject: [PATCH v5 07/12] thermal/core: Rename trips to ntrips Date: Sun, 10 Jul 2022 14:35:06 +0200 Message-Id: <20220710123512.1714714-8-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710123512.1714714-1-daniel.lezcano@linexp.org> References: <20220710123512.1714714-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 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 | 4 ++-- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/thermal/gov_fair_share.c b/drivers/thermal/gov_fair_sh= are.c index 1e5abf4822be..6a2abcfc648f 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->num_trips =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->num_trips; 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->num_trips); } =20 /** diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_po= wer_allocator.c index 13e375751d22..1d5052470967 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->num_trips; 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->num_trips > 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..05886684f429 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->num_trips; 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..cb9b1bd03bd3 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->num_trips; 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->num_trips || 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->num_trips; 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->num_trips; 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 + * @num_trips: 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 num_trips, 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 (num_trips > THERMAL_MAX_TRIPS || num_trips < 0 || mask >> num_trips) { 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 (num_trips > 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->num_trips =3D num_trips; =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 < num_trips; 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..690890f054a3 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->num_trips; 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->num_trips; 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..050d243a5fa1 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->num_trips; 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..5018459e8dd9 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->num_trips <=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->num_trips, sizeof(*tz->trip_type_attr= s), 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->num_trips, sizeof(*tz->trip_temp_attr= s), 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->num_trips, 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->num_trips * 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->num_trips; 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->num_trips] =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->num_trips * 2] =3D &tz->trip_hyst_attrs[indx].attr.attr; } - attrs[tz->trips * 3] =3D NULL; + attrs[tz->num_trips * 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->num_trips) { 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->num_trips) destroy_trip_attrs(tz); =20 kfree(tz->device.groups); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 6289b0bb1c97..03e968d61471 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -125,7 +125,7 @@ struct thermal_cooling_device { * @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis * @mode: current mode of this thermal zone * @devdata: private pointer for device private data - * @trips: number of trip points the thermal zone supports + * @num_trips: number of trip points the thermal zone supports * @trips_disabled; bitmap for disabled trips * @passive_delay_jiffies: number of jiffies to wait between polls when * performing passive cooling. @@ -165,7 +165,7 @@ struct thermal_zone_device { struct thermal_attr *trip_hyst_attrs; enum thermal_device_mode mode; void *devdata; - int trips; + int num_trips; unsigned long trips_disabled; /* bitmap for disabled trips */ unsigned long passive_delay_jiffies; unsigned long polling_delay_jiffies; --=20 2.25.1 From nobody Sat Apr 18 21:01: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 40273C433EF for ; Sun, 10 Jul 2022 12:36:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229601AbiGJMgD (ORCPT ); Sun, 10 Jul 2022 08:36:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229697AbiGJMfl (ORCPT ); Sun, 10 Jul 2022 08:35:41 -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 DB95B13DD9 for ; Sun, 10 Jul 2022 05:35:33 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id y22-20020a7bcd96000000b003a2e2725e89so1295715wmj.0 for ; Sun, 10 Jul 2022 05:35: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=L3skzrLPntV9feVuTsato+Vtj+oVFJD2KdodKzkC6Z0=; b=sAEw6cqMT71U33e7SfvrJcyAd2gE6AbB0vJgY7xd/u/Wf5P7Hgv4HIFH8Mt4pPTBY0 H9UwhD872eu7I05zlTmOX9jsuLJsZDjjJ1LRqKrn1NDYfKMmkU56VKQUJUjL5M7WBnkT 1QaAyYFnQVv5YPzkOky3WVzZyA6XSwuSRhqV06xWzJtUnnBYjRsJoiQNLPM8ndVaihE5 Wr1J6d4itq6U7yWXS3Dm+BJa8bCiy5a4ZUzkPLXZoaJcW4nkZnlPJ/z/LeY8HSZnOT1N rXLj1WPcg3HCbMFRxoU7L6z8Dp5trADaQG3vOi7apEGkXPR5E5tTYGd0lCfH6A9uHe6a EI7w== 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=L3skzrLPntV9feVuTsato+Vtj+oVFJD2KdodKzkC6Z0=; b=wM6Xk9+rzOVU55Rm6RsH707MRb/OmJd12ZWkeVqOnO1nJh/JIkEGIBL5vsxGXJbDGT WVkw51VKKAiYMirwV7ZJNIQIt1SJtw13bvODtv8BeKGPsnN0Ww3myHj5sJklMdxHy9+z b0s1Im1rWdxrKuEB7lRJ9dwL4zOYvl5EGfuJWFVOdbUu2S+o//yqB8RL7tJhhaOWw1Rx xHXhHUO0iK8B/4zqC03KRD1DeGVLr8iZs+CViNcuXSG/lLDBFBcRAoySeuw/CwEb46LJ Ps61qcl2cROXawmp2H999lnBGU0ajQKTihYrqfq42MmWq0v5yXV/rL/AaBysNNz4cgkp TcTg== X-Gm-Message-State: AJIora+/EJGFmGO6gbmNVL0dWSpCj3GlXiVqrVFodL+V9QqhomC+OV6A lGnRodTZ0CXfy08/8KL4FmheFw== X-Google-Smtp-Source: AGRyM1vyUbaeoRaMhBmtCkfSXCX5V+7e9GTFAynDXwVIc5gIYTc+2A6USfeykIpaXMES3eiUTmijkw== X-Received: by 2002:a05:600c:4f08:b0:3a1:99ed:4f1f with SMTP id l8-20020a05600c4f0800b003a199ed4f1fmr10121049wmq.199.1657456532071; Sun, 10 Jul 2022 05:35:32 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id 24-20020a05600c22d800b003a0375c4f73sm3775144wmg.44.2022.07.10.05.35.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 05:35:31 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, lukasz.luba@arm.com, Amit Kucheria , Thierry Reding , Jonathan Hunter , Dmitry Osipenko , linux-tegra@vger.kernel.org (open list:TEGRA ARCHITECTURE SUPPORT) Subject: [PATCH v5 07/12] thermal/core: Rename 'trips' to 'num_trips' Date: Sun, 10 Jul 2022 14:35:07 +0200 Message-Id: <20220710123512.1714714-9-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710123512.1714714-1-daniel.lezcano@linexp.org> References: <20220710123512.1714714-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 'num_trips' to have the 'trips' field containing the thermal trip points. Cc: Alexandre Bailon Cc: Kevin Hilman 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 | 4 ++-- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/thermal/gov_fair_share.c b/drivers/thermal/gov_fair_sh= are.c index 1e5abf4822be..6a2abcfc648f 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->num_trips =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->num_trips; 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->num_trips); } =20 /** diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_po= wer_allocator.c index 13e375751d22..1d5052470967 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->num_trips; 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->num_trips > 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..05886684f429 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->num_trips; 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..cb9b1bd03bd3 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->num_trips; 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->num_trips || 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->num_trips; 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->num_trips; 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 + * @num_trips: 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 num_trips, 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 (num_trips > THERMAL_MAX_TRIPS || num_trips < 0 || mask >> num_trips) { 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 (num_trips > 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->num_trips =3D num_trips; =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 < num_trips; 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..690890f054a3 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->num_trips; 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->num_trips; 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..050d243a5fa1 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->num_trips; 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..5018459e8dd9 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->num_trips <=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->num_trips, sizeof(*tz->trip_type_attr= s), 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->num_trips, sizeof(*tz->trip_temp_attr= s), 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->num_trips, 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->num_trips * 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->num_trips; 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->num_trips] =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->num_trips * 2] =3D &tz->trip_hyst_attrs[indx].attr.attr; } - attrs[tz->trips * 3] =3D NULL; + attrs[tz->num_trips * 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->num_trips) { 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->num_trips) destroy_trip_attrs(tz); =20 kfree(tz->device.groups); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 6289b0bb1c97..03e968d61471 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -125,7 +125,7 @@ struct thermal_cooling_device { * @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis * @mode: current mode of this thermal zone * @devdata: private pointer for device private data - * @trips: number of trip points the thermal zone supports + * @num_trips: number of trip points the thermal zone supports * @trips_disabled; bitmap for disabled trips * @passive_delay_jiffies: number of jiffies to wait between polls when * performing passive cooling. @@ -165,7 +165,7 @@ struct thermal_zone_device { struct thermal_attr *trip_hyst_attrs; enum thermal_device_mode mode; void *devdata; - int trips; + int num_trips; unsigned long trips_disabled; /* bitmap for disabled trips */ unsigned long passive_delay_jiffies; unsigned long polling_delay_jiffies; --=20 2.25.1 From nobody Sat Apr 18 21:01: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 49C39CCA480 for ; Sun, 10 Jul 2022 12:36:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229748AbiGJMf7 (ORCPT ); Sun, 10 Jul 2022 08:35:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229694AbiGJMfl (ORCPT ); Sun, 10 Jul 2022 08:35:41 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4B8511149 for ; Sun, 10 Jul 2022 05:35:33 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id q9so3829952wrd.8 for ; Sun, 10 Jul 2022 05:35: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=tWXSn875oBDJq4Q/0NyDjwM2E/hA/gxhBWxbmBReloU=; b=wrpaz+erB/SUAvWKJfI4hiKHYzgifm9j24LzmoyTVnQ+aeaN10CpMA/HqHSI4TayaE giVHjnJRDvxYgsTKfEERbvJNaNhtJBOP9pYaqKqdt9pLLliYPYawwtf8EFSZxScd470I BurTlZO8cj/FsXkm56qa8nVYlR0JEtuIOoWyBE3I6QbN3olYAAMXwppRitHyHf6eXDr7 +hbbwiNLcTH1rdG2nMLxGLD8Qkr+A5EY9KuDnQLq4qIhqDvOMFg1RU4lqkQQ7LvUZwB1 bs7clzfvdo7RrO88MWVgPOnts2aeHVVzKYWVlOuUEWKZkyaTymc4s9t07QZWpRI+7Hur GknQ== 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=tWXSn875oBDJq4Q/0NyDjwM2E/hA/gxhBWxbmBReloU=; b=fjJ+DSQCZbyupJi1//fVXkpGv+RWAY8d5z9DEJ2qhEse3k8QyyhkVyzcZJD/DLmqwH i7hRGFdTevKfcWnsH6+w+TNUmTC4B0j/idNEa7q1Jfywv56w5Ow8kSnOlfkQ4Z/ruJsK pdZmP2spymCwDgpulBq8edw+AsAyoSWN+NbE+SOXtcPZ3Y3kIf616YPO+pv9LdA2Osng uNIAlZhdcrcapleIxXwAFGlGvh85E2rsuzJmaXg4rpLiJVDrebCISQBAMtrKknRdG8fd HvsZc7WORAdRjJi/zWuqUk319AvV2WcdCsryDvzdLxg3EFLVf4+1iopDwD0a3z/MF97w 6svQ== X-Gm-Message-State: AJIora/ofOaobw7zLuKp36BE5EhnQhsbLXnrH94Y0FcZ1muW9Ggd4BND WfuJfS5CDxlwFaPtGkewNB59WA== X-Google-Smtp-Source: AGRyM1tPY+iS5RNpkA8nAJfTHqN1aiU4tOpl3nsbv+m0ThfN9FW2NaL8g7K8RL0Q5IixxkhtMl1puA== X-Received: by 2002:adf:d1e9:0:b0:21b:c8f8:3c16 with SMTP id g9-20020adfd1e9000000b0021bc8f83c16mr12265818wrd.659.1657456533117; Sun, 10 Jul 2022 05:35:33 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id 24-20020a05600c22d800b003a0375c4f73sm3775144wmg.44.2022.07.10.05.35.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 05:35:32 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, lukasz.luba@arm.com, Amit Kucheria Subject: [PATCH v5 08/12] thermal/core: Add thermal_trip in thermal_zone Date: Sun, 10 Jul 2022 14:35:08 +0200 Message-Id: <20220710123512.1714714-10-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710123512.1714714-1-daniel.lezcano@linexp.org> References: <20220710123512.1714714-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 Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.h | 10 ++++++++++ include/linux/thermal.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index c991bb290512..a4e730391cab 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_device *tz) +{ + return tz->trips; +} + +static inline int thermal_zone_get_num_trips(struct thermal_zone_device *t= z) +{ + return tz->num_trips; +} + /* 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 03e968d61471..c7fcb9e2a4fc 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -125,6 +125,7 @@ struct thermal_cooling_device { * @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis * @mode: current mode of this thermal zone * @devdata: private pointer for device private data + * @trips: an array of struct thermal_trip * @num_trips: number of trip points the thermal zone supports * @trips_disabled; bitmap for disabled trips * @passive_delay_jiffies: number of jiffies to wait between polls when @@ -165,6 +166,7 @@ struct thermal_zone_device { struct thermal_attr *trip_hyst_attrs; enum thermal_device_mode mode; void *devdata; + struct thermal_trip *trips; int num_trips; unsigned long trips_disabled; /* bitmap for disabled trips */ unsigned long passive_delay_jiffies; --=20 2.25.1 From nobody Sat Apr 18 21:01: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 25744C43334 for ; Sun, 10 Jul 2022 12:36:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229780AbiGJMgF (ORCPT ); Sun, 10 Jul 2022 08:36:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229652AbiGJMfs (ORCPT ); Sun, 10 Jul 2022 08:35:48 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64A9913F08 for ; Sun, 10 Jul 2022 05:35:36 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id n185so1644229wmn.4 for ; Sun, 10 Jul 2022 05:35:35 -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=burLk/fepKB3+kx0gOsH0ETHWrtJk7gcAQVl65eRfYw=; b=ZHITaPM2U5eltBWgrJlc+uIVRp+NQyPHoIPszR/bSkjshmzbo+1hY8uDY0zjgw7wpO 48hxCkL1WDkIkOhT4X7xf9ACw84xG5pSHU+Hq2KlZoZfJO+HIwQ/1VGPcVLuYD/16mGW Xna9HYKGi7pmBxj9jM30w8TYq2lzpfDs7TF6XP7myVrrGFaXqTNjHA6qqlNU+8vDARR0 6VwZKtqQOWmLgHZaAsfaudeSjlcGdbxhzBH0YY3MAK26qijvQGXyWB/MOz8q4djTSQve bf74z/SEcitKLyOY0LApHP5tVU//nXRmMKhIZ5QBbgjO66jC/I8bEktyhQhEvvK0ZqKb ncCQ== 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=burLk/fepKB3+kx0gOsH0ETHWrtJk7gcAQVl65eRfYw=; b=VBsSN831r4BnW03eqqKh++mnA0DHzOC3b8xwjv9uOiiaSfmK42jkAnXwDWYOGFG5zg APTGLv4e87jOY4LgydtGOE5hgwBW2oga0lEfqL7haZf2g9FMy8V9VC7/Yb3JwvPQ8gPG BAYgJSSxomr0bKGOFS/ovfiR5pmgL5vARjdIHwktpQRsCcmjkIwR0RcAWqN6MU+8lVmy EPUiwb6EnaNMJuV5rnpLKpBDXAulP532nJYu7GbOxcQt8Lc5FCsafqONoxp/dDkNvq5q uxUZJcKCrp2r9W44C1uq76RZJM9kdDU8e+fPGxiFD+7nrkelompUvYNRMAUJSxEXx39z XDOg== X-Gm-Message-State: AJIora8nHWulEzjvlJdboegYJJ6GTTpR5SbrFKqEU8ovKTuwQ7X54vor m25uDYdhky7EJDh/WMLqNcr9CA== X-Google-Smtp-Source: AGRyM1u7ZlkCzRREUWKXHrn56yx/cIE01INx7QX+NsYupIIw1cZa4r3/aWzlwj4lViv8LHi/Gq19mw== X-Received: by 2002:a05:600c:3b95:b0:3a2:e579:d196 with SMTP id n21-20020a05600c3b9500b003a2e579d196mr2521504wms.185.1657456534208; Sun, 10 Jul 2022 05:35:34 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id 24-20020a05600c22d800b003a0375c4f73sm3775144wmg.44.2022.07.10.05.35.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 05:35:33 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, lukasz.luba@arm.com, Amit Kucheria Subject: [PATCH v5 09/12] thermal/core: Register with the trip points Date: Sun, 10 Jul 2022 14:35:09 +0200 Message-Id: <20220710123512.1714714-11-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710123512.1714714-1-daniel.lezcano@linexp.org> References: <20220710123512.1714714-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 Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 22 +++++++++++++++++----- include/linux/thermal.h | 6 ++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index cb9b1bd03bd3..0d9e9b175f93 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 * @num_trips: 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 num_trips, 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 num_trips, 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; @@ -1255,6 +1256,7 @@ thermal_zone_device_register(const char *type, int nu= m_trips, int mask, tz->tzp =3D tzp; tz->device.class =3D &thermal_class; tz->devdata =3D devdata; + tz->trips =3D trips; tz->num_trips =3D num_trips; =20 thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay); @@ -1331,6 +1333,16 @@ thermal_zone_device_register(const char *type, int n= um_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/include/linux/thermal.h b/include/linux/thermal.h index c7fcb9e2a4fc..fde4689a1755 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -380,8 +380,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 Sat Apr 18 21:01: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 9C5B6C43334 for ; Sun, 10 Jul 2022 12:36:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229804AbiGJMgK (ORCPT ); Sun, 10 Jul 2022 08:36:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229616AbiGJMf4 (ORCPT ); Sun, 10 Jul 2022 08:35: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 0F8B213F0F for ; Sun, 10 Jul 2022 05:35:36 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id l68so1644516wml.3 for ; Sun, 10 Jul 2022 05:35:36 -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=icoUiwKgc5ZfQQb9kyqtM6xsdul/av8PcZiURdbMJFs=; b=vkJN2lqSLPWI+/BzP3FTUMAWQRWtBP8xmHL3ekSHL5rJH0Ptvb9mdaQLLWO8JOWHSS kjEd5BEORRxLXF908meXd+XqhmnZfRVJAO1/FqhWSMhANXxpNAsldabulQmFmkEEA+o5 t4tpeAHg4R/FtM/QEFw/2Om2c0s5au2jD1TGufvbMyEJbQ9I+hZK2Gchmm7XO/5fLuqI Bdguu6GimTFv1+2L+AUtIsu5zHTCJnzCIex4Z0z4yXa7uqsxl78ctfrq0n6Vyti1Ps5K 4YObqy2kT9BQcoxU0YeB3CmQj5Pjd7odxPYxuMw0nwZ4VFaIpoJ6FvbFSk+bL4IXjOOe sOQw== 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=icoUiwKgc5ZfQQb9kyqtM6xsdul/av8PcZiURdbMJFs=; b=r0+T9y3VF6CNA4pzNjP62DP0cf5gn4BnsLsA8+GfoC7HHxZf9PeEQsBCCvM1f6MA0j WiuOKCEv/DtjasDTjdKETHy9MdakUQ0wyEk0UjbHpByNMS4kPRvmctd9EGGzlLtF5oK3 hy6T5q+49blO9ejVyXtVmP7Q99DwmNwPr3X+X9Tb/BfcjtyTc4AfNyep4lt6lDpw8FNr Nc6Ohp6l8TcdCpj0rNWa57IYZDXtNB8aZXOfMSic6w+r9+wQufTgeQhz6kh0ugpmEQ7p VedWZonKKNqZu/l48olv+6mTM1/muBibAGXa1K9ysZ7gZn1/xIWsjlOaaOZiCegdw6fc bZ3g== X-Gm-Message-State: AJIora/gSpr/ngleOU1/WG9tMMt60mRW5ackNlK1uwMQy5IcBSs0gKYn 5vPrhGq8MspMZNFvyj0dmFnX8A== X-Google-Smtp-Source: AGRyM1vscx2qlLVeh0vOTuSaNxBbf1hHDyONcEKP7d1JduHpRBsmUTYb7SigAchElqILmC+8nPWvWw== X-Received: by 2002:a05:600c:22c9:b0:3a2:d069:a046 with SMTP id 9-20020a05600c22c900b003a2d069a046mr10690759wmg.29.1657456535250; Sun, 10 Jul 2022 05:35:35 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id 24-20020a05600c22d800b003a0375c4f73sm3775144wmg.44.2022.07.10.05.35.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 05:35:35 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, lukasz.luba@arm.com, Amit Kucheria Subject: [PATCH v5 10/12] thermal/of: Store the trips in the thermal zone Date: Sun, 10 Jul 2022 14:35:10 +0200 Message-Id: <20220710123512.1714714-12-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710123512.1714714-1-daniel.lezcano@linexp.org> References: <20220710123512.1714714-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 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 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 19243c57b3f4..e187461dd396 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -1119,11 +1119,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 Sat Apr 18 21:01: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 9678BCCA479 for ; Sun, 10 Jul 2022 12:36:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229798AbiGJMgH (ORCPT ); Sun, 10 Jul 2022 08:36:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229723AbiGJMf4 (ORCPT ); Sun, 10 Jul 2022 08:35:56 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F270A11156 for ; Sun, 10 Jul 2022 05:35:36 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id p4so1669585wms.0 for ; Sun, 10 Jul 2022 05:35:36 -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=MOV3jBcg82SkJlwYwOt/rJO7ag2lj0Zbffx6z7DzHn0=; b=GlWxOymnKUTWYKcO5EKHUZoe6f7tMxw/PFOOLAd9i23TL4YVvGMyjmPQ619roa/tLO PmKq9buzU1CFpD9KR/ZWjzTjHkF0V7tUEHDko8aTnfbw4Ku6nfERlwD0GM1Qyv04FOF/ MRzJifeIwq/DeMj7cCv1wBrTikhkhchMfnUKixnRiAwA7Y7wohO9wTC1gqnBVEVBbgzN vEbBAkGpjyTAqk0FqUBVGrh+HT6AP0YYAI0D5JRUf+QWYHhjsIYZVQgdxB/PA7uHcwaO WnbjvbT0xlyrrsk+qdgSV/S/XmMD5g1VUhmALlFMm8h6fTgVQKqz9Faluu+cMaE/LRPv d6dw== 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=MOV3jBcg82SkJlwYwOt/rJO7ag2lj0Zbffx6z7DzHn0=; b=8QZkOfXNfkM3l4UrgLyyVYLX7HtUCDByT72Il+bIqPPjtEMfSocKkx7hJMJ7WxxJe3 NaRzYtfWKd51PsbgS2wUf9VMKAMNQ0D5TRMyzeW1O0XIWPUC6chk7qkG9lZZuEbnh4TG INikQDwbioSVPYDYgwi6lcD+UN17bTtyN3cIlt4vzXhTzGCFLwz7A9YvLNhWg+R4O3z9 C6cvsJOt0g2QOkDCi95TfteIM2YgKeokuD8aleRuzAu8MUwJ0OjKm3eCXBHUZ7nnDBcY GS7oidxULeBcvvpOjZxVkb5LeS8sHABHVW2cSmgQCsQQhUHSO+zfZOlvGRdw+VBhZHrs /+uA== X-Gm-Message-State: AJIora+0wWu7UvRNQEc/u3d4qFM7YqHGbDv5H7SI5MrM1XUH4csAkVUn vIEmRIoUigmkPOPKC39IZafygw== X-Google-Smtp-Source: AGRyM1vc4Ap92ThwhdsU24BHeRV5vu6gEn7so/V6hNX1a8ltazDAwhNfpNCM5ft932XtN5VblpQing== X-Received: by 2002:a7b:c401:0:b0:3a2:ca58:85bc with SMTP id k1-20020a7bc401000000b003a2ca5885bcmr10613647wmi.156.1657456536246; Sun, 10 Jul 2022 05:35:36 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id 24-20020a05600c22d800b003a0375c4f73sm3775144wmg.44.2022.07.10.05.35.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 05:35:36 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, lukasz.luba@arm.com, Amit Kucheria Subject: [PATCH v5 11/12] thermal/of: Use thermal trips stored in the thermal zone Date: Sun, 10 Jul 2022 14:35:11 +0200 Message-Id: <20220710123512.1714714-13-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710123512.1714714-1-daniel.lezcano@linexp.org> References: <20220710123512.1714714-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 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 e187461dd396..601552c55d0b 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 Sat Apr 18 21:01: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 A7F6DC43334 for ; Sun, 10 Jul 2022 12:36:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229823AbiGJMgQ (ORCPT ); Sun, 10 Jul 2022 08:36:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229733AbiGJMf5 (ORCPT ); Sun, 10 Jul 2022 08:35:57 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D88681145A for ; Sun, 10 Jul 2022 05:35:37 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id bi22-20020a05600c3d9600b003a04de22ab6so1612821wmb.1 for ; Sun, 10 Jul 2022 05:35:37 -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=DMovIUMU9IB4F56zxQvm9VYr7WFPPP8mufoJe3SI6xw=; b=JKIgwceJ17zdG5NJAvOUZ2YHaz79yM3RULs4bXVPMv4BmM6sp9TcFiXJoX4Kryv7Hq fYxdeG0SocJKVKSpz3Xj2d4cfuPX2tvdZZx2hG4RyB85hBppeK4p4fBjGz4+6s7+RLe6 n4Ccv8u2fWT59YLG2cLYNoc57VfxPbyyuD5cfBO6zBQN4tkV7U2kA83dc2OoMSdnbqXA tW0cwcw4GNylZOcVucPcU9StTH6TcAKO42tiA/oY7P0l7/K2MKVmB0Qx3ReUvJFvN6tK HAEI4f770m4DxUXhEUbRAL27QPXhAEF9RQnHXkkdz3IfIVJil1LW4QOLn+m6nrjb9DtV j7rw== 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=DMovIUMU9IB4F56zxQvm9VYr7WFPPP8mufoJe3SI6xw=; b=UkjHBxlmoNxR3doLuGP8l4sLtPRk59wdKEYA/vaM6pXI8q3TUrdjaybc+EIQkkhUqa kmcwcc4jjcCdseyaQDJ/kzj8xup2Vp9+vWTj7H0uWApVNXBW/QELFy+px0aCqNjCyh+Z 5oxxqHLe3O91BlR0Aviz7P29qlpGMswbOn9YVlXdEdPD2buzcoALK6ZwSr6c5jka0hlK 7p7OMr/8y+bC2fmywhMtU77u3uaYmJHRWTJfUJGjxHnF7bO/F38Lbgx8h3lmYJ642Ex1 z/M78uWxQTAoFX+ibCM8Esb0njM06i9CMDSRTLd5aVBJvtWxKReIzxIBjdfo4r+HD9TD /S0w== X-Gm-Message-State: AJIora8q1+cAMt1XotccA3ZjG689WCQYVS8fYEHgiUMBbPIQUNe63yCK Ap/Q21nX+5BkRKgfr7CebYZ/0Q== X-Google-Smtp-Source: AGRyM1slDJXVc+SVSYNpyfvlyEWaa57gj+z1rQ1DxY7hOVLPpLWmg6eehIMp17JzKfDRogoWraDLWg== X-Received: by 2002:a7b:c381:0:b0:3a2:aef9:8df4 with SMTP id s1-20020a7bc381000000b003a2aef98df4mr10622445wmj.7.1657456537255; Sun, 10 Jul 2022 05:35:37 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id 24-20020a05600c22d800b003a0375c4f73sm3775144wmg.44.2022.07.10.05.35.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 05:35:37 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, lukasz.luba@arm.com, Amit Kucheria Subject: [PATCH v5 12/12] thermal/of: Initialize trip points separately Date: Sun, 10 Jul 2022 14:35:12 +0200 Message-Id: <20220710123512.1714714-14-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710123512.1714714-1-daniel.lezcano@linexp.org> References: <20220710123512.1714714-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 Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 102 ++++++++++++++++++++++------------- 1 file changed, 65 insertions(+), 37 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 601552c55d0b..0693edc00f60 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -118,7 +118,7 @@ static int of_thermal_set_trips(struct thermal_zone_dev= ice *tz, */ int of_thermal_get_ntrips(struct thermal_zone_device *tz) { - return tz->ntrips; + return tz->num_trips; } EXPORT_SYMBOL_GPL(of_thermal_get_ntrips); =20 @@ -134,7 +134,7 @@ EXPORT_SYMBOL_GPL(of_thermal_get_ntrips); */ bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, int trip) { - if (trip >=3D tz->ntrips || trip < 0) + if (trip >=3D tz->num_trips || trip < 0) return false; =20 return true; @@ -269,7 +269,7 @@ static int of_thermal_unbind(struct thermal_zone_device= *thermal, static int of_thermal_get_trip_type(struct thermal_zone_device *tz, int tr= ip, enum thermal_trip_type *type) { - if (trip >=3D tz->ntrips || trip < 0) + if (trip >=3D tz->num_trips || trip < 0) return -EDOM; =20 *type =3D tz->trips[trip].type; @@ -280,7 +280,7 @@ static int of_thermal_get_trip_type(struct thermal_zone= _device *tz, int trip, static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int tr= ip, int *temp) { - if (trip >=3D tz->ntrips || trip < 0) + if (trip >=3D tz->num_trips || trip < 0) return -EDOM; =20 *temp =3D tz->trips[trip].temperature; @@ -293,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 tz->ntrips || trip < 0) + if (trip >=3D tz->num_trips || trip < 0) return -EDOM; =20 if (data->ops && data->ops->set_trip_temp) { @@ -313,7 +313,7 @@ static int of_thermal_set_trip_temp(struct thermal_zone= _device *tz, int trip, static int of_thermal_get_trip_hyst(struct thermal_zone_device *tz, int tr= ip, int *hyst) { - if (trip >=3D tz->ntrips || trip < 0) + if (trip >=3D tz->num_trips || trip < 0) return -EDOM; =20 *hyst =3D tz->trips[trip].hysteresis; @@ -324,7 +324,7 @@ static int of_thermal_get_trip_hyst(struct thermal_zone= _device *tz, int trip, static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int tr= ip, int hyst) { - if (trip >=3D tz->ntrips || trip < 0) + if (trip >=3D tz->num_trips || trip < 0) return -EDOM; =20 /* thermal framework should take care of data->mask & (1 << trip) */ @@ -338,7 +338,7 @@ static int of_thermal_get_crit_temp(struct thermal_zone= _device *tz, { int i; =20 - for (i =3D 0; i < tz->ntrips; i++) + for (i =3D 0; i < tz->num_trips; i++) if (tz->trips[i].type =3D=3D THERMAL_TRIP_CRITICAL) { *temp =3D tz->trips[i].temperature; return 0; @@ -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) + tz->trips =3D thermal_of_trips_init(np, &tz->ntrips); + if (IS_ERR(tz->trips)) { + ret =3D PTR_ERR(tz->trips); goto finish; - - tz->ntrips =3D of_get_child_count(trips); - if (tz->ntrips =3D=3D 0) /* must have at least one child */ - 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,13 +981,14 @@ __init *thermal_of_build_thermal_zone(struct device_n= ode *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: - of_node_put(trips); of_node_put(child); =20 return tz; @@ -977,8 +1007,6 @@ __init *thermal_of_build_thermal_zone(struct device_no= de *np) kfree(tz->tbps); free_trips: kfree(tz->trips); - of_node_put(trips); - of_node_put(gchild); free_tz: kfree(tz); of_node_put(child); --=20 2.25.1