Merge branch 'avr32-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/hskinnemo...
[sfrench/cifs-2.6.git] / lib / devres.c
index b1d336ce7f3d0c34f694844c8bd7dfd0f1dc687d..edc27a5d1b735aba4855d33e9756ab375d9569ce 100644 (file)
@@ -297,6 +297,31 @@ int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name)
 }
 EXPORT_SYMBOL(pcim_iomap_regions);
 
+/**
+ * pcim_iomap_regions_request_all - Request all BARs and iomap specified ones
+ * @pdev: PCI device to map IO resources for
+ * @mask: Mask of BARs to iomap
+ * @name: Name used when requesting regions
+ *
+ * Request all PCI BARs and iomap regions specified by @mask.
+ */
+int pcim_iomap_regions_request_all(struct pci_dev *pdev, u16 mask,
+                                  const char *name)
+{
+       int request_mask = ((1 << 6) - 1) & ~mask;
+       int rc;
+
+       rc = pci_request_selected_regions(pdev, request_mask, name);
+       if (rc)
+               return rc;
+
+       rc = pcim_iomap_regions(pdev, mask, name);
+       if (rc)
+               pci_release_selected_regions(pdev, request_mask);
+       return rc;
+}
+EXPORT_SYMBOL(pcim_iomap_regions_request_all);
+
 /**
  * pcim_iounmap_regions - Unmap and release PCI BARs
  * @pdev: PCI device to map IO resources for