Skip to contentSkip to conversation

of_match[] warnings

DISCUSSION Bjorn Helgaas 2 participants 5 messages Sep 30, 2020 – Oct 1, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

These warnings are sort of annoying. I guess most of the other drivers avoid this by depending on OF as well as COMPILE_TEST.

  $ grep -E "CONFIG_(OF|PCIE_(SPEAR13XX|ARMADA_8K))" .config
  CONFIG_PCIE_SPEAR13XX=y
  CONFIG_PCIE_ARMADA_8K=y
  # CONFIG_OF is not set
  $ make W=1 drivers/pci/
  ...
    CC      drivers/pci/controller/dwc/pcie-spear13xx.o
  drivers/pci/controller/dwc/pcie-spear13xx.c:270:34: warning: ‘spear13xx_pcie_of_match’ defined but not used [-Wunused-const-variable=]
    270 | static const struct of_device_id spear13xx_pcie_of_match[] = {
	|                                  ^~~~~~~~~~~~~~~~~~~~~~~
  ...
    CC      drivers/pci/controller/dwc/pcie-armada8k.o
  drivers/pci/controller/dwc/pcie-armada8k.c:344:34: warning: ‘armada8k_pcie_of_match’ defined but not used [-Wunused-const-variable=]
    344 | static const struct of_device_id armada8k_pcie_of_match[] = {
	|                                  ^~~~~~~~~~~~~~~~~~~~~~
reviewer
#1 lore raw
Quoted 3 lines · Bjorn Helgaas

These warnings are sort of annoying. I guess most of the other drivers avoid this by depending on OF as well as COMPILE_TEST.

Using the of_match_ptr() macro should prevent this.

Quoted 17 lines
  $ grep -E "CONFIG_(OF|PCIE_(SPEAR13XX|ARMADA_8K))" .config
  CONFIG_PCIE_SPEAR13XX=y
  CONFIG_PCIE_ARMADA_8K=y
  # CONFIG_OF is not set
  $ make W=1 drivers/pci/
  ...
    CC      drivers/pci/controller/dwc/pcie-spear13xx.o
  drivers/pci/controller/dwc/pcie-spear13xx.c:270:34: warning: ‘spear13xx_pcie_of_match’ defined but not used [-Wunused-const-variable=]
    270 | static const struct of_device_id spear13xx_pcie_of_match[] = {
        |                                  ^~~~~~~~~~~~~~~~~~~~~~~
  ...
    CC      drivers/pci/controller/dwc/pcie-armada8k.o
  drivers/pci/controller/dwc/pcie-armada8k.c:344:34: warning: ‘armada8k_pcie_of_match’ defined but not used [-Wunused-const-variable=]
    344 | static const struct of_device_id armada8k_pcie_of_match[] = {
        |                                  ^~~~~~~~~~~~~~~~~~~~~~
#2 lore raw
Quoted 6 lines · Rob Herring
Quoted 3 lines · Bjorn Helgaas

These warnings are sort of annoying. I guess most of the other drivers avoid this by depending on OF as well as COMPILE_TEST.

Using the of_match_ptr() macro should prevent this.

Both drivers *do* use of_match_ptr(), but the of_device_id table is unused when of_match_ptr() throws away the pointer.

I guess we could add __maybe_unused to squelch the warning. Ugly, but I do think COMPILE_TEST has some value.

Quoted 17 lines
Quoted 17 lines
  $ grep -E "CONFIG_(OF|PCIE_(SPEAR13XX|ARMADA_8K))" .config
  CONFIG_PCIE_SPEAR13XX=y
  CONFIG_PCIE_ARMADA_8K=y
  # CONFIG_OF is not set
  $ make W=1 drivers/pci/
  ...
    CC      drivers/pci/controller/dwc/pcie-spear13xx.o
  drivers/pci/controller/dwc/pcie-spear13xx.c:270:34: warning: ‘spear13xx_pcie_of_match’ defined but not used [-Wunused-const-variable=]
    270 | static const struct of_device_id spear13xx_pcie_of_match[] = {
        |                                  ^~~~~~~~~~~~~~~~~~~~~~~
  ...
    CC      drivers/pci/controller/dwc/pcie-armada8k.o
  drivers/pci/controller/dwc/pcie-armada8k.c:344:34: warning: ‘armada8k_pcie_of_match’ defined but not used [-Wunused-const-variable=]
    344 | static const struct of_device_id armada8k_pcie_of_match[] = {
        |                                  ^~~~~~~~~~~~~~~~~~~~~~
reviewer
#3 lore raw
Quoted 11 lines · Bjorn Helgaas
Quoted 6 lines · Rob Herring
Quoted 3 lines · Bjorn Helgaas

These warnings are sort of annoying. I guess most of the other drivers avoid this by depending on OF as well as COMPILE_TEST.

Using the of_match_ptr() macro should prevent this.

Both drivers *do* use of_match_ptr(), but the of_device_id table is unused when of_match_ptr() throws away the pointer.

Oh right, it's actually we don't want to use of_match_ptr() in this case.

Quoted 2 lines

I guess we could add __maybe_unused to squelch the warning. Ugly, but I do think COMPILE_TEST has some value.

We do that or an ifdef for drivers that actually work for !OF.

We also have lot's of 'depends on OF' as proposed too, but that's not really my preference given we have empty functions for most everything.

Rob

#4 lore raw
Quoted 15 lines · Rob Herring
Quoted 11 lines · Bjorn Helgaas
Quoted 6 lines · Rob Herring
Quoted 3 lines · Bjorn Helgaas

These warnings are sort of annoying. I guess most of the other drivers avoid this by depending on OF as well as COMPILE_TEST.

Using the of_match_ptr() macro should prevent this.

Both drivers *do* use of_match_ptr(), but the of_device_id table is unused when of_match_ptr() throws away the pointer.

Oh right, it's actually we don't want to use of_match_ptr() in this case.

Quoted 8 lines
Quoted 2 lines

I guess we could add __maybe_unused to squelch the warning. Ugly, but I do think COMPILE_TEST has some value.

We do that or an ifdef for drivers that actually work for !OF.

We also have lot's of 'depends on OF' as proposed too, but that's not really my preference given we have empty functions for most everything.

So just removing of_match_ptr() as below? That seems way nicer than any of the #ifdef, __maybe_unused, or "depends on OF" options.

drivers/pci/controller/dwc/pcie-spear13xx.c +1 -1
index 62846562da0b..b2ef8ffde79e 100644
@@ -303,7 +303,7 @@ static struct platform_driver spear13xx_pcie_driver = {
 	.probe		= spear13xx_pcie_probe,
 	.driver = {
 		.name	= "spear-pcie",
-		.of_match_table = of_match_ptr(spear13xx_pcie_of_match),
+		.of_match_table = spear13xx_pcie_of_match,
 		.suppress_bind_attrs = true,
 	},
 };