PCI: Convert pci_resource_to_user() to a weak function
Subsystems (5)
v2 cover PCI: Convert pci_resource_to_user() to a weak function
Architectures currently define HAVE_ARCH_PCI_RESOURCE_TO_USER if they want to provide their own pci_resource_to_user() implementation. This could be simplified if we make the generic version a weak function. Thus, architecture specific versions will automatically override the generic one.
Changes in v2:
1. Removed __weak from pci_resource_to_user() declaration
2. Fixed typo s/spark/sparc/g
Denis Efremov (5):
PCI: Convert pci_resource_to_user to a weak function microblaze/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER mips/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER powerpc/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER sparc/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
arch/microblaze/include/asm/pci.h | 2 -- arch/mips/include/asm/pci.h | 1 - arch/powerpc/include/asm/pci.h | 2 -- arch/sparc/include/asm/pci.h | 2 -- drivers/pci/pci.c | 8 ++++++++ include/linux/pci.h | 12 ------------ 6 files changed, 8 insertions(+), 19 deletions(-)
Signature · 1 line
2.21.0
PATCH v2 1/5 PCI: Convert pci_resource_to_user to a weak function
The patch turns pci_resource_to_user() to a weak function. Thus, architecture-specific versions will automatically override the generic one. This allows to remove the HAVE_ARCH_PCI_RESOURCE_TO_USER macro and avoid the conditional compilation for this single function.
--- drivers/pci/pci.c | 8 ++++++++ include/linux/pci.h | 12 ------------ 2 files changed, 8 insertions(+), 12 deletions(-)
drivers/pci/pci.c +8 -0
@@ -5932,6 +5932,14 @@ resource_size_t __weak pcibios_default_alignment(void)return 0 ; } +void __weak pci_resource_to_user (const struct pci_dev *dev,int bar, +const struct resource *rsrc,resource_size_t *start, +resource_size_t *end) +{ + *start = rsrc->start; + *end = rsrc->end; +} +#define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZEstatic char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE ] = {0 };static DEFINE_SPINLOCK (resource_alignment_lock);
include/linux/pci.h +0 -12
@@ -1870,25 +1870,13 @@ static inline const char *pci_name(const struct pci_dev *pdev)return dev_name (&pdev->dev); } -/* * Some archs don't want to expose struct resource to userland as-is * in sysfs and /proc */ -#ifdef HAVE_ARCH_PCI_RESOURCE_TO_USER void pci_resource_to_user (const struct pci_dev *dev,int bar,const struct resource *rsrc,resource_size_t *start,resource_size_t *end); -#else -static inline void pci_resource_to_user (const struct pci_dev *dev,int bar, -const struct resource *rsrc,resource_size_t *start, -resource_size_t *end) -{ - *start = rsrc->start; - *end = rsrc->end; -} -#endif /* HAVE_ARCH_PCI_RESOURCE_TO_USER */ -/* * The world is not perfect and supplies us with broken PCI devices.
Signature · 1 line
2.21.0
PATCH v2 2/5 microblaze/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
In reply to Denis EfremovThe function pci_resource_to_user() was turned to a weak one. Thus, microblase-specific version will automatically override the generic one and the HAVE_ARCH_PCI_RESOURCE_TO_USER macro should be removed.
--- arch/microblaze/include/asm/pci.h | 2 -- 1 file changed, 2 deletions(-)
arch/microblaze/include/asm/pci.h +0 -2
@@ -66,8 +66,6 @@ extern pgprot_t pci_phys_mem_access_prot(struct file *file,unsigned long size, pgprot_t prot); -#define HAVE_ARCH_PCI_RESOURCE_TO_USER -/* This part of code was originally in xilinx-pci.h */ #ifdef CONFIG_PCI_XILINX extern void __init xilinx_pci_init (void );
Signature · 1 line
2.21.0
PATCH v2 3/5 mips/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
In reply to Denis EfremovThe function pci_resource_to_user() was turned to a weak one. Thus, mips-specific version will automatically override the generic one and the HAVE_ARCH_PCI_RESOURCE_TO_USER macro should be removed.
--- arch/mips/include/asm/pci.h | 1 - 1 file changed, 1 deletion(-)
arch/mips/include/asm/pci.h +0 -1
@@ -108,7 +108,6 @@ extern unsigned long PCIBIOS_MIN_MEM;#define HAVE_PCI_MMAP #define ARCH_GENERIC_PCI_MMAP_RESOURCE -#define HAVE_ARCH_PCI_RESOURCE_TO_USER /* * Dynamic DMA mapping stuff.
Signature · 1 line
2.21.0
Re: [PATCH v2 3/5] mips/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
Hi Denis,
Quoted 5 lines · Denis Efremov
The function
pci_resource_to_user()was turned to a weak one. Thus, mips-specific version will automatically override the generic one and theHAVE_ARCH_PCI_RESOURCE_TO_USERmacro should be removed.Signed-off-by Denis Efremov <[email protected]>
Assuming this is the way Bjorn wants to go:
Thanks,
Paul
Quoted 19 lines
--- arch/mips/include/asm/pci.h | 1 - 1 file changed, 1 deletion(-)arch/mips/include/asm/pci.h +0
-1@@ -108,7 +108,6 @@ extern unsigned long PCIBIOS_MIN_MEM;#define HAVE_PCI_MMAP #define ARCH_GENERIC_PCI_MMAP_RESOURCE -#define HAVE_ARCH_PCI_RESOURCE_TO_USER /* * Dynamic DMA mapping stuff. Signature · 1 line
2.21.0
PATCH v2 4/5 powerpc/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
In reply to Denis EfremovThe function pci_resource_to_user() was turned to a weak one. Thus, powerpc-specific version will automatically override the generic one and the HAVE_ARCH_PCI_RESOURCE_TO_USER macro should be removed.
--- arch/powerpc/include/asm/pci.h | 2 -- 1 file changed, 2 deletions(-)
arch/powerpc/include/asm/pci.h +0 -2
@@ -112,8 +112,6 @@ extern pgprot_t pci_phys_mem_access_prot(struct file *file,unsigned long size, pgprot_t prot); -#define HAVE_ARCH_PCI_RESOURCE_TO_USER -extern resource_size_t pcibios_io_space_offset (struct pci_controller *hose);extern void pcibios_setup_bus_devices (struct pci_bus *bus);extern void pcibios_setup_bus_self (struct pci_bus *bus);
Signature · 1 line
2.21.0
PATCH v2 5/5 sparc/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
In reply to Denis EfremovThe function pci_resource_to_user() was turned to a weak one. Thus, sparc-specific version will automatically override the generic one and the HAVE_ARCH_PCI_RESOURCE_TO_USER macro should be removed.
--- arch/sparc/include/asm/pci.h | 2 -- 1 file changed, 2 deletions(-)
arch/sparc/include/asm/pci.h +0 -2
@@ -38,8 +38,6 @@ static inline int pci_proc_domain(struct pci_bus *bus)#define arch_can_pci_mmap_io () 1#define HAVE_ARCH_PCI_GET_UNMAPPED_AREA #define get_pci_unmapped_area get_fb_unmapped_area - -#define HAVE_ARCH_PCI_RESOURCE_TO_USER #endif /* CONFIG_SPARC64 */ #if defined(CONFIG_SPARC64 ) || defined(CONFIG_LEON_PCI )
Signature · 1 line
2.21.0
Quoted 16 lines · Denis Efremov
Architectures currently define
HAVE_ARCH_PCI_RESOURCE_TO_USERif they want to provide their ownpci_resource_to_user()implementation. This could be simplified if we make the generic version a weak function. Thus, architecture specific versions will automatically override the generic one.Changes in v2:
1. Removed__weakfrompci_resource_to_user()declaration
2. Fixed typo s/spark/sparc/gDenis Efremov (5):
PCI: Convertpci_resource_to_userto a weak function microblaze/PCI: RemoveHAVE_ARCH_PCI_RESOURCE_TO_USERmips/PCI: RemoveHAVE_ARCH_PCI_RESOURCE_TO_USERpowerpc/PCI: RemoveHAVE_ARCH_PCI_RESOURCE_TO_USERsparc/PCI: RemoveHAVE_ARCH_PCI_RESOURCE_TO_USER
Quoted 7 lines
arch/microblaze/include/asm/pci.h | 2 -- arch/mips/include/asm/pci.h | 1 - arch/powerpc/include/asm/pci.h | 2 -- arch/sparc/include/asm/pci.h | 2 -- drivers/pci/pci.c | 8 ++++++++ include/linux/pci.h | 12 ------------ 6 files changed, 8 insertions(+), 19 deletions(-)
Thanks, I added Paul's ack, squashed into a single patch since I think it's easier to see what's going on then, and applied to pci/misc for v4.5.