ARM Sunxi Platform Development
 help / color / mirror / Atom feed
From: Dragan Simic <dsimic@manjaro.org>
To: Chen-Yu Tsai <wenst@chromium.org>
Cc: "Daniel Lezcano" <daniel.lezcano@linaro.org>,
	"Amit Kucheria" <amitk@kernel.org>,
	"Zhang Rui" <rui.zhang@intel.com>,
	"Icenowy Zheng" <uwu@icenowy.me>,
	"Mark Brown" <broonie@kernel.org>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev,
	"Nícolas F. R. A. Prado" <nfraprado@collabora.com>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	linux-mediatek@lists.infradead.org,
	"Hsin-Te Yuan" <yuanhsinte@chromium.org>
Subject: Re: [PATCH v2] thermal/of: support thermal zones w/o trips subnode
Date: Mon, 12 Aug 2024 03:22:05 +0200	[thread overview]
Message-ID: <b00273d65dfc4b48cca474784184c62b@manjaro.org> (raw)
In-Reply-To: <20240809070822.2835371-1-wenst@chromium.org>

Hello Chen-Yu,

Thanks for the patch.  Please see one comment below.

On 2024-08-09 09:08, Chen-Yu Tsai wrote:
> From: Icenowy Zheng <uwu@icenowy.me>
> 
> Although the current device tree binding of thermal zones require the
> trips subnode, the binding in kernel v5.15 does not require it, and 
> many
> device trees shipped with the kernel, for example,
> allwinner/sun50i-a64.dtsi and mediatek/mt8183-kukui.dtsi in ARM64, 
> still
> comply to the old binding and contain no trips subnode.
> 
> Allow the code to successfully register thermal zones w/o trips subnode
> for DT binding compatibility now.
> 
> Furtherly, the inconsistency between DTs and bindings should be 
> resolved
> by either adding empty trips subnode or dropping the trips subnode
> requirement.
> 
> Fixes: d0c75fa2c17f ("thermal/of: Initialize trip points separately")
> Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> Reviewed-by: Mark Brown <broonie@kernel.org>
> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
> ---
> Resurrecting this patch specifically for MediaTek MT8183 Kukui devices.
> 
> Changes since v1:
> - set *ntrips at beginning of thermal_of_trips_init()
> - Keep goto out_of_node_put in of_get_child_count(trips) == 0 branch
> - Check return value of thermal_of_trips_init(), if it is -ENXIO, print
>   warning and clear |trips| pointer
> - Drop |mask| change, as the variable was removed
> 
> I kept Mark's reviewed-by since the changes are more stylish than
> functional.
> ---
>  drivers/thermal/thermal_of.c | 19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/thermal/thermal_of.c 
> b/drivers/thermal/thermal_of.c
> index aa34b6e82e26..f237e74c92fc 100644
> --- a/drivers/thermal/thermal_of.c
> +++ b/drivers/thermal/thermal_of.c
> @@ -128,16 +128,17 @@ static struct thermal_trip
> *thermal_of_trips_init(struct device_node *np, int *n
>  	struct device_node *trips, *trip;
>  	int ret, count;
> 
> +	*ntrips = 0;
>  	trips = of_get_child_by_name(np, "trips");
>  	if (!trips) {
> -		pr_err("Failed to find 'trips' node\n");
> -		return ERR_PTR(-EINVAL);
> +		pr_debug("Failed to find 'trips' node\n");
> +		return ERR_PTR(-ENXIO);
>  	}
> 
>  	count = of_get_child_count(trips);
>  	if (!count) {
> -		pr_err("No trip point defined\n");
> -		ret = -EINVAL;
> +		pr_debug("No trip point defined\n");
> +		ret = -ENXIO;
>  		goto out_of_node_put;
>  	}
> 
> @@ -162,7 +163,6 @@ static struct thermal_trip
> *thermal_of_trips_init(struct device_node *np, int *n
> 
>  out_kfree:
>  	kfree(tt);
> -	*ntrips = 0;
>  out_of_node_put:
>  	of_node_put(trips);

It might be a bit cleaner to keep the "*ntrips = 0" assignment
in the error handling path(s) only, with the positions of the goto
labels adjusted a bit, and then assign -ENXIO to "ret" and jump
to the right label when of_get_child_by_name(np, "trips") fails,
instead of returning from there.

If it's unclear what I'm talking about, please let me know and
I'll send back the proposed hunk.

> @@ -490,8 +490,13 @@ static struct thermal_zone_device
> *thermal_of_zone_register(struct device_node *
> 
>  	trips = thermal_of_trips_init(np, &ntrips);
>  	if (IS_ERR(trips)) {
> -		pr_err("Failed to find trip points for %pOFn id=%d\n", sensor, id);
> -		return ERR_CAST(trips);
> +		if (PTR_ERR(trips) != -ENXIO) {
> +			pr_err("Failed to find trip points for %pOFn id=%d\n", sensor, id);
> +			return ERR_CAST(trips);
> +		}
> +
> +		pr_warn("Failed to find trip points for %pOFn id=%d\n", sensor, id);
> +		trips = NULL;
>  	}
> 
>  	ret = thermal_of_monitor_init(np, &delay, &pdelay);

  reply	other threads:[~2024-08-12  1:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-09  7:08 [PATCH v2] thermal/of: support thermal zones w/o trips subnode Chen-Yu Tsai
2024-08-12  1:22 ` Dragan Simic [this message]
2024-08-12  4:46   ` Chen-Yu Tsai
2024-08-15  4:45     ` Chen-Yu Tsai
2024-08-17  2:42       ` Dragan Simic

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=b00273d65dfc4b48cca474784184c62b@manjaro.org \
    --to=dsimic@manjaro.org \
    --cc=amitk@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=broonie@kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=matthias.bgg@gmail.com \
    --cc=nfraprado@collabora.com \
    --cc=rui.zhang@intel.com \
    --cc=uwu@icenowy.me \
    --cc=wenst@chromium.org \
    --cc=yuanhsinte@chromium.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