Skip to contentSkip to conversation

Remove acpi.h implicit include of of.h

PATCH In review Rob Herring 3 participants 13 messages Apr 5, 2023 – Apr 6, 2023

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

v2 cover Remove acpi.h implicit include of of.h

In the process of cleaning up DT includes, I found that some drivers using DT functions could build without any explicit DT include. I traced the include to be coming from acpi.h via irqdomain.h.

I was pleasantly surprised that there were not 100s or even 10s of warnings when breaking the include chain. So here's the resulting series.

I'd suggest Rafael take the whole series. Alternatively,the fixes can be applied in 6.4 and then the last patch either after rc1 or the following cycle.

Compile tested on x86 and powerpc allmodconfig and arm64 allmodconfig minus CONFIG_ACPI.

---
Changes in v2:
- More explicit include fixes reported by Stephen
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Rob Herring (10):
iio: adc: ad7292: Add explicit include for of.h
staging: iio: resolver: ad2s1210: Add explicit include for of.h
net: rfkill-gpio: Add explicit include for of.h
serial: 8250_tegra: Add explicit include for of.h
ata: pata_macio: Add explicit include of irqdomain.h
pata: ixp4xx: Add explicit include for of.h
virtio-mmio: Add explicit include for of.h
tpm: atmel: Add explicit include for of.h
fpga: lattice-sysconfig-spi: Add explicit include for of.h
ACPI: Replace irqdomain.h include with struct declarations

 drivers/ata/pata_ixp4xx_cf.c            | 1 +
 drivers/ata/pata_macio.c                | 1 +
 drivers/char/tpm/tpm_atmel.h            | 2 +-
 drivers/fpga/lattice-sysconfig-spi.c    | 1 +
 drivers/iio/adc/ad7292.c                | 1 +
 drivers/staging/iio/resolver/ad2s1210.c | 1 +
 drivers/tty/serial/8250/8250_tegra.c    | 1 +
 drivers/virtio/virtio_mmio.c            | 1 +
 include/linux/acpi.h                    | 6 ++++--
 net/rfkill/rfkill-gpio.c                | 1 +
 10 files changed, 13 insertions(+), 3 deletions(-)

---
base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6
change-id: 20230329-acpi-header-cleanup-665331828436

Best regards,

Signature · 1 line
Rob Herring <[email protected]>
#1 lore raw

PATCH v2 1/10 iio: adc: ad7292: Add explicit include for of.h

With linux/acpi.h no longer implicitly including of.h, add an explicit include of of.h to fix the following error:

drivers/iio/adc/ad7292.c:307:9: error: implicit declaration of function 'for_each_available_child_of_node'; did you mean 'fwnode_for_each_available_child_node'? [-Werror=implicit-function-declaration]

---
 drivers/iio/adc/ad7292.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/adc/ad7292.c +1 -0
index a2f9fda25ff3..cccacec5db6d 100644
@@ -8,6 +8,7 @@
 #include <linux/bitfield.h>
 #include <linux/device.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/regulator/consumer.h>
 #include <linux/spi/spi.h>
 
Signature · 1 line
2.39.2
#2 lore raw

PATCH v2 2/10 staging: iio: resolver: ad2s1210: Add explicit include for of.h

In reply to Rob Herring

With linux/acpi.h no longer implicitly including of.h, add an explicit include of of.h to fix the following error:

drivers/staging/iio/resolver/ad2s1210.c:706:21: error: implicit declaration of function 'of_match_ptr' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

---
 drivers/staging/iio/resolver/ad2s1210.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/iio/resolver/ad2s1210.c +1 -0
index e4cf42438487..eb364639fa58 100644
@@ -7,6 +7,7 @@
 #include <linux/types.h>
 #include <linux/mutex.h>
 #include <linux/device.h>
+#include <linux/of.h>
 #include <linux/spi/spi.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
Signature · 1 line
2.39.2
#3 lore raw

PATCH v2 3/10 net: rfkill-gpio: Add explicit include for of.h

In reply to Rob Herring

With linux/acpi.h no longer implicitly including of.h, add an explicit include of of.h to fix the following error:

net/rfkill/rfkill-gpio.c:181:21: error: implicit declaration of function 'of_match_ptr' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

---
 net/rfkill/rfkill-gpio.c | 1 +
 1 file changed, 1 insertion(+)
net/rfkill/rfkill-gpio.c +1 -0
index 786dbfdad772..e9d1b2f2ff0a 100644
@@ -8,6 +8,7 @@
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/rfkill.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/slab.h>
Signature · 1 line
2.39.2
#4 lore raw

PATCH v2 4/10 serial: 8250_tegra: Add explicit include for of.h

In reply to Rob Herring

With linux/acpi.h no longer implicitly including of.h, add an explicit include of of.h to fix the following error:

