From patchwork Sat Jul 9 22:32:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589119 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 D2755C43334 for ; Sat, 9 Jul 2022 22:32:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229537AbiGIWcq (ORCPT ); Sat, 9 Jul 2022 18:32:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbiGIWcp (ORCPT ); Sat, 9 Jul 2022 18:32:45 -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 33E6D1759F for ; Sat, 9 Jul 2022 15:32:44 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id v67-20020a1cac46000000b003a1888b9d36so3043785wme.0 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=oZ/CFatwZE9/qhv9kWB4a5mxsA09Ps8JsPgqNIRLH4z+XzziMNL8WkzYRHThP9ELyd JKmKv+wxQlCnp7FqxqSZ1Ku48CU/BbRUCbcjBY/ZIF1bN5YWG2uMbB6XHxbNIsb8j/OC Gso139Osjyyi6p7tT+RXUfttmbgq+qGmqFVD62ttWLORE9LuGcLCL8+hUGxplEa2r8KZ O8MZU162/xpDFkMpGY0YyTSavP/8QI0G7O7aC/rkLrF1xhVePj4fGAA0ZqiyWT3rlX36 QKxU7Hm/hhGysWRxpzm6xr1+zBoerAjNcHoTtB0jOMMVftWmx4LgbSAQfykoktAwo90z 5hwA== X-Gm-Message-State: AJIora99y9RxAOnZpVnxcuo53n/c7OtGuB+/DodYBcT5CFF6hJCyaWvr C4yJEkSZfDolNwHbYEiPvplrRvRPy/A2Hw== 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 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 Sat Jul 9 22:32:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589691 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 C934DC43334 for ; Sat, 9 Jul 2022 22:32:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229649AbiGIWcr (ORCPT ); Sat, 9 Jul 2022 18:32:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229638AbiGIWcq (ORCPT ); Sat, 9 Jul 2022 18:32:46 -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 49D7C17587 for ; Sat, 9 Jul 2022 15:32:45 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id d16so2583630wrv.10 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=JjaOGXu1Rl9vRNkZtNEqXqydiL7zSqjFW7jSihUCNEfXqCYCl7CyWLOpqEnPx3cKFD iYJnwpsSPBUoqClt6QLYwdH+0fI9rRA/1eq6eC8khg0AT/adygkYcP3hMdnH2Pzehkcw 4/2qe32m08NsbNOhWPvLHVf6C+Hs7PvsluI8a8ZASF4naEMAxqIxr83GfBa/dkjK+cFB cA4jxH2Ve6kbbo5L1Dz8KV81NvNEreZxt4Pub3mPBdMvbvd8gtqgxwKao+ZD4k/+N3U1 megns6VAkIkQ8MjVErZEhDPjQkkZsMv9tLhO3BJ5PYppK7k79rHmoQ7+gDdoZZTTy5C1 A2dw== X-Gm-Message-State: AJIora+zYD5SHw7r7qvLJg3nUG1wCPTKlmZjtVUMZZlmZr2JZLX3xZSY thBmT68Qbv5hE1FYjpSPGvSIuA== 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 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 Sat Jul 9 22:32:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589118 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 3866FCCA47C for ; Sat, 9 Jul 2022 22:32:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229651AbiGIWcs (ORCPT ); Sat, 9 Jul 2022 18:32:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229645AbiGIWcr (ORCPT ); Sat, 9 Jul 2022 18:32:47 -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 48850167C2 for ; Sat, 9 Jul 2022 15:32:46 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id h17so2655994wrx.0 for ; Sat, 09 Jul 2022 15:32:46 -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=ST4sBXntCgQcQZXmNWQCr9aVadKGdQ2I0VRw5gGtCxStW/FRmyl06xoLGy6QAS5vLr FeuQ2wJ1cDN4zP+JBfEUm14JLM2O2mh+xWMNOPpw+p9I65sAEHC6XvE3CRONDMcOXaZB QNZIX9X0gCXK3KUI5mKZR5prx1TLJodnnvMnEhFvpNO0ZfbnZANNF6nycoCQ3l2rC1Rm 1XZe+9RSJ9W2DLGzGQRvW7Rb7uWdGa6tf6mZ33c3csWpv1EaMqHNXonNdI3MRMUYTojT FlyluWbCrztmiymtvoNaWSKi8DHHe4gq0FMFyrlNZuVHxo1hrP54CTJ7c1OcdqiNV9wL mRQw== X-Gm-Message-State: AJIora/uDhKw3gJO+hnhnAFel6xRRHkIKluT93pJgcuXmZi4TfaRCUEK m5JBIqVjRGFSTybn13ltuyVDFg== 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 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 Sat Jul 9 22:32:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589690 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 5156EC433EF for ; Sat, 9 Jul 2022 22:32:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229676AbiGIWc6 (ORCPT ); Sat, 9 Jul 2022 18:32:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbiGIWcs (ORCPT ); Sat, 9 Jul 2022 18:32:48 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64CB018342 for ; Sat, 9 Jul 2022 15:32:47 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id v16so2570313wrd.13 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=JcC7xgWTUncA1fNU2jU/PL6G52gQ5teqyNxpCAO1qz+Jr4Hg623LvzArCVtEMyqttQ lQ9yzDIPKTfankU6M/r5QKl0HwJ8TXha49A6hGomTHC//mJ+w90OcXOP9GIS92JZlLFR tv7Uawuw0zXZCvdhJJESDydb2XbfFuiB3VemWq+PWOSwTcpkGUoIgTKMXkO+KLu7ow7m mASgXrzaWt9OTOSKH5kHoiyYTrzb7v+caJGqoM23KuBwsZ0svq+2VMFmpCNGt8gP8rd4 OKya16LNos/34zlpEvAeOcicT13q6iILGhrFRSvfsoZr0nKQZpSahdjZTvmlf/ixNzkR 7NOQ== X-Gm-Message-State: AJIora9ZBgoUCUELJqgP3fD/PcIWplOHSGwNhkcTDOw3/z90yvzdKkxa /rmbmYgAAsvfbRPpUW/9mtteRw== 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 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 Sat Jul 9 22:32:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589117 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 5CB23C43334 for ; Sat, 9 Jul 2022 22:33:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229695AbiGIWc7 (ORCPT ); Sat, 9 Jul 2022 18:32:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbiGIWc6 (ORCPT ); Sat, 9 Jul 2022 18:32:58 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6087018373 for ; Sat, 9 Jul 2022 15:32:48 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id q9so2591778wrd.8 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=bcBmATxSsNTF+m8xIqG3WAvOjcKPtfuyc7fHOZRgdMeQrOCy7ee5DqfUl6j4F+bWAZ NOQWkGI4ebqX9TqcI23h+7FHsbg0L3HxSlrHycMrVclvNRi9s7qU2OKF0mMhYatBh1Lc BP/TVKumSbw7FpKxVq704K5CzzJM6Vvhip9V14TPP00bXRneT18hwkDKCIovMQ/t0dVs amcEidZANGVE8dydKhfSAaBnR2wrN6n5qophJRokaZQuMeyFpsniZoqFJ0LunjVjPT4e cHK3eIDA3QAN7kO+DQmywG8WI/LpWP/Y7Osz5fMD4FN4yk+/ci35Mh826Q9laqwQJNup sqgg== X-Gm-Message-State: AJIora/DUo6R2uxqkMHmhLs5HWOi1AWflV7NOn6fnRek7+xK0Iufafil 25Q9lYTmom7wrJIdPfNOBAF9xA== 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 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 Sat Jul 9 22:32:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589689 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 72024C433EF for ; Sat, 9 Jul 2022 22:33:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229701AbiGIWc7 (ORCPT ); Sat, 9 Jul 2022 18:32:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbiGIWc6 (ORCPT ); Sat, 9 Jul 2022 18:32:58 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B217286D2 for ; Sat, 9 Jul 2022 15:32:49 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id q9so2591804wrd.8 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=xFKo0nfm/rgHWNUCPAVTMnU0mNjtt7OU8EC2rNyKxR2FNowop+DwVgPDG8LYtOWTQN v9sNR2DT5+NmssRHX/INE3THDXoU3Nnlao3x6z+iesW5taqViXIDh16nevWOsan9S0Cr 0+skX4kZefXHxDJeBouP205KpUl2PR3938f62GTKrtpRo0cLdwgZA4P7EyGyN9mNeG8d rt2Ji2nv1h7OKJhWcYNoz+x6bWVWcU8DiIXf2AaVbd+OjchRbg6tRY3mSFJlCV6No9IH p4MvUIzNn4HY1+VwortkyYmBLCP9/qHm9g3iklBz1dueWixMxW5WPED7u86gx+PKGSBw mV1g== X-Gm-Message-State: AJIora+VHEuq8axfEZYUhhvBPdXaoLU7cc/teg2pF/KIEs51gVUrgjt8 m+93D6ExngWV4bFqU+ydyYBqwA== 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 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 Sat Jul 9 22:32:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589688 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 D91F2CCA47C for ; Sat, 9 Jul 2022 22:33:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229756AbiGIWdM (ORCPT ); Sat, 9 Jul 2022 18:33:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbiGIWdB (ORCPT ); Sat, 9 Jul 2022 18:33:01 -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 C406F2A256 for ; Sat, 9 Jul 2022 15:32:55 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id i128-20020a1c3b86000000b003a2ce31b4f8so3026436wma.1 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=1JHxmLkWoBG3ZCxX+AAzvz6341U6A5zhOOSBt8AFBhyCA7xFuI65SNRaUEeYZCvnFs AhcfUp2Zt71pUoZ0fpJ/ENWNv0Bxvqq8nkkUt0R2UfRRgtrzPcQp6md+jEA9cqqoj87t cHXqZMRwfa3lFd7lh2t9GIBm+jUwe6qaeaBI94G5xQUvcqfmwYW/0dOLqMqVrpk+FcTD tyT1/lIf0OQeztxdi2Uh13zFQfpGDzFeWNQ0jF2nxfME7jzDXpP8EJGYdhBH7XNTUDs/ x0NC7TNP072uC7J2SZOV0fdrA3CLFN6BoylOKX1jABjMzu5tXAsyYJv4cZ3Tibex11ok FmHg== X-Gm-Message-State: AJIora/C4kpPcZWdFCx6eFzGu0HSZW2nzYO/mYana/yj6uoV7kPYBlIv Nuz++ck0OqA5b+WJQc2+HjKSvg== 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 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 Sat Jul 9 22:32:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589116 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 4428DC433EF for ; Sat, 9 Jul 2022 22:33:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229675AbiGIWdH (ORCPT ); Sat, 9 Jul 2022 18:33:07 -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 S229697AbiGIWc7 (ORCPT ); Sat, 9 Jul 2022 18:32:59 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5D752A24A for ; Sat, 9 Jul 2022 15:32:55 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id v16so2570578wrd.13 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=J0ToP61lDEGum7INnHSrmeaZ6QhlZfD/6rwDqciN3pQ3b+X6yOkoS3XSbTwo3TJ/C3 Vkqja+lanqokUpA6ZynqOYFYbxZ1YL5viGnH+KiPPRAq3eOyucJzW/pnCbKQ8/NfZLyn sUAtGFlw8+cYMo2zvwdPuD0+XB1umyGgpbHMq/yKy77q2gTBJrdf3WEcc7QWT/dWjYMq Wat0K03TgeXW1UR/RenNoxz+hPn2NGhZP/p3upQD5DfiVDe3jYBhy0HqbQPYcKsw/1G0 IQOdeLDHyPHCmxxmasKhfFhmSpPJFWApM1frIVyCx8LFqkaq8jlMQ4PgZwk1HOYiL+mX 8XmA== X-Gm-Message-State: AJIora88AmWECKFpozxHXzLSTYAR8m537Sa9tu6h0ZmVuykhnSm2nYoG mjoqWGqGrIbkFqF38PHksN8e+g== 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 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 Sat Jul 9 22:32:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589687 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 2EEC8C433EF for ; Sat, 9 Jul 2022 22:33:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229805AbiGIWd3 (ORCPT ); Sat, 9 Jul 2022 18:33:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbiGIWdI (ORCPT ); Sat, 9 Jul 2022 18:33:08 -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 995C32A979 for ; Sat, 9 Jul 2022 15:32:58 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id a5so2581607wrx.12 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=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=rgzB+QpjXxxdvNMGWG/yjwMf4vl2PPwCbi/NdGB16qUzV8/TtKqITSk0Sm7+QgE083 l2tSjC7rbKpkELTaxdFdtJr6WBy2jGDCZYsiOFKytBKglZ3Fg12Nvxy57T9vOfBbutKY wYECYGZV5/bW42xE7X4tJGLa88PIdcqV8gy/+SXRxaVqByBFMgD+upl44IhPO0DhTupS Lxe+ChAR5wJ1u2Ov6PiV/i00ok4nSQJuY+il09RKXIW8UtzUeIwDQjCg5H78g8mmjyNp DsqowN9wjDOcV5ClI9Fb+HvH6l2tCHcjJuO/ONbBiglCflFMGUZpgBUe4GmjO63CjdH7 nSjA== X-Gm-Message-State: AJIora+O/qyhsKpfwCPlKExxoPMJ+z8iVEk25+BWOwrUO/ujHfHVvm/H 62WebBu1eS5482K8VWLEwHWYMQ== 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 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 Sat Jul 9 22:32:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589114 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 28AF3CCA47F for ; Sat, 9 Jul 2022 22:33:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229813AbiGIWda (ORCPT ); Sat, 9 Jul 2022 18:33:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229745AbiGIWdK (ORCPT ); Sat, 9 Jul 2022 18:33:10 -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 4B0C22AC45 for ; Sat, 9 Jul 2022 15:32:59 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id z12so2596566wrq.7 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=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=LEbMUDZyxxMq/YteTHQwAXRcvoSV+knBIaWnQWiK78U0DfMamV9FfC0G90dM3KAC2v 9XX8Oc1SX5TjM4e8jSUlfBHZ20VsoIwJEHwkbBYZc1fmAItDkd8WWj9goXwfD//exW5r LErWahzFi+hHROlorYrTwHKBK/Ru3oNRYiHnmmUWg7YmLnSinnYtipSmhVe34/SAPaJs 5Q5VWXTxQb+H5C+IIF1CE9JvAofAjq1T7fdwkMELG096LcQPvLtu/YleuEviF12XeClO YZIcK6ALezHIg4N9ZdEpigBGjb72Q1jazWBFj85DB5huNZvoQbCJwiZbjVganNvokl2H f9Sg== X-Gm-Message-State: AJIora96w90Y19vjrZrWPI6Mm4fivBxykzRGDmwt1Wtl00Ev+WaqKQyE 8OFAD/KQCJEWeBvySJQce4aP1g== 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 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 Sat Jul 9 22:32:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589115 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 C423EC433EF for ; Sat, 9 Jul 2022 22:33:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229782AbiGIWdZ (ORCPT ); Sat, 9 Jul 2022 18:33:25 -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 S229727AbiGIWdH (ORCPT ); Sat, 9 Jul 2022 18:33:07 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01F8B18373 for ; Sat, 9 Jul 2022 15:32:58 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id v16so2570677wrd.13 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=hcOhVj7JenIQ8kNCMRfYVuh/O23uS5NJXovjkad0ZvK9aLtFY1lbPEq3uBkhknuaTx tKwFD2faORKZZh6kaKxQ6CLV9i1x3Drn5/TUE69JAqJLN0/kJoHCuaGNWZS+vrec8AiI 4WSJjUHeIKvLUjHs6eGCVXuvo729DejdYe2L/A8vs21xRCS++0GYDq5RwcfRDoT4wIL5 z/QNgBMtlKBdAAQGrh3tj/AzKoCKzNliBe/TL7kBeh3BOTeY2B+0IdVmm3kcrdqrYX4J 4z4NBFx2GTG7ezLNJ6JA6Aa9QxQdO3mFyZr01rjxlcKg6ZcS+91QV0SqzpB0h06S9bXW I/Tw== X-Gm-Message-State: AJIora9jQez6szKXT6gRedEmI6N46/+zusiuHKSQHljhYbglU1hBbCNZ w2bJsI00HCCgHKbbo+/rnYpWww== 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 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 Sat Jul 9 22:32:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 589686 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 BB181C433EF for ; Sat, 9 Jul 2022 22:33:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229563AbiGIWdc (ORCPT ); Sat, 9 Jul 2022 18:33:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229716AbiGIWdM (ORCPT ); Sat, 9 Jul 2022 18:33:12 -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 520172B196 for ; Sat, 9 Jul 2022 15:33:01 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id z12so2596626wrq.7 for ; Sat, 09 Jul 2022 15:33:01 -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=U6dr04rzWAMmE+OZfWB/O5S5izVKgzKb2BEAgC6Ovg/7cBmS5l0IDqWUHKPSGSZtj/ SOVjpacFxw7+gTOAQEri6m+tzU3szquqKQ/yJevWvqBlupTxUpoOAppElIXodmFyHBg2 3dtFcd+KZE6Z3LJw0XznqoGJL6Wyde9tYepVedqrCBeYFuXA+4fqbR3Yr3nvKzkU2cDw elcNtfMNCoCrFvf5XjE7fm1gvhdudHZWLeKVz7kcPniVA6NI/79vg0Sf19d2GnfFEtNp CA65w0Ggy2d9BZyCKdI42e4mSRARwGtfxwL1EuJtdxd9ocxSVwQtNelBPRFOheQCck2u 5J5w== X-Gm-Message-State: AJIora+c8L2RKBVMFWRDF5csJ+yIA3HJpY+6RFLdvki3PlYIeAnF5yed Jbl59HBafu+O4dAmFSF8TMQ4oQ== 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 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 | 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_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,7 +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);