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

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
Loading
Loading
Loading
Loading
+11 −40
Original line number Diff line number Diff line
@@ -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,21 +477,13 @@ 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:
	win = resource_list_first_type(&host->windows, IORESOURCE_IO);
	if (win) {
		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 */
@@ -503,22 +492,6 @@ static int faraday_pci_probe(struct platform_device *pdev)
			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;
		}
	}

	/* Setup hostbridge */
@@ -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;
}