diff options
author | Tejun Heo <htejun@gmail.com> | 2008-03-12 02:26:34 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2008-03-17 08:26:44 -0400 |
commit | 916fbfb7ae5f8c8f86399794d89e6d273df8826b (patch) | |
tree | 0b3982923e2b4114b83f67cfca9b950004caef9c | |
parent | 233f112042d0b50170212dbff99c3b34b8773cd3 (diff) |
devres: implement pcim_iomap_regions_request_all()
Some drivers need to reserve all PCI BARs to prevent other drivers
misusing unoccupied BARs. pcim_iomap_regions_request_all() requests
all BARs and iomap specified BARs.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r-- | include/linux/pci.h | 2 | ||||
-rw-r--r-- | lib/devres.c | 25 |
2 files changed, 27 insertions, 0 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h index 9010f5458767..b7e4b633c69b 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -1045,6 +1045,8 @@ void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); | |||
1045 | void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr); | 1045 | void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr); |
1046 | void __iomem * const *pcim_iomap_table(struct pci_dev *pdev); | 1046 | void __iomem * const *pcim_iomap_table(struct pci_dev *pdev); |
1047 | int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name); | 1047 | int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name); |
1048 | int pcim_iomap_regions_request_all(struct pci_dev *pdev, u16 mask, | ||
1049 | const char *name); | ||
1048 | void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask); | 1050 | void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask); |
1049 | 1051 | ||
1050 | extern int pci_pci_problems; | 1052 | extern int pci_pci_problems; |
diff --git a/lib/devres.c b/lib/devres.c index b1d336ce7f3d..edc27a5d1b73 100644 --- a/lib/devres.c +++ b/lib/devres.c | |||
@@ -298,6 +298,31 @@ int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name) | |||
298 | EXPORT_SYMBOL(pcim_iomap_regions); | 298 | EXPORT_SYMBOL(pcim_iomap_regions); |
299 | 299 | ||
300 | /** | 300 | /** |
301 | * pcim_iomap_regions_request_all - Request all BARs and iomap specified ones | ||
302 | * @pdev: PCI device to map IO resources for | ||
303 | * @mask: Mask of BARs to iomap | ||
304 | * @name: Name used when requesting regions | ||
305 | * | ||
306 | * Request all PCI BARs and iomap regions specified by @mask. | ||
307 | */ | ||
308 | int pcim_iomap_regions_request_all(struct pci_dev *pdev, u16 mask, | ||
309 | const char *name) | ||
310 | { | ||
311 | int request_mask = ((1 << 6) - 1) & ~mask; | ||
312 | int rc; | ||
313 | |||
314 | rc = pci_request_selected_regions(pdev, request_mask, name); | ||
315 | if (rc) | ||
316 | return rc; | ||
317 | |||
318 | rc = pcim_iomap_regions(pdev, mask, name); | ||
319 | if (rc) | ||
320 | pci_release_selected_regions(pdev, request_mask); | ||
321 | return rc; | ||
322 | } | ||
323 | EXPORT_SYMBOL(pcim_iomap_regions_request_all); | ||
324 | |||
325 | /** | ||
301 | * pcim_iounmap_regions - Unmap and release PCI BARs | 326 | * pcim_iounmap_regions - Unmap and release PCI BARs |
302 | * @pdev: PCI device to map IO resources for | 327 | * @pdev: PCI device to map IO resources for |
303 | * @mask: Mask of BARs to unmap and release | 328 | * @mask: Mask of BARs to unmap and release |