From: Nathan Chancellor <nathan@kernel.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Rob Herring <robh+dt@kernel.org>,
Frank Rowand <frowand.list@gmail.com>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Matt Flax <flatmax@flatmax.com>
Subject: Re: [PATCH] of: Define of_match_ptr() with PTR_IF() to avoid unused variable warnings
Date: Fri, 14 Oct 2022 09:47:43 -0700 [thread overview]
Message-ID: <Y0mSrxar/QwNAESd@dev-arch.thelio-3990X> (raw)
In-Reply-To: <767d768e-70e5-4a94-accb-3384a3bfd582@app.fastmail.com>
On Fri, Oct 14, 2022 at 10:10:39AM +0200, Arnd Bergmann wrote:
> On Thu, Oct 13, 2022, at 9:51 PM, Nathan Chancellor wrote:
> >
> > -#define of_match_ptr(_ptr) NULL
> > #define of_match_node(_matches, _node) NULL
> > #endif /* CONFIG_OF */
> >
> > +#define of_match_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_OF), (_ptr))
> > +
>
> I think this is counterproductive, as it means we cannot use
> of_match_ptr() for its intended purpose any more, it will
> now cause a build failure for any driver that references a
> match table inside of an #ifdef.
Ack, I obviously had not considered this before sending the change,
shows how much compile testing it got ;)
> Ideally we should be able to find the misuse of this macro with
> coccinelle and have it automatically generate patches that just remove
> it from drivers.
>
> A first-level approximation would be this oneliner:
>
> git grep -wl of_match_ptr | xargs git grep -wL CONFIG_OF | xargs sed -i "s:of_match_ptr(\([\ \#\>\"a-zA-Z0-9_-]*\)):\1:"
>
> which takes care of 535 files that don't reference CONFIG_OF at all.
> There are 496 more files that use of_match_ptr() as well but also
> guard something inside of CONFIG_OF. Most of these are just
> incorrectly copy-pasted from older drivers and should not have an
> #ifdef in them to make the of_match_ptr() work, but they are not actually
> usable without CONFIG_OF.
>
> Historically, we added the #ifdef at the time when we supported hundreds
> of boards without DT and only a couple of boards with DT, so having the
> extra #ifdef was a way of ensuring that the DT conversion would not add
> a few extra bytes of .data to each driver. Now we support thousands of
> boards with DT and only a few dozen without DT, so this is all pointless.
Ack to all of this but it sounds like this will be a bit of a larger
project than I am interested in picking up right now so consider this
patch retracted with an open invitation for someone else to continue
this clean up.
Cheers,
Nathan
prev parent reply other threads:[~2022-10-14 16:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-13 19:51 [PATCH] of: Define of_match_ptr() with PTR_IF() to avoid unused variable warnings Nathan Chancellor
2022-10-14 2:27 ` kernel test robot
2022-10-14 2:27 ` kernel test robot
2022-10-14 2:37 ` kernel test robot
2022-10-14 8:10 ` Arnd Bergmann
2022-10-14 16:47 ` Nathan Chancellor [this message]
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=Y0mSrxar/QwNAESd@dev-arch.thelio-3990X \
--to=nathan@kernel.org \
--cc=arnd@arndb.de \
--cc=devicetree@vger.kernel.org \
--cc=flatmax@flatmax.com \
--cc=frowand.list@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@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