Skip to content

Commit 4785591

Browse files
Marc ZyngierMani-Sadhasivam
authored andcommitted
PCI: apple: Move over to standalone probing
Now that we have the required infrastructure, split the Apple PCIe setup into two categories: - stuff that has to do with PCI setup stays in the .init() callback - stuff that is just driver gunk (such as MSI setup) goes into a probe routine, which will eventually call into the host-common code The result is a far more logical setup process. Signed-off-by: Marc Zyngier <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Tested-by: Janne Grunau <[email protected]> Reviewed-by: Rob Herring (Arm) <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Acked-by: Alyssa Rosenzweig <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 4900454 commit 4785591

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed

drivers/pci/controller/pcie-apple.c

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -730,34 +730,14 @@ static void apple_pcie_disable_device(struct pci_host_bridge *bridge, struct pci
730730

731731
static int apple_pcie_init(struct pci_config_window *cfg)
732732
{
733+
struct apple_pcie *pcie = cfg->priv;
733734
struct device *dev = cfg->parent;
734-
struct platform_device *platform = to_platform_device(dev);
735-
struct apple_pcie *pcie;
736735
int ret;
737736

738-
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
739-
if (!pcie)
740-
return -ENOMEM;
741-
742-
pcie->dev = dev;
743-
744-
mutex_init(&pcie->lock);
745-
746-
pcie->base = devm_platform_ioremap_resource(platform, 1);
747-
if (IS_ERR(pcie->base))
748-
return PTR_ERR(pcie->base);
749-
750-
cfg->priv = pcie;
751-
INIT_LIST_HEAD(&pcie->ports);
752-
753-
ret = apple_msi_init(pcie);
754-
if (ret)
755-
return ret;
756-
757737
for_each_available_child_of_node_scoped(dev->of_node, of_port) {
758738
ret = apple_pcie_setup_port(pcie, of_port);
759739
if (ret) {
760-
dev_err(pcie->dev, "Port %pOF setup fail: %d\n", of_port, ret);
740+
dev_err(dev, "Port %pOF setup fail: %d\n", of_port, ret);
761741
return ret;
762742
}
763743
}
@@ -776,14 +756,40 @@ static const struct pci_ecam_ops apple_pcie_cfg_ecam_ops = {
776756
}
777757
};
778758

759+
static int apple_pcie_probe(struct platform_device *pdev)
760+
{
761+
struct device *dev = &pdev->dev;
762+
struct apple_pcie *pcie;
763+
int ret;
764+
765+
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
766+
if (!pcie)
767+
return -ENOMEM;
768+
769+
pcie->dev = dev;
770+
pcie->base = devm_platform_ioremap_resource(pdev, 1);
771+
if (IS_ERR(pcie->base))
772+
return PTR_ERR(pcie->base);
773+
774+
mutex_init(&pcie->lock);
775+
INIT_LIST_HEAD(&pcie->ports);
776+
dev_set_drvdata(dev, pcie);
777+
778+
ret = apple_msi_init(pcie);
779+
if (ret)
780+
return ret;
781+
782+
return pci_host_common_init(pdev, &apple_pcie_cfg_ecam_ops);
783+
}
784+
779785
static const struct of_device_id apple_pcie_of_match[] = {
780-
{ .compatible = "apple,pcie", .data = &apple_pcie_cfg_ecam_ops },
786+
{ .compatible = "apple,pcie" },
781787
{ }
782788
};
783789
MODULE_DEVICE_TABLE(of, apple_pcie_of_match);
784790

785791
static struct platform_driver apple_pcie_driver = {
786-
.probe = pci_host_common_probe,
792+
.probe = apple_pcie_probe,
787793
.driver = {
788794
.name = "pcie-apple",
789795
.of_match_table = apple_pcie_of_match,

0 commit comments

Comments
 (0)