summaryrefslogtreecommitdiff
path: root/drivers/pci/controller/pci-host-common.c
diff options
context:
space:
mode:
authorMarc Zyngier <maz@kernel.org>2025-11-25 10:27:26 +0000
committerManivannan Sadhasivam <mani@kernel.org>2025-11-25 19:39:42 +0530
commitb1e24e05e1408602d3414b95031242bbaa72226a (patch)
tree8f27671f01c6d1d3b1f7c5dd76a09a282e7752df /drivers/pci/controller/pci-host-common.c
parent3a8660878839faadb4f1a6dd72c3179c1df56787 (diff)
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. Signed-off-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Reviewed-by: Radu Rendec <rrendec@redhat.com> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: Manivannan Sadhasivam <mani@kernel.org> Cc: Rob Herring <robh@kernel.org> Cc: Krzysztof WilczyƄski <kwilczynski@kernel.org> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org> Link: https://lore.kernel.org/r/86jyzms036.wl-maz@kernel.org Link: https://patch.msgid.link/20251125102726.865617-1-maz@kernel.org
Diffstat (limited to 'drivers/pci/controller/pci-host-common.c')
-rw-r--r--drivers/pci/controller/pci-host-common.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/controller/pci-host-common.c
index 810d1c8de24e..c473e7c03bac 100644
--- a/drivers/pci/controller/pci-host-common.c
+++ b/drivers/pci/controller/pci-host-common.c
@@ -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);