031-0001-PCI-iproc-Directly-add-PCI-resources.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. From 18c4342aa56d70176eea85021e6fe8f6f8f39c7b Mon Sep 17 00:00:00 2001
  2. From: Hauke Mehrtens <hauke@hauke-m.de>
  3. Date: Sun, 24 May 2015 22:37:02 +0200
  4. Subject: [PATCH 1/2] PCI: iproc: Directly add PCI resources
  5. The struct iproc_pcie.resources member was pointing to a stack variable and
  6. is invalid after the registration function returned.
  7. Remove this pointer and add a parameter to the function.
  8. Tested-by: Ray Jui <rjui@broadcom.com>
  9. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
  10. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
  11. Reviewed-by: Ray Jui <rjui@broadcom.com>
  12. ---
  13. drivers/pci/host/pcie-iproc-bcma.c | 4 +---
  14. drivers/pci/host/pcie-iproc-platform.c | 4 +---
  15. drivers/pci/host/pcie-iproc.c | 4 ++--
  16. drivers/pci/host/pcie-iproc.h | 3 +--
  17. 4 files changed, 5 insertions(+), 10 deletions(-)
  18. --- a/drivers/pci/host/pcie-iproc-bcma.c
  19. +++ b/drivers/pci/host/pcie-iproc-bcma.c
  20. @@ -62,11 +62,9 @@ static int iproc_pcie_bcma_probe(struct
  21. res_mem.flags = IORESOURCE_MEM;
  22. pci_add_resource(&res, &res_mem);
  23. - pcie->resources = &res;
  24. -
  25. pcie->map_irq = iproc_pcie_bcma_map_irq;
  26. - ret = iproc_pcie_setup(pcie);
  27. + ret = iproc_pcie_setup(pcie, &res);
  28. if (ret) {
  29. dev_err(pcie->dev, "PCIe controller setup failed\n");
  30. return ret;
  31. --- a/drivers/pci/host/pcie-iproc-platform.c
  32. +++ b/drivers/pci/host/pcie-iproc-platform.c
  33. @@ -69,11 +69,9 @@ static int iproc_pcie_pltfm_probe(struct
  34. return ret;
  35. }
  36. - pcie->resources = &res;
  37. -
  38. pcie->map_irq = of_irq_parse_and_map_pci;
  39. - ret = iproc_pcie_setup(pcie);
  40. + ret = iproc_pcie_setup(pcie, &res);
  41. if (ret) {
  42. dev_err(pcie->dev, "PCIe controller setup failed\n");
  43. return ret;
  44. --- a/drivers/pci/host/pcie-iproc.c
  45. +++ b/drivers/pci/host/pcie-iproc.c
  46. @@ -183,7 +183,7 @@ static void iproc_pcie_enable(struct ipr
  47. writel(SYS_RC_INTX_MASK, pcie->base + SYS_RC_INTX_EN);
  48. }
  49. -int iproc_pcie_setup(struct iproc_pcie *pcie)
  50. +int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
  51. {
  52. int ret;
  53. struct pci_bus *bus;
  54. @@ -211,7 +211,7 @@ int iproc_pcie_setup(struct iproc_pcie *
  55. pcie->sysdata.private_data = pcie;
  56. bus = pci_create_root_bus(pcie->dev, 0, &iproc_pcie_ops,
  57. - &pcie->sysdata, pcie->resources);
  58. + &pcie->sysdata, res);
  59. if (!bus) {
  60. dev_err(pcie->dev, "unable to create PCI root bus\n");
  61. ret = -ENOMEM;
  62. --- a/drivers/pci/host/pcie-iproc.h
  63. +++ b/drivers/pci/host/pcie-iproc.h
  64. @@ -29,7 +29,6 @@
  65. struct iproc_pcie {
  66. struct device *dev;
  67. void __iomem *base;
  68. - struct list_head *resources;
  69. struct pci_sys_data sysdata;
  70. struct pci_bus *root_bus;
  71. struct phy *phy;
  72. @@ -37,7 +36,7 @@ struct iproc_pcie {
  73. int (*map_irq)(const struct pci_dev *, u8, u8);
  74. };
  75. -int iproc_pcie_setup(struct iproc_pcie *pcie);
  76. +int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res);
  77. int iproc_pcie_remove(struct iproc_pcie *pcie);
  78. #endif /* _PCIE_IPROC_H */