drivers/tty/serial/8250/8250_tegra.c:68:15: error: implicit declaration of function 'of_alias_get_id' [-Werror=implicit-function-declaration]

---
 drivers/tty/serial/8250/8250_tegra.c | 1 +
 1 file changed, 1 insertion(+)
drivers/tty/serial/8250/8250_tegra.c +1 -0
index e7cddeec9d8e..2509e7f74ccf 100644
@@ -11,6 +11,7 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/reset.h>
 #include <linux/slab.h>
 
Signature · 1 line
2.39.2
Acked-by on v2 4/10
#5 lore raw

Re: [PATCH v2 04/10] serial: 8250_tegra: Add explicit include for of.h

Quoted 5 lines · Rob Herring

With linux/acpi.h no longer implicitly including of.h, add an explicit include of of.h to fix the following error:

drivers/tty/serial/8250/8250_tegra.c:68:15: error: implicit declaration of function 'of_alias_get_id' [-Werror=implicit-function-declaration]

Quoted 7 lines
---
 drivers/tty/serial/8250/8250_tegra.c | 1 +
 1 file changed, 1 insertion(+)
#6 lore raw

PATCH v2 5/10 ata: pata_macio: Add explicit include of irqdomain.h

In reply to Rob Herring

With linux/acpi.h no longer including irqdomain.h, add an explicit include of irqdomain.h to fix the following error:

drivers/ata/pata_macio.c:1172:23: error: implicit declaration of function 'irq_create_mapping' [-Werror=implicit-function-declaration]

---
v2: New patch

---
 drivers/ata/pata_macio.c | 1 +
 1 file changed, 1 insertion(+)
drivers/ata/pata_macio.c +1 -0
index 9ccaac9e2bc3..335e339a7ada 100644
@@ -21,6 +21,7 @@
 #include <linux/adb.h>
 #include <linux/pmu.h>
 #include <linux/scatterlist.h>
+#include <linux/irqdomain.h>
 #include <linux/of.h>
 #include <linux/gfp.h>
 #include <linux/pci.h>
Signature · 1 line
2.39.2
#7 lore raw

PATCH v2 6/10 pata: ixp4xx: Add explicit include for of.h

In reply to Rob Herring

With linux/acpi.h no longer implicitly including of.h, add an explicit include of of.h to fix the following error:

drivers/ata/pata_ixp4xx_cf.c:258:15: error: implicit declaration of function 'of_property_read_u32_index'; did you mean 'fwnode_property_read_u32_array'? [-Werror=implicit-function-declaration]

---
v2: New patch

---
 drivers/ata/pata_ixp4xx_cf.c | 1 +
 1 file changed, 1 insertion(+)
drivers/ata/pata_ixp4xx_cf.c +1 -0
index e225913a619d..113087665832 100644
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/libata.h>
 #include <linux/irq.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <scsi/scsi_host.h>
Signature · 1 line
2.39.2
#8 lore raw

PATCH v2 7/10 virtio-mmio: Add explicit include for of.h

In reply to Rob Herring

With linux/acpi.h no longer implicitly including of.h, add an explicit include of of.h to fix the following error:

drivers/virtio/virtio_mmio.c:492:13: error: implicit declaration of function 'of_property_read_bool'; did you mean 'fwnode_property_read_bool'? [-Werror=implicit-function-declaration]

---
v2: New patch

---
 drivers/virtio/virtio_mmio.c | 1 +
 1 file changed, 1 insertion(+)
drivers/virtio/virtio_mmio.c +1 -0
index 3ff746e3f24a..4b5e883055ee 100644
@@ -61,6 +61,7 @@
 #include <linux/io.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 #include <linux/slab.h>
Signature · 1 line
2.39.2
#9 lore raw

PATCH v2 8/10 tpm: atmel: Add explicit include for of.h

In reply to Rob Herring

With linux/acpi.h (in linux/tpm.h) no longer implicitly including of.h, add an explicit include of of.h to fix the following errors:

drivers/char/tpm/tpm_atmel.h:50:14: error: implicit declaration of function 'of_find_node_by_name'; did you mean 'bus_find_device_by_name'? [-Werror=implicit-function-declaration] drivers/char/tpm/tpm_atmel.h:50:12: error: assignment to 'struct device_node *' from 'int' makes pointer from integer without a cast [-Werror=int-conversion] drivers/char/tpm/tpm_atmel.h:55:14: error: implicit declaration of function 'of_device_is_compatible'; did you mean 'fwnode_device_is_compatible'? [-Werror=implicit-function-declaration]
...

---
v2: New patch

---
 drivers/char/tpm/tpm_atmel.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_atmel.h +1 -1
