s390/pci: use claim_resource
authorSebastian Ott <sebott@linux.vnet.ibm.com>
Thu, 29 Aug 2013 17:34:37 +0000 (19:34 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Fri, 30 Aug 2013 06:57:10 +0000 (08:57 +0200)
Use pci_claim_resource to find and request bus ressources in
pcibios_add_device. Also move some (de)initialization stuff to
pcibios_enable_device/pcibios_disable_device.

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 56f8a1c4d9bf853d1d64e2b534682b4a0b751372..61167b1209a33a471cd1c4f535271530dacced9a 100644 (file)
@@ -541,8 +541,6 @@ static void zpci_map_resources(struct zpci_dev *zdev)
                        continue;
                pdev->resource[i].start = (resource_size_t) pci_iomap(pdev, i, 0);
                pdev->resource[i].end = pdev->resource[i].start + len - 1;
-               pr_debug("BAR%i: -> start: %Lx  end: %Lx\n",
-                       i, pdev->resource[i].start, pdev->resource[i].end);
        }
 }
 
@@ -574,32 +572,6 @@ void zpci_free_device(struct zpci_dev *zdev)
        kfree(zdev);
 }
 
-/*
- * Too late for any s390 specific setup, since interrupts must be set up
- * already which requires DMA setup too and the pci scan will access the
- * config space, which only works if the function handle is enabled.
- */
-int pcibios_enable_device(struct pci_dev *pdev, int mask)
-{
-       struct resource *res;
-       u16 cmd;
-       int i;
-
-       pci_read_config_word(pdev, PCI_COMMAND, &cmd);
-
-       for (i = 0; i < PCI_BAR_COUNT; i++) {
-               res = &pdev->resource[i];
-
-               if (res->flags & IORESOURCE_IO)
-                       return -EINVAL;
-
-               if (res->flags & IORESOURCE_MEM)
-                       cmd |= PCI_COMMAND_MEMORY;
-       }
-       pci_write_config_word(pdev, PCI_COMMAND, cmd);
-       return 0;
-}
-
 int pcibios_add_platform_entries(struct pci_dev *pdev)
 {
        return zpci_sysfs_add_device(&pdev->dev);
@@ -689,16 +661,49 @@ static void zpci_free_iomap(struct zpci_dev *zdev, int entry)
 int pcibios_add_device(struct pci_dev *pdev)
 {
        struct zpci_dev *zdev = get_zdev(pdev);
+       struct resource *res;
+       int i;
+
+       zdev->pdev = pdev;
+       zpci_map_resources(zdev);
+
+       for (i = 0; i < PCI_BAR_COUNT; i++) {
+               res = &pdev->resource[i];
+               if (res->parent || !res->flags)
+                       continue;
+               pci_claim_resource(pdev, i);
+       }
+
+       return 0;
+}
+
+int pcibios_enable_device(struct pci_dev *pdev, int mask)
+{
+       struct zpci_dev *zdev = get_zdev(pdev);
+       struct resource *res;
+       u16 cmd;
+       int i;
 
        zdev->pdev = pdev;
        zpci_debug_init_device(zdev);
        zpci_fmb_enable_device(zdev);
        zpci_map_resources(zdev);
 
+       pci_read_config_word(pdev, PCI_COMMAND, &cmd);
+       for (i = 0; i < PCI_BAR_COUNT; i++) {
+               res = &pdev->resource[i];
+
+               if (res->flags & IORESOURCE_IO)
+                       return -EINVAL;
+
+               if (res->flags & IORESOURCE_MEM)
+                       cmd |= PCI_COMMAND_MEMORY;
+       }
+       pci_write_config_word(pdev, PCI_COMMAND, cmd);
        return 0;
 }
 
-void pcibios_release_device(struct pci_dev *pdev)
+void pcibios_disable_device(struct pci_dev *pdev)
 {
        struct zpci_dev *zdev = get_zdev(pdev);
 
This page took 0.02661 seconds and 5 git commands to generate.