Commit 055f87a2 authored by Jan Kiszka's avatar Jan Kiszka Committed by Bjorn Helgaas

PCI: Pass struct device to of_pci_get_host_bridge_resources()

Another step towards a managed version of
of_pci_get_host_bridge_resources(): Feed in the underlying device, rather
than just the OF node.  This will allow us to use managed resource
allocation internally later on.
Tested-by: default avatarVladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: default avatarVladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Acked-by: default avatarJingoo Han <jingoohan1@gmail.com>
CC: Joao Pinto <Joao.Pinto@synopsys.com>
CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
parent 126b7de6
...@@ -342,7 +342,7 @@ int dw_pcie_host_init(struct pcie_port *pp) ...@@ -342,7 +342,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
if (!bridge) if (!bridge)
return -ENOMEM; return -ENOMEM;
ret = of_pci_get_host_bridge_resources(np, 0, 0xff, ret = of_pci_get_host_bridge_resources(dev, 0, 0xff,
&bridge->windows, &pp->io_base); &bridge->windows, &pp->io_base);
if (ret) if (ret)
return ret; return ret;
......
...@@ -815,14 +815,13 @@ static int advk_pcie_parse_request_of_pci_ranges(struct advk_pcie *pcie) ...@@ -815,14 +815,13 @@ static int advk_pcie_parse_request_of_pci_ranges(struct advk_pcie *pcie)
{ {
int err, res_valid = 0; int err, res_valid = 0;
struct device *dev = &pcie->pdev->dev; struct device *dev = &pcie->pdev->dev;
struct device_node *np = dev->of_node;
struct resource_entry *win, *tmp; struct resource_entry *win, *tmp;
resource_size_t iobase; resource_size_t iobase;
INIT_LIST_HEAD(&pcie->resources); INIT_LIST_HEAD(&pcie->resources);
err = of_pci_get_host_bridge_resources(np, 0, 0xff, &pcie->resources, err = of_pci_get_host_bridge_resources(dev, 0, 0xff,
&iobase); &pcie->resources, &iobase);
if (err) if (err)
return err; return err;
......
...@@ -476,7 +476,7 @@ static int faraday_pci_probe(struct platform_device *pdev) ...@@ -476,7 +476,7 @@ 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 = of_pci_get_host_bridge_resources(dev->of_node, 0, 0xff, ret = of_pci_get_host_bridge_resources(dev, 0, 0xff,
&res, &io_base); &res, &io_base);
if (ret) if (ret)
return ret; return ret;
......
...@@ -791,7 +791,8 @@ static int v3_pci_probe(struct platform_device *pdev) ...@@ -791,7 +791,8 @@ static int v3_pci_probe(struct platform_device *pdev)
if (IS_ERR(v3->config_base)) if (IS_ERR(v3->config_base))
return PTR_ERR(v3->config_base); return PTR_ERR(v3->config_base);
ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &res, &io_base); ret = of_pci_get_host_bridge_resources(dev, 0, 0xff, &res,
&io_base);
if (ret) if (ret)
return ret; return ret;
......
...@@ -64,11 +64,10 @@ static int versatile_pci_parse_request_of_pci_ranges(struct device *dev, ...@@ -64,11 +64,10 @@ static int versatile_pci_parse_request_of_pci_ranges(struct device *dev,
struct list_head *res) struct list_head *res)
{ {
int err, mem = 1, res_valid = 0; int err, mem = 1, res_valid = 0;
struct device_node *np = dev->of_node;
resource_size_t iobase; resource_size_t iobase;
struct resource_entry *win, *tmp; struct resource_entry *win, *tmp;
err = of_pci_get_host_bridge_resources(np, 0, 0xff, res, &iobase); err = of_pci_get_host_bridge_resources(dev, 0, 0xff, res, &iobase);
if (err) if (err)
return err; return err;
......
...@@ -632,7 +632,8 @@ static int xgene_pcie_probe(struct platform_device *pdev) ...@@ -632,7 +632,8 @@ static int xgene_pcie_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
ret = of_pci_get_host_bridge_resources(dn, 0, 0xff, &res, &iobase); ret = of_pci_get_host_bridge_resources(dev, 0, 0xff, &res,
&iobase);
if (ret) if (ret)
return ret; return ret;
......
...@@ -488,11 +488,10 @@ static int altera_pcie_parse_request_of_pci_ranges(struct altera_pcie *pcie) ...@@ -488,11 +488,10 @@ static int altera_pcie_parse_request_of_pci_ranges(struct altera_pcie *pcie)
{ {
int err, res_valid = 0; int err, res_valid = 0;
struct device *dev = &pcie->pdev->dev; struct device *dev = &pcie->pdev->dev;
struct device_node *np = dev->of_node;
struct resource_entry *win; struct resource_entry *win;
err = of_pci_get_host_bridge_resources(np, 0, 0xff, &pcie->resources, err = of_pci_get_host_bridge_resources(dev, 0, 0xff,
NULL); &pcie->resources, NULL);
if (err) if (err)
return err; return err;
......
...@@ -99,7 +99,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) ...@@ -99,7 +99,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
pcie->phy = NULL; pcie->phy = NULL;
} }
ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &resources, ret = of_pci_get_host_bridge_resources(dev, 0, 0xff, &resources,
&iobase); &iobase);
if (ret) { if (ret) {
dev_err(dev, "unable to get PCI host bridge resources\n"); dev_err(dev, "unable to get PCI host bridge resources\n");
......
...@@ -1067,12 +1067,11 @@ static int rcar_pcie_parse_request_of_pci_ranges(struct rcar_pcie *pci) ...@@ -1067,12 +1067,11 @@ static int rcar_pcie_parse_request_of_pci_ranges(struct rcar_pcie *pci)
{ {
int err; int err;
struct device *dev = pci->dev; struct device *dev = pci->dev;
struct device_node *np = dev->of_node;
resource_size_t iobase; resource_size_t iobase;
struct resource_entry *win, *tmp; struct resource_entry *win, *tmp;
err = of_pci_get_host_bridge_resources(np, 0, 0xff, &pci->resources, err = of_pci_get_host_bridge_resources(dev, 0, 0xff,
&iobase); &pci->resources, &iobase);
if (err) if (err)
return err; return err;
......
...@@ -1560,7 +1560,7 @@ static int rockchip_pcie_probe(struct platform_device *pdev) ...@@ -1560,7 +1560,7 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
if (err < 0) if (err < 0)
goto err_deinit_port; goto err_deinit_port;
err = of_pci_get_host_bridge_resources(dev->of_node, 0, 0xff, err = of_pci_get_host_bridge_resources(dev, 0, 0xff,
&res, &io_base); &res, &io_base);
if (err) if (err)
goto err_remove_irq_domain; goto err_remove_irq_domain;
......
...@@ -825,7 +825,6 @@ static const struct of_device_id nwl_pcie_of_match[] = { ...@@ -825,7 +825,6 @@ static const struct of_device_id nwl_pcie_of_match[] = {
static int nwl_pcie_probe(struct platform_device *pdev) static int nwl_pcie_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *node = dev->of_node;
struct nwl_pcie *pcie; struct nwl_pcie *pcie;
struct pci_bus *bus; struct pci_bus *bus;
struct pci_bus *child; struct pci_bus *child;
...@@ -855,7 +854,8 @@ static int nwl_pcie_probe(struct platform_device *pdev) ...@@ -855,7 +854,8 @@ static int nwl_pcie_probe(struct platform_device *pdev)
return err; return err;
} }
err = of_pci_get_host_bridge_resources(node, 0, 0xff, &res, &iobase); err = of_pci_get_host_bridge_resources(dev, 0, 0xff, &res,
&iobase);
if (err) { if (err) {
dev_err(dev, "Getting bridge resources failed\n"); dev_err(dev, "Getting bridge resources failed\n");
return err; return err;
......
...@@ -643,7 +643,7 @@ static int xilinx_pcie_probe(struct platform_device *pdev) ...@@ -643,7 +643,7 @@ static int xilinx_pcie_probe(struct platform_device *pdev)
return err; return err;
} }
err = of_pci_get_host_bridge_resources(dev->of_node, 0, 0xff, &res, err = of_pci_get_host_bridge_resources(dev, 0, 0xff, &res,
&iobase); &iobase);
if (err) { if (err) {
dev_err(dev, "Getting bridge resources failed\n"); dev_err(dev, "Getting bridge resources failed\n");
......
...@@ -245,7 +245,7 @@ EXPORT_SYMBOL_GPL(of_pci_check_probe_only); ...@@ -245,7 +245,7 @@ EXPORT_SYMBOL_GPL(of_pci_check_probe_only);
#if defined(CONFIG_OF_ADDRESS) #if defined(CONFIG_OF_ADDRESS)
/** /**
* of_pci_get_host_bridge_resources - Parse PCI host bridge resources from DT * of_pci_get_host_bridge_resources - Parse PCI host bridge resources from DT
* @dev_node: device node of the host bridge having the range property * @dev: host bridge device
* @busno: bus number associated with the bridge root bus * @busno: bus number associated with the bridge root bus
* @bus_max: maximum number of buses for this bridge * @bus_max: maximum number of buses for this bridge
* @resources: list where the range of resources will be added after DT parsing * @resources: list where the range of resources will be added after DT parsing
...@@ -262,10 +262,11 @@ EXPORT_SYMBOL_GPL(of_pci_check_probe_only); ...@@ -262,10 +262,11 @@ EXPORT_SYMBOL_GPL(of_pci_check_probe_only);
* It returns zero if the range parsing has been successful or a standard error * It returns zero if the range parsing has been successful or a standard error
* value if it failed. * value if it failed.
*/ */
int of_pci_get_host_bridge_resources(struct device_node *dev_node, int of_pci_get_host_bridge_resources(struct device *dev,
unsigned char busno, unsigned char bus_max, unsigned char busno, unsigned char bus_max,
struct list_head *resources, resource_size_t *io_base) struct list_head *resources, resource_size_t *io_base)
{ {
struct device_node *dev_node = dev->of_node;
struct resource_entry *window; struct resource_entry *window;
struct resource *res; struct resource *res;
struct resource *bus_range; struct resource *bus_range;
...@@ -599,12 +600,12 @@ int pci_parse_request_of_pci_ranges(struct device *dev, ...@@ -599,12 +600,12 @@ int pci_parse_request_of_pci_ranges(struct device *dev,
struct resource **bus_range) struct resource **bus_range)
{ {
int err, res_valid = 0; int err, res_valid = 0;
struct device_node *np = dev->of_node;
resource_size_t iobase; resource_size_t iobase;
struct resource_entry *win, *tmp; struct resource_entry *win, *tmp;
INIT_LIST_HEAD(resources); INIT_LIST_HEAD(resources);
err = of_pci_get_host_bridge_resources(np, 0, 0xff, resources, &iobase); err = of_pci_get_host_bridge_resources(dev, 0, 0xff, resources,
&iobase);
if (err) if (err)
return err; return err;
......
...@@ -71,11 +71,11 @@ of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin) ...@@ -71,11 +71,11 @@ of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin)
#endif #endif
#if defined(CONFIG_OF_ADDRESS) #if defined(CONFIG_OF_ADDRESS)
int of_pci_get_host_bridge_resources(struct device_node *dev_node, int of_pci_get_host_bridge_resources(struct device *dev,
unsigned char busno, unsigned char bus_max, unsigned char busno, unsigned char bus_max,
struct list_head *resources, resource_size_t *io_base); struct list_head *resources, resource_size_t *io_base);
#else #else
static inline int of_pci_get_host_bridge_resources(struct device_node *dev_node, static inline int of_pci_get_host_bridge_resources(struct device *dev,
unsigned char busno, unsigned char bus_max, unsigned char busno, unsigned char bus_max,
struct list_head *resources, resource_size_t *io_base) struct list_head *resources, resource_size_t *io_base)
{ {
......
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