index ba37e77e8af3..7ac3f69dcf0f 100644
@@ -26,7 +26,7 @@ struct tpm_atmel_priv {
 
 #ifdef CONFIG_PPC64
 
-#include <asm/prom.h>
+#include <linux/of.h>
 
 #define atmel_getb(priv, offset) readb(priv->iobase + offset)
 #define atmel_putb(val, priv, offset) writeb(val, priv->iobase + offset)
Signature · 1 line
2.39.2
#10 lore raw

PATCH v2 9/10 fpga: lattice-sysconfig-spi: Add explicit include for of.h

In reply to Rob Herring

With linux/acpi.h (in spi/spi.h) no longer implicitly including of.h, add an explicit include of of.h to fix the following errors:

drivers/fpga/lattice-sysconfig-spi.c:146:35: error: implicit declaration of function 'of_match_ptr' [-Werror=implicit-function-declaration]

---
v2: New patch

---
 drivers/fpga/lattice-sysconfig-spi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/fpga/lattice-sysconfig-spi.c +1 -0
index 2702b26b7f55..44691cfcf50a 100644
@@ -3,6 +3,7 @@
  * Lattice FPGA programming over slave SPI sysCONFIG interface.
  */
 
+#include <linux/of.h>
 #include <linux/spi/spi.h>
 
 #include "lattice-sysconfig.h"
Signature · 1 line
2.39.2
#11 lore raw

PATCH v2 10/10 ACPI: Replace irqdomain.h include with struct declarations

In reply to Rob Herring

linux/acpi.h includes irqdomain.h which includes of.h. Break the include chain by replacing the irqdomain include with forward declarations for struct irq_domain and irq_domain_ops which is sufficient for acpi.h.

of.h also includes mod_devicetable.h which many drivers implicitly depend on. As acpi.h already includes it, just move it out of the '#ifdef CONFIG_ACPI'.

---
v2:
- Move mod_devicetable.h out of #ifdef

---
 include/linux/acpi.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
include/linux/acpi.h +4 -2
index efff750f326d..96bd672dc336 100644
@@ -10,12 +10,15 @@
 
 #include <linux/errno.h>
 #include <linux/ioport.h>	/* for struct resource */
-#include <linux/irqdomain.h>
 #include <linux/resource_ext.h>
 #include <linux/device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/property.h>
 #include <linux/uuid.h>
 
+struct irq_domain;
+struct irq_domain_ops;
+
 #ifndef _LINUX
 #define _LINUX
 #endif
@@ -24,7 +27,6 @@
 #ifdef	CONFIG_ACPI
 
 #include <linux/list.h>
-#include <linux/mod_devicetable.h>
 #include <linux/dynamic_debug.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
Signature · 1 line
2.39.2
#12 lore raw
In reply to Rob Herring
Quoted 46 lines · Rob Herring

In the process of cleaning up DT includes, I found that some drivers using DT functions could build without any explicit DT include. I traced the include to be coming from acpi.h via irqdomain.h.

I was pleasantly surprised that there were not 100s or even 10s of warnings when breaking the include chain. So here's the resulting series.

I'd suggest Rafael take the whole series. Alternatively,the fixes can be applied in 6.4 and then the last patch either after rc1 or the following cycle.

Compile tested on x86 and powerpc allmodconfig and arm64 allmodconfig minus CONFIG_ACPI.

---
Changes in v2:
- More explicit include fixes reported by Stephen
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Rob Herring (10):
iio: adc: ad7292: Add explicit include for of.h
staging: iio: resolver: ad2s1210: Add explicit include for of.h
net: rfkill-gpio: Add explicit include for of.h
serial: 8250_tegra: Add explicit include for of.h
ata: pata_macio: Add explicit include of irqdomain.h
pata: ixp4xx: Add explicit include for of.h
virtio-mmio: Add explicit include for of.h
tpm: atmel: Add explicit include for of.h
fpga: lattice-sysconfig-spi: Add explicit include for of.h
ACPI: Replace irqdomain.h include with struct declarations

 drivers/ata/pata_ixp4xx_cf.c            | 1 +
 drivers/ata/pata_macio.c                | 1 +
 drivers/char/tpm/tpm_atmel.h            | 2 +-
 drivers/fpga/lattice-sysconfig-spi.c    | 1 +
 drivers/iio/adc/ad7292.c                | 1 +
 drivers/staging/iio/resolver/ad2s1210.c | 1 +
 drivers/tty/serial/8250/8250_tegra.c    | 1 +
 drivers/virtio/virtio_mmio.c            | 1 +
 include/linux/acpi.h                    | 6 ++++--
 net/rfkill/rfkill-gpio.c                | 1 +
 10 files changed, 13 insertions(+), 3 deletions(-)
Quoted 3 lines

---
base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6
change-id: 20230329-acpi-header-cleanup-665331828436

All applied as 6.4 material, thanks!