Skip to contentSkip to conversation

iomap: implement pcim_iounmap_regions()

PATCH Applied Tejun Heo 2 participants 2 messages Mar 9, 2007

Subsystems (3)
lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/1 iomap: implement pcim_iounmap_regions()

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

---
This one is used by libata's new init model and generally useful for driver midlayers. Please push it through libata-dev#upstream.

Thanks.

 include/linux/pci.h |    1 +
 lib/devres.c        |   26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 0 deletions(-)
include/linux/pci.h +1 -0
index 2c4b684..8d3b221 100644
@@ -844,6 +844,7 @@ void __iomem * pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
 void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
 void __iomem * const * pcim_iomap_table(struct pci_dev *pdev);
 int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name);
+void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask);
 
 extern int pci_pci_problems;
 #define PCIPCI_FAIL		1	/* No PCI PCI DMA */
lib/devres.c +26 -0
index eb38849..b1d336c 100644
@@ -296,5 +296,31 @@ int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name)
 	return rc;
 }
 EXPORT_SYMBOL(pcim_iomap_regions);
+
+/**
+ * pcim_iounmap_regions - Unmap and release PCI BARs
+ * @pdev: PCI device to map IO resources for
+ * @mask: Mask of BARs to unmap and release
+ *
+ * Unamp and release regions specified by @mask.
+ */
+void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask)
+{
+	void __iomem * const *iomap;
+	int i;
+
+	iomap = pcim_iomap_table(pdev);
+	if (!iomap)
+		return;
+
+	for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
+		if (!(mask & (1 << i)))
+			continue;
+
+		pcim_iounmap(pdev, iomap[i]);
+		pci_release_region(pdev, i);
+	}
+}
+EXPORT_SYMBOL(pcim_iounmap_regions);
 #endif
 #endif
Signature · 1 line
1.5.0.1
Applied
#1 lore raw
Quoted 8 lines · Tejun Heo

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

---
This one is used by libata's new init model and generally useful for driver midlayers. Please push it through libata-dev#upstream.

Quoted 5 lines

Thanks.

 include/linux/pci.h |    1 +
 lib/devres.c        |   26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 0 deletions(-)

applied