Commit ec04b075843d12b5115267415d0426b48e672136

Authored by Tejun Heo
Committed by Jeff Garzik
1 parent a73984a0d5

iomap: implement pcim_iounmap_regions()

Implement pcim_iounmap_regions() - the opposite of
pcim_iomap_regions().

Signed-off-by: Tejun heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>

Showing 2 changed files with 27 additions and 0 deletions Side-by-side Diff

... ... @@ -838,6 +838,7 @@
838 838 void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
839 839 void __iomem * const * pcim_iomap_table(struct pci_dev *pdev);
840 840 int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name);
  841 +void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask);
841 842  
842 843 extern int pci_pci_problems;
843 844 #define PCIPCI_FAIL 1 /* No PCI PCI DMA */
... ... @@ -296,6 +296,32 @@
296 296 return rc;
297 297 }
298 298 EXPORT_SYMBOL(pcim_iomap_regions);
  299 +
  300 +/**
  301 + * pcim_iounmap_regions - Unmap and release PCI BARs
  302 + * @pdev: PCI device to map IO resources for
  303 + * @mask: Mask of BARs to unmap and release
  304 + *
  305 + * Unamp and release regions specified by @mask.
  306 + */
  307 +void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask)
  308 +{
  309 + void __iomem * const *iomap;
  310 + int i;
  311 +
  312 + iomap = pcim_iomap_table(pdev);
  313 + if (!iomap)
  314 + return;
  315 +
  316 + for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
  317 + if (!(mask & (1 << i)))
  318 + continue;
  319 +
  320 + pcim_iounmap(pdev, iomap[i]);
  321 + pci_release_region(pdev, i);
  322 + }
  323 +}
  324 +EXPORT_SYMBOL(pcim_iounmap_regions);
299 325 #endif
300 326 #endif