Re: [PATCH v7 1/5] driver core: Introduce device_{add,remove}_of_node()
From: Herve Codina
Date: Thu Feb 20 2025 - 03:14:46 EST
Hi Jonathan,
On Wed, 19 Feb 2025 15:59:01 +0000
Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> wrote:
...
> > Signed-off-by: Herve Codina <herve.codina@xxxxxxxxxxx>
> A few passing comments. Not suggestions to actually change anything
> at this stage though. Maybe a potential follow up if you think it's
> a good idea.
>
...
> > +void device_remove_of_node(struct device *dev)
> > +{
> > + dev = get_device(dev);
> > + if (!dev)
> > + return;
> Maybe use
> struct device *d __free(put_device) = get_device(dev);
>
> if (!d->of_node);
> return;
>
> Not a reason to respin though!
>
>
...
> > +int device_add_of_node(struct device *dev, struct device_node *of_node)
> > +{
> > + int ret;
> > +
> > + if (!of_node)
> > + return -EINVAL;
> > +
> > + dev = get_device(dev);
>
> Likewise could use __free() magic here as well for slight simpliciations.
>
I see. Indeed, the __free(put_device) can be an improvement in core.c
I think that this has to be done out of this series in a more globally way
because put_device() is used in several place in this file and having a mix
between __free(put_device) and put_device() calls in a goto label is not the
best solution.
For this reason, as you proposed except if someone else pushes in the
__free(put_device) direction in functions introduced in this patch, I
prefer to keep this patch as it is.
Thanks for your feedback,
Hervé