All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Input: da7280 - protect OF match table with CONFIG_OF
@ 2020-12-18  6:50 Dmitry Torokhov
  2020-12-18 16:49 ` Roy Im
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Torokhov @ 2020-12-18  6:50 UTC (permalink / raw)
  To: linux-input; +Cc: Roy Im, linux-kernel

The OF match table is only used when OF is enabled.

Fixes: cd3f609823a5 ("Input: new da7280 haptic driver")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/misc/da7280.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
index 2f698a8c1d65..b08610d6e575 100644
--- a/drivers/input/misc/da7280.c
+++ b/drivers/input/misc/da7280.c
@@ -1300,11 +1300,13 @@ static int __maybe_unused da7280_resume(struct device *dev)
 	return retval;
 }
 
+#ifdef CONFIG_OF
 static const struct of_device_id da7280_of_match[] = {
 	{ .compatible = "dlg,da7280", },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, da7280_of_match);
+#endif
 
 static const struct i2c_device_id da7280_i2c_id[] = {
 	{ "da7280", },
-- 
2.29.2.729.g45daf8777d-goog


-- 
Dmitry

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH] Input: da7280 - protect OF match table with CONFIG_OF
  2020-12-18  6:50 [PATCH] Input: da7280 - protect OF match table with CONFIG_OF Dmitry Torokhov
@ 2020-12-18 16:49 ` Roy Im
  2020-12-20  2:01   ` Jeff LaBundy
  0 siblings, 1 reply; 5+ messages in thread
From: Roy Im @ 2020-12-18 16:49 UTC (permalink / raw)
  To: Dmitry Torokhov, linux-input; +Cc: Roy Im, linux-kernel

On Friday, December 18, 2020 3:50 PM, Dmitry Torokhov wrote:

> The OF match table is only used when OF is enabled.
> 
> Fixes: cd3f609823a5 ("Input: new da7280 haptic driver")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/input/misc/da7280.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c index 2f698a8c1d65..b08610d6e575 100644
> --- a/drivers/input/misc/da7280.c
> +++ b/drivers/input/misc/da7280.c
> @@ -1300,11 +1300,13 @@ static int __maybe_unused da7280_resume(struct device *dev)
>  	return retval;
>  }
> 
> +#ifdef CONFIG_OF
>  static const struct of_device_id da7280_of_match[] = {
>  	{ .compatible = "dlg,da7280", },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(of, da7280_of_match);
> +#endif
> 
>  static const struct i2c_device_id da7280_i2c_id[] = {
>  	{ "da7280", },
> --
> 2.29.2.729.g45daf8777d-goog
> 
> 
> --
> Dmitry

Thanks!

Acked-by: Roy Im <roy.im.opensource@diasemi.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: da7280 - protect OF match table with CONFIG_OF
  2020-12-18 16:49 ` Roy Im
@ 2020-12-20  2:01   ` Jeff LaBundy
  2021-01-04  1:58     ` Dmitry Torokhov
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff LaBundy @ 2020-12-20  2:01 UTC (permalink / raw)
  To: Roy Im; +Cc: Dmitry Torokhov, linux-input, linux-kernel

Hi Dmitry,

On Fri, Dec 18, 2020 at 04:49:48PM +0000, Roy Im wrote:
> On Friday, December 18, 2020 3:50 PM, Dmitry Torokhov wrote:
> 
> > The OF match table is only used when OF is enabled.
> > 
> > Fixes: cd3f609823a5 ("Input: new da7280 haptic driver")
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> >  drivers/input/misc/da7280.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c index 2f698a8c1d65..b08610d6e575 100644
> > --- a/drivers/input/misc/da7280.c
> > +++ b/drivers/input/misc/da7280.c
> > @@ -1300,11 +1300,13 @@ static int __maybe_unused da7280_resume(struct device *dev)
> >  	return retval;
> >  }
> > 
> > +#ifdef CONFIG_OF
> >  static const struct of_device_id da7280_of_match[] = {
> >  	{ .compatible = "dlg,da7280", },
> >  	{ }
> >  };
> >  MODULE_DEVICE_TABLE(of, da7280_of_match);
> > +#endif

Just for my own understanding, would it not work just as well
to include of_device.h? This includes mod_devicetable.h which
in turn defines the of_device_id struct (even if CONFIG_OF is
not set).

The reason for asking is because it seems many drivers do not
include these guards.

