aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pci.h
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@infradead.org>2008-09-28 19:36:11 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2008-10-20 14:01:48 -0400
commitaa42d7c6138afdc54f74e971456a0fbfec16b77b (patch)
tree2fb140d3c6e3924b6c91e736df327d6668d68b2a /include/linux/pci.h
parente9f82cb75096ae30658a72d473bf170bf4d3bb2e (diff)
PCI: introduce an pci_ioremap(pdev, barnr) function
A common thing in many PCI drivers is to ioremap() an entire bar. This is a slightly fragile thing right now, needing both an address and a size, and many driver writers do.. various things there. This patch introduces an pci_ioremap() function taking just a PCI device struct and the bar number as arguments, and figures this all out itself, in one place. In addition, we can add various sanity checks to this function (the patch already checks to make sure that the bar in question really is a MEM bar; few to no drivers do that sort of thing). Hopefully with this type of API we get less chance of mistakes in drivers with ioremap() operations. Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'include/linux/pci.h')
-rw-r--r--include/linux/pci.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 7e9a1f0715e6..46ad282ffe4d 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1119,5 +1119,18 @@ static inline void pci_mmcfg_early_init(void) { }
1119static inline void pci_mmcfg_late_init(void) { } 1119static inline void pci_mmcfg_late_init(void) { }
1120#endif 1120#endif
1121 1121
1122static inline void * pci_ioremap_bar(struct pci_dev *pdev, int bar)
1123{
1124 /*
1125 * Make sure the BAR is actually a memory resource, not an IO resource
1126 */
1127 if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
1128 WARN_ON(1);
1129 return NULL;
1130 }
1131 return ioremap_nocache(pci_resource_start(pdev, bar),
1132 pci_resource_len(pdev, bar));
1133}
1134
1122#endif /* __KERNEL__ */ 1135#endif /* __KERNEL__ */
1123#endif /* LINUX_PCI_H */ 1136#endif /* LINUX_PCI_H */