linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] serial: pic32: Fix build warning when CONFIG_OF is disabled
@ 2025-01-26 16:31 Yu-Chun Lin
  2025-01-26 19:30 ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Yu-Chun Lin @ 2025-01-26 16:31 UTC (permalink / raw)
  To: gregkh, jirislaby
  Cc: linux-kernel, linux-serial, jserv, visitorckw, Yu-Chun Lin,
	kernel test robot

As reported by the kernel test robot, the following warning occurs:

>> drivers/tty/serial/pic32_uart.c:904:34: warning: 'pic32_serial_dt_ids' defined but not used [-Wunused-const-variable=]
     904 | static const struct of_device_id pic32_serial_dt_ids[] = {
         |                                  ^~~~~~~~~~~~~~~~~~~

The 'pic32_serial_dt_ids' array is only used when CONFIG_OF is enabled.
Wrapping its definition and 'MODULE_DEVICE_TABLE' in '#ifdef CONFIG_OF'
prevents a compiler warning when OF is disabled.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202501260006.ecUsBidz-lkp@intel.com/
Signed-off-by: Yu-Chun Lin <eleanor15x@gmail.com>
---
 drivers/tty/serial/pic32_uart.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tty/serial/pic32_uart.c b/drivers/tty/serial/pic32_uart.c
index 14d50bd7f1bd..a228a55102c6 100644
--- a/drivers/tty/serial/pic32_uart.c
+++ b/drivers/tty/serial/pic32_uart.c
@@ -948,11 +948,13 @@ static void pic32_uart_remove(struct platform_device *pdev)
 	pic32_sports[sport->idx] = NULL;
 }
 
+#ifdef CONFIG_OF
 static const struct of_device_id pic32_serial_dt_ids[] = {
 	{ .compatible = "microchip,pic32mzda-uart" },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, pic32_serial_dt_ids);
