Re: [PATCH] of: Define of_match_ptr() with PTR_IF() to avoid unused variable warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux