Re: [PATCH] staging: wfx: avoid compiler warning on empty array

From: Jerome Pouiller
Date: Thu Apr 30 2020 - 04:42:28 EST


On Wednesday 29 April 2020 22:34:56 CEST Arnd Bergmann wrote:
>
> On Wed, Apr 29, 2020 at 6:04 PM Jerome Pouiller
> <Jerome.Pouiller@xxxxxxxxxx> wrote:
> > On Wednesday 29 April 2020 16:21:09 CEST Arnd Bergmann wrote:
> > >
> > > -static const struct of_device_id wfx_sdio_of_match[];
> > > +static const struct of_device_id wfx_sdio_of_match[] = {
> > > + { .compatible = "silabs,wfx-sdio" },
> > > + { .compatible = "silabs,wf200" },
> > > + { },
> > > +};
> > > +MODULE_DEVICE_TABLE(of, wfx_sdio_of_match);
> >
> > I suggest to keep the '#ifdef CONFIG_OF' around this definition. If
> > CONFIG_OF is undefined, of_match_ptr() and of_match_node() will be NULL
> > and it should compile.
>
> I would generally always go for fewer #ifdef instead of more when the result
> is the same. Are you worried about wasting 600 bytes of object code size for
> the array on systems that need this driver but not CONFIG_OF, or something
> else?

I am not very concerned about the size of the object. However, I think
that all the modules should apply the same policy regarding the device
tables. With a few greps, I found 3954 struct of_device_id. About 500 are
inside #ifdef and about 1000 use of_match_ptr().

Should we consider that the structs of_device_id have to be defined even
if CONFIG_OF is not defined? And In this case, should we drop
of_match_ptr()?

Or in contrary, when kernel is compiled without CONFIG_OF, no modules
should contains OF entries in its device table?

--
Jérôme Pouiller