From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Rob Herring <robh@kernel.org>, <linux-iio@vger.kernel.org>,
<devicetree@vger.kernel.org>,
Frank Rowand <frowand.list@gmail.com>
Subject: Re: [RFC PATCH 1/4] of: Add cleanup.h based autorelease via __free(device_node) markings.
Date: Mon, 8 Jan 2024 12:53:49 +0000 [thread overview]
Message-ID: <20240108125349.000020d9@Huawei.com> (raw)
In-Reply-To: <20231221105434.5842ff3a@jic23-huawei>
> >
> > >
> > > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > > ---
> > > include/linux/of.h | 2 ++
> > > 1 file changed, 2 insertions(+)
> > >
> > > diff --git a/include/linux/of.h b/include/linux/of.h
> > > index 6a9ddf20e79a..50e882ee91da 100644
> > > --- a/include/linux/of.h
> > > +++ b/include/linux/of.h
> > > @@ -13,6 +13,7 @@
> > > */
> > > #include <linux/types.h>
> > > #include <linux/bitops.h>
> > > +#include <linux/cleanup.h>
> > > #include <linux/errno.h>
> > > #include <linux/kobject.h>
> > > #include <linux/mod_devicetable.h>
> > > @@ -134,6 +135,7 @@ static inline struct device_node *of_node_get(struct device_node *node)
> > > }
> > > static inline void of_node_put(struct device_node *node) { }
> > > #endif /* !CONFIG_OF_DYNAMIC */
> > > +DEFINE_FREE(device_node, struct device_node *, if (_T) of_node_put(_T))
> >
> > of_node_put() can be called with NULL, so do we need the "if (_T)"?
>
> Nope - should be fine to call it without. I was being lazy and didn't check :)
Seems there has been a lot of discussion of this for similar cases and
consensus is to keep the if (_T)
e.g.
https://lore.kernel.org/all/6596edda327c8_8dc68294b2@dwillia2-xfh.jf.intel.com.notmuch/
>
> >
> > Rob
>
>
next prev parent reply other threads:[~2024-01-08 12:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-17 18:46 [RFC PATCH 0/4] of: Automate handling of of_node_put() Jonathan Cameron
2023-12-17 18:46 ` [RFC PATCH 1/4] of: Add cleanup.h based autorelease via __free(device_node) markings Jonathan Cameron
2023-12-20 22:11 ` Rob Herring
2023-12-21 10:54 ` Jonathan Cameron
2024-01-08 12:53 ` Jonathan Cameron [this message]
2024-01-14 16:39 ` Jonathan Cameron
2023-12-17 18:46 ` [RFC PATCH 2/4] of: unittest: Use __free(device_node) Jonathan Cameron
2023-12-17 18:46 ` [RFC PATCH 3/4] iio: adc: fsl-imx25-gcq: " Jonathan Cameron
2023-12-17 18:46 ` [RFC PATCH 4/4] iio: adc: rcar-gyroadc: use __free(device_node) Jonathan Cameron
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=20240108125349.000020d9@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=robh@kernel.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).