Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: Convert pci_resource_to_user() to a weak function

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

authored by

Denis Efremov and committed by
Bjorn Helgaas
b8074aa2 5f9e832c

+12 -23
-2
arch/microblaze/include/asm/pci.h
··· 66 66 unsigned long size, 67 67 pgprot_t prot); 68 68 69 - #define HAVE_ARCH_PCI_RESOURCE_TO_USER 70 - 71 69 /* This part of code was originally in xilinx-pci.h */ 72 70 #ifdef CONFIG_PCI_XILINX 73 71 extern void __init xilinx_pci_init(void);
-1
arch/mips/include/asm/pci.h
··· 108 108 109 109 #define HAVE_PCI_MMAP 110 110 #define ARCH_GENERIC_PCI_MMAP_RESOURCE 111 - #define HAVE_ARCH_PCI_RESOURCE_TO_USER 112 111 113 112 /* 114 113 * Dynamic DMA mapping stuff.
-2
arch/powerpc/include/asm/pci.h
··· 112 112 unsigned long size, 113 113 pgprot_t prot); 114 114 115 - #define HAVE_ARCH_PCI_RESOURCE_TO_USER 116 - 117 115 extern resource_size_t pcibios_io_space_offset(struct pci_controller *hose); 118 116 extern void pcibios_setup_bus_devices(struct pci_bus *bus); 119 117 extern void pcibios_setup_bus_self(struct pci_bus *bus);
-2
arch/sparc/include/asm/pci.h
··· 38 38 #define arch_can_pci_mmap_io() 1 39 39 #define HAVE_ARCH_PCI_GET_UNMAPPED_AREA 40 40 #define get_pci_unmapped_area get_fb_unmapped_area 41 - 42 - #define HAVE_ARCH_PCI_RESOURCE_TO_USER 43 41 #endif /* CONFIG_SPARC64 */ 44 42 45 43 #if defined(CONFIG_SPARC64) || defined(CONFIG_LEON_PCI)
+12
drivers/pci/pci.c
··· 5932 5932 return 0; 5933 5933 } 5934 5934 5935 + /* 5936 + * Arches that don't want to expose struct resource to userland as-is in 5937 + * sysfs and /proc can implement their own pci_resource_to_user(). 5938 + */ 5939 + void __weak pci_resource_to_user(const struct pci_dev *dev, int bar, 5940 + const struct resource *rsrc, 5941 + resource_size_t *start, resource_size_t *end) 5942 + { 5943 + *start = rsrc->start; 5944 + *end = rsrc->end; 5945 + } 5946 + 5935 5947 #define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE 5936 5948 static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0}; 5937 5949 static DEFINE_SPINLOCK(resource_alignment_lock);
-16
include/linux/pci.h
··· 1870 1870 return dev_name(&pdev->dev); 1871 1871 } 1872 1872 1873 - 1874 - /* 1875 - * Some archs don't want to expose struct resource to userland as-is 1876 - * in sysfs and /proc 1877 - */ 1878 - #ifdef HAVE_ARCH_PCI_RESOURCE_TO_USER 1879 1873 void pci_resource_to_user(const struct pci_dev *dev, int bar, 1880 1874 const struct resource *rsrc, 1881 1875 resource_size_t *start, resource_size_t *end); 1882 - #else 1883 - static inline void pci_resource_to_user(const struct pci_dev *dev, int bar, 1884 - const struct resource *rsrc, resource_size_t *start, 1885 - resource_size_t *end) 1886 - { 1887 - *start = rsrc->start; 1888 - *end = rsrc->end; 1889 - } 1890 - #endif /* HAVE_ARCH_PCI_RESOURCE_TO_USER */ 1891 - 1892 1876 1893 1877 /* 1894 1878 * The world is not perfect and supplies us with broken PCI devices.