Skip to contentSkip to conversation

drm/ssd130x: Only define a SPI device ID table when built as a module

PATCH In review Javier Martinez Canillas 2 participants 3 messages May 30, 2022 – Jun 1, 2022

Subsystems (3)
lore
Share & tools
lore

Javier Martinez Canillas

author maintainer
#0 lore raw

PATCH 1/1 drm/ssd130x: Only define a SPI device ID table when built as a module

The kernel test robot reports a compile warning due the ssd130x_spi_table variable being defined but not used. This happen when ssd130x-spi driver is built-in instead of being built as a module, i.e:

  CC      drivers/gpu/drm/solomon/ssd130x-spi.o
  AR      drivers/base/firmware_loader/built-in.a
  AR      drivers/base/built-in.a
  CC      kernel/trace/trace.o
drivers/gpu/drm/solomon/ssd130x-spi.c:155:35: warning: ‘ssd130x_spi_table’ defined but not used [-Wunused-const-variable=]
  155 | static const struct spi_device_id ssd130x_spi_table[] = {
      |                                   ^~~~~~~~~~~~~~~~~

The driver shouldn't need a SPI device ID table and only have an OF device ID table, but the former is needed to workaround an issue in the SPI core. This always reports a MODALIAS of the form "spi:<device>" even for devices registered through Device Trees.

But the table is only needed when the driver built as a module to populate the .ko alias info. It's not needed when the driver is built-in the kernel.

Fixes 74373977d2ca ("drm/solomon: Add SSD130x OLED displays SPI support")

---

 drivers/gpu/drm/solomon/ssd130x-spi.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/solomon/ssd130x-spi.c +2 -0
index 43722adab1f8..07802907e39a 100644
@@ -143,6 +143,7 @@ static const struct of_device_id ssd130x_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, ssd130x_of_match);
 
+#if IS_MODULE(CONFIG_DRM_SSD130X_SPI)
 /*
  * The SPI core always reports a MODALIAS uevent of the form "spi:<dev>", even
  * if the device was registered via OF. This means that the module will not be
@@ -160,6 +161,7 @@ static const struct spi_device_id ssd130x_spi_table[] = {
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(spi, ssd130x_spi_table);
+#endif
 
 static struct spi_driver ssd130x_spi_driver = {
 	.driver = {
Signature · 1 line
2.36.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Javier Martinez Canillas

The kernel test robot reports a compile warning due the ssd130x_spi_table variable being defined but not used. This happen when ssd130x-spi driver is built-in instead of being built as a module, i.e:

  CC      drivers/gpu/drm/solomon/ssd130x-spi.o
  AR      drivers/base/firmware_loader/built-in.a
  AR      drivers/base/built-in.a
  CC      kernel/trace/trace.o
drivers/gpu/drm/solomon/ssd130x-spi.c:155:35: warning: ‘ssd130x_spi_table’ defined but not used [-Wunused-const-variable=]
  155 | static const struct spi_device_id ssd130x_spi_table[] = {
      |                                   ^~~~~~~~~~~~~~~~~

The driver shouldn't need a SPI device ID table and only have an OF device ID table, but the former is needed to workaround an issue in the SPI core. This always reports a MODALIAS of the form "spi:<device>" even for devices registered through Device Trees.

Quoted 6 lines

But the table is only needed when the driver built as a module to populate the .ko alias info. It's not needed when the driver is built-in the kernel.

Fixes 74373977d2ca ("drm/solomon: Add SSD130x OLED displays SPI support")
Quoted 28 lines

---

 drivers/gpu/drm/solomon/ssd130x-spi.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/solomon/ssd130x-spi.c +2 -0
index 43722adab1f8..07802907e39a 100644
@@ -143,6 +143,7 @@ static const struct of_device_id ssd130x_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, ssd130x_of_match);
 
+#if IS_MODULE(CONFIG_DRM_SSD130X_SPI)
 /*
  * The SPI core always reports a MODALIAS uevent of the form "spi:<dev>", even
  * if the device was registered via OF. This means that the module will not be
@@ -160,6 +161,7 @@ static const struct spi_device_id ssd130x_spi_table[] = {
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(spi, ssd130x_spi_table);
+#endif
 
 static struct spi_driver ssd130x_spi_driver = {
 	.driver = {
Signature · 1 line
2.36.1
author maintainer
#2 lore raw
Quoted 18 lines · Nathan Chancellor
Quoted 17 lines · Javier Martinez Canillas

The kernel test robot reports a compile warning due the ssd130x_spi_table variable being defined but not used. This happen when ssd130x-spi driver is built-in instead of being built as a module, i.e:

  CC      drivers/gpu/drm/solomon/ssd130x-spi.o
  AR      drivers/base/firmware_loader/built-in.a
  AR      drivers/base/built-in.a
  CC      kernel/trace/trace.o
drivers/gpu/drm/solomon/ssd130x-spi.c:155:35: warning: ‘ssd130x_spi_table’ defined but not used [-Wunused-const-variable=]
  155 | static const struct spi_device_id ssd130x_spi_table[] = {
      |                                   ^~~~~~~~~~~~~~~~~

The driver shouldn't need a SPI device ID table and only have an OF device ID table, but the former is needed to workaround an issue in the SPI core. This always reports a MODALIAS of the form "spi:<device>" even for devices registered through Device Trees.

Quoted 9 lines
Quoted 6 lines

But the table is only needed when the driver built as a module to populate the .ko alias info. It's not needed when the driver is built-in the kernel.

Fixes 74373977d2ca ("drm/solomon: Add SSD130x OLED displays SPI support")

Thanks! Pushed this to drm-misc (drm-misc-next).

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat