Skip to contentSkip to conversation

serial: pic32: Fix build warning when CONFIG_OF is disabled

PATCH In review Yu-Chun Lin 2 participants 6 messages Jan 26, 2025 – Jan 27, 2025 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: pic32: Fix build warning when CONFIG_OF is disabled

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

Quoted 1 line
Quoted 1 line

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.

---
 drivers/tty/serial/pic32_uart.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/tty/serial/pic32_uart.c +2 -0
index 14d50bd7f1bd..a228a55102c6 100644
@@ -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,
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 22 lines · Yu-Chun Lin

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

Quoted 1 line
Quoted 1 line

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.

---
 drivers/tty/serial/pic32_uart.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/tty/serial/pic32_uart.c +0 -0
index 14d50bd7f1bd..a228a55102c6 100644

drivers/tty/serial/pic32_uart.c static void pic32_uart_remove(struct platform_device *pdev) · line 957

Quoted 10 lines
drivers/tty/serial/pic32_uart.c +2 -0
@@ -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

#2 lore raw
Quoted 26 lines · Greg KH
Quoted 25 lines · Yu-Chun Lin

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

Quoted 1 line
Quoted 1 line

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.

---
 drivers/tty/serial/pic32_uart.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/tty/serial/pic32_uart.c +0 -0
index 14d50bd7f1bd..a228a55102c6 100644
@@ -948,11 +948,13 @@ static void pic32_uart_remove(struct platform_device *pdev)
 	pic32_sports[sport->idx] = NULL;
 }
 
Quoted 10 lines

drivers/tty/serial/pic32_uart.c static void pic32_uart_remove(struct platform_device *pdev) · line 957

Quoted 7 lines
drivers/tty/serial/pic32_uart.c +2 -0
+#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

maintainer
#3 lore raw
Quoted 38 lines · Yu-Chun Lin
Quoted 26 lines · Greg KH
Quoted 25 lines · Yu-Chun Lin

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

Quoted 1 line
Quoted 1 line

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.

---
 drivers/tty/serial/pic32_uart.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/tty/serial/pic32_uart.c +0 -0
index 14d50bd7f1bd..a228a55102c6 100644
@@ -948,11 +948,13 @@ static void pic32_uart_remove(struct platform_device *pdev)
 	pic32_sports[sport->idx] = NULL;
 }
 
Quoted 10 lines

drivers/tty/serial/pic32_uart.c static void pic32_uart_remove(struct platform_device *pdev) · line 957

Quoted 7 lines
drivers/tty/serial/pic32_uart.c +2 -0
+#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.

Quoted 2 lines

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

#4 lore raw
Quoted 5 lines · Greg KH
Quoted 2 lines

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

maintainer
#5 lore raw
Quoted 7 lines · Yu-Chun Lin
Quoted 5 lines · Greg KH
Quoted 2 lines

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.

Quoted 6 lines

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.

Quoted 1 line

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