From: Chen-Yu Tsai <wenst@chromium.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>,
Amit Kucheria <amitk@kernel.org>,
Thara Gopinath <thara.gopinath@gmail.com>,
Thierry Reding <thierry.reding@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
Vasily Khoruzhick <anarsoul@gmail.com>,
Yangtao Li <tiny.windzz@gmail.com>, Chen-Yu Tsai <wens@csie.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev
Subject: Re: [PATCH 3/7] thermal: of: Use scoped device node handling to simplify of_thermal_zone_find()
Date: Thu, 15 Aug 2024 15:19:25 +0800 [thread overview]
Message-ID: <20240815071925.GC350960@google.com> (raw)
In-Reply-To: <20240814-b4-cleanup-h-of-node-put-thermal-v1-3-7a1381e1627e@linaro.org>
On Wed, Aug 14, 2024 at 10:17:49PM +0200, Krzysztof Kozlowski wrote:
> Obtain the device node reference with scoped/cleanup.h to reduce error
> handling and make the code a bit simpler.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
> ---
>
> This depends on my earlier fixes:
>
> https://lore.kernel.org/all/20240814195823.437597-1-krzysztof.kozlowski@linaro.org/
> ---
> drivers/thermal/thermal_of.c | 18 ++++++------------
> 1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
> index c8ded4462bb8..fb5472d6ffea 100644
> --- a/drivers/thermal/thermal_of.c
> +++ b/drivers/thermal/thermal_of.c
> @@ -157,10 +157,9 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n
>
> static struct device_node *of_thermal_zone_find(struct device_node *sensor, int id)
> {
> - struct device_node *np, *tz;
> struct of_phandle_args sensor_specs;
>
> - np = of_find_node_by_name(NULL, "thermal-zones");
> + struct device_node *np __free(device_node) = of_find_node_by_name(NULL, "thermal-zones");
> if (!np) {
> pr_debug("No thermal zones description\n");
> return ERR_PTR(-ENODEV);
> @@ -178,8 +177,7 @@ static struct device_node *of_thermal_zone_find(struct device_node *sensor, int
> "#thermal-sensor-cells");
> if (count <= 0) {
> pr_err("%pOFn: missing thermal sensor\n", child);
> - tz = ERR_PTR(-EINVAL);
> - goto out;
> + return ERR_PTR(-EINVAL);
> }
>
> for (i = 0; i < count; i++) {
> @@ -191,22 +189,18 @@ static struct device_node *of_thermal_zone_find(struct device_node *sensor, int
> i, &sensor_specs);
> if (ret < 0) {
> pr_err("%pOFn: Failed to read thermal-sensors cells: %d\n", child, ret);
> - tz = ERR_PTR(ret);
> - goto out;
> + return ERR_PTR(ret);
> }
>
> if ((sensor == sensor_specs.np) && id == (sensor_specs.args_count ?
> sensor_specs.args[0] : 0)) {
> pr_debug("sensor %pOFn id=%d belongs to %pOFn\n", sensor, id, child);
> - tz = no_free_ptr(child);
> - goto out;
> + return no_free_ptr(child);
> }
> }
> }
> - tz = ERR_PTR(-ENODEV);
> -out:
> - of_node_put(np);
> - return tz;
> +
> + return ERR_PTR(-ENODEV);
> }
>
> static int thermal_of_monitor_init(struct device_node *np, int *delay, int *pdelay)
>
> --
> 2.43.0
>
next prev parent reply other threads:[~2024-08-15 7:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-14 20:17 [PATCH 0/7] thermal: scope/cleanup.h improvements Krzysztof Kozlowski
2024-08-14 20:17 ` [PATCH 1/7] thermal: of: Use scoped device node handling to simplify of_find_trip_id() Krzysztof Kozlowski
2024-08-15 7:10 ` Chen-Yu Tsai
2024-08-14 20:17 ` [PATCH 2/7] thermal: of: Use scoped device node handling to simplify thermal_of_trips_init() Krzysztof Kozlowski
2024-08-15 7:15 ` Chen-Yu Tsai
2024-08-16 5:28 ` Krzysztof Kozlowski
2024-08-17 2:47 ` Dragan Simic
2024-08-14 20:17 ` [PATCH 3/7] thermal: of: Use scoped device node handling to simplify of_thermal_zone_find() Krzysztof Kozlowski
2024-08-15 7:19 ` Chen-Yu Tsai [this message]
2024-08-14 20:17 ` [PATCH 4/7] thermal: of: Simplify thermal_of_for_each_cooling_maps() with scoped for each OF child loop Krzysztof Kozlowski
2024-08-15 7:22 ` Chen-Yu Tsai
2024-08-14 20:17 ` [PATCH 5/7] thermal: qcom-spmi-adc-tm5: Simplify " Krzysztof Kozlowski
2024-08-15 7:29 ` Chen-Yu Tsai
2024-08-14 20:17 ` [PATCH 6/7] thermal: tegra: " Krzysztof Kozlowski
2024-08-15 7:31 ` Chen-Yu Tsai
2024-08-14 20:17 ` [PATCH 7/7] thermal: sun8i: Use scoped device node handling to simplify error paths Krzysztof Kozlowski
2024-08-15 7:33 ` Chen-Yu Tsai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240815071925.GC350960@google.com \
--to=wenst@chromium.org \
--cc=amitk@kernel.org \
--cc=anarsoul@gmail.com \
--cc=daniel.lezcano@linaro.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonathanh@nvidia.com \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=linux-tegra@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=samuel@sholland.org \
--cc=thara.gopinath@gmail.com \
--cc=thierry.reding@gmail.com \
--cc=tiny.windzz@gmail.com \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).