This file is guarded by an #ifdef CONFIG_PCI. It, consequently, does not
belong to lib/ because it is not generic infrastructure.
Move the file to drivers/pci/ and implement the necessary changes to
Makefiles and Kconfigs.
Update MAINTAINERS file.
Suggested-by: Danilo Krummrich <dakr@redhat.com>
Signed-off-by: Philipp Stanner <pstanner@redhat.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
MAINTAINERS | 1 -
drivers/pci/Kconfig | 5 +++++
drivers/pci/Makefile | 1 +
lib/pci_iomap.c => drivers/pci/iomap.c | 3 ---
lib/Kconfig | 3 ---
lib/Makefile | 1 -
6 files changed, 6 insertions(+), 8 deletions(-)
rename lib/pci_iomap.c => drivers/pci/iomap.c (99%)
diff --git a/MAINTAINERS b/MAINTAINERS
index edae86acdfdc..efa37ee81d30 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -16762,7 +16762,6 @@ F: include/asm-generic/pci*
F: include/linux/of_pci.h
F: include/linux/pci*
F: include/uapi/linux/pci*
-F: lib/pci*
PCIE DRIVER FOR AMAZON ANNAPURNA LABS
M: Jonathan Chocron <jonnyc@amazon.com>
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index 74147262625b..d35001589d88 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -13,6 +13,11 @@ config FORCE_PCI
select HAVE_PCI
select PCI
+# select this to provide a generic PCI iomap,
+# without PCI itself having to be defined
+config GENERIC_PCI_IOMAP
+ bool
+
menuconfig PCI
bool "PCI support"
depends on HAVE_PCI
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index cc8b4e01e29d..64dcedccfc87 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -14,6 +14,7 @@ ifdef CONFIG_PCI
obj-$(CONFIG_PROC_FS) += proc.o
obj-$(CONFIG_SYSFS) += slot.o
obj-$(CONFIG_ACPI) += pci-acpi.o
+obj-$(CONFIG_GENERIC_PCI_IOMAP) += iomap.o
endif
obj-$(CONFIG_OF) += of.o
diff --git a/lib/pci_iomap.c b/drivers/pci/iomap.c
similarity index 99%
rename from lib/pci_iomap.c
rename to drivers/pci/iomap.c
index 6e144b017c48..91285fcff1ba 100644
--- a/lib/pci_iomap.c
+++ b/drivers/pci/iomap.c
@@ -9,7 +9,6 @@
#include <linux/export.h>
-#ifdef CONFIG_PCI
/**
* pci_iomap_range - create a virtual mapping cookie for a PCI BAR
* @dev: PCI device that owns the BAR
@@ -178,5 +177,3 @@ void pci_iounmap(struct pci_dev *dev, void __iomem *p)
EXPORT_SYMBOL(pci_iounmap);
#endif /* ARCH_WANTS_GENERIC_PCI_IOUNMAP */
-
-#endif /* CONFIG_PCI */
diff --git a/lib/Kconfig b/lib/Kconfig
index 3ea1c830efab..1bf859166ac7 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -70,9 +70,6 @@ source "lib/math/Kconfig"
config NO_GENERIC_PCI_IOPORT_MAP
bool
-config GENERIC_PCI_IOMAP
- bool
-
config GENERIC_IOMAP
bool
select GENERIC_PCI_IOMAP
diff --git a/lib/Makefile b/lib/Makefile
index 6b09731d8e61..0800289ec6c5 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -153,7 +153,6 @@ CFLAGS_debug_info.o += $(call cc-option, -femit-struct-debug-detailed=any)
obj-y += math/ crypto/
obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
-obj-$(CONFIG_GENERIC_PCI_IOMAP) += pci_iomap.o
obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o
obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
--
2.43.0
On Thu, Jan 11, 2024 at 09:55:37AM +0100, Philipp Stanner wrote: > This file is guarded by an #ifdef CONFIG_PCI. It, consequently, does not > belong to lib/ because it is not generic infrastructure. > > Move the file to drivers/pci/ and implement the necessary changes to > Makefiles and Kconfigs. > ... > --- a/drivers/pci/Kconfig > +++ b/drivers/pci/Kconfig > @@ -13,6 +13,11 @@ config FORCE_PCI > select HAVE_PCI > select PCI > > +# select this to provide a generic PCI iomap, > +# without PCI itself having to be defined > +config GENERIC_PCI_IOMAP > + bool > --- a/lib/pci_iomap.c > +++ b/drivers/pci/iomap.c > @@ -9,7 +9,6 @@ > > #include <linux/export.h> > > -#ifdef CONFIG_PCI IIUC, in the case where CONFIG_GENERIC_PCI_IOMAP=y but CONFIG_PCI was not set, pci_iomap.c was compiled but produced no code because the entire file was wrapped with this #ifdef. But after this patch, it looks like pci_iomap_range(), pci_iomap_wc_range(), etc., *will* be compiled? Is that what you intend, or did I miss something? Bjorn
On Tue, 2024-01-23 at 14:20 -0600, Bjorn Helgaas wrote: > On Thu, Jan 11, 2024 at 09:55:37AM +0100, Philipp Stanner wrote: > > This file is guarded by an #ifdef CONFIG_PCI. It, consequently, > > does not > > belong to lib/ because it is not generic infrastructure. > > > > Move the file to drivers/pci/ and implement the necessary changes > > to > > Makefiles and Kconfigs. > > ... > > > --- a/drivers/pci/Kconfig > > +++ b/drivers/pci/Kconfig > > @@ -13,6 +13,11 @@ config FORCE_PCI > > select HAVE_PCI > > select PCI > > > > +# select this to provide a generic PCI iomap, > > +# without PCI itself having to be defined > > +config GENERIC_PCI_IOMAP > > + bool > > > --- a/lib/pci_iomap.c > > +++ b/drivers/pci/iomap.c > > @@ -9,7 +9,6 @@ > > > > #include <linux/export.h> > > > > -#ifdef CONFIG_PCI > > IIUC, in the case where CONFIG_GENERIC_PCI_IOMAP=y but CONFIG_PCI was > not set, pci_iomap.c was compiled but produced no code because the > entire file was wrapped with this #ifdef. > > But after this patch, it looks like pci_iomap_range(), > pci_iomap_wc_range(), etc., *will* be compiled? > > Is that what you intend, or did I miss something? They *will* be compiled when BOTH, CONFIG_PCI and CONFIG_GENERIC_PCI_IOMAP have been set. It's a bit hard to see that in the patch's diff. Here, look closely: --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -14,6 +14,7 @@ ifdef CONFIG_PCI <----------- obj-$(CONFIG_PROC_FS) += proc.o obj-$(CONFIG_SYSFS) += slot.o obj-$(CONFIG_ACPI) += pci-acpi.o +obj-$(CONFIG_GENERIC_PCI_IOMAP) += iomap.o <------------ endif So if I am not mistaken it behaves 100% as it did before I prefered Makefile-logic over even more C Preprocessor to implement that. The preprocessor has caused us so much trouble... :( P. > > Bjorn >
On Thu, Jan 25, 2024 at 03:54:51PM +0100, Philipp Stanner wrote: > On Tue, 2024-01-23 at 14:20 -0600, Bjorn Helgaas wrote: > > On Thu, Jan 11, 2024 at 09:55:37AM +0100, Philipp Stanner wrote: > > > This file is guarded by an #ifdef CONFIG_PCI. It, consequently, > > > does not > > > belong to lib/ because it is not generic infrastructure. > > > > > > Move the file to drivers/pci/ and implement the necessary changes > > > to > > > Makefiles and Kconfigs. > > > ... > > > > > --- a/drivers/pci/Kconfig > > > +++ b/drivers/pci/Kconfig > > > @@ -13,6 +13,11 @@ config FORCE_PCI > > > select HAVE_PCI > > > select PCI > > > > > > +# select this to provide a generic PCI iomap, > > > +# without PCI itself having to be defined > > > +config GENERIC_PCI_IOMAP > > > + bool > > > > > --- a/lib/pci_iomap.c > > > +++ b/drivers/pci/iomap.c > > > @@ -9,7 +9,6 @@ > > > > > > #include <linux/export.h> > > > > > > -#ifdef CONFIG_PCI > > > > IIUC, in the case where CONFIG_GENERIC_PCI_IOMAP=y but CONFIG_PCI was > > not set, pci_iomap.c was compiled but produced no code because the > > entire file was wrapped with this #ifdef. > > > > But after this patch, it looks like pci_iomap_range(), > > pci_iomap_wc_range(), etc., *will* be compiled? > > > > Is that what you intend, or did I miss something? > > They *will* be compiled when BOTH, CONFIG_PCI and > CONFIG_GENERIC_PCI_IOMAP have been set. I was asking about CONFIG_GENERIC_PCI_IOMAP=y but CONFIG_PCI unset. But the Makefile contains this: ifdef CONFIG_PCI obj-$(CONFIG_GENERIC_PCI_IOMAP) += iomap.o endif So iomap.c will not be compiled when CONFIG_PCI is unset, which is what I missed. Bjorn
© 2016 - 2025 Red Hat, Inc.