aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-10 21:04:27 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-10 21:04:27 -0500
commite343a895a9f342f239c5e3c5ffc6c0b1707e6244 (patch)
tree46c81c6ae375b1f14e209b13c8ac020842807ece /lib
parent06792c4dde2ad143928cc95c1ba218c6269c494b (diff)
parent193a667fba76b3df482cbf865228e26ee246e889 (diff)
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
lib: use generic pci_iomap on all architectures Many architectures don't want to pull in iomap.c, so they ended up duplicating pci_iomap from that file. That function isn't trivial, and we are going to modify it https://lkml.org/lkml/2011/11/14/183 so the duplication hurts. This reduces the scope of the problem significantly, by moving pci_iomap to a separate file and referencing that from all architectures. * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: alpha: drop pci_iomap/pci_iounmap from pci-noop.c mn10300: switch to GENERIC_PCI_IOMAP mn10300: add missing __iomap markers frv: switch to GENERIC_PCI_IOMAP tile: switch to GENERIC_PCI_IOMAP tile: don't panic on iomap sparc: switch to GENERIC_PCI_IOMAP sh: switch to GENERIC_PCI_IOMAP powerpc: switch to GENERIC_PCI_IOMAP parisc: switch to GENERIC_PCI_IOMAP mips: switch to GENERIC_PCI_IOMAP microblaze: switch to GENERIC_PCI_IOMAP arm: switch to GENERIC_PCI_IOMAP alpha: switch to GENERIC_PCI_IOMAP lib: add GENERIC_PCI_IOMAP lib: move GENERIC_IOMAP to lib/Kconfig Fix up trivial conflicts due to changes nearby in arch/{m68k,score}/Kconfig
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig7
-rw-r--r--lib/Makefile1
-rw-r--r--lib/iomap.c38
-rw-r--r--lib/pci_iomap.c48
4 files changed, 58 insertions, 36 deletions
diff --git a/lib/Kconfig b/lib/Kconfig
index f34be6417d71..7f6b8bca8c25 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -19,6 +19,13 @@ config RATIONAL
19config GENERIC_FIND_FIRST_BIT 19config GENERIC_FIND_FIRST_BIT
20 bool 20 bool
21 21
22config GENERIC_PCI_IOMAP
23 bool
24
25config GENERIC_IOMAP
26 bool
27 select GENERIC_PCI_IOMAP
28
22config CRC_CCITT 29config CRC_CCITT
23 tristate "CRC-CCITT functions" 30 tristate "CRC-CCITT functions"
24 help 31 help
diff --git a/lib/Makefile b/lib/Makefile
index c0ffaaff6534..884ed376164d 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -33,6 +33,7 @@ endif
33 33
34lib-$(CONFIG_HOTPLUG) += kobject_uevent.o 34lib-$(CONFIG_HOTPLUG) += kobject_uevent.o
35obj-$(CONFIG_GENERIC_IOMAP) += iomap.o 35obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
36obj-$(CONFIG_GENERIC_PCI_IOMAP) += pci_iomap.o
36obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o 37obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
37obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o 38obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o
38obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o 39obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
diff --git a/lib/iomap.c b/lib/iomap.c
index 5dbcb4b2d864..ada922a808e6 100644
--- a/lib/iomap.c
+++ b/lib/iomap.c
@@ -242,45 +242,11 @@ EXPORT_SYMBOL(ioport_unmap);
242#endif /* CONFIG_HAS_IOPORT */ 242#endif /* CONFIG_HAS_IOPORT */
243 243
244#ifdef CONFIG_PCI 244#ifdef CONFIG_PCI
245/** 245/* Hide the details if this is a MMIO or PIO address space and just do what
246 * pci_iomap - create a virtual mapping cookie for a PCI BAR 246 * you expect in the correct way. */
247 * @dev: PCI device that owns the BAR
248 * @bar: BAR number
249 * @maxlen: length of the memory to map
250 *
251 * Using this function you will get a __iomem address to your device BAR.
252 * You can access it using ioread*() and iowrite*(). These functions hide
253 * the details if this is a MMIO or PIO address space and will just do what
254 * you expect from them in the correct way.
255 *
256 * @maxlen specifies the maximum length to map. If you want to get access to
257 * the complete BAR without checking for its length first, pass %0 here.
258 * */
259void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
260{
261 resource_size_t start = pci_resource_start(dev, bar);
262 resource_size_t len = pci_resource_len(dev, bar);
263 unsigned long flags = pci_resource_flags(dev, bar);
264
265 if (!len || !start)
266 return NULL;
267 if (maxlen && len > maxlen)
268 len = maxlen;
269 if (flags & IORESOURCE_IO)
270 return ioport_map(start, len);
271 if (flags & IORESOURCE_MEM) {
272 if (flags & IORESOURCE_CACHEABLE)
273 return ioremap(start, len);
274 return ioremap_nocache(start, len);
275 }
276 /* What? */
277 return NULL;
278}
279
280void pci_iounmap(struct pci_dev *dev, void __iomem * addr) 247void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
281{ 248{
282 IO_COND(addr, /* nothing */, iounmap(addr)); 249 IO_COND(addr, /* nothing */, iounmap(addr));
283} 250}
284EXPORT_SYMBOL(pci_iomap);
285EXPORT_SYMBOL(pci_iounmap); 251EXPORT_SYMBOL(pci_iounmap);
286#endif /* CONFIG_PCI */ 252#endif /* CONFIG_PCI */
diff --git a/lib/pci_iomap.c b/lib/pci_iomap.c
new file mode 100644
index 000000000000..4b0fdc22e688
--- /dev/null
+++ b/lib/pci_iomap.c
@@ -0,0 +1,48 @@
1/*
2 * Implement the default iomap interfaces
3 *
4 * (C) Copyright 2004 Linus Torvalds
5 */
6#include <linux/pci.h>
7#include <linux/io.h>
8
9#include <linux/export.h>
10
11#ifdef CONFIG_PCI
12/**
13 * pci_iomap - create a virtual mapping cookie for a PCI BAR
14 * @dev: PCI device that owns the BAR
15 * @bar: BAR number
16 * @maxlen: length of the memory to map
17 *
18 * Using this function you will get a __iomem address to your device BAR.
19 * You can access it using ioread*() and iowrite*(). These functions hide
20 * the details if this is a MMIO or PIO address space and will just do what
21 * you expect from them in the correct way.
22 *
23 * @maxlen specifies the maximum length to map. If you want to get access to
24 * the complete BAR without checking for its length first, pass %0 here.
25 * */
26void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
27{
28 resource_size_t start = pci_resource_start(dev, bar);
29 resource_size_t len = pci_resource_len(dev, bar);
30 unsigned long flags = pci_resource_flags(dev, bar);
31
32 if (!len || !start)
33 return NULL;
34 if (maxlen && len > maxlen)
35 len = maxlen;
36 if (flags & IORESOURCE_IO)
37 return ioport_map(start, len);
38 if (flags & IORESOURCE_MEM) {
39 if (flags & IORESOURCE_CACHEABLE)
40 return ioremap(start, len);
41 return ioremap_nocache(start, len);
42 }
43 /* What? */
44 return NULL;
45}
46
47EXPORT_SYMBOL(pci_iomap);
48#endif /* CONFIG_PCI */