From patchwork Sun Jul 10 12:35:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589321 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 96FFFC43334 for ; Sun, 10 Jul 2022 12:35:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229625AbiGJMfW (ORCPT ); Sun, 10 Jul 2022 08:35:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229616AbiGJMfV (ORCPT ); Sun, 10 Jul 2022 08:35:21 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA1491114C for ; Sun, 10 Jul 2022 05:35:18 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id v10-20020a05600c15ca00b003a2db8aa2c4so1607720wmf.2 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=Fl5RZbRnzUe1q8L5b8HhYThvHfPTFAo3O9m4uIG/yC6HwBXzAMnYT2jckOL4zrZMtT 9HcKFx3DtPEmEiQK5+y7FUxFMNlYqG1oCJTxPzfKw8RC7OxTqiz6YMsBJd29gwJ54wIr rFDPmZnWY+ik+s2QB8XKTF2bJD1WQ+Ktgi3jScr9FFZsdkMh3SD88DM6GuOGrGhQ3d+H WEgSDNGXXsbWk12e2muYEMr4gEIiD1WeMHc/T4Ethb5sEyJTOd4SGQ5zQ98DtY0WRmaS 9OECLQHyuvK32vQf1qvN9lM3hqowkD0/36tBUcOnuxs13b5xiBp3URMGbnkEffMVZRkF +USw== X-Gm-Message-State: AJIora86614LoLm15+TlDBNmCG1XjrfIv5X/DQ7OZL152PDjKljciG/H Z0Hor0nmiq+c+T2cfdJzkjUlJw== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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; if (!type || strlen(type) == 0) { - pr_err("Error: No thermal zone type defined\n"); + pr_err("No thermal zone type defined\n"); return ERR_PTR(-EINVAL); } if (type && strlen(type) >= 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); } 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); } 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); } From patchwork Sun Jul 10 12:35:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589682 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 B4CB0C433EF for ; Sun, 10 Jul 2022 12:35:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229638AbiGJMfX (ORCPT ); Sun, 10 Jul 2022 08:35:23 -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 S229622AbiGJMfV (ORCPT ); Sun, 10 Jul 2022 08:35:21 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E497E1115F for ; Sun, 10 Jul 2022 05:35:19 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id o4so3855995wrh.3 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=jmQz+Dz5lPfs66skunIehO+yxUvuCZGFAjdS+6ZRQcgFr8LFTXyAF2yZ3eyGQ7E25n 4mO19Inkrx+D8Y2Rnt+CxkLDxyLyReJ8bdhl2sKg8xIBytsw9QpmlUAdfX8aCBxR3K0s BUrAIw/kjtiQ7tQnGbmxP6mLVICpIan+RL0FA/vjLu1YEyJ/8aV9rqCzEU+g+ZYznRFd M0+jo8fXuT1Xs29DQqCTfV0A8txowElsKyPcJru0OfBobeOLvAbM90yXsBdkLerY6LPg CnOsL/bLsy7gDHQ8uD2hPuX+FOK9it2gpx5rHT99l4qT9Q6rx/Z1OGto3sPvWoMPDw+P WUjQ== X-Gm-Message-State: AJIora8CQQVfDaqhT8qvxzOy9AMj2WK199ekI6TiuU1UfoHyvhgZ/Wek Hwt+Zno8oMU6bGEYX4F6UL3uqg== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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_unregister); /*** functions parsing device tree nodes ***/ +static int of_find_trip_id(struct device_node *np, struct device_node *trip) +{ + struct device_node *trips; + struct device_node *t; + int i = 0; + + trips = 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 == trip) + goto out; + i++; + } + + i = -ENXIO; +out: + 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_unregister); * 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; /* Default weight. Usage is optional */ @@ -708,18 +736,14 @@ static int thermal_of_populate_bind_params(struct device_node *np, return -ENODEV; } - /* match using device_node */ - for (i = 0; i < ntrips; i++) - if (trip == trips[i].np) { - __tbp->trip_id = i; - break; - } - - if (i == ntrips) { - ret = -ENODEV; + trip_id = of_find_trip_id(np, trip); + if (trip_id < 0) { + ret = trip_id; goto end; } + __tbp->trip_id = trip_id; + count = of_count_phandle_with_args(np, "cooling-device", "#cooling-cells"); if (count <= 0) { @@ -868,6 +892,7 @@ static struct __thermal_zone __init *thermal_of_build_thermal_zone(struct device_node *np) { struct device_node *child = 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_node *np) } /* trips */ - child = of_get_child_by_name(np, "trips"); + trips = of_get_child_by_name(np, "trips"); /* No trips provided */ - if (!child) + if (!trips) goto finish; - tz->ntrips = of_get_child_count(child); + tz->ntrips = of_get_child_count(trips); if (tz->ntrips == 0) /* must have at least one child */ goto finish; @@ -927,14 +952,12 @@ __init *thermal_of_build_thermal_zone(struct device_node *np) } i = 0; - for_each_child_of_node(child, gchild) { + for_each_child_of_node(trips, gchild) { ret = thermal_of_populate_trip(gchild, &tz->trips[i++]); if (ret) goto free_trips; } - of_node_put(child); - /* cooling-maps */ child = of_get_child_by_name(np, "cooling-maps"); @@ -954,13 +977,13 @@ __init *thermal_of_build_thermal_zone(struct device_node *np) i = 0; for_each_child_of_node(child, gchild) { - ret = thermal_of_populate_bind_params(gchild, &tz->tbps[i++], - tz->trips, tz->ntrips); + ret = thermal_of_populate_bind_params(gchild, &tz->tbps[i++]); if (ret) goto free_tbps; } finish: + of_node_put(trips); of_node_put(child); return tz; @@ -981,6 +1004,7 @@ __init *thermal_of_build_thermal_zone(struct device_node *np) for (i = 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); From patchwork Sun Jul 10 12:35:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589320 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 70E10CCA480 for ; Sun, 10 Jul 2022 12:35:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229622AbiGJMfY (ORCPT ); Sun, 10 Jul 2022 08:35:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbiGJMfW (ORCPT ); Sun, 10 Jul 2022 08:35:22 -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 0346111160 for ; Sun, 10 Jul 2022 05:35:21 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id l68so1644343wml.3 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=QxzO8al2zfnK9148dtIJUuUFoR/4++3hc+D2j9lWrDibGYbAOCAkvC9r0hX/qMjV8C XK5Ti7ft7FbYZ9l1hRwfsK6VDvr5mcS/QCLpQAI4dLLUh50ymUbDcBIcg03qjVXzXqnW uE+ZYnU+ZI/PCrKqlwwXGcEnP2roWFvb2QhH6tFjIicuYxwsgzE/Fo8oVpA/fVRuC04T RObLfKCCdXcOj20Aw/PFHBgfRCeIzHd8fFYeL5G3egtL4ph4h9zhmknXvs34VR0dkEvw 9bR7lCgnV6LphaJ4zatFbvEtmLlMTGtOWbhMCyXk6SwDm+XE1OPaRPw05Zu4NYD95aQi SLgg== X-Gm-Message-State: AJIora8DUZKeETE1vYHrI3Gjm2M9r0NzI5KjrpTV2qFfXhGWikRCojD6 b/h3BzBk9ef6z7xgh2XIXlQrug== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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_device *cdev); /** * 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; } - /* Required for cooling map matching */ - trip->np = np; - of_node_get(np); - return 0; } @@ -1001,8 +997,6 @@ __init *thermal_of_build_thermal_zone(struct device_node *np) kfree(tz->tbps); free_trips: - for (i = 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 __thermal_zone *tz) } kfree(tz->tbps); - for (i = 0; i < tz->ntrips; i++) - of_node_put(tz->trips[i].np); kfree(tz->trips); kfree(tz); } From patchwork Sun Jul 10 12:35:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589319 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 91F5FCCA479 for ; Sun, 10 Jul 2022 12:35:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229626AbiGJMf0 (ORCPT ); Sun, 10 Jul 2022 08:35:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbiGJMfX (ORCPT ); Sun, 10 Jul 2022 08:35:23 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06DBF11149 for ; Sun, 10 Jul 2022 05:35:22 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id v16so3809940wrd.13 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=isdiQ26OoHSOwIdlqm0h6Ft5pLfPyr/vOwGovvmMiBU9hzvPCfmaSHkn+NP85IjgJg xQcKe/VxXUOTnxXj6vXreP+RZl87EAfB7BgKvCk8YGN7vM6zHAVhhchaxMAOYZHNRFdn 59sya+11HkcHVf/OetPsse+y1LpEL5RJ8EpNYh/bYn87yQX7Y+8f5IjmqUTl/QqgZSvj n+DyvNP0KWVoUlm8wkZv4TU1lDWEWbOM/EQN/7qdunCDvmWEDmQTPCiupTPvUNs1equD kQ+rIAUCFiaoCC3I/uCbW1mNNxuNydWz3pR7g4+Z7TgULljVsWLrFtULIGDZKRANskI8 HFdw== X-Gm-Message-State: AJIora8b/vbkvQEofyosEWoDG7XNf+YYlkR0kCurTth1/DhhrWDsMZdy Y8I5lebIwgjO4YmmrcSGcdU1O8soA5ibCQ== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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_cooling_device *cdev) void thermal_cdev_update(struct thermal_cooling_device *); void __thermal_cdev_update(struct thermal_cooling_device *cdev); -/** - * 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); 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 *); }; +/** + * 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 *); From patchwork Sun Jul 10 12:35:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589681 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 5238BCCA482 for ; Sun, 10 Jul 2022 12:35:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229642AbiGJMfZ (ORCPT ); Sun, 10 Jul 2022 08:35:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229633AbiGJMfX (ORCPT ); Sun, 10 Jul 2022 08:35:23 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E11411156 for ; Sun, 10 Jul 2022 05:35:22 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id v10-20020a05600c15ca00b003a2db8aa2c4so1607760wmf.2 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=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=ci0b9xx8ylH/3HIBSpM0PIn+Mq/ltD9sPYpeyT6Xm6izEO3GXj77MdltsRWn/fsIu/ PhPqV3FSPFX6UsLKSyssfQdkJDykyRJoQIO2fF5ZLrBb5Av1sRoMIJ4LBcaag79vIF5o zHHHdgIDk0/buJhfr4fnEP16fehc69LWRCmcQDVjTqOmgjlZtEslUeWtMbl6Scpqq75J xQwtabt4RPsz26PiSN5qai7g4QsrOxetDMwcjRA44w1kV0Pb2P9AKhPSWx2gSMjk4GIb o9m7FUKe4ZUDsBB8nTDBRWfIgiEXaAmgPI4YWMfg+SrSwiLVx1FaCdOQGiMlp0g/rrT1 Kj2w== X-Gm-Message-State: AJIora8TloYpDDwMvKmj+BjIZfvQMFsOBksNjt0irRg7jkjeZViTUM0E AZIJKqm6UUwZa0iUKFCAfHao7vBjYri7/w== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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_helpers.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) return trend; } -EXPORT_SYMBOL(get_tz_trend); 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); /** * thermal_zone_get_slope - return the slope attribute of the thermal zone From patchwork Sun Jul 10 12:35:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589680 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 8C729C43334 for ; Sun, 10 Jul 2022 12:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229632AbiGJMf1 (ORCPT ); Sun, 10 Jul 2022 08:35:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbiGJMfZ (ORCPT ); Sun, 10 Jul 2022 08:35:25 -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 3FC7E1114C for ; Sun, 10 Jul 2022 05:35:24 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id b26so3851549wrc.2 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=qR1Ix5CVQ7YMUgrcuLMVYuqU56TT0ihkPrgat1Xu2u2Uc4EelVjeYZFZ35wcgh9Lxn yW66oTKuD9CC+zU69455CRPXmsIAb64TPrl1M6dwlrwdAIFMkQEImxA9pCwOUaGmrkqZ ol309XFPeqMfwUAlyA3krejDUZ81tdVKDsA4KfQsRUvtXodc7/kcrYj202O05AmW6Mlq OUn5Ql4CbZe2lw8wivTqRyQm0V/gqGZYiKMEHy5AKyekW2TUG6dfJHRpPB+uqnVEKCox IVsAUI+WThSo4MuyNbtJcGpIQuQDjHDxve2tuSHaHmOelG40dm7qlQHl/H+sLHsxiH66 mTsA== X-Gm-Message-State: AJIora+/PW+Baim7VbOVP522mii/w1YrIqdVc+ZdtKuyMuUN4eE4vMnX Eh97/LvCFENzQp3SAjERMFNYkBbHJfO4lg== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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); } +static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms) +{ + *delay_jiffies = msecs_to_jiffies(delay_ms); + if (delay_ms > 1000) + *delay_jiffies = 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); /* Helpers */ void thermal_zone_set_trips(struct thermal_zone_device *tz); -void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms); /* 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_helpers.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); } -void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms) -{ - *delay_jiffies = msecs_to_jiffies(delay_ms); - if (delay_ms > 1000) - *delay_jiffies = round_jiffies(*delay_jiffies); -} - static void thermal_cdev_set_cur_state(struct thermal_cooling_device *cdev, int target) { From patchwork Sun Jul 10 12:35:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589318 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 8259ECCA479 for ; Sun, 10 Jul 2022 12:35:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229664AbiGJMfc (ORCPT ); Sun, 10 Jul 2022 08:35:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbiGJMf3 (ORCPT ); Sun, 10 Jul 2022 08:35:29 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D705511447 for ; Sun, 10 Jul 2022 05:35:27 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id v16so3810142wrd.13 for ; Sun, 10 Jul 2022 05:35:27 -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=dsC+Nb7T9ppe1oMYRRoDJjXw2Y3c19yrxzC8AIXFTR0TtPOb+6VZF5FBy6XgGzESIO 0uERo1QOkKLXgeYlcBu61rOMpvWPsL06oF6YRl2dagYU9W2SD7ytRRJni4CvacecgRtk tlvCNBnvkwYp6vcoOe4BtHVbAo/7NQifeVBjj+5fMeKNILV0Ro/ohFHkyjVuK+US36Vh Ie1vtFb18Gj6eib1PmQCIcdO86G4iL6pXNoL1xbKD0eTI1km2KfNIZs73ap3q5ot+8u0 fLxyg8nnq5ziQtqaSkprD/KKt6tLEThr+Dr9CNQPrqunBOLXnYZSC0fzWJfFgUPiwn71 npYw== X-Gm-Message-State: AJIora9GUMoOkG+iSHwDSKTU0u6ZsmGlJ+jnR3eEK6yxojVqDvlFPcWg inqng9hJzogJwkbMzWjQ49rk0Q== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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_share.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 *tz) int trip_temp; enum thermal_trip_type trip_type; - if (tz->trips == 0 || !tz->ops->get_trip_temp) + if (tz->num_trips == 0 || !tz->ops->get_trip_temp) return 0; - for (count = 0; count < tz->trips; count++) { + for (count = 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, cdev->ops->get_max_state(cdev, &max_state); - return (long)(percentage * level * max_state) / (100 * tz->trips); + return (long)(percentage * level * max_state) / (100 * tz->num_trips); } /** diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_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_device *tz, last_active = INVALID_TRIP; last_passive = INVALID_TRIP; - for (i = 0; i < tz->trips; i++) { + for (i = 0; i < tz->num_trips; i++) { enum thermal_trip_type type; int ret; @@ -668,7 +668,7 @@ static int power_allocator_bind(struct thermal_zone_device *tz) get_governor_trips(tz, params); - if (tz->trips > 0) { + if (tz->num_trips > 0) { ret = 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/tegra/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 thermal_zone_device *tzd, *hot_trip = 85000; *crit_trip = 90000; - for (i = 0; i < tzd->trips; i++) { + for (i = 0; i < tzd->num_trips; i++) { enum thermal_trip_type type; int trip_temp; 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_device *tz, tz->notify_event = event; - for (count = 0; count < tz->trips; count++) + for (count = 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_zone_device *tz, unsigned long max_state; int result, ret; - if (trip >= tz->trips || trip < 0) + if (trip >= tz->num_trips || trip < 0) return -EINVAL; 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; - for (i = 0; i < tz->trips; i++) { + for (i = 0; i < tz->num_trips; i++) { if (mask & (1 << i)) { unsigned long upper, lower; @@ -1057,7 +1057,7 @@ static void __unbind(struct thermal_zone_device *tz, int mask, { int i; - for (i = 0; i < tz->trips; i++) + for (i = 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 trips, int mask, return ERR_PTR(-EINVAL); } - 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 trips, int mask, return ERR_PTR(-EINVAL); } - 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); tz = kzalloc(sizeof(*tz), GFP_KERNEL); @@ -1255,7 +1255,7 @@ thermal_zone_device_register(const char *type, int trips, int mask, tz->tzp = tzp; tz->device.class = &thermal_class; tz->devdata = devdata; - tz->trips = trips; + tz->num_trips = num_trips; 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 trips, int mask, if (result) goto release_device; - for (count = 0; count < trips; count++) { + for (count = 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_helpers.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 = tz->ops->get_temp(tz, temp); if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) { - for (count = 0; count < tz->trips; count++) { + for (count = 0; count < tz->num_trips; count++) { ret = tz->ops->get_trip_type(tz, count, &type); if (!ret && type == THERMAL_TRIP_CRITICAL) { ret = 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; - for (i = 0; i < tz->trips; i++) { + for (i = 0; i < tz->num_trips; i++) { int trip_low; tz->ops->get_trip_temp(tz, i, &trip_temp); diff --git a/drivers/thermal/thermal_netlink.c b/drivers/thermal/thermal_netlink.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) mutex_lock(&tz->lock); - for (i = 0; i < tz->trips; i++) { + for (i = 0; i < tz->num_trips; i++) { enum thermal_trip_type type; int temp, hyst = 0; diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.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_device *tz, int mask) int indx; /* This function works only for zones with at least one trip */ - if (tz->trips <= 0) + if (tz->num_trips <= 0) return -EINVAL; - tz->trip_type_attrs = kcalloc(tz->trips, sizeof(*tz->trip_type_attrs), + tz->trip_type_attrs = kcalloc(tz->num_trips, sizeof(*tz->trip_type_attrs), GFP_KERNEL); if (!tz->trip_type_attrs) return -ENOMEM; - tz->trip_temp_attrs = kcalloc(tz->trips, sizeof(*tz->trip_temp_attrs), + tz->trip_temp_attrs = kcalloc(tz->num_trips, sizeof(*tz->trip_temp_attrs), GFP_KERNEL); if (!tz->trip_temp_attrs) { kfree(tz->trip_type_attrs); @@ -432,7 +432,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) } if (tz->ops->get_trip_hyst) { - tz->trip_hyst_attrs = kcalloc(tz->trips, + tz->trip_hyst_attrs = 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) } } - attrs = kcalloc(tz->trips * 3 + 1, sizeof(*attrs), GFP_KERNEL); + attrs = 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; } - for (indx = 0; indx < tz->trips; indx++) { + for (indx = 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 = trip_point_temp_store; } - attrs[indx + tz->trips] = &tz->trip_temp_attrs[indx].attr.attr; + attrs[indx + tz->num_trips] = &tz->trip_temp_attrs[indx].attr.attr; /* create Optional trip hyst attribute */ if (!tz->ops->get_trip_hyst) @@ -496,10 +496,10 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) tz->trip_hyst_attrs[indx].attr.store = trip_point_hyst_store; } - attrs[indx + tz->trips * 2] = + attrs[indx + tz->num_trips * 2] = &tz->trip_hyst_attrs[indx].attr.attr; } - attrs[tz->trips * 3] = NULL; + attrs[tz->num_trips * 3] = NULL; tz->trips_attribute_group.attrs = attrs; @@ -540,7 +540,7 @@ int thermal_zone_create_device_groups(struct thermal_zone_device *tz, for (i = 0; i < size - 2; i++) groups[i] = thermal_zone_attribute_groups[i]; - if (tz->trips) { + if (tz->num_trips) { result = 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; - if (tz->trips) + if (tz->num_trips) destroy_trip_attrs(tz); 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; From patchwork Sun Jul 10 12:35:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589678 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 AE52DC43334 for ; Sun, 10 Jul 2022 12:36:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229540AbiGJMgA (ORCPT ); Sun, 10 Jul 2022 08:36:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbiGJMfr (ORCPT ); Sun, 10 Jul 2022 08:35:47 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFEA513E94 for ; Sun, 10 Jul 2022 05:35:34 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id v14so3845582wra.5 for ; Sun, 10 Jul 2022 05:35:34 -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=77KDJe79ZegZQsPnHz3z6IiJQAs5HMcfjvbqd7yKN/nFb56/N7DeKt0N/ZE4W+U7bV I/68U9ADiPijujwxqHpXXiz4+Myc+oY+++Xxmnn9aH6pKcJIC5ID6mfhiLE5mWQ8nNL6 SnzSxvCeJLSvhxU1M261QDRM6mrgcPfi7JLMnz+u+NXmI8LnGMnxsteifQ7YPIiz2jrK DByY5D3IuFAiR+UCrxSC/4hgQg6MCiM/Pr6ZkHgqHcbUFKbTqYvP9dgKXU8x3HvzWpy4 PhFFKfNSDvkqRWb+a+mFoKYR3EefBld7plaSJ0go7EI4Omn15QGV6Ev0VrntydJB8teU AWbA== X-Gm-Message-State: AJIora/tLE31PrEOIEvbuu1ACrYLoJNIlbd8NnuONjao6N05oZfq9glJ wqp12aqKrhHU5zLKwPdvQu0XGg== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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); +static inline struct thermal_trip *thermal_zone_get_trips(struct thermal_zone_device *tz) +{ + return tz->trips; +} + +static inline int thermal_zone_get_num_trips(struct thermal_zone_device *tz) +{ + 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; From patchwork Sun Jul 10 12:35:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589317 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 230ACCCA479 for ; Sun, 10 Jul 2022 12:36:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229749AbiGJMf7 (ORCPT ); Sun, 10 Jul 2022 08:35:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbiGJMfr (ORCPT ); Sun, 10 Jul 2022 08:35:47 -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 B8EED13E2C for ; Sun, 10 Jul 2022 05:35:34 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id l68so1644494wml.3 for ; Sun, 10 Jul 2022 05:35:34 -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=00UGAMLB39R/+6fyLko8Lp7ePcYPyXW89cvVOQMcH5uzkN8xJ5hM8V5SapQr/2a5tV i+25qcAmjx4kqKy1mXGtss/EQgLZsdNfmuHG0uXN538kVLwSyk2s1MH/5Hy5v5xEE4yY xggrvLZsqpnAg9p/yi/tPyF/A+yCRQRRosV4t0PiB2G4fyb8jw1VnHqj6/wxgg7hSVWJ Knt7TGwvIl39B1kNjKJv4u8rLDZMwbW47vuF1i6vxJFm6BpS1VtvEVCZkkdXfz8NdXnf t/XY0+VFsNyAioi7woVcU8QNX4EftW78H35KaK8VEjTtBHwHDttIHOQP/H1lNQjTVpfO 6lAQ== X-Gm-Message-State: AJIora/u6+HcFNt5510i+sSlfpTRnugIpdogiA2qOeMesYVkgCaBY8Rm OmE8qBid7B/mQs0HXwXpwbilvw== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 } /** - * 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_trip *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 num_trips, int mask, tz->tzp = tzp; tz->device.class = &thermal_class; tz->devdata = devdata; + tz->trips = trips; tz->num_trips = num_trips; thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay); @@ -1331,6 +1333,16 @@ thermal_zone_device_register(const char *type, int num_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); /** 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 device *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 *); +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, From patchwork Sun Jul 10 12:35:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589316 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 1216CC433EF for ; Sun, 10 Jul 2022 12:36:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229788AbiGJMgF (ORCPT ); Sun, 10 Jul 2022 08:36:05 -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 S229725AbiGJMf4 (ORCPT ); Sun, 10 Jul 2022 08:35:56 -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 F287913F0A for ; Sun, 10 Jul 2022 05:35:36 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id y22-20020a7bcd96000000b003a2e2725e89so1295750wmj.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=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=s96A1qAm+TnOGtUG1GCFhjwbnsVrqrhg6F5b0a9/UEVMdsN6LfcKsr6gHYauGCrTdy ID1ZaDRI0lN9/svgj3VL3xhsK/ihNQP8NxdCQIRisLbbLnCMJA/IexSLMlBZJAqbdqcc bmvUrCoZiRxQBq98ZPnE1zrr5hp3Ej1YSpas/PwuJpfp+ZWQ0gEemS7kFSyQO/z2Sq7d Z28ckQ7wJ8DdLVltY1Xm1M3MguSk16pekcGJtzl5mvVYQVx6mtZpnKz6iYr/KBzkxut1 W1kQpb3QyDNrusWCFTP7LHx0vfM2aAEbNF2j9LKKjlbpYbh+P9nANiDwUlO0WRU2YKXN Ol9A== X-Gm-Message-State: AJIora8mzsY4tsk04XYj+ks/Pq03Z1H8QMRSZTV84QiJFpD1d47E1yZ6 1xAew3TxctSurr8QlsZ7MN2d2g== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 = tz->slope; tzp->offset = tz->offset; - zone = thermal_zone_device_register(child->name, tz->ntrips, - mask, tz, - ops, tzp, - tz->passive_delay, - tz->polling_delay); + zone = 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)); From patchwork Sun Jul 10 12:35:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589677 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 92880C433EF for ; Sun, 10 Jul 2022 12:36:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229821AbiGJMgP (ORCPT ); Sun, 10 Jul 2022 08:36:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229693AbiGJMf5 (ORCPT ); Sun, 10 Jul 2022 08:35:57 -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 2BC6713F19 for ; Sun, 10 Jul 2022 05:35:37 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id i128-20020a1c3b86000000b003a2ce31b4f8so3563532wma.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=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=YgF6BMb6qbRLGff5m8cYM7kGXjzp5fwGVMsP0s2S/wAGPAcIjoTcbYOe/iCQrr7XyI BeEfJCGJuvy7ffv0R2NH35c2YnKWmkbsU6g4IkRUiCe3BPQhVlVTQIBDMg1Zm4jc2DtA 7aofb3ZSxMVM0gIc4wr60SGGajJD4qqbaGBEDZzlF5X4AqNG1eCn+rUfrGljMbCWHLvr b7DwUht46xFQ6KUBrf8RZYNVfcTzWFHjdFxQt8bDUKUpHJaOApjPWgGPXfXIq5/X/OjL /Gausm0fGoud0P487KO+Zwe2StjB8KChqP4uBYGCUdZCZWvSDoLXKMi/6Rj0/tfzE1Q8 K5fg== X-Gm-Message-State: AJIora+UCFSK1Puni9IAHGcFuRry3lmgVL5o5WL4+6nHjZWkFONGt/+k p+M9xQ3WPKoQ460e2/rO35aT6g== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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_device *tz, */ int of_thermal_get_ntrips(struct thermal_zone_device *tz) { - struct __thermal_zone *data = tz->devdata; - - if (!data || IS_ERR(data)) - return -ENODEV; - - return data->ntrips; + return tz->ntrips; } EXPORT_SYMBOL_GPL(of_thermal_get_ntrips); @@ -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 = tz->devdata; - - if (!data || trip >= data->ntrips || trip < 0) + if (trip >= tz->ntrips || trip < 0) return false; 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 = tz->devdata; - - if (!data) - return NULL; - - return data->trips; + return tz->trips; } EXPORT_SYMBOL_GPL(of_thermal_get_trip_points); @@ -281,12 +269,10 @@ static int of_thermal_unbind(struct thermal_zone_device *thermal, static int of_thermal_get_trip_type(struct thermal_zone_device *tz, int trip, enum thermal_trip_type *type) { - struct __thermal_zone *data = tz->devdata; - - if (trip >= data->ntrips || trip < 0) + if (trip >= tz->ntrips || trip < 0) return -EDOM; - *type = data->trips[trip].type; + *type = tz->trips[trip].type; return 0; } @@ -294,12 +280,10 @@ 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 trip, int *temp) { - struct __thermal_zone *data = tz->devdata; - - if (trip >= data->ntrips || trip < 0) + if (trip >= tz->ntrips || trip < 0) return -EDOM; - *temp = data->trips[trip].temperature; + *temp = tz->trips[trip].temperature; return 0; } @@ -309,7 +293,7 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip, { struct __thermal_zone *data = tz->devdata; - if (trip >= data->ntrips || trip < 0) + if (trip >= tz->ntrips || trip < 0) return -EDOM; 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, } /* thermal framework should take care of data->mask & (1 << trip) */ - data->trips[trip].temperature = temp; + tz->trips[trip].temperature = temp; return 0; } @@ -329,12 +313,10 @@ 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 trip, int *hyst) { - struct __thermal_zone *data = tz->devdata; - - if (trip >= data->ntrips || trip < 0) + if (trip >= tz->ntrips || trip < 0) return -EDOM; - *hyst = data->trips[trip].hysteresis; + *hyst = tz->trips[trip].hysteresis; return 0; } @@ -342,13 +324,11 @@ 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 trip, int hyst) { - struct __thermal_zone *data = tz->devdata; - - if (trip >= data->ntrips || trip < 0) + if (trip >= tz->ntrips || trip < 0) return -EDOM; /* thermal framework should take care of data->mask & (1 << trip) */ - data->trips[trip].hysteresis = hyst; + tz->trips[trip].hysteresis = hyst; return 0; } @@ -356,12 +336,11 @@ static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip, static int of_thermal_get_crit_temp(struct thermal_zone_device *tz, int *temp) { - struct __thermal_zone *data = tz->devdata; int i; - for (i = 0; i < data->ntrips; i++) - if (data->trips[i].type == THERMAL_TRIP_CRITICAL) { - *temp = data->trips[i].temperature; + for (i = 0; i < tz->ntrips; i++) + if (tz->trips[i].type == THERMAL_TRIP_CRITICAL) { + *temp = tz->trips[i].temperature; return 0; } From patchwork Sun Jul 10 12:35:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589315 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 58A7CCCA479 for ; Sun, 10 Jul 2022 12:36:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229700AbiGJMgR (ORCPT ); Sun, 10 Jul 2022 08:36:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229740AbiGJMf6 (ORCPT ); Sun, 10 Jul 2022 08:35:58 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2680613F2B for ; Sun, 10 Jul 2022 05:35:39 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id l68so1644547wml.3 for ; Sun, 10 Jul 2022 05:35:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=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=k0Wt/SU6BMqXuGDQUrWqBV5Ll3ocd9R5SzEv17jrefyjWDz/0KAa7GnbDJ9yqqKYIv 0H7uiXEpq1XyoD1boqnIuK9DQsQSYs6yTCwhy38QtUkLU00p8FQDFB+Su2icDxY6V5OS 4dDJECL6KfEphhsk5mCKTj+ATdjxxPTrsFPsV615JAwJggoy45OU4odRX/RSlk+fvogQ 8hwa4g5ZDz6H1En04S4q9sEJQAlKByLSU1GZhcITy/Ft8uGFfj94v5kSAaS4FyFpvjvl qInparEhx7yrYuhiuatZICE3UcOIJhdlftEa2PnUZ2rdpiSvvUkGpKP5FNUV3fVFtGoa Xr5A== X-Gm-Message-State: AJIora8R+G7XUqIn4apfwPNvqj/52DCDQWMIch4m0xwk+6lqEFpnuRHy yEu3+1KbSRVgVR1IeacSXg8V/A== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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_device *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); @@ -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 >= tz->ntrips || trip < 0) + if (trip >= tz->num_trips || trip < 0) return false; 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 trip, enum thermal_trip_type *type) { - if (trip >= tz->ntrips || trip < 0) + if (trip >= tz->num_trips || trip < 0) return -EDOM; *type = 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 trip, int *temp) { - if (trip >= tz->ntrips || trip < 0) + if (trip >= tz->num_trips || trip < 0) return -EDOM; *temp = 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 = tz->devdata; - if (trip >= tz->ntrips || trip < 0) + if (trip >= tz->num_trips || trip < 0) return -EDOM; 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 trip, int *hyst) { - if (trip >= tz->ntrips || trip < 0) + if (trip >= tz->num_trips || trip < 0) return -EDOM; *hyst = 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 trip, int hyst) { - if (trip >= tz->ntrips || trip < 0) + if (trip >= tz->num_trips || trip < 0) return -EDOM; /* 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; - for (i = 0; i < tz->ntrips; i++) + for (i = 0; i < tz->num_trips; i++) if (tz->trips[i].type == THERMAL_TRIP_CRITICAL) { *temp = tz->trips[i].temperature; return 0; @@ -693,7 +693,8 @@ static int of_find_trip_id(struct device_node *np, struct 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 device_node *np, return -ENODEV; } - trip_id = of_find_trip_id(np, trip); + trip_id = of_find_trip_id(tz_np, trip); if (trip_id < 0) { ret = trip_id; goto end; @@ -849,6 +850,53 @@ static int thermal_of_populate_trip(struct device_node *np, return 0; } +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 = of_get_child_by_name(np, "trips"); + if (!trips) { + pr_err("Failed to find 'trips' node\n"); + return ERR_PTR(-EINVAL); + } + + count = of_get_child_count(trips); + if (!count) { + pr_err("No trip point defined\n"); + ret = -EINVAL; + goto out_of_node_put; + } + + tt = kzalloc(sizeof(*tt) * count, GFP_KERNEL); + if (!tt) { + ret = -ENOMEM; + goto out_of_node_put; + } + + *ntrips = count; + + count = 0; + for_each_child_of_node(trips, trip) { + ret = thermal_of_populate_trip(trip, &tt[count++]); + if (ret) + goto out_kfree; + } + + of_node_put(trips); + + return tt; + +out_kfree: + kfree(tt); + *ntrips = 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 = 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_node *np) tz->offset = 0; } - /* trips */ - trips = of_get_child_by_name(np, "trips"); - - /* No trips provided */ - if (!trips) + tz->trips = thermal_of_trips_init(np, &tz->ntrips); + if (IS_ERR(tz->trips)) { + ret = PTR_ERR(tz->trips); goto finish; - - tz->ntrips = of_get_child_count(trips); - if (tz->ntrips == 0) /* must have at least one child */ - goto finish; - - tz->trips = kcalloc(tz->ntrips, sizeof(*tz->trips), GFP_KERNEL); - if (!tz->trips) { - ret = -ENOMEM; - goto free_tz; - } - - i = 0; - for_each_child_of_node(trips, gchild) { - ret = thermal_of_populate_trip(gchild, &tz->trips[i++]); - if (ret) - goto free_trips; } /* cooling-maps */ @@ -952,13 +981,14 @@ __init *thermal_of_build_thermal_zone(struct device_node *np) i = 0; for_each_child_of_node(child, gchild) { - ret = thermal_of_populate_bind_params(gchild, &tz->tbps[i++]); - if (ret) + ret = thermal_of_populate_bind_params(np, gchild, &tz->tbps[i++]); + if (ret) { + of_node_put(gchild); goto free_tbps; + } } finish: - of_node_put(trips); of_node_put(child); return tz; @@ -977,8 +1007,6 @@ __init *thermal_of_build_thermal_zone(struct device_node *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);