Re: [PATCH 29/38] ASoC: tas2562: skip of_device_id table when !CONFIG_OF

Krzysztof Kozlowski
2020-11-20T16:37:03Z

On Fri, Nov 20, 2020 at 10:21:56AM -0600, Dan Murphy wrote:
> Hello
>
> On 11/20/20 10:16 AM, Krzysztof Kozlowski wrote:
> > The driver can match by multiple methods. Its of_device_id table is
> > referenced via of_match_ptr() so it will be unused for !CONFIG_OF
> > builds:
> >
> > sound/soc/codecs/tas2562.c:805:34: warning: ‘tas2562_of_match’ defined but not used [-Wunused-const-variable=]
> >
> > Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> > ---
> > sound/soc/codecs/tas2562.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/sound/soc/codecs/tas2562.c b/sound/soc/codecs/tas2562.c
> > index f1ff204e3ad0..19965fabe949 100644
> > --- a/sound/soc/codecs/tas2562.c
> > +++ b/sound/soc/codecs/tas2562.c
> > @@ -802,6 +802,7 @@ static const struct i2c_device_id tas2562_id[] = {
> > };
> > MODULE_DEVICE_TABLE(i2c, tas2562_id);
> > +#ifdef CONFIG_OF
>
> Should we use #if IS_ENABLED(CONFIG_OF) ?

I think it does not matter:
1. OF is only bool,
2. This is the existing pattern in many driver (for OF and ACPI),
see also: Documentation/firmware-guide/acpi/enumeration.rst
3. ifdef should be faster for preprocessor (less macros to unwind),

It would matter if OF became a module option. In such case anyway a lot
of existing ifdef CONFIG_OF would have to be corrected.

Best regards,
Krzysztof