aboutsummaryrefslogtreecommitdiffstats
path: root/lib/iomap.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2011-11-24 13:45:20 -0500
committerMichael S. Tsirkin <mst@redhat.com>2011-11-28 14:12:42 -0500
commit66eab4df288aaee75938ae99877c4f759fc6d56c (patch)
tree0b663bfe2d464a55c2a85b27140a53b32f261542 /lib/iomap.c
parent4673ca8eb3690832e76371371955a8b02e1f59d4 (diff)
lib: add GENERIC_PCI_IOMAP
Many architectures want a generic pci_iomap but not the rest of iomap.c. Split that to a separate .c file and add a new config symbol. select automatically by GENERIC_IOMAP. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'lib/iomap.c')
-rw-r--r--lib/iomap.c38
1 files changed, 2 insertions, 36 deletions
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 */