+#endif
 
 static struct platform_driver pic32_uart_platform_driver = {
 	.probe		= pic32_uart_probe,
-- 
2.43.0


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

* Re: [PATCH] serial: pic32: Fix build warning when CONFIG_OF is disabled
  2025-01-26 16:31 [PATCH] serial: pic32: Fix build warning when CONFIG_OF is disabled Yu-Chun Lin
@ 2025-01-26 19:30 ` Greg KH
  2025-01-27  8:29   ` Yu-Chun Lin
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2025-01-26 19:30 UTC (permalink / raw)
  To: Yu-Chun Lin
  Cc: jirislaby, linux-kernel, linux-serial, jserv, visitorckw,
	kernel test robot

On Mon, Jan 27, 2025 at 12:31:15AM +0800, Yu-Chun Lin wrote:
> As reported by the kernel test robot, the following warning occurs:
> 
> >> drivers/tty/serial/pic32_uart.c:904:34: warning: 'pic32_serial_dt_ids' defined but not used [-Wunused-const-variable=]
>      904 | static const struct of_device_id pic32_serial_dt_ids[] = {
>          |                                  ^~~~~~~~~~~~~~~~~~~
> 
> The 'pic32_serial_dt_ids' array is only used when CONFIG_OF is enabled.
> Wrapping its definition and 'MODULE_DEVICE_TABLE' in '#ifdef CONFIG_OF'
> prevents a compiler warning when OF is disabled.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202501260006.ecUsBidz-lkp@intel.com/
> Signed-off-by: Yu-Chun Lin <eleanor15x@gmail.com>
> ---
>  drivers/tty/serial/pic32_uart.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/tty/serial/pic32_uart.c b/drivers/tty/serial/pic32_uart.c
> index 14d50bd7f1bd..a228a55102c6 100644
> --- a/drivers/tty/serial/pic32_uart.c
> +++ b/drivers/tty/serial/pic32_uart.c
> @@ -948,11 +948,13 @@ static void pic32_uart_remove(struct platform_device *pdev)
>  	pic32_sports[sport->idx] = NULL;
>  }
>  
> +#ifdef CONFIG_OF
>  static const struct of_device_id pic32_serial_dt_ids[] = {
>  	{ .compatible = "microchip,pic32mzda-uart" },
>  	{ /* sentinel */ }
>  };
>  MODULE_DEVICE_TABLE(of, pic32_serial_dt_ids);
> +#endif

That should not be needed, no other bus requires this, please fix up the
use of the OF macros instead.

thanks,

greg k-h

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

* Re: [PATCH] serial: pic32: Fix build warning when CONFIG_OF is disabled
  2025-01-26 19:30 ` Greg KH
@ 2025-01-27  8:29   ` Yu-Chun Lin
  2025-01-27  9:12     ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Yu-Chun Lin @ 2025-01-27  8:29 UTC (permalink / raw)
  To: Greg KH
  Cc: jirislaby, linux-kernel, linux-serial, jserv, visitorckw,
	kernel test robot

On Sun, Jan 26, 2025 at 08:30:33PM +0100, Greg KH wrote:
> On Mon, Jan 27, 2025 at 12:31:15AM +0800, Yu-Chun Lin wrote:
> > As reported by the kernel test robot, the following warning occurs:
> > 
> > >> drivers/tty/serial/pic32_uart.c:904:34: warning: 'pic32_serial_dt_ids' defined but not used [-Wunused-const-variable=]
> >      904 | static const struct of_device_id pic32_serial_dt_ids[] = {
> >          |                                  ^~~~~~~~~~~~~~~~~~~
> > 
> > The 'pic32_serial_dt_ids' array is only used when CONFIG_OF is enabled.
> > Wrapping its definition and 'MODULE_DEVICE_TABLE' in '#ifdef CONFIG_OF'
> > prevents a compiler warning when OF is disabled.
> > 
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202501260006.ecUsBidz-lkp@intel.com/
> > Signed-off-by: Yu-Chun Lin <eleanor15x@gmail.com>
> > ---
> >  drivers/tty/serial/pic32_uart.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/tty/serial/pic32_uart.c b/drivers/tty/serial/pic32_uart.c
> > index 14d50bd7f1bd..a228a55102c6 100644
> > --- a/drivers/tty/serial/pic32_uart.c
> > +++ b/drivers/tty/serial/pic32_uart.c
> > @@ -948,11 +948,13 @@ static void pic32_uart_remove(struct platform_device *pdev)
> >  	pic32_sports[sport->idx] = NULL;
> >  }
> >  
> > +#ifdef CONFIG_OF
> >  static const struct of_device_id pic32_serial_dt_ids[] = {
> >  	{ .compatible = "microchip,pic32mzda-uart" },
> >  	{ /* sentinel */ }
> >  };
> >  MODULE_DEVICE_TABLE(of, pic32_serial_dt_ids);
> > +#endif
> 
> That should not be needed, no other bus requires this, please fix up the
> use of the OF macros instead.

So I should remove of_match_ptr and add the CONFIG_OF as a dependency
for the configuration. Correct?

Yu-Chun Lin

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

* Re: [PATCH] serial: pic32: Fix build warning when CONFIG_OF is disabled
  2025-01-27  8:29   ` Yu-Chun Lin
@ 2025-01-27  9:12     ` Greg KH
  2025-01-27 10:07       ` Yu-Chun Lin
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2025-01-27  9:12 UTC (permalink / raw)
  To: Yu-Chun Lin
  Cc: jirislaby, linux-kernel, linux-serial, jserv, visitorckw,
	kernel test robot

On Mon, Jan 27, 2025 at 04:29:24PM +0800, Yu-Chun Lin wrote:
> On Sun, Jan 26, 2025 at 08:30:33PM +0100, Greg KH wrote:
> > On Mon, Jan 27, 2025 at 12:31:15AM +0800, Yu-Chun Lin wrote:
> > > As reported by the kernel test robot, the following warning occurs:
> > > 
> > > >> drivers/tty/serial/pic32_uart.c:904:34: warning: 'pic32_serial_dt_ids' defined but not used [-Wunused-const-variable=]
> > >      904 | static const struct of_device_id pic32_serial_dt_ids[] = {
> > >          |                                  ^~~~~~~~~~~~~~~~~~~
> > > 
> > > The 'pic32_serial_dt_ids' array is only used when CONFIG_OF is enabled.
> > > Wrapping its definition and 'MODULE_DEVICE_TABLE' in '#ifdef CONFIG_OF'
> > > prevents a compiler warning when OF is disabled.
> > > 
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Closes: https://lore.kernel.org/oe-kbuild-all/202501260006.ecUsBidz-lkp@intel.com/
> > > Signed-off-by: Yu-Chun Lin <eleanor15x@gmail.com>
> > > ---
> > >  drivers/tty/serial/pic32_uart.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/drivers/tty/serial/pic32_uart.c b/drivers/tty/serial/pic32_uart.c
> > > index 14d50bd7f1bd..a228a55102c6 100644
> > > --- a/drivers/tty/serial/pic32_uart.c
> > > +++ b/drivers/tty/serial/pic32_uart.c
> > > @@ -948,11 +948,13 @@ static void pic32_uart_remove(struct platform_device *pdev)
> > >  	pic32_sports[sport->idx] = NULL;
> > >  }
> > >  
> > > +#ifdef CONFIG_OF
> > >  static const struct of_device_id pic32_serial_dt_ids[] = {
> > >  	{ .compatible = "microchip,pic32mzda-uart" },
> > >  	{ /* sentinel */ }
> > >  };
> > >  MODULE_DEVICE_TABLE(of, pic32_serial_dt_ids);
> > > +#endif
> > 
> > That should not be needed, no other bus requires this, please fix up the
> > use of the OF macros instead.
> 
> So I should remove of_match_ptr and add the CONFIG_OF as a dependency
> for the configuration. Correct?

I don't know, but putting #ifdef in .c files is not the correct solution
at all.

thanks,

greg k-h

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

* Re: [PATCH] serial: pic32: Fix build warning when CONFIG_OF is disabled
  2025-01-27  9:12     ` Greg KH
@ 2025-01-27 10:07       ` Yu-Chun Lin
  2025-01-27 10:21         ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Yu-Chun Lin @ 2025-01-27 10:07 UTC (permalink / raw)
  To: Greg KH
  Cc: jirislaby, linux-kernel, linux-serial, jserv, visitorckw,
	kernel test robot

On Mon, Jan 27, 2025 at 10:12:47AM +0100, Greg KH wrote:
> > So I should remove of_match_ptr and add the CONFIG_OF as a dependency
> > for the configuration. Correct?
> 
> I don't know, but putting #ifdef in .c files is not the correct solution
> at all.

I fixed the build warning this way because I saw it was done the same way
in these three files:

drivers/tty/serial/samsung_tty.c 
drivers/tty/serial/mps2-uart.c
drivers/tty/serial/altera_jtaguart.c

Or maybe we can add __maybe_unused to avoid the warning?

Yu-Chun Lin

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

* Re: [PATCH] serial: pic32: Fix build warning when CONFIG_OF is disabled
  2025-01-27 10:07       ` Yu-Chun Lin
@ 2025-01-27 10:21         ` Greg KH
  0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2025-01-27 10:21 UTC (permalink / raw)
  To: Yu-Chun Lin
  Cc: jirislaby, linux-kernel, linux-serial, jserv, visitorckw,
	kernel test robot

On Mon, Jan 27, 2025 at 06:07:13PM +0800, Yu-Chun Lin wrote:
> On Mon, Jan 27, 2025 at 10:12:47AM +0100, Greg KH wrote:
> > > So I should remove of_match_ptr and add the CONFIG_OF as a dependency
> > > for the configuration. Correct?
> > 
> > I don't know, but putting #ifdef in .c files is not the correct solution
> > at all.
> 
> I fixed the build warning this way because I saw it was done the same way
> in these three files:
> 
> drivers/tty/serial/samsung_tty.c 
> drivers/tty/serial/mps2-uart.c
> drivers/tty/serial/altera_jtaguart.c

Those too should be fixed properly.

> Or maybe we can add __maybe_unused to avoid the warning?

No, again, no other bus has this issue, please fix the macros properly.

thanks,

greg k-h

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

end of thread, other threads:[~2025-01-27 10:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-26 16:31 [PATCH] serial: pic32: Fix build warning when CONFIG_OF is disabled Yu-Chun Lin
2025-01-26 19:30 ` Greg KH
2025-01-27  8:29   ` Yu-Chun Lin
2025-01-27  9:12     ` Greg KH
2025-01-27 10:07       ` Yu-Chun Lin
2025-01-27 10:21         ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).