PCI: host-generic: Move bridge allocation outside of pci_host_common_init()
Subsystems (4)
Marc Zyngier
maintainerPATCH v2 1/1 PCI: host-generic: Move bridge allocation outside of pci_host_common_init()
Having the host bridge allocation inside pci_host_common_init() results in a lot of complexity in the pcie-apple driver (the only direct user of this function outside of core PCI code).
It forces the allocation of driver-specific tracking structures outside of the bridge allocation, which in turn requires it to use inefficient data structures to match the bridge and the private structure as needed.
Instead, let the bridge structure be passed to pci_host_common_init(), allowing the driver to allocate it together with the private data, as it is usually intended. The driver can then retrieve the bridge via the owning device attached to the PCI config window structure. This allows the pcie-apple driver to be significantly simplified.
Both core and driver code are changed in one go to avoid going via a transitional interface.
---
Notes:
- Removed unused list_head from apple_pcie structure
- Fixed numerous typos
- Added Radu's RB
drivers/pci/controller/pci-host-common.c | 13 +++---- drivers/pci/controller/pci-host-common.h | 1 + drivers/pci/controller/pcie-apple.c | 43 ++++-------------------- 3 files changed, 14 insertions(+), 43 deletions(-)
drivers/pci/controller/pci-host-common.c +7 -6
@@ -53,16 +53,12 @@ struct pci_config_window *pci_host_common_ecam_create(struct device *dev,EXPORT_SYMBOL_GPL (pci_host_common_ecam_create);int pci_host_common_init (struct platform_device *pdev, +struct pci_host_bridge *bridge,const struct pci_ecam_ops *ops) {struct device *dev = &pdev->dev; -struct pci_host_bridge *bridge;struct pci_config_window *cfg; - bridge =devm_pci_alloc_host_bridge (dev,0 ); -if (!bridge) -return -ENOMEM ; -of_pci_check_probe_only ();platform_set_drvdata (pdev, bridge);
@@ -85,12 +81,17 @@ EXPORT_SYMBOL_GPL(pci_host_common_init);int pci_host_common_probe (struct platform_device *pdev) {const struct pci_ecam_ops *ops; +struct pci_host_bridge *bridge; ops =of_device_get_match_data (&pdev->dev);if (!ops)return -ENODEV ; -return pci_host_common_init (pdev, ops); + bridge =devm_pci_alloc_host_bridge (&pdev->dev,0 ); +if (!bridge) +return -ENOMEM ; + +return pci_host_common_init (pdev, bridge, ops); }EXPORT_SYMBOL_GPL (pci_host_common_probe);
drivers/pci/controller/pci-host-common.h +1 -0
@@ -14,6 +14,7 @@ struct pci_ecam_ops;int pci_host_common_probe (struct platform_device *pdev);int pci_host_common_init (struct platform_device *pdev, +struct pci_host_bridge *bridge,const struct pci_ecam_ops *ops);void pci_host_common_remove (struct platform_device *pdev);
drivers/pci/controller/pcie-apple.c +6 -37
80 lines not on this page · raw message
Signature · 1 line
2.47.3
Manivannan Sadhasivam
AppliedQuoted 9 lines · Marc Zyngier
Having the host bridge allocation inside
pci_host_common_init()results in a lot of complexity in the pcie-apple driver (the only direct user of this function outside of core PCI code).It forces the allocation of driver-specific tracking structures outside of the bridge allocation, which in turn requires it to use inefficient data structures to match the bridge and the private structure as needed.
[...]
Applied, thanks!
[1/1] PCI: host-generic: Move bridge allocation outside of pci_host_common_init()
commit: b1e24e05e1408602d3414b95031242bbaa72226a
Best regards,
Signature · 1 line
Manivannan Sadhasivam <[email protected]>