Skip to content

Commit

Permalink
PCI: iproc: Directly add PCI resources
Browse files Browse the repository at this point in the history
The struct iproc_pcie.resources member was pointing to a stack variable and
is invalid after the registration function returned.

Remove this pointer and add a parameter to the function.

Tested-by: Ray Jui <rjui@broadcom.com>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Ray Jui <rjui@broadcom.com>
  • Loading branch information
Hauke Mehrtens authored and Bjorn Helgaas committed May 27, 2015
1 parent 4785ffb commit 18c4342
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
4 changes: 1 addition & 3 deletions drivers/pci/host/pcie-iproc-bcma.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,9 @@ static int iproc_pcie_bcma_probe(struct bcma_device *bdev)
res_mem.flags = IORESOURCE_MEM;
pci_add_resource(&res, &res_mem);

pcie->resources = &res;

pcie->map_irq = iproc_pcie_bcma_map_irq;

ret = iproc_pcie_setup(pcie);
ret = iproc_pcie_setup(pcie, &res);
if (ret) {
dev_err(pcie->dev, "PCIe controller setup failed\n");
return ret;
Expand Down
4 changes: 1 addition & 3 deletions drivers/pci/host/pcie-iproc-platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
return ret;
}

pcie->resources = &res;

pcie->map_irq = of_irq_parse_and_map_pci;

ret = iproc_pcie_setup(pcie);
ret = iproc_pcie_setup(pcie, &res);
if (ret) {
dev_err(pcie->dev, "PCIe controller setup failed\n");
return ret;
Expand Down
4 changes: 2 additions & 2 deletions drivers/pci/host/pcie-iproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static void iproc_pcie_enable(struct iproc_pcie *pcie)
writel(SYS_RC_INTX_MASK, pcie->base + SYS_RC_INTX_EN);
}

int iproc_pcie_setup(struct iproc_pcie *pcie)
int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
{
int ret;
struct pci_bus *bus;
Expand Down Expand Up @@ -211,7 +211,7 @@ int iproc_pcie_setup(struct iproc_pcie *pcie)
pcie->sysdata.private_data = pcie;

bus = pci_create_root_bus(pcie->dev, 0, &iproc_pcie_ops,
&pcie->sysdata, pcie->resources);
&pcie->sysdata, res);
if (!bus) {
dev_err(pcie->dev, "unable to create PCI root bus\n");
ret = -ENOMEM;
Expand Down
3 changes: 1 addition & 2 deletions drivers/pci/host/pcie-iproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@
struct iproc_pcie {
struct device *dev;
void __iomem *base;
struct list_head *resources;
struct pci_sys_data sysdata;
struct pci_bus *root_bus;
struct phy *phy;
int irqs[IPROC_PCIE_MAX_NUM_IRQS];
int (*map_irq)(const struct pci_dev *, u8, u8);
};

int iproc_pcie_setup(struct iproc_pcie *pcie);
int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res);
int iproc_pcie_remove(struct iproc_pcie *pcie);

#endif /* _PCIE_IPROC_H */

0 comments on commit 18c4342

Please sign in to comment.