Messages in this thread | | | Date | Wed, 16 Aug 2023 12:04:59 +0200 | Subject | Re: [PATCH RESEND RESEND] thermal/of: support thermal zones w/o trips subnode | From | Daniel Lezcano <> |
| |
On 22/07/2023 14:25, Icenowy Zheng 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> > --- > > Unfortunately the code gets dropped by mailing lists again and again... > > Sorry for the disturbance. > > drivers/thermal/thermal_of.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c > index 6fb14e521197..2c76df847e84 100644 > --- a/drivers/thermal/thermal_of.c > +++ b/drivers/thermal/thermal_of.c > @@ -127,15 +127,17 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n > > 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"); > + *ntrips = 0;
set ntrips at the beginning of the function.
> + return NULL;
return ERR_PTR(-ENXIO);
> } > > count = of_get_child_count(trips); > if (!count) { > - pr_err("No trip point defined\n"); > - ret = -EINVAL; > - goto out_of_node_put; > + pr_debug("No trip point defined\n"); > + of_node_put(trips); > + *ntrips = 0; > + return NULL;
Why not keep goto out_of_node_put ?
> } > > tt = kzalloc(sizeof(*tt) * count, GFP_KERNEL); > @@ -519,7 +521,10 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
The function should check the return value of thermal_of_trips_init()
If this one returns -ENXIO, it should pr_warn().
> of_ops->bind = thermal_of_bind; > of_ops->unbind = thermal_of_unbind; > > - mask = GENMASK_ULL((ntrips) - 1, 0); > + if (ntrips) > + mask = GENMASK_ULL((ntrips) - 1, 0); > + else > + mask = 0;
mask = ntrips ? GENMASK_ULL((ntrips) - 1, 0) : 0;
> tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips, > mask, data, of_ops, tzp,
-- <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
| |