s390/pci: implement pcibios_release_device
authorSebastian Ott <sebott@linux.vnet.ibm.com>
Wed, 5 Jun 2013 14:06:16 +0000 (16:06 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Wed, 26 Jun 2013 19:10:06 +0000 (21:10 +0200)
Use pcibios_release_device to implement architecture-specific
functionality when a pci device is released. This function
will be called during pci_release_dev.

Reviewed-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/pci/pci.c

index f1e5be8..a56fce4 100644 (file)
@@ -565,7 +565,21 @@ static void zpci_map_resources(struct zpci_dev *zdev)
                pr_debug("BAR%i: -> start: %Lx  end: %Lx\n",
                        i, pdev->resource[i].start, pdev->resource[i].end);
        }
-};
+}
+
+static void zpci_unmap_resources(struct zpci_dev *zdev)
+{
+       struct pci_dev *pdev = zdev->pdev;
+       resource_size_t len;
+       int i;
+
+       for (i = 0; i < PCI_BAR_COUNT; i++) {
+               len = pci_resource_len(pdev, i);
+               if (!len)
+                       continue;
+               pci_iounmap(pdev, (void *) pdev->resource[i].start);
+       }
+}
 
 struct zpci_dev *zpci_alloc_device(void)
 {
@@ -810,6 +824,16 @@ int pcibios_add_device(struct pci_dev *pdev)
        return 0;
 }
 
+void pcibios_release_device(struct pci_dev *pdev)
+{
+       struct zpci_dev *zdev = get_zdev(pdev);
+
+       zpci_unmap_resources(zdev);
+       zpci_fmb_disable_device(zdev);
+       zpci_debug_exit_device(zdev);
+       zdev->pdev = NULL;
+}
+
 static int zpci_scan_bus(struct zpci_dev *zdev)
 {
        struct resource *res;