PCI: Convert pci_resource_to_user() to a weak function
authorDenis Efremov <efremov@linux.com>
Mon, 29 Jul 2019 10:13:57 +0000 (13:13 +0300)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 8 Aug 2019 20:12:07 +0000 (15:12 -0500)
Convert pci_resource_to_user() to a weak function so the existing
architecture-specific implementations will automatically override the
generic one.  This allows us to remove HAVE_ARCH_PCI_RESOURCE_TO_USER
definitions and avoid the conditional compilation for this single function.

Link: https://lore.kernel.org/r/20190729101401.28068-1-efremov@linux.com
Link: https://lore.kernel.org/r/20190729101401.28068-2-efremov@linux.com
Link: https://lore.kernel.org/r/20190729101401.28068-3-efremov@linux.com
Link: https://lore.kernel.org/r/20190729101401.28068-4-efremov@linux.com
Link: https://lore.kernel.org/r/20190729101401.28068-5-efremov@linux.com
Link: https://lore.kernel.org/r/20190729101401.28068-6-efremov@linux.com
Signed-off-by: Denis Efremov <efremov@linux.com>
[bhelgaas: squash into one commit]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Paul Burton <paul.burton@mips.com> # MIPS
arch/microblaze/include/asm/pci.h
arch/mips/include/asm/pci.h
arch/powerpc/include/asm/pci.h
arch/sparc/include/asm/pci.h
drivers/pci/pci.c
include/linux/pci.h

index 21ddba9188b20f499f8ec09328457740a3c823fd..7c4dc5d85f531c32683163b5eec07a938d425b03 100644 (file)
@@ -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);
index 436099883022127f1bc882903f4b5df956cfe9b1..6f48649201c571bb11a5ff4a059171396c99dd83 100644 (file)
@@ -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.
index 2372d35533adcc01dc0298c8158c0c5cdd1ba3d5..327567b8f7d6faa9a2ef60cf7b108358768872f7 100644 (file)
@@ -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);
index cfec79bb1831c70bf1926e6af592c434065eab63..4deddf430e5d18cae2710cf1d74ebdb2aaf170a6 100644 (file)
@@ -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)
index 29ed5ec1ac27bf1c1d0b2d4028123a992594a513..da3241bb4479dac2460a812be5f3de2f7e976b07 100644 (file)
@@ -5932,6 +5932,18 @@ resource_size_t __weak pcibios_default_alignment(void)
        return 0;
 }
 
+/*
+ * Arches that don't want to expose struct resource to userland as-is in
+ * sysfs and /proc can implement their own pci_resource_to_user().
+ */
+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_SIZE
 static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0};
 static DEFINE_SPINLOCK(resource_alignment_lock);
index 9e700d9f9f287d0db0bf770cd5c4ee2a564db94c..dcc5dd310c14efe187920ef5d08ee97ff57f3a8c 100644 (file)
@@ -1870,25 +1870,9 @@ 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.