From patchwork Fri Jul 22 19:59:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12926826 X-Patchwork-Delegate: daniel.lezcano@linaro.org 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 4E771C43334 for ; Fri, 22 Jul 2022 20:00:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236509AbiGVUAf (ORCPT ); Fri, 22 Jul 2022 16:00:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236124AbiGVUAe (ORCPT ); Fri, 22 Jul 2022 16:00:34 -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 394C2747A9 for ; Fri, 22 Jul 2022 13:00:32 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id z13so7862520wro.13 for ; Fri, 22 Jul 2022 13:00:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7UKKS5f7QbJpxlk+iXwxbcq70b7aqG7EJc4B5ZEy8YU=; b=fvyzh6EwYLnAPYw9qRlgMfMJC9tpW5CB7/eX86RxN3Y09XauD2TDaxWKmQ0Vxjg3Ws HwuAcj6GIEirkvPYqBbFmyGXNwq1ZLZIp8v+zvXz/8GWX01twz/eerkniNsnb5n2pMUQ avnbI6OryCNePF3Z5wa80niBQm+j7meeayyHn4LZXmu36PnpWYjWGkMng1/Vp72pv1D0 sNOa0k6eElXcL41KT4jJhMJwZj9vwbCG2Ve8wZaTtIPE7YVyS4xQWm4QxgFDe2mNEa1I gtyb9uz7F2fkDdRrtUjc7nv+m/XSU2Iz/ILbUbmAUlo9UZUZuY2dHKkBTmSWdUvDT0bf jM1g== 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=EW08iork9thhfWc8JomkMjYPl95BNxPqD4CIWBEataXRenP/qMWUSzykSvQ6m/qGMC 6tLPaRuvKgY5NI4EL5isGzpBjtrgjB0CemXTZYRhyR2jAATLX6s3aKhHTS4pys1Y/icO X1WyDJbX4Wy3yFhD6OOUPfYiWzTpACffpAP5DqycIT/QlCtNU1BRiz5aRvVbruVvIgRH YUxMcdCGhhVfuO4OJkTYB8Yk4DHvzNTVUqOL53mFstMVFZatY4LKW2H3vT9AAN0AQcxU 7BvKz0WE2YvFYkXEi2vO1Cy1qMfNT68l8mT9T0w5RR33/KTXCha79VWo2RU2OlDzPza1 oC+w== X-Gm-Message-State: AJIora9jGmF5UboovGfPNU1uNuGzolfhZvuwHrypMBYehqmTpfigrtNs 4f8iwj3F3llNAJDyDOfEx99Z3w== X-Google-Smtp-Source: AGRyM1u1XAz+2HpKZbt7QaNpruxsbTp371HvHRAil253bJP2l772ZNkuxuoohMs/JPs+6KyWlqyYDQ== X-Received: by 2002:a5d:538b:0:b0:21e:4b08:7474 with SMTP id d11-20020a5d538b000000b0021e4b087474mr909649wrv.465.1658520030644; Fri, 22 Jul 2022 13:00:30 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:957f:d36d:87f9:5c17]) by smtp.gmail.com with ESMTPSA id k23-20020a05600c1c9700b003a31b00c216sm6429008wms.0.2022.07.22.13.00.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00:30 -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 v6 01/10] thermal/core: Remove duplicate information when an error occurs Date: Fri, 22 Jul 2022 21:59:58 +0200 Message-Id: <20220722200007.1839356-2-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722200007.1839356-1-daniel.lezcano@linexp.org> References: <20220722200007.1839356-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 Fri Jul 22 19:59:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12926827 X-Patchwork-Delegate: daniel.lezcano@linaro.org 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 7CAF7C433EF for ; Fri, 22 Jul 2022 20:00:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235636AbiGVUAg (ORCPT ); Fri, 22 Jul 2022 16:00:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233326AbiGVUAe (ORCPT ); Fri, 22 Jul 2022 16:00:34 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 441CE796BB for ; Fri, 22 Jul 2022 13:00:33 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id id17so3378529wmb.1 for ; Fri, 22 Jul 2022 13:00:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gJpp/3sovrJilbrJccW08MiNpRgjzFnvxf+q+uGsrtg=; b=A6V0hjUu8fF52MCW0FmJsIkFjHEQEgS015fOywmSHGiTPcmvB/5J+is83Yndi4C28b CQdevu/DwlBvys+4DgcnUtDqMro7ErsdEF8FOvb19SjEN9RjzItO9WDYl7G33N3IIoSI 2kCdav3oBIajAoX7+3rNa5ActnKjiTCVMcoiCkV31Jcj31EWh0lOvG/WgIOvFfdjWqGg K4Xiaww+Udz7TKSMGPr5HY7oelQjf2w/abB3Rl+OqBc2fup7+oENppfe+z62hf9Y9l8a y5QCoDY83SdNmfkVpT4iKkOCDB1Ycp3IIO52ZQh0ELpBEitMG/D2G0cilBWzkhlp7DXP hv2w== 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=xXS67wQ7w4fo9T5V0dFBw/TeZU01fhdGwg5p7KX9aBKR+9qqxgic43rkFF+lkTFPXE 27jPNywpxn9lPv/bY1/2z6tXAFwayxblaE0wDunnUpcC8rMPuE228GaXFp2RH9sfbcIn dLMwkEKbwIAdI1bnAcHNxH/a42KDRzoNgFUv1KN2MfSVLz6kZYE8JA6+Oa3HmdrpdlBI 2yKuAjEniT/0ZjVll+7j1c60vVt8gSM0UsJes2DUg5UpjiNB4R3hbUy+bN4exsQmdNSZ V5KJtlthec8Zf2lc1bTveFzh5lGBSL+5umRjqK2CZOVYim+DcPmR2fVPPIvxA9uUuTTx 0Pyg== X-Gm-Message-State: AJIora/J0KKSyODILKA4uMCuTOqwl4TDVjXk1la8c1hB6o8n8BU9hg/h AZ9tpNEmlxK4ZO4KYe9ml2LyuQ== X-Google-Smtp-Source: AGRyM1s3VVrFTw21YEDuHFqvpNVhlueAeonrdC74eY7FNRsMdtORGelajcon+or33MEeH02WiicxOg== X-Received: by 2002:a05:600c:cd:b0:3a3:f40:8776 with SMTP id u13-20020a05600c00cd00b003a30f408776mr893573wmm.9.1658520031788; Fri, 22 Jul 2022 13:00:31 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:957f:d36d:87f9:5c17]) by smtp.gmail.com with ESMTPSA id k23-20020a05600c1c9700b003a31b00c216sm6429008wms.0.2022.07.22.13.00.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00:31 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, lukasz.luba@arm.com, Amit Kucheria Subject: [PATCH v6 02/10] thermal/of: Replace device node match with device node search Date: Fri, 22 Jul 2022 21:59:59 +0200 Message-Id: <20220722200007.1839356-3-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722200007.1839356-1-daniel.lezcano@linexp.org> References: <20220722200007.1839356-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 Fri Jul 22 20:00: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: 12926828 X-Patchwork-Delegate: daniel.lezcano@linaro.org 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 63D06CCA473 for ; Fri, 22 Jul 2022 20:00:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236473AbiGVUAg (ORCPT ); Fri, 22 Jul 2022 16:00:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236457AbiGVUAf (ORCPT ); Fri, 22 Jul 2022 16:00:35 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48BC15007E for ; Fri, 22 Jul 2022 13:00:34 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id id17so3378552wmb.1 for ; Fri, 22 Jul 2022 13:00: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=TKRi+GmwXFnPZbvdKLtGDHFP5gB36/7lKJQI47b4ftU=; b=SuIi2BPEaOCamo8F4dt60V4K3a/ZMV9tpP7ZInqWFBBMAOTEBHFXqmB/SmL0ePbY9W m68Zz61vWLMLlZfBLeneW3F1SVXVzRYOn5NvwOMA2KIYzyijsqsqsS2rM620dp6FiQwD Nbna8zakZ2wtHbrM0M8SinIW0oc/F0QWephdw0DQyPgpzbw/NljkNWhKCNPTajD4srXN XQdY+ztqKAjh4jwbmV6jxI+7BofV2ObkKEBBhmp4aBKay8Cf1ykZMJHDxWh+Oe8zaqPq T1y512leznpoIdFCr/C4eBGQL3BAKPo1JF5Sve9P850Ed9yuZxbhC2Aj4i/fTF3ofvu9 TW+g== 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=jqozhAAWAYCPpkPCgoxBeUiXhe5NCJ1DHIXcx/T4iGhyGZHTkpFblPiyKOi/aWNdkd mPBrKW0iRNQEWtXnO4QRgs81s1MzZkq3GHVWbe7d24KtCVe2rWmNE8b4UlwTOh75UrcV UEQ/tvWEeyvuoxavziou3lpXWjLNqcLQeMb1l5+f5aDcLaYQ8OBTriQlN9jNnLyG4720 6se2ORuzpYdJA2JswV3IDhH5vbfYOTzJGACCE0q0NVKFQmmziXL9aPpVWyl470f0raxw fBZFO1LJbAF1znYW0g70QPIY/3EGAihIdQC8LGap42TnsCYgQaPoaP/HAXAO97t6d6L2 Mk/Q== X-Gm-Message-State: AJIora+5bWI86u52bsWhox3sIf7YUddXHWCeL6DSvnen5oLC0J2Z7bBW HU1ge1DAuSnUvfjdNL6AwD94wQ== X-Google-Smtp-Source: AGRyM1ti22mtKLYbr5cawcbMgI7Jnwh855ikTVJk6SmicfawczFM3OeTFtDdx88EHkKMRfqJToRVLg== X-Received: by 2002:a7b:ce8e:0:b0:3a3:1b01:8e7 with SMTP id q14-20020a7bce8e000000b003a31b0108e7mr13575204wmj.31.1658520032914; Fri, 22 Jul 2022 13:00:32 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:957f:d36d:87f9:5c17]) by smtp.gmail.com with ESMTPSA id k23-20020a05600c1c9700b003a31b00c216sm6429008wms.0.2022.07.22.13.00.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00: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 v6 03/10] thermal/of: Remove the device node pointer for thermal_trip Date: Fri, 22 Jul 2022 22:00:00 +0200 Message-Id: <20220722200007.1839356-4-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722200007.1839356-1-daniel.lezcano@linexp.org> References: <20220722200007.1839356-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 Fri Jul 22 20:00: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: 12926829 X-Patchwork-Delegate: daniel.lezcano@linaro.org 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 692D5C43334 for ; Fri, 22 Jul 2022 20:00:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236544AbiGVUAh (ORCPT ); Fri, 22 Jul 2022 16:00:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233326AbiGVUAg (ORCPT ); Fri, 22 Jul 2022 16:00:36 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94F01796BB for ; Fri, 22 Jul 2022 13:00:35 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id r1-20020a05600c35c100b003a326685e7cso5038843wmq.1 for ; Fri, 22 Jul 2022 13:00:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2Cg8NIEv3M0ZsrQ6LuqyJLiJb25T+jZLIiP7PzCJ4Cg=; b=jhlOUJ60KT6l/iTJg3SfQ2S82Y4QGgj2fjsOHInVSIB6f18jLAoz0DgvHqCu8yIV2f vBnAnhH2MOFB1YT6XQkUUGepn3EQ212i66MiU9BZMPmQFu1jmeO/M57DxnTTuTSnoypJ QH4pi+8YZho86tG4lWv3BVhCMQQpUABQaKORkwF+4eKmuTUQX7NR2wwvZRdUWwd80Vj7 gLuaGK1f/ROKlKmF42kgvsBUUortXqIJtV89M2+gydO7DInbkZiJsRgBP5v5p4XAJyS7 RVeJqtXW5FiPXs/vyM+SpmcFTuBaPm4kKL1wNV97A9BVXjPujrZfWqcNhx5+A/wOWmGa mAwg== 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=S80e1aa+XlrLoW/hwALabCXfdOwuhJ1CzEeb13hActVe5gDABv3QPqQv0nIagueOz7 CQ5PdteJEOc0gCbPIWsqAwpm4vzLAClWvvSEl3avnphbb8cJQuolL5CaqjbvG1UylViN spoDxtpyiKSvH0DUwEkdSXJ/wUxLvKWf006h9bVvxhMeK5uWowz3OBU1H0cWBOyuK69P woQ45pZsooJL/8EzifgfaiRGdzXzvmjdD8Y6DicVD0k/5lmp5be67WnMDdJla/4P2v8i XIexkXVGV5VzpKvASy3ikVoHNXD2Byw75DEvBmR2QiwU/KTb1dKJGTgkouvSk6clfdzl VMRg== X-Gm-Message-State: AJIora8Dq0c2oyhXrRx1ZnxSJ7nVeuFJIDTL4lb9Xhrd+mg1eeZIbdlU XzCoa88B5IrshyuGObjBwAelBQ== X-Google-Smtp-Source: AGRyM1vJz/i3tldpQmZ7vmiE/x09TOC3aQtZK1txvGzhPRhB7qM7vhA6UX8BSmQxDoej55+LydGhNQ== X-Received: by 2002:a05:600c:1c27:b0:3a3:294b:ad25 with SMTP id j39-20020a05600c1c2700b003a3294bad25mr910438wms.69.1658520033986; Fri, 22 Jul 2022 13:00:33 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:957f:d36d:87f9:5c17]) by smtp.gmail.com with ESMTPSA id k23-20020a05600c1c9700b003a31b00c216sm6429008wms.0.2022.07.22.13.00.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00: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 v6 04/10] thermal/of: Move thermal_trip structure to thermal.h Date: Fri, 22 Jul 2022 22:00:01 +0200 Message-Id: <20220722200007.1839356-5-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722200007.1839356-1-daniel.lezcano@linexp.org> References: <20220722200007.1839356-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 Fri Jul 22 20:00: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: 12926830 X-Patchwork-Delegate: daniel.lezcano@linaro.org 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 17BA8CCA473 for ; Fri, 22 Jul 2022 20:00:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233326AbiGVUAl (ORCPT ); Fri, 22 Jul 2022 16:00:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236457AbiGVUAh (ORCPT ); Fri, 22 Jul 2022 16:00:37 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8980B5007E for ; Fri, 22 Jul 2022 13:00:36 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id p26-20020a1c545a000000b003a2fb7c1274so5808515wmi.1 for ; Fri, 22 Jul 2022 13:00: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=K+KDnyI1rYWiKYKY6BfUNrB+RXhqQv2REJcaYGxminc=; b=RyYMkEWRyWyXOzZ5XLwkOoQNB6fRI6SQctP/iVvNIF0fmKVF2QL1gtVXaSZJXVhpGt 3i1l0opPXyqvdYiC622Z98kL9Amqj4C1PxfApDPpsVbf96hfIYTiEiolf0CiPsyb3blk AC5iI96atSSJ5o6NJJTNyljknYTvI0G/EM9EzCCJNyLELZTB5gSTw65ElDVARIxTexag BhtCkoZrCJMCOnh9YhAhC79zkT8XaPkNOUB9+0N55l1yjZZ99bjRsene6RY6AH9s2e1W u4S9VaIB9/cP5zPBX0Fycys+GiSWK2kxByiL9cfvGH9BLhWdkHIlwct4k0mdBdPrJprY KRxw== 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=kbIyyV03awxvBG/CRZGBVmiMpOXVs/Y4mcsQQflmXsdZ3cU2wGvrvtjykkcddl5zCd aiPKPTbpyz2QuRjuAO8H55VhHcry61xXK8BaHXt+9k2B6PZRIiRcO4JfLz45TnGT0xNf 6kpaXOPmKKVsBFPLfmVt9Xok0QH2aYGW3RPWu9UuIP4fF8r+U6cfX5fOBWSRXtMmHrpw JbJ6NBlcRfVYoYG9sLTMPJ/S7E4zU1ZJMf1j0v0vBX4pRhnX+uCjm95gWhkCUSMyJhs9 0UGGaytv5rP8J6fkcMpZMakQBYHpAvKEmjcHfYjeaZQduoHQ7OV+5c15r2UP5ajko7w+ ymkQ== X-Gm-Message-State: AJIora9RHvtiLWKQJN2klDkNVmggY1yseuGqC0vTcvlnlRnonwIROTj7 +qAY/QSQYglbeMztGDIe2uMPSQ== X-Google-Smtp-Source: AGRyM1tnyJxzBpHxYYdJ40EdcBvRM9oa2Z2ZuGUYHijtJmgWZh17dZEvh+pAYXtjDo9lKFF5pTNpYQ== X-Received: by 2002:a1c:cc15:0:b0:3a3:a03:588 with SMTP id h21-20020a1ccc15000000b003a30a030588mr895303wmb.29.1658520035087; Fri, 22 Jul 2022 13:00:35 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:957f:d36d:87f9:5c17]) by smtp.gmail.com with ESMTPSA id k23-20020a05600c1c9700b003a31b00c216sm6429008wms.0.2022.07.22.13.00.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00:34 -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 v6 05/10] thermal/core: Remove unneeded EXPORT_SYMBOLS Date: Fri, 22 Jul 2022 22:00:02 +0200 Message-Id: <20220722200007.1839356-6-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722200007.1839356-1-daniel.lezcano@linexp.org> References: <20220722200007.1839356-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 Fri Jul 22 20:00: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: 12926831 X-Patchwork-Delegate: daniel.lezcano@linaro.org 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 32797C43334 for ; Fri, 22 Jul 2022 20:00:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236608AbiGVUAn (ORCPT ); Fri, 22 Jul 2022 16:00:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236527AbiGVUAl (ORCPT ); Fri, 22 Jul 2022 16:00:41 -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 DE730804AA for ; Fri, 22 Jul 2022 13:00:37 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id h8so7883288wrw.1 for ; Fri, 22 Jul 2022 13:00: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=m3yHMzkH3fXgNxlTdZV4uJD5eQrxfqVqNnQSzgsUY+c=; b=J7W7ZXzjIzo1kHosDe6601n92X1SuBIOO/UYObdbTNuN420iB+j3mJMgJZ65Lv23Qe KNhzqeEkE50nBeagKstycoMWpYZmROTCZX1mGr3GdvRaCOfdTwQ8HBQcgkMttf7eiXtR duA6/1+ub1PXmywd3S/QFh/yJ+kF3Lre6RwKK4n/ujan2I2lm51NIuRLVt1EtXU5EEtQ 4gAGKBIMtrRe5Fo18QWHoyzPuOjfgqfFVGa4JA1vpF6WXK52r+CicyS6ykErrcqzdLEg 8mzdL9y/1z3mbY0gEl8voDQfaD9i1V6FlXVYGgjJ1xR5OhK4csGEDbhmB7mbu7CtGzG+ eYiw== 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=fRJ3JU0kWJxRG/VsnZvJ0E2CSJGa6L4lov+YumCbaiwztjP4DLJDTPG607FLo941j7 ulzwnPrq9sihDNWnqzpfrp9sUP+pfjjSu45ggd3OhN4NsN2tufG4hXaD/e5s9sOf1eBx mlsWN3lI0sxTFeiJup+VtIBB/pktvk9M4b2pakCepme5nhZo8fv1/uoQVxrZb90SBWQX a8I5QC1TXrPh9xpxiTujRpYUGW32aKHftGGCSbsYoc4sdUFmFdJdVAu4JH3tc9Ip7A/c 7znw1k+lLUMiAsp+4TENdIgZrHQmmFyPo2R0O0NWLc/uS6Lrd2nxHH5KNOqF8/FQTIqp LuUw== X-Gm-Message-State: AJIora+id/+NqhqfapomM3yT4b1Vr9W1KmDa7eXCBG7x7TEEyLu5F9Iz KKCSNLjejP1Lwr3Ap0LdZAdeXg== X-Google-Smtp-Source: AGRyM1s6kW/hpfAkwjRp5ft8p82osh4eWrW6jMIuSS+hLl8imvl+00wy3V1y8Ixj70bko8B/IT0P8w== X-Received: by 2002:a05:6000:100d:b0:21e:69b3:1901 with SMTP id a13-20020a056000100d00b0021e69b31901mr939964wrx.622.1658520036337; Fri, 22 Jul 2022 13:00:36 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:957f:d36d:87f9:5c17]) by smtp.gmail.com with ESMTPSA id k23-20020a05600c1c9700b003a31b00c216sm6429008wms.0.2022.07.22.13.00.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00: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 v6 06/10] thermal/core: Move thermal_set_delay_jiffies to static Date: Fri, 22 Jul 2022 22:00:03 +0200 Message-Id: <20220722200007.1839356-7-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722200007.1839356-1-daniel.lezcano@linexp.org> References: <20220722200007.1839356-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 Fri Jul 22 20:00: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: 12926834 X-Patchwork-Delegate: daniel.lezcano@linaro.org 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 50932C433EF for ; Fri, 22 Jul 2022 20:01:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236681AbiGVUA6 (ORCPT ); Fri, 22 Jul 2022 16:00:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236624AbiGVUAt (ORCPT ); Fri, 22 Jul 2022 16:00:49 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 252BCA8768 for ; Fri, 22 Jul 2022 13:00:44 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id b26so7897395wrc.2 for ; Fri, 22 Jul 2022 13:00: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=L3skzrLPntV9feVuTsato+Vtj+oVFJD2KdodKzkC6Z0=; b=yb5QWNrkaYPA6uPzKR/BKpI1lwgqcVnv1vSF0SlbF2nBLUNoyNwZe05GtVa9viUHXB eGFdkGLJRDRD9CU2ri8gR4+rhxCoZwFiwEY97BQvguCJsp2kPU1HZIgT4PkC09htcev8 MPpLwegdpyz3P8VMMU3qznBwaV97XKxAlNMnSU2I1Fc/MjObEx4Nmvp8Pyg2jmgiA4CL 9VcoRqFiQLKPmGDsuQoyvvGrlyrmgzXDt2lyD/DWUQXLZLkMZg8ZVMIgXHF2AeOreTh4 rkX03LzSibm5zvujmcOjHjCpa3O+ySlhBcF7Rfs6/N603T39qYgKQ7KVvsw8uwq+ioPc awUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L3skzrLPntV9feVuTsato+Vtj+oVFJD2KdodKzkC6Z0=; b=H2TnNM/AgW8pRgVDTsYvi9+IyflwTaolcwG4qT2oLf8sWOg4XJaUNc/JM5/7MuwLdv bCasTz4ggAbmAlXwB5lDLVFcJFa++4B8UeN0zSHxm5r9tWjfLgw47tUe4cSBBUJ6zTwJ ir29Wck1ayHDOfdHEHZo7+Y3nE6ak3eQI77Kx/HCYG3G5TAKL2gOIKsHS7WlBj+YiFRk qpXayd7W4SIroHpoElTRgIzj7QQznhGF9IwpF1vDb+BymzEh/Zb7wwr8TsPkqUJDJO+5 lVH96tKp+YxvgC2S+qMBmMAcWjxqR926omBw9fFnrMftUpRl0qyiVzXdolrTmDgklSUi u/Dw== X-Gm-Message-State: AJIora+mFRuOzQyc0tn8G5YMCC9extIuyPMbCqQiAN5mdZI6yibNQi/h GumEAZca7hoQgZ8xvll1oCK5kgZ6c1awpA== X-Google-Smtp-Source: AGRyM1s/lk344eDgcyuNvIHbsRB9tsYrqqjf2ojiuJAKUSC/SSLBnVRvNZQuGY2+68mY9rmFQC5jPQ== X-Received: by 2002:adf:eed1:0:b0:21d:7052:278a with SMTP id a17-20020adfeed1000000b0021d7052278amr1014735wrp.170.1658520042394; Fri, 22 Jul 2022 13:00:42 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:957f:d36d:87f9:5c17]) by smtp.gmail.com with ESMTPSA id k23-20020a05600c1c9700b003a31b00c216sm6429008wms.0.2022.07.22.13.00.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00: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 , Thierry Reding , Jonathan Hunter , Dmitry Osipenko , linux-tegra@vger.kernel.org (open list:TEGRA ARCHITECTURE SUPPORT) Subject: [PATCH v6 07/10] thermal/core: Rename 'trips' to 'num_trips' Date: Fri, 22 Jul 2022 22:00:04 +0200 Message-Id: <20220722200007.1839356-8-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722200007.1839356-1-daniel.lezcano@linexp.org> References: <20220722200007.1839356-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 'num_trips' to have the 'trips' field containing the thermal trip points. Cc: Alexandre Bailon Cc: Kevin Hilman Signed-off-by: Daniel Lezcano --- drivers/thermal/gov_fair_share.c | 6 +++--- drivers/thermal/gov_power_allocator.c | 4 ++-- drivers/thermal/tegra/tegra30-tsensor.c | 2 +- drivers/thermal/thermal_core.c | 20 ++++++++++---------- drivers/thermal/thermal_helpers.c | 4 ++-- drivers/thermal/thermal_netlink.c | 2 +- drivers/thermal/thermal_sysfs.c | 22 +++++++++++----------- include/linux/thermal.h | 4 ++-- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/thermal/gov_fair_share.c b/drivers/thermal/gov_fair_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 Fri Jul 22 20:00: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: 12926832 X-Patchwork-Delegate: daniel.lezcano@linaro.org 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 1F246C433EF for ; Fri, 22 Jul 2022 20:00:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235652AbiGVUAz (ORCPT ); Fri, 22 Jul 2022 16:00:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236603AbiGVUAv (ORCPT ); Fri, 22 Jul 2022 16:00:51 -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 33E15A894A for ; Fri, 22 Jul 2022 13:00:45 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id d13so217164wrn.10 for ; Fri, 22 Jul 2022 13:00: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=ygELt+w2niDufxqg+IYClbCGoWLEzDI4biE+DTmo/4U=; b=RNASHCLkxOYDWKlTL4APl6rJr7Di7k+aKh7QB4MLeQbj8koZOb8gwbldKNH1jOb2I1 TMjAIls0xpg6rFiEANAw5B56Zc426soBCQB3rdT262JfY9JO3ehFA7tpONLgCVKdWBiV 1vQ/MpW77cqS+nsrtQ8R4culkbM0Sds4D1YblzXWmOT/hO8VybokZNZ165zRSTaYW2TB QlhdTi3h2dKNFVXFQxcepH93JvTUkXiuITwRzlMBNaLxLxA0JhlpULRtnm0Rq9MNFJZN jnSNyjNNi1JZr210ZNcUeyA7/Mp2kjQvnAejugFWZfqIuVfu5y6pvsIvNhq9DOt1jS/3 iYhA== 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=ygELt+w2niDufxqg+IYClbCGoWLEzDI4biE+DTmo/4U=; b=wqABdyHNvM5zPOFLhSXDbMiW6EIA2Jvb1eqPNpnSbF6izWKrg+QX3u2qnmq136BGwY 1Z8PToOKYrRjiAD11Wt6YPmidfKv2X07ykJU4TMl+5X4OOPoskrlCioomhtDccrZtBbj 6eEu/SW9OPmKKFRLWTC1xQ2faMGBAhAPba4vAIkNWXD9/FB7laPdEoksCUqPt6t64xKJ hcnbM9t3JjAKqatEhvdMEKgwAQtidir4Yd8b8CJg9SPVj9U6Y/zvyCoIy8K5KcM017qD eF9EOh9vdMzrYtNDmZW6FE5diakwIpj7c7HYg442wjS3i6jNOGkqd520+97tdYfNd3o/ YGIw== X-Gm-Message-State: AJIora8XCYSLHj6tEDunJ63SvwwPQD/yz/KZbhQWNkEAX4nQIPLvb8NW FAyBHtVPggUhLoMyHbw84fjLvA== X-Google-Smtp-Source: AGRyM1vlFkQyiF/YclfF60LhXmvuuE8FrGDDL0jm/ooKehytFiUmRQpct35zTomGZokoDdDHjA7VEQ== X-Received: by 2002:a05:6000:15c1:b0:21d:b72c:a9ad with SMTP id y1-20020a05600015c100b0021db72ca9admr988666wry.94.1658520043564; Fri, 22 Jul 2022 13:00:43 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:957f:d36d:87f9:5c17]) by smtp.gmail.com with ESMTPSA id k23-20020a05600c1c9700b003a31b00c216sm6429008wms.0.2022.07.22.13.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00: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 v6 08/10] thermal/core: Add thermal_trip in thermal_zone Date: Fri, 22 Jul 2022 22:00:05 +0200 Message-Id: <20220722200007.1839356-9-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722200007.1839356-1-daniel.lezcano@linexp.org> References: <20220722200007.1839356-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. 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. 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_core.c | 22 +++++++++++++++++----- drivers/thermal/thermal_of.c | 8 +++----- include/linux/thermal.h | 8 ++++++++ 3 files changed, 28 insertions(+), 10 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/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)); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 03e968d61471..fde4689a1755 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; @@ -378,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 Fri Jul 22 20:00: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: 12926833 X-Patchwork-Delegate: daniel.lezcano@linaro.org 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 3522ACCA473 for ; Fri, 22 Jul 2022 20:00:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235292AbiGVUA5 (ORCPT ); Fri, 22 Jul 2022 16:00:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236628AbiGVUAv (ORCPT ); Fri, 22 Jul 2022 16:00:51 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34129AF71B for ; Fri, 22 Jul 2022 13:00:45 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id a11so3365643wmq.3 for ; Fri, 22 Jul 2022 13:00: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=pfwxGREqovTLfBwtFWXl08zrAx/30xJr9AVKnnlYCfo=; b=zJSYFS5fqOUuCya5n62OeqA4ya4Gscqp7is8Zx78n9LnYWYblaz/WpbRvK+XQQBXMt XSvF+rh3linEnBgfwxtH3eZkyAJdF8+udYgAPglsouKNmurohJU3MHljgOga9PmwLuwN sri0tz8RHbVHnVAo77NBZ1dp6HqQwdXL4RuHqn8d8j+RY3nibtankXVQulB0v6SEdddI gU0pyJaiLuapSELCSkFVnE4Rs364N0YrjDEcXDAaqfzCnlitNbYKxqm7PhxMHdDQ0hWH 4bW/QuGKFGB3TPhTiyjoMIt1DYZYvsSpDrTCQBdrnMJN2xPaVzlHoYDsR7xUg+OpiX5S l5Fw== 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=pfwxGREqovTLfBwtFWXl08zrAx/30xJr9AVKnnlYCfo=; b=U3Y+m8JtrUEIcdz2J+3CmERK7j0WlvUtRiogstBHtwy2oMraCA3iusZWZ25aa0cjAk vOmEmYfNeu7byk5vzJYXjlBYn37ZX9jCw4Q2norN9IphRlCR3cjRoKrIDjylQ1g9cf+6 yTyWtRkzyr4P0DO89xb4V8GtyM9ktIhdu50Nq6a+utowo7X1K6wVyUYkvT77lLu0ginn jrMWhUEfBvYamDPLHKiaXVuwkwg6tH/koSMaLx4SPlmJTUPSNsJI6imy33i4r2pf6uWG CldS5SBtGB5gvQWOpfCqt4kq4xghzYCeX5yZsVCrT4kb51d97nQwCufrmpvCxZPBt3lU 0/lw== X-Gm-Message-State: AJIora+aeEMfywIiCUhQBILfeBQpl+DrtoEdHbao9TS6PzDzC+nsXLiR HuQcViE2i36GPbTgnXone5VogA== X-Google-Smtp-Source: AGRyM1tr2w5l8qH4SFnlCi7j5HoiBv+h72hja8sqeq3zpP6CI2Ax9CgHcY9rlBZxDq5BFiqwO4OH/w== X-Received: by 2002:a05:600c:4e4d:b0:3a3:1fe6:6b20 with SMTP id e13-20020a05600c4e4d00b003a31fe66b20mr864989wmq.197.1658520044641; Fri, 22 Jul 2022 13:00:44 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:957f:d36d:87f9:5c17]) by smtp.gmail.com with ESMTPSA id k23-20020a05600c1c9700b003a31b00c216sm6429008wms.0.2022.07.22.13.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00: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 v6 09/10] thermal/of: Use thermal trips stored in the thermal zone Date: Fri, 22 Jul 2022 22:00:06 +0200 Message-Id: <20220722200007.1839356-10-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722200007.1839356-1-daniel.lezcano@linexp.org> References: <20220722200007.1839356-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..b59eec4af0eb 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->num_trips; } 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->num_trips || 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->num_trips || 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->num_trips || 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->num_trips || 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->num_trips || 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->num_trips || 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->num_trips; i++) + if (tz->trips[i].type == THERMAL_TRIP_CRITICAL) { + *temp = tz->trips[i].temperature; return 0; } From patchwork Fri Jul 22 20:00:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12926835 X-Patchwork-Delegate: daniel.lezcano@linaro.org 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 CFCC6C43334 for ; Fri, 22 Jul 2022 20:01:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236686AbiGVUA7 (ORCPT ); Fri, 22 Jul 2022 16:00:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236644AbiGVUAx (ORCPT ); Fri, 22 Jul 2022 16:00:53 -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 5DF03AF733 for ; Fri, 22 Jul 2022 13:00:46 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id h8so7883937wrw.1 for ; Fri, 22 Jul 2022 13:00: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=iVtxa+vuykpc9jPpe/gzYZEspPiDTyEIGx5jh5o8tcM=; b=4+janghD8Dw6whSA55KQShCIG1hZCMxlZM8n3+d/7DyuGeEXbFzq9kO106S8vbPv0+ Rgb0Chkf9UnhCrktg7tnuJ8YPcyuOuy5Wdf2OVrqtFfOAFiYEzWaJ4RJ59SdW2oUTHki VzGLtrgcdcwNNFjXPCH4f64jjS2RI5PtEf+JjwHeQ2Rd0QDaRUvNMjsen2h8QAp5f1Db 9POiG7MQRrFZWZwI8bL69nhoDPP9mDpsukBcfkO4doPLV77OCnBiRvx/IEmmWZ4ip+4/ fBskA+67+Po0owOmuknbOboqvxzSrYl2HGjn7iJebU1koBjkMfFKsAnPaqCbsfqP1oz0 XSNA== 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=iVtxa+vuykpc9jPpe/gzYZEspPiDTyEIGx5jh5o8tcM=; b=VZ8kFuP4G/apRMntDk8kwzwsNbpQ/k5ng7mI1XXOPtWJVIq+41vwiNFEtwl4bOacfk 9DU/Huubs5V8S/hsw8DUgBMHabviKxSBFiXZlTmkpeBXCpvHGhL5aeEJJNmT8lvPeqYJ WmW993Bw634yJvL/TWfkBJDjBnEqdWcp5KmJl2jkHH7Krq9okuDdzthzIiOAZxpNAMz4 YFJrUJxnFrECcZjJkyJ3c7ZMMcZnmVu17Cx4ujKzoZ+o58UNJbm/4+iY6ForksB2ilms NcIfWUiu0+1uvEdHizixSQ8aWh6+mKp6h/zUOQ/FXPMbxAvaiz2eWwl7Vt9D7bIERfNB aJyg== X-Gm-Message-State: AJIora9+zEUnYmIDKdlPyxc3QTTlw1I3F355F13aguGWbzfH95uY7vvx gFbCBp6UfQrQ3T4C6/UdGDObYQ== X-Google-Smtp-Source: AGRyM1vYAZglTmENhkJtrAMPgyidh7bkVjeuKlt0YW+4lqn+1k/roXGT0kDvWuZy7s2DD6CN9VB5zw== X-Received: by 2002:a5d:460e:0:b0:21e:6d12:d308 with SMTP id t14-20020a5d460e000000b0021e6d12d308mr795545wrq.419.1658520045826; Fri, 22 Jul 2022 13:00:45 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:957f:d36d:87f9:5c17]) by smtp.gmail.com with ESMTPSA id k23-20020a05600c1c9700b003a31b00c216sm6429008wms.0.2022.07.22.13.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00: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 v6 10/10] thermal/of: Initialize trip points separately Date: Fri, 22 Jul 2022 22:00:07 +0200 Message-Id: <20220722200007.1839356-11-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722200007.1839356-1-daniel.lezcano@linexp.org> References: <20220722200007.1839356-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 | 86 ++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 29 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index b59eec4af0eb..0693edc00f60 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -693,7 +693,8 @@ static int of_find_trip_id(struct device_node *np, 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);