PCI: faraday: Use pci_parse_request_of_pci_ranges()
authorRob Herring <robh@kernel.org>
Mon, 28 Oct 2019 16:32:37 +0000 (11:32 -0500)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tue, 29 Oct 2019 10:49:14 +0000 (10:49 +0000)
Convert the Faraday host bridge to use the common
pci_parse_request_of_pci_ranges().

There's no need to assign the resources to a temporary list first. Just
use bridge->windows directly and remove all the temporary list handling.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Andrew Murray <andrew.murray@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/controller/pci-ftpci100.c

index bf5ece5..7560334 100644 (file)
@@ -430,10 +430,8 @@ static int faraday_pci_probe(struct platform_device *pdev)
        const struct faraday_pci_variant *variant =
                of_device_get_match_data(dev);
        struct resource *regs;
-       resource_size_t io_base;
        struct resource_entry *win;
        struct faraday_pci *p;
-       struct resource *mem;
        struct resource *io;
        struct pci_host_bridge *host;
        struct clk *clk;
@@ -441,7 +439,6 @@ static int faraday_pci_probe(struct platform_device *pdev)
        unsigned char cur_bus_speed = PCI_SPEED_33MHz;
        int ret;
        u32 val;
-       LIST_HEAD(res);
 
        host = devm_pci_alloc_host_bridge(dev, sizeof(*p));
        if (!host)
@@ -480,44 +477,20 @@ static int faraday_pci_probe(struct platform_device *pdev)
        if (IS_ERR(p->base))
                return PTR_ERR(p->base);
 
-       ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff,
-                                                   &res, &io_base);
+       ret = pci_parse_request_of_pci_ranges(dev, &host->windows, NULL);
        if (ret)
                return ret;
 
-       ret = devm_request_pci_bus_resources(dev, &res);
-       if (ret)
-               return ret;
-
-       /* Get the I/O and memory ranges from DT */
-       resource_list_for_each_entry(win, &res) {
-               switch (resource_type(win->res)) {
-               case IORESOURCE_IO:
-                       io = win->res;
-                       io->name = "Gemini PCI I/O";
-                       if (!faraday_res_to_memcfg(io->start - win->offset,
-                                                  resource_size(io), &val)) {
-                               /* setup I/O space size */
-                               writel(val, p->base + PCI_IOSIZE);
-                       } else {
-                               dev_err(dev, "illegal IO mem size\n");
-                               return -EINVAL;
-                       }
-                       ret = devm_pci_remap_iospace(dev, io, io_base);
-                       if (ret) {
-                               dev_warn(dev, "error %d: failed to map resource %pR\n",
-                                        ret, io);
-                               continue;
-                       }
-                       break;
-               case IORESOURCE_MEM:
-                       mem = win->res;
-                       mem->name = "Gemini PCI MEM";
-                       break;
-               case IORESOURCE_BUS:
-                       break;
-               default:
-                       break;
+       win = resource_list_first_type(&host->windows, IORESOURCE_IO);
+       if (win) {
+               io = win->res;
+               if (!faraday_res_to_memcfg(io->start - win->offset,
+                                          resource_size(io), &val)) {
+                       /* setup I/O space size */
+                       writel(val, p->base + PCI_IOSIZE);
+               } else {
+                       dev_err(dev, "illegal IO mem size\n");
+                       return -EINVAL;
                }
        }
 
@@ -569,7 +542,6 @@ static int faraday_pci_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
-       list_splice_init(&res, &host->windows);
        ret = pci_scan_root_bus_bridge(host);
        if (ret) {
                dev_err(dev, "failed to scan host: %d\n", ret);
@@ -581,7 +553,6 @@ static int faraday_pci_probe(struct platform_device *pdev)
 
        pci_bus_assign_resources(p->bus);
        pci_bus_add_devices(p->bus);
-       pci_free_resource_list(&res);
 
        return 0;
 }