> > 
> >  static const struct i2c_device_id da7280_i2c_id[] = {
> >  	{ "da7280", },
> > --
> > 2.29.2.729.g45daf8777d-goog
> > 
> > 
> > --
> > Dmitry
> 
> Thanks!
> 
> Acked-by: Roy Im <roy.im.opensource@diasemi.com>
> 

Kind regards,
Jeff LaBundy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: da7280 - protect OF match table with CONFIG_OF
  2020-12-20  2:01   ` Jeff LaBundy
@ 2021-01-04  1:58     ` Dmitry Torokhov
  2021-01-04  4:03       ` Jeff LaBundy
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Torokhov @ 2021-01-04  1:58 UTC (permalink / raw)
  To: Jeff LaBundy; +Cc: Roy Im, linux-input, linux-kernel

Hi Jeff,

On Sat, Dec 19, 2020 at 08:01:09PM -0600, Jeff LaBundy wrote:
> Hi Dmitry,
> 
> On Fri, Dec 18, 2020 at 04:49:48PM +0000, Roy Im wrote:
> > On Friday, December 18, 2020 3:50 PM, Dmitry Torokhov wrote:
> > 
> > > The OF match table is only used when OF is enabled.
> > > 
> > > Fixes: cd3f609823a5 ("Input: new da7280 haptic driver")
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > > ---
> > >  drivers/input/misc/da7280.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c index 2f698a8c1d65..b08610d6e575 100644
> > > --- a/drivers/input/misc/da7280.c
> > > +++ b/drivers/input/misc/da7280.c
> > > @@ -1300,11 +1300,13 @@ static int __maybe_unused da7280_resume(struct device *dev)
> > >  	return retval;
> > >  }
> > > 
> > > +#ifdef CONFIG_OF
> > >  static const struct of_device_id da7280_of_match[] = {
> > >  	{ .compatible = "dlg,da7280", },
> > >  	{ }
> > >  };
> > >  MODULE_DEVICE_TABLE(of, da7280_of_match);
> > > +#endif
> 
> Just for my own understanding, would it not work just as well
> to include of_device.h? This includes mod_devicetable.h which
> in turn defines the of_device_id struct (even if CONFIG_OF is
> not set).

The issue here is not that the structure is undefined, but the variable
is unused. We could also fix this by not using of_match_ptr() when
assigning the match table to the driver structure, making the variable
referenced even if CONFIG_OF is off.

> 
> The reason for asking is because it seems many drivers do not
> include these guards.

It could be that they are either only compiled with OF, or they decided
it is not worth saving a few bytes, or maybe they are used on ACPI-based
systems with PRP0001 bindings in which case the match table in the
driver might still be needed.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: da7280 - protect OF match table with CONFIG_OF
  2021-01-04  1:58     ` Dmitry Torokhov
@ 2021-01-04  4:03       ` Jeff LaBundy
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff LaBundy @ 2021-01-04  4:03 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Roy Im, linux-input, linux-kernel

Hi Dmitry,

On Sun, Jan 03, 2021 at 05:58:41PM -0800, Dmitry Torokhov wrote:
> Hi Jeff,
> 
> On Sat, Dec 19, 2020 at 08:01:09PM -0600, Jeff LaBundy wrote:
> > Hi Dmitry,
> > 
> > On Fri, Dec 18, 2020 at 04:49:48PM +0000, Roy Im wrote:
> > > On Friday, December 18, 2020 3:50 PM, Dmitry Torokhov wrote:
> > > 
> > > > The OF match table is only used when OF is enabled.
> > > > 
> > > > Fixes: cd3f609823a5 ("Input: new da7280 haptic driver")
> > > > Reported-by: kernel test robot <lkp@intel.com>
> > > > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > > > ---
> > > >  drivers/input/misc/da7280.c | 2 ++
> > > >  1 file changed, 2 insertions(+)
> > > > 
> > > > diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c index 2f698a8c1d65..b08610d6e575 100644
> > > > --- a/drivers/input/misc/da7280.c
> > > > +++ b/drivers/input/misc/da7280.c
> > > > @@ -1300,11 +1300,13 @@ static int __maybe_unused da7280_resume(struct device *dev)
> > > >  	return retval;
> > > >  }
> > > > 
> > > > +#ifdef CONFIG_OF
> > > >  static const struct of_device_id da7280_of_match[] = {
> > > >  	{ .compatible = "dlg,da7280", },
> > > >  	{ }
> > > >  };
> > > >  MODULE_DEVICE_TABLE(of, da7280_of_match);
> > > > +#endif
> > 
> > Just for my own understanding, would it not work just as well
> > to include of_device.h? This includes mod_devicetable.h which
> > in turn defines the of_device_id struct (even if CONFIG_OF is
> > not set).
> 
> The issue here is not that the structure is undefined, but the variable
> is unused. We could also fix this by not using of_match_ptr() when
> assigning the match table to the driver structure, making the variable
> referenced even if CONFIG_OF is off.

ACK. The call to of_match_ptr() is what I was missing; the other
drivers I was looking at do not use it which must be why the bot
has not complained.

> 
> > 
> > The reason for asking is because it seems many drivers do not
> > include these guards.
> 
> It could be that they are either only compiled with OF, or they decided
> it is not worth saving a few bytes, or maybe they are used on ACPI-based
> systems with PRP0001 bindings in which case the match table in the
> driver might still be needed.

Makes perfect sense; thank you for the follow-up.

> 
> Thanks.
> 
> -- 
> Dmitry

Kind regards,
Jeff LaBundy

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-04  4:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-18  6:50 [PATCH] Input: da7280 - protect OF match table with CONFIG_OF Dmitry Torokhov
2020-12-18 16:49 ` Roy Im
2020-12-20  2:01   ` Jeff LaBundy
2021-01-04  1:58     ` Dmitry Torokhov
2021-01-04  4:03       ` Jeff LaBundy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.