mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Nathan Chancellor" <nathan@kernel.org>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Frank Rowand" <frowand.list@gmail.com>
Cc: 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 10:10:39 +0200	[thread overview]
Message-ID: <767d768e-70e5-4a94-accb-3384a3bfd582@app.fastmail.com> (raw)
In-Reply-To: <20221013195153.2767632-1-nathan@kernel.org>

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.

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.

       Arnd

  parent reply	other threads:[~2022-10-14  8:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-13 19:51 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 [this message]
2022-10-14 16:47   ` Nathan Chancellor

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=767d768e-70e5-4a94-accb-3384a3bfd582@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=flatmax@flatmax.com \
    --cc=frowand.list@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@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

all inboxes | Powered by JetHome®