Commit 783a8625 authored by Rob Herring's avatar Rob Herring Committed by Lorenzo Pieralisi

PCI: faraday: Use pci_parse_request_of_pci_ranges()

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: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: default avatarAndrew Murray <andrew.murray@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
parent 7fe71aa8
...@@ -430,10 +430,8 @@ static int faraday_pci_probe(struct platform_device *pdev) ...@@ -430,10 +430,8 @@ static int faraday_pci_probe(struct platform_device *pdev)
const struct faraday_pci_variant *variant = const struct faraday_pci_variant *variant =
of_device_get_match_data(dev); of_device_get_match_data(dev);
struct resource *regs; struct resource *regs;
resource_size_t io_base;
struct resource_entry *win; struct resource_entry *win;
struct faraday_pci *p; struct faraday_pci *p;
struct resource *mem;
struct resource *io; struct resource *io;
struct pci_host_bridge *host; struct pci_host_bridge *host;
struct clk *clk; struct clk *clk;
...@@ -441,7 +439,6 @@ static int faraday_pci_probe(struct platform_device *pdev) ...@@ -441,7 +439,6 @@ static int faraday_pci_probe(struct platform_device *pdev)
unsigned char cur_bus_speed = PCI_SPEED_33MHz; unsigned char cur_bus_speed = PCI_SPEED_33MHz;
int ret; int ret;
u32 val; u32 val;
LIST_HEAD(res);
host = devm_pci_alloc_host_bridge(dev, sizeof(*p)); host = devm_pci_alloc_host_bridge(dev, sizeof(*p));
if (!host) if (!host)
...@@ -480,21 +477,13 @@ static int faraday_pci_probe(struct platform_device *pdev) ...@@ -480,21 +477,13 @@ static int faraday_pci_probe(struct platform_device *pdev)
if (IS_ERR(p->base)) if (IS_ERR(p->base))
return PTR_ERR(p->base); return PTR_ERR(p->base);
ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, ret = pci_parse_request_of_pci_ranges(dev, &host->windows, NULL);
&res, &io_base);
if (ret) if (ret)
return ret; return ret;
ret = devm_request_pci_bus_resources(dev, &res); win = resource_list_first_type(&host->windows, IORESOURCE_IO);
if (ret) if (win) {
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 = win->res;
io->name = "Gemini PCI I/O";
if (!faraday_res_to_memcfg(io->start - win->offset, if (!faraday_res_to_memcfg(io->start - win->offset,
resource_size(io), &val)) { resource_size(io), &val)) {
/* setup I/O space size */ /* setup I/O space size */
...@@ -503,22 +492,6 @@ static int faraday_pci_probe(struct platform_device *pdev) ...@@ -503,22 +492,6 @@ static int faraday_pci_probe(struct platform_device *pdev)
dev_err(dev, "illegal IO mem size\n"); dev_err(dev, "illegal IO mem size\n");
return -EINVAL; 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;
}
} }
/* Setup hostbridge */ /* Setup hostbridge */
...@@ -569,7 +542,6 @@ static int faraday_pci_probe(struct platform_device *pdev) ...@@ -569,7 +542,6 @@ static int faraday_pci_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
list_splice_init(&res, &host->windows);
ret = pci_scan_root_bus_bridge(host); ret = pci_scan_root_bus_bridge(host);
if (ret) { if (ret) {
dev_err(dev, "failed to scan host: %d\n", ret); dev_err(dev, "failed to scan host: %d\n", ret);
...@@ -581,7 +553,6 @@ static int faraday_pci_probe(struct platform_device *pdev) ...@@ -581,7 +553,6 @@ static int faraday_pci_probe(struct platform_device *pdev)
pci_bus_assign_resources(p->bus); pci_bus_assign_resources(p->bus);
pci_bus_add_devices(p->bus); pci_bus_add_devices(p->bus);
pci_free_resource_list(&res);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment