From nobody Sat Apr 18 22:41:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27847C43334 for ; Sat, 9 Jul 2022 22:32:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229650AbiGIWcs (ORCPT ); Sat, 9 Jul 2022 18:32:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbiGIWcp (ORCPT ); Sat, 9 Jul 2022 18:32:45 -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 398F8175A4 for ; Sat, 9 Jul 2022 15:32:44 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id o19-20020a05600c511300b003a2de48b4bbso1659737wms.5 for ; Sat, 09 Jul 2022 15:32:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7UKKS5f7QbJpxlk+iXwxbcq70b7aqG7EJc4B5ZEy8YU=; b=K3WpTj9IS4oPO/xbKdn90VqUsZ5OqorLd/R+V9gn4eVgJYfr7JCn1opHg3Yu3q2JKk CsZYAuRX31p6y6hWTAGpAWkTMDXLg3vVMgpMULT6TRcgbDuBDpxvoYfCKTaQzSVurlQH ZpwEZCaRrprG9k+X4XTjVVCya4BtHd8QSQtY79IL63j52rf9oiCd46ZK8kItgvOvfSjw hUlUSM8p04IA08iOp2WRa0+hxCSXm3VmDnIDeqkC/qCJjQqUeZd8M57ic8M+rQXjmq9z QFpqpnj6xuIRi4qejPwJL2MYkHMW2gKzZMEGMOZIzT9+3aFCAMw2Fxc3cOJVGZ6OQk5c V8iw== 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=pfLW1Yw8+y14aB7lWph5+cmMndCdEY/ZQMMCZTl6Ghp79TIlEzVn9zpZuATR77vDst gPYXQPb9hKRwK4N8EdWXUjpboQ9qAs2Iu/ZjKj0SbHIlFrj4aTmUS0EMFlgmwUWFedGZ kjdnomw1dqPRAOJmnhVM+kKmcD7tjFDG559za4mSxmLpyvayTl/SQ1F1VjjThB7epEBY hj6lLqAxjd0Hy8LS8ttUgf9Qf14ksR+FzUvWFzyf4hFJV6Ox5m8rLRv+0BLEwhaa2V9V tGAHk6ptHi4nnnBwcJKITZ6QevoeEZWVSAVWnBIw/5e9bNcnE6cRQe30iKL6syzACOov snQw== X-Gm-Message-State: AJIora8da/EmYMPTc5DdC9hONnE4mxSgQvdo/HPewRsf2g9e0YnMrdzd sS73zaaqkGGjuJRdT5WqmWQr3A== X-Google-Smtp-Source: AGRyM1syNknWUeDtrb2zQ0mSXavdYoNhvvHnt/MZKAWdXrFo8uNvNeBGeUFitcifm5x9u5JPmkFmfg== X-Received: by 2002:a05:600c:4e8b:b0:3a0:5826:3321 with SMTP id f11-20020a05600c4e8b00b003a058263321mr7572674wmq.108.1657405962755; Sat, 09 Jul 2022 15:32:42 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id w15-20020a1cf60f000000b003a2c7bf0497sm2525342wmc.16.2022.07.09.15.32.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jul 2022 15:32:42 -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 v4 01/12] thermal/core: Remove duplicate information when an error occurs Date: Sun, 10 Jul 2022 00:32:18 +0200 Message-Id: <20220709223229.1619339-2-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709223229.1619339-1-daniel.lezcano@linexp.org> References: <20220709223229.1619339-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 22:41:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17821C433EF for ; Sat, 9 Jul 2022 22:32:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229661AbiGIWcu (ORCPT ); Sat, 9 Jul 2022 18:32:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbiGIWcr (ORCPT ); Sat, 9 Jul 2022 18:32:47 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EA8E17A8E for ; Sat, 9 Jul 2022 15:32:45 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id f2so2603603wrr.6 for ; Sat, 09 Jul 2022 15:32:45 -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=gY+ofGz0rYakT7/O6Ovk6+5iviYBD0V0sZ5Evn8IbZ0iBqrmxsNy8WSDpdwyZgSmJh YjQYrdZLOBx0pYhjPuvEIZG4xGhVCkrFkoBUlYfd/G6vA5LqbcK8lzhg0mtwC7eODIs8 RAp0O+rFzfVE0dMbceLUoIPkqQJGXJnNSMcEP5cYvyrE02kROV0PxTV4N4tNUQABiuSh /RC4dTrk9RnhNWDs0qyu42BGjSKIGwUwEmEsqD9Q1WR7aBWaTO2p4AiiVPpaWjADmN9W mQrwrs3m4oU8Lk67rp4aMvz9bbNm7A7/730BxBenRrrQex5/AI0Mz6BsDSGRE44J2H9g wVlg== 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=Sn7e/dhHiY1I7ffojyCLT8v0XHwo/6+BLXbgHtTLzVt+x8Jhh02Y89YFY4ONojPbuw H0Ll+t8LrUdzzhHnyy7EuU945QM0pf99VkMNUGYcp6rflmt3Aj+zkj2b8ydKr/H0RNGp sRhW5erMAG6SRAHZDiNo+MotUEjKCv6LFAp8SAU02Zs+6OGahZsi7Y5K7nM4oGG3DOF2 zlcv6LfPcozDfpjtdROsPimDq7bU1zABzPaJBlmy+uB9VidWfXu6RYxoNd+rC0WLTr9/ hYA6Rjp5TCOOHISb07YbrjmWrQx1dmK4nNioQmFGLNyDW5Uh+v8rLR+rYZ/8ubtfvI5h cWtQ== X-Gm-Message-State: AJIora9fBMq0XvEq25Vnqc1HcSNE5hyJzmoGkxKupdiV38VTnKoP8p/h eTjqdmvWDkHq1MMUzyKp7qhQ2g== X-Google-Smtp-Source: AGRyM1uJghMTxTQSsVttRXDjHVtjhUA0bXXeYfGhS+aAe6UASYICGkOR7dHOmcKK7PL3r62xbDX3RA== X-Received: by 2002:adf:e6cc:0:b0:21d:6e8b:a66b with SMTP id y12-20020adfe6cc000000b0021d6e8ba66bmr9868592wrm.322.1657405963777; Sat, 09 Jul 2022 15:32:43 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id w15-20020a1cf60f000000b003a2c7bf0497sm2525342wmc.16.2022.07.09.15.32.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jul 2022 15:32:43 -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 v4 02/12] thermal/of: Replace device node match with device node search Date: Sun, 10 Jul 2022 00:32:19 +0200 Message-Id: <20220709223229.1619339-3-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709223229.1619339-1-daniel.lezcano@linexp.org> References: <20220709223229.1619339-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 22:41:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E29BC43334 for ; Sat, 9 Jul 2022 22:32:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229670AbiGIWcy (ORCPT ); Sat, 9 Jul 2022 18:32:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbiGIWcr (ORCPT ); Sat, 9 Jul 2022 18:32:47 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A0B617075 for ; Sat, 9 Jul 2022 15:32:45 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id z12so2596213wrq.7 for ; Sat, 09 Jul 2022 15:32:45 -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=PY6cEgCpTPJZ0uoYtaE4XuqUYyoqmbizJ9qK2c3wkpZIvRg6A9mpUSauT/LRjdMNm5 qQQI4nbw9kSoFzNS/URVomAffyQMaYa+bV31B15Z0qTbZgVtv5/wUMrw2dC4RzaOeKrM ow1oXAdCoEdsEs8TDfLoJJTloyquuUZh5KJuy+Jbu3G+VAeRqn5caKBr3Wt+sXP4i4Xc YH4OLWkR4Yo+p0DNPpYmqIf4Sip1DE6r1aWCCTIivcFTMu4Yrl0q3vQw7zx1ODE/q0Pa qMBLqQLTZEn7CG1UXVzr2O2ROvgLecBBsfynFS5piw82i5b/9eFiVtXhGl4yuUfCfMPM WDrg== 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=PHFUHBwMt1JDXJruGmzFeceutFFQY6ETDNlmHYLFYEOXEXgEvuBZ7EV9y+GCPe3Bty DcESTPRA2W5J2/5Kd8Wtbb8qL3q+oFB2Rt7WrECZbh9dftOvF7+16gK0m3fMf7DlDpHO 052qmlbxSexQjfOPs2Uc8180TBwvSEzYULl90YKKF9LBaiX5nnb/0J6/pahzYbfGYHbX oblgHwOMxKvBVSJWT8bF0y/u2SGT9RaOduVe+Qx07IM1GgRI3qMUwBXeJOyWxmm/jHru AlBTeFDq/JkpMqAmrThW1MCA45QxzjjhHiJSh0hMDJCJHo3cza74+L7DhrRo4PCR8Ftb qG9w== X-Gm-Message-State: AJIora+87T504gor7z3RM2elNDCd7T41/GPDSi0Ky/mDafCY3Y9+hZSQ GWQJJYG9MjX8vx6QaSxQfK4h9w== X-Google-Smtp-Source: AGRyM1sksXji7tuh/qAHEJvOQnNH8qh+QiAdaTbHXlTREYckhqvSrcPz10/b/IcVKYUGqJNitknnQg== X-Received: by 2002:adf:c64c:0:b0:21a:7a3:54a4 with SMTP id u12-20020adfc64c000000b0021a07a354a4mr9646809wrg.163.1657405964871; Sat, 09 Jul 2022 15:32:44 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id w15-20020a1cf60f000000b003a2c7bf0497sm2525342wmc.16.2022.07.09.15.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jul 2022 15:32:44 -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 v4 03/12] thermal/of: Remove the device node pointer for thermal_trip Date: Sun, 10 Jul 2022 00:32:20 +0200 Message-Id: <20220709223229.1619339-4-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709223229.1619339-1-daniel.lezcano@linexp.org> References: <20220709223229.1619339-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 22:41:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B450CCA47C for ; Sat, 9 Jul 2022 22:33:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229694AbiGIWc7 (ORCPT ); Sat, 9 Jul 2022 18:32:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbiGIWcs (ORCPT ); Sat, 9 Jul 2022 18:32:48 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64C2A17E26 for ; Sat, 9 Jul 2022 15:32:47 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id q9so2591738wrd.8 for ; Sat, 09 Jul 2022 15:32:47 -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=5+nVIY1h5cCqeMSuGbhtRjv4VG+ayIC1YDkoQWXD9lNlwIb2hlr/n7ia48iLg8uA0X wD7QPzSr3zNdbS6lcE6k7JrcxMfElaPBp5T7W//s2zy2BJW3IKqlXPWsOFej0hvgKL1I ZO1g62euWmVM6eb2bXSWs2myWiNNqpFKJkWOx68OHkN8YV5OiW2zjEJHJqlSsdPiCEw7 7pYnICXBy6iz1duDmg+3tRtpfGfvinHhCuyG5QF3kR73VMnhcTNjrxyXny0gdya95JIU PRhgAXmKhV8s+w/Y5ymdRhsULjkHh1ZGTd8ErfOYC8FNn/rzveDkypp/Ghww2c+wUuUL ye/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=baXMxBrS0VyvN3VONEOr0KDrB+AMDj3lgsHUEP9YGhxVPNoohSAVwdHO1sqyfnvWRP pk7r+iCJEx9JTodcRhhF2WVrkAMpG+Rv9+2qWfaDLd6LthrOwXcrP2gy0chlkwLEpZtU 1Zsu1ScBKMFg8RUQnlBx8QRjpxv/pO9SMMejj75jInOQgg85XOVE37SysOiI3T982Lvq g+4GVqFuvVFHN63/LN9Fb7ebLZd0Bdan7Xb3gnJIUuXHyo5pb21rzC/Ji2RFvxHLBHcG sg9FaxJkx76CwFa+xe+F9XCjc92a4Lp40XrZRqQXefM2iGVgrYvxZ6lfpiPuZnBA24hb cwXg== X-Gm-Message-State: AJIora/rEtogOPvWlhUt6PLTrGpstP322CMlrPEHH94zzMCnkr8lnnVt FLAp5a07HSqQHx5yumelTgr3zA== X-Google-Smtp-Source: AGRyM1traD5Jboz0hFEubYpwKHbok+/hNmqOaGd+HXEHcCQnMDbLvWMBSsczFLNNKxrkoDjMLg0CxA== X-Received: by 2002:adf:f646:0:b0:21d:7000:95b1 with SMTP id x6-20020adff646000000b0021d700095b1mr10207787wrp.486.1657405965975; Sat, 09 Jul 2022 15:32:45 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id w15-20020a1cf60f000000b003a2c7bf0497sm2525342wmc.16.2022.07.09.15.32.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jul 2022 15:32:45 -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 v4 04/12] thermal/of: Move thermal_trip structure to thermal.h Date: Sun, 10 Jul 2022 00:32:21 +0200 Message-Id: <20220709223229.1619339-5-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709223229.1619339-1-daniel.lezcano@linexp.org> References: <20220709223229.1619339-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 22:41:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE003C43334 for ; Sat, 9 Jul 2022 22:33:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229717AbiGIWdB (ORCPT ); Sat, 9 Jul 2022 18:33:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229672AbiGIWc6 (ORCPT ); Sat, 9 Jul 2022 18:32:58 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87B36186C8 for ; Sat, 9 Jul 2022 15:32:48 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id o4so2614177wrh.3 for ; Sat, 09 Jul 2022 15:32:48 -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=HcpqwxZikqXjR6TUiqlV1zMK15j5+AFK+kPI4Gqfyv0tYjrStuATm49z6VAu3+2MbS nYutoLrPGid9YTw2Y2jUMIVVJu8GIHnr/jznmABXgCm8no6tsisjTtt0MP0kMn3cQLNZ BGxKyyY56PLT+BXVI9DXtORAvVGKtEXDciHkS2mO74wcSaGLWoAjRbyNWdiJuXGioq8t sgeqedA8r8qYVUpbEIPP4VZh4zIoWNuXmhE9mnA2LpbBV1rINxuuFJi/KVnaYh8+p4Ub WlH6wjmtkDjQVeEX2FqsNidPE4w6hCZ+B7Er46SjW3u3Jn8EyVUeLp8cq0pBot/fSG4X SIkg== 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=uDpMNQrucaH60gGSq69D8HaUmeqqpZcJzXKNAgQb2SKr+ISQKGRt2YUEKy6aJc0TKF gwtW4gAlfFMse+V5/bGWzxU0m4/MZM9NxpLds7WpyIrpVmB33RAsHDGmoI6WJsIhXERz siH0nP/3XyhQfxrmC/oCL4Oztu9EJtK6QUDVWPhhcEzWWgYQJwW8zvTT2065YP5sVPeo G9ZjRiIWg7uxPP5G41vUyEF7IQsVNGyxOH6zYa0yl3vkWu0bvz1SSdxCYW34fpXzHPqa Or2bOS07odjA9K3mndzdVvK3mqqkL94xsAxSa9aZ50VqELVoB92n/EJ+xVFVjDk6gurz k7qw== X-Gm-Message-State: AJIora/GJlB83KOPYufEM3fTPSrLxso9FXlQr9++4q3kW1QCsWrEvPVR jH8lglku8AqhfNq4/dqk/C8FpA== X-Google-Smtp-Source: AGRyM1tsSkzuJFzYQD6I3kxw5bTYNEUrOqI++35wwohmRJ5/QIG/KARbvz8Hn7LzBGTwm8Ix5hS/+Q== X-Received: by 2002:a5d:440e:0:b0:21d:85ce:6b8e with SMTP id z14-20020a5d440e000000b0021d85ce6b8emr9918504wrq.248.1657405966976; Sat, 09 Jul 2022 15:32:46 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id w15-20020a1cf60f000000b003a2c7bf0497sm2525342wmc.16.2022.07.09.15.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jul 2022 15:32:46 -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 v4 05/12] thermal/core: Remove unneeded EXPORT_SYMBOLS Date: Sun, 10 Jul 2022 00:32:22 +0200 Message-Id: <20220709223229.1619339-6-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709223229.1619339-1-daniel.lezcano@linexp.org> References: <20220709223229.1619339-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 22:41:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CCC9C433EF for ; Sat, 9 Jul 2022 22:33:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229681AbiGIWdF (ORCPT ); Sat, 9 Jul 2022 18:33:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229678AbiGIWc6 (ORCPT ); Sat, 9 Jul 2022 18:32:58 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C13A286EF for ; Sat, 9 Jul 2022 15:32:49 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id r14so2620718wrg.1 for ; Sat, 09 Jul 2022 15:32:49 -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=24xBtJgtSBDKylRS46FvI0oI+VUMvnqGnrZVjJQfK/v2gF5KgV1/LJyH6zzhtwmARp 5Q3f39IONBzdBFv9wMgg2zD30vN5Vk4CwZViZ/K68toixnsEeCbnTrhUb9u6mac3vL59 4aYo825VYEj66rt3KRza4OGuNbMLKt5Pf0ekztEKCqIjFbIl/tNKbPCQNJzPej3M42Nr 5nhpTV74T/Odj6ns9hgRrEyRFu3mr/zyipqkzLiNSSUM9t8HVdAaQxRhbU0bHn8z5+vq UVpcMEvE3Mkw2BgokQJBj7dG/oyMHD9DDqopGlP1q75TCNjt2Qua15KoCLR/9Y6pxbDh I9ig== 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=cAhYQVGfWSxQEz+QotwhCTgv4OLjszwFL0hMjxoVv8HETWHcUPW4UPeas0xiWInOfh X1OMZFRLq+lawH+WOhFNXAsXcJsp17JtsopmOUQziP0Qm6QQKw4iZpV3JbFlIgwDXUIY t6+c/XbknTX6W+GYNPgiU9NcLNk3YGQp3XuouUEEuFi6wnO/M2baIlBUaM11Gg8ltEnU tT8MHsP9kauTi1+IFtH4/pViUBy5acXsC1LypuAFN9hnM8quZWUITGyY3G71i8QMJPIf ZWiB4SJzYNiQZ2pDwPYqmo3UjfvOO7dlD342Avd028+oTRd/xqRJz637jfB9wAgYfC5x zklw== X-Gm-Message-State: AJIora+k9VivoCubf/uTyTQEUx/xMlrHPmSRTSZmS2Em4kZygwNA5OpA oPpMjncFoRGOBpB4O++v/P+2wA== X-Google-Smtp-Source: AGRyM1sIFcInXH4TeuOaGsIA0l3LNcz85kdgn0+Bvonwwm0YBYGrp1zS91z9BF30Oa7s+kVT75OwZA== X-Received: by 2002:a5d:48cf:0:b0:210:1229:2e7 with SMTP id p15-20020a5d48cf000000b00210122902e7mr9796471wrs.567.1657405968103; Sat, 09 Jul 2022 15:32:48 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id w15-20020a1cf60f000000b003a2c7bf0497sm2525342wmc.16.2022.07.09.15.32.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jul 2022 15:32:47 -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 v4 06/12] thermal/core: Move thermal_set_delay_jiffies to static Date: Sun, 10 Jul 2022 00:32:23 +0200 Message-Id: <20220709223229.1619339-7-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709223229.1619339-1-daniel.lezcano@linexp.org> References: <20220709223229.1619339-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 22:41:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55D5BC433EF for ; Sat, 9 Jul 2022 22:33:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229566AbiGIWdN (ORCPT ); Sat, 9 Jul 2022 18:33:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229715AbiGIWdB (ORCPT ); Sat, 9 Jul 2022 18:33:01 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9EEB2A258 for ; Sat, 9 Jul 2022 15:32:55 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id n185so1140257wmn.4 for ; Sat, 09 Jul 2022 15:32:55 -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=k0cnum/P7v/NoYC58+sPIbpJjhuFHtROqqz0oXXmi3jMa2RUUp6wirlBhZLD6fGG9e LRogOPlCCOLAfm7uV4sjjaaNgOVnQ76rSfX+XPGYfrmZZln89wGShZXM971dp3ljDlbh Nc7gWE46hrsjrS5HXLCxMtCoR5VG3YsobB4lm0OQU1i0ZNh4hcudROSOQnP/pebJgPxV 67lCDXnnUGNePN+mBMk4OqamftJ07oaDuFYqfEIQzoG5amsEZACBuZj+tzVCGvtgr2I7 YQuM0TtH54Tfe4NnP+Ekj/dr91jn0FufQAwP62/DZPSUmteEnseqNETQyjxFtpgSxxwK XJmg== 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=A5OuvGc1VHWhfYsH6+4PmQ5Gum7+0PHx4NKV78kTyS9WOhLvxt9sKI0Hz2WRQH9bvb ILiIZld7FQdrDhKEJ7AEFCbAD0j234Eww9ad/D97v9hbXwMkBNE9MJDKg8rAc2Nft7H9 qCkvtluD5TuubRBwyTxo3F1GqAUH32vF5y7Rxsvm+MtGwmTEH5dssEnpr0lpEQnoZ6z3 SS6Mu8+Wku41I7PfFSBGv/HqZPGLQoicr4cVgtMKy+zrB0LuSBBubRG8Umm7nObrB7IG 5lJHWSWG175Ri5JzrQoMBzi5F1y9d90hS4ZGka6MpVjVAHphjSozgzJciQJ7dtvkcZvs O8nw== X-Gm-Message-State: AJIora/ilour21huSNojrSbFwIs77yEH+7ZINpS0SeftGbGUuWiagMJO r8CvdU2I+SeHqE5823jsZWJyEQ== X-Google-Smtp-Source: AGRyM1uqa5z1QdfHrDDTNAEoY79PlBr2NG6XAbkadDyl6F12jNSP/i7IKoIShuYZnNUTgdDRqmswZg== X-Received: by 2002:a1c:3b09:0:b0:3a2:e125:c8ad with SMTP id i9-20020a1c3b09000000b003a2e125c8admr5088526wma.115.1657405974175; Sat, 09 Jul 2022 15:32:54 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id w15-20020a1cf60f000000b003a2c7bf0497sm2525342wmc.16.2022.07.09.15.32.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jul 2022 15:32:53 -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 v4 07/12] thermal/core: Rename 'trips' to 'num_trips' Date: Sun, 10 Jul 2022 00:32:24 +0200 Message-Id: <20220709223229.1619339-8-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709223229.1619339-1-daniel.lezcano@linexp.org> References: <20220709223229.1619339-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 22:41:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76101C433EF for ; Sat, 9 Jul 2022 22:33:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229743AbiGIWdJ (ORCPT ); Sat, 9 Jul 2022 18:33:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229700AbiGIWc7 (ORCPT ); Sat, 9 Jul 2022 18:32:59 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC23C2A250 for ; Sat, 9 Jul 2022 15:32:55 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id o4so2614404wrh.3 for ; Sat, 09 Jul 2022 15:32:55 -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=o7JVRHYVfcul4OsqSwYRYPwnc7kaBwGWcy0Q7KTjK+F8T0BtG9AIrCOBziM2A6RLQu bU9dxRD06ujY+ZbwApfCBEeINGn2iJ25fvbwULFbE8z/lZi2vHPft6kLtSk995Lk+lLq oX1eMYF1dFvo8XFot8n+C4v3wnQDz6YCvG8ccrCyuOc7gVmOi6yUr4UmkR9AoEKhMUmd 2zDr5xtDRSl8oQ4AFguUadc6MO7F+Tmy5A8nJQa0Uar8tQWK/Am6286ye52NFEBJwI6l iMvRkWtjsUKMGNugwBid8NQ0FqEfh11VZD0PghJMWnUyrW0TxbikVDfRJRMqEzsh/hN4 Kt0Q== 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=8RUVRiyn3rPc0LgJ6WTfD/2VeYV1/eA82V2eUAz4uH/uQ/yTC/Q2FQjJSvYQG48Eb5 LklTuPuIc1WVLpyeP6eAjV+jKW7s/PTpj4DvCgt7qrRPtBSurk8rv0BLtCZLGMX4llgh L9+Oyu+yeYT9iWqoH4vMWzRGaAnuhYMlU+m0XfdG+AuDHEq6A91gZWyNvTZ/O85/Y45c 6wWYndWYX+OeKGDcdvND1guLYCFpbRNIUmTmZyoF+jN+oGiGgiYyQIX6fJsDs1o1znZU 9seGicO0uu5zlxWKxBkNXkCmQc8guwspTA9k20/rDK5n44onLMcgEKrByY3Qm1Ylb33D ntPw== X-Gm-Message-State: AJIora8lPG7RnPzT76HcGOIX8vWVRxOHK7LIKH/OyUuiOIxPh98qZ+lu cB+de9G5C9nbLC8cp76W8TYZKQ== X-Google-Smtp-Source: AGRyM1umdJo9ZTc3GyMtiWJlfdUbbBFE1MKOITaUsVXBsD4/Bx9P+7vqwAv/HTFdeUO0cRAagW05HQ== X-Received: by 2002:a5d:4388:0:b0:21d:691d:7d0e with SMTP id i8-20020a5d4388000000b0021d691d7d0emr9434177wrq.684.1657405975254; Sat, 09 Jul 2022 15:32:55 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id w15-20020a1cf60f000000b003a2c7bf0497sm2525342wmc.16.2022.07.09.15.32.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jul 2022 15:32:55 -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 v4 08/12] thermal/core: Add thermal_trip in thermal_zone Date: Sun, 10 Jul 2022 00:32:25 +0200 Message-Id: <20220709223229.1619339-9-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709223229.1619339-1-daniel.lezcano@linexp.org> References: <20220709223229.1619339-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 22:41:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDE7CC433EF for ; Sat, 9 Jul 2022 22:33:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbiGIWdQ (ORCPT ); Sat, 9 Jul 2022 18:33:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229718AbiGIWdB (ORCPT ); Sat, 9 Jul 2022 18:33:01 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 501842A426 for ; Sat, 9 Jul 2022 15:32:56 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id z12so2596543wrq.7 for ; Sat, 09 Jul 2022 15:32:56 -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=bH6742FDglY2kU6jXlKKPKjXNlX27zB8iJgh2WYv37KH6V3zlecXMNzRmHHf8CRJ5+ WkhAquzDcIYswqKFEsAiGZo2M0Yqy3Lz1wWKmUPcXa1GXnUaVO88tyvssS65rW9pv/3d RgkGNehTel76Qh4uvCYvWWy8jqEvJYXTXBzrefaiLQpVVYFWIKcDl50arC0HFjNmQgmA 7EZt8MAK1Fp2mt+oFNxYMbaFKTz47h6cKX4XzLGybmsufC3mZz8zs7wXK7XhHJ1tydF0 wbtXvy7XwJq35v/zxJ41wfsM454TmQpjb/a0qFzQ0+yGfVwPwJpy6lX/C058WftEJQou XnfQ== 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=jmN4qJ1mm0VVRWybmf0/iiXbXyWD0aediqj6ijdNVdK+HVNkWrRqi1epbUURT6YjYu jSqAN3qwikbOx38h8r3RnQv0r/XfUexv8R5JnWSiQ1cleHEjzPK+fbRBtI06kvC7L2ag +geLnYGB3hnlE922LSwLyL/LjhD/MztLF8GpPPRbL1rJjlEVNgx57iuAj/RMrt/cJdY7 Rzk/DO5a/Nbzi4BK4+PBIZVUC1YZBjDJ+i6n7OSBOGib1B5pz5nJ4AT8eTNqWmW/IL2T u/RRTpfjXelZ5NSvylEI6vSnOga3+OVmDwDmbaBlwDg/E0UWNfLBaWrdvzj+3x7zpR9o Z4OA== X-Gm-Message-State: AJIora9SeFtL2b5I9IeqAcQGsJbjZWTlfrA0QCplFcKgxFhcPiZG8jT+ AYPLQShaLQz8ayBX9czxURiI5w== X-Google-Smtp-Source: AGRyM1uwDEiaAzaNxfIhzSyUGX04kVAWlULP559SIBrxeGce/wKUTX6zhdOrhl9uHB9lsmKEtV6T2w== X-Received: by 2002:a5d:60c1:0:b0:21d:7469:9687 with SMTP id x1-20020a5d60c1000000b0021d74699687mr9714013wrt.361.1657405976370; Sat, 09 Jul 2022 15:32:56 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id w15-20020a1cf60f000000b003a2c7bf0497sm2525342wmc.16.2022.07.09.15.32.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jul 2022 15:32:56 -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 v4 09/12] thermal/core: Register with the trip points Date: Sun, 10 Jul 2022 00:32:26 +0200 Message-Id: <20220709223229.1619339-10-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709223229.1619339-1-daniel.lezcano@linexp.org> References: <20220709223229.1619339-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 22:41:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6EADC43334 for ; Sat, 9 Jul 2022 22:33:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229697AbiGIWd3 (ORCPT ); Sat, 9 Jul 2022 18:33:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229729AbiGIWdH (ORCPT ); Sat, 9 Jul 2022 18:33:07 -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 11F0D2A96A for ; Sat, 9 Jul 2022 15:32:57 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id h17so2656312wrx.0 for ; Sat, 09 Jul 2022 15:32:57 -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=RcvOqEck88xAzhO8wdgxIvjttBHQPuMGZUg/RETkEveNw4cdaCfgGf/7RjGuDNZ0WG +ujPPcMSAzKcgAxazIq6k17Eu71ZnNwHHN2ILAEqxyJrfii6iB6Qty+XiONR77p4may6 f6ZrzYBOOvmN2vkW2SLXMXYYAGJgcth2KyQO/oq+JEkn7mkD6lt9TYtVum8Jq+BhPlJh S8lpuVVHl40EUBTBkBA3XJ86/7LRFkSJk2Bwq/CNO3lnntpW1Rq6dEwfam+7YIDRqnHK Jk4dtuOHRy1DIdUmh/yj4Zmb/VrZopuKAmTArPy3M0hTsY5Qw7bCEqTQ+eZlRKbRmMYE YKJg== 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=fo2u8GKT8vyFF4bIaFh0sPpd5kBDC9auZDHSZUkDAxu/EoEZnootbTHwZ7rqChGRn0 XvJ88kcAGqEGLIUqNNLm0WZOE7jJpkwZL0XaKEeD+CScZDEsle/P7wjbNa+hZTPZ8plo +Yg82kiqQjsLJ387eJ14bbl0ZkZYljJbbaMpbWx8u9fOCp97P1MsqHL6JcOMopwG6O7i NL7fihV9H6g+saOnHKJwdVl3VFhHPJ3ibMzDCMRXcngHLNhZB41aK/5hOPxfJgiWEbJB 3u8d+lFeXa3hJy2Gez8I14gFEBSQN58oMsWCdpYPYtaZ/OYdiuKawW9s6gzhb+Dou6Ke 2yNw== X-Gm-Message-State: AJIora/8kvM/OEuXwLakDhJXL9o0Zjx7RGQFgnF18O32FAEi5oQmPo/w 3x38Vbsx6uFtIchRoHcaBGhckQ== X-Google-Smtp-Source: AGRyM1sGkxRlyHa+gpai0tumMnF8pEalUeKlv4qXaDBxC3YJsKbtt5dGaIUI842HEHohfM6d/rw2vQ== X-Received: by 2002:a5d:4aca:0:b0:21d:6793:1c11 with SMTP id y10-20020a5d4aca000000b0021d67931c11mr9560106wrs.202.1657405977407; Sat, 09 Jul 2022 15:32:57 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id w15-20020a1cf60f000000b003a2c7bf0497sm2525342wmc.16.2022.07.09.15.32.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jul 2022 15:32:57 -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 v4 10/12] thermal/of: Store the trips in the thermal zone Date: Sun, 10 Jul 2022 00:32:27 +0200 Message-Id: <20220709223229.1619339-11-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709223229.1619339-1-daniel.lezcano@linexp.org> References: <20220709223229.1619339-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 22:41:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5DF3C43334 for ; Sat, 9 Jul 2022 22:33:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229572AbiGIWde (ORCPT ); Sat, 9 Jul 2022 18:33:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229740AbiGIWdI (ORCPT ); Sat, 9 Jul 2022 18:33:08 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 388FF1759B for ; Sat, 9 Jul 2022 15:32:58 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id f2so2604011wrr.6 for ; Sat, 09 Jul 2022 15:32:58 -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=zK9PlRT+MmTJG8PsfD4SBWj1MISwo8yjXhL1qjJfd8tNkY+cFxFn+ZrZzgPB2yld/B dzrteJUD1f072pBJ+qCQros0ZRYAdZAuEsMYBUvHTNGwyEgH64Gww7LgurlbfgtYPsAW o+/S0rZXmq4e/caWfQi6s227mfDjD/GJZV24SOgIJ/Q476MZSgMkpCom4HYbWYRukVf3 1g9kKq/8NyHdBohUT87vAvs95LerVG9KWedslFDwLRn4oE9NONqwlXHHgP4ZwiyjDSsX AGtXPNEeD1fMkG5w4wLkOC1eonfcwwyf/I3e/wS0vBuSJR5fMyo3sGg5oUQrMdFRkmFb 9miA== 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=mHxR+rAosIeqq3AOjYUL5ip6QlcjReNK7HahHRNW90UFmhzQaIHuaTWbodHlIQvuBf Bm1Uojd9u9+NGiwwpUi2o7ctSeUdNcw4lXZX3vUTKVtBzRRUh2+fgiiwwgeKTEnlBuBq fzEHgw+6l4deSkqDZcX4t4l82sEw6H9Uyfm73Hqwy0OVVPbsYml2+SjGGrkWotnp3EyV 4nURbyAu8EUOQ83Nk/FmPOJgX09X4v4IrLkNLmoUOQlLokdDnYQiT+Wlpy2goiybMgsK 3Ddm1PbBTErZekCamyZULp6U32LqWHwITcgQfeu932yf/QWttJe/ss2ZJ6BVm/c0jkRx bUPg== X-Gm-Message-State: AJIora+FM0XHrB+BC7J614/5Q1QcB1udkOcyqJtzoU2IUrhgJZ9jrvVH TyJx+fZOUi9xwvKnC39ZBwdXEg== X-Google-Smtp-Source: AGRyM1sKxwEX8OhydrMs9D6/2l/kCVSrOoNaz0Cv+wxzwUCjev1kZxTM6Z4FKZlOqAQbrQ4ttCKoKA== X-Received: by 2002:adf:ce0c:0:b0:21d:929e:1522 with SMTP id p12-20020adfce0c000000b0021d929e1522mr7402087wrn.126.1657405978483; Sat, 09 Jul 2022 15:32:58 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id w15-20020a1cf60f000000b003a2c7bf0497sm2525342wmc.16.2022.07.09.15.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jul 2022 15:32:58 -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 v4 11/12] thermal/of: Use thermal trips stored in the thermal zone Date: Sun, 10 Jul 2022 00:32:28 +0200 Message-Id: <20220709223229.1619339-12-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709223229.1619339-1-daniel.lezcano@linexp.org> References: <20220709223229.1619339-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 22:41:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE772C43334 for ; Sat, 9 Jul 2022 22:33:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229571AbiGIWdh (ORCPT ); Sat, 9 Jul 2022 18:33:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229700AbiGIWdK (ORCPT ); Sat, 9 Jul 2022 18:33:10 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 154842AE0A for ; Sat, 9 Jul 2022 15:32:59 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id q9so2592086wrd.8 for ; Sat, 09 Jul 2022 15:32:59 -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=SD0RKMK5Q3Q8sjw2sPd6eKcyMSLlIgckhKohOzGFpgA=; b=ZIEO3IlRH+KuDYcW/Ly7aWJaqzvxd7fr87WmVORkAzuJrzb8VlXQFc9y8lxe0Owago l6h9PXfHbnkJeQ5GJY/VOYE0Z+Zaf/55a/0LpHoiNruO8Ozj9pcvAeE7FhEVLMUxdnY4 PST+FyaLCcSdf4wt2lCAQPbdSW1Af+j2HKhx6unTWSj8KD5jzSmryYTI+3iNG4L5yHmo E2zwey00IJt1LMCOwMMUJUxNTuBKamMZo1Dj73scyIVGt7S2f7VYoC8vYnLpfCf3mkNo HmC6fgGex/sK9LbfplxQAOxwSCKDrb4CqkzD3I9Fo6QnZvQFLwp76WSC8suZFFTB98AC QVUA== 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=SD0RKMK5Q3Q8sjw2sPd6eKcyMSLlIgckhKohOzGFpgA=; b=E3eW2YCDWSbVQf3FdUYqb9oBxnYWyc2IIE2Ey5SkdmFOSGncsGjy0ls6A/YX5qsc7h rvA3/29m/1O66VJSAo8KKhWv3XGdaXMgo7ShTqZ0MD7ag51lf8yeUnkayg96emi3Tjag V2MPd+hgnd9ZMKGrG8CSwBEBn33mf0truqhfZAZtcW+tuxS1bYL48WnTtSViW1dZjRxl pjRnkmvjaihax9taNHWBvFwlQ3QbC1uuzCKgsm/4pQd+PW4Kug4MBzrPfq45s0L3wZCS cCViiykzJQn3C2iXNHSf9N9cYn/ftbHo/ip0lSiWfNDhdNTkUB7Ysnzk3a/h4rh1GiRL YZXg== X-Gm-Message-State: AJIora85j0dFOallWMXg8hJsd3+JIlsy1Kyq30sA4TvWNe0PYJiPaSKP xKctAmoTPQZ4hFgZDcvS5NEHQg== X-Google-Smtp-Source: AGRyM1vJiqJOq6HGvrFV4Tks9HUdABrK9yN85JtvQWBxd2IQheikTmMizAs21z53u8Eac7clIJj/Sw== X-Received: by 2002:a05:6000:1549:b0:21b:c7fb:9dd0 with SMTP id 9-20020a056000154900b0021bc7fb9dd0mr9117346wry.446.1657405979536; Sat, 09 Jul 2022 15:32:59 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id w15-20020a1cf60f000000b003a2c7bf0497sm2525342wmc.16.2022.07.09.15.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jul 2022 15:32:59 -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 v4 12/12] thermal/of: Initialize trip points separately Date: Sun, 10 Jul 2022 00:32:29 +0200 Message-Id: <20220709223229.1619339-13-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709223229.1619339-1-daniel.lezcano@linexp.org> References: <20220709223229.1619339-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 Reported-by: kernel test robot --- drivers/thermal/thermal_of.c | 101 ++++++++++++++++++++++------------- 1 file changed, 65 insertions(+), 36 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 601552c55d0b..40fd7260b2ad 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,7 +1007,6 @@ __init *thermal_of_build_thermal_zone(struct device_no= de *np) kfree(tz->tbps); free_trips: kfree(tz->trips); - of_node_put(trips); of_node_put(gchild); free_tz: kfree(tz); --=20 2.25.1