Skip to content

Commit 103ec2b

Browse files
Marc Zyngierjannau
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 <maz@kernel.org>
1 parent 1012fb7 commit 103ec2b

1 file changed

Lines changed: 30 additions & 24 deletions

File tree

drivers/pci/controller/pcie-apple.c

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -730,35 +730,15 @@ 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);
735735
struct device_node *of_port;
736-
struct apple_pcie *pcie;
737736
int ret;
738737

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

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

787793
static struct platform_driver apple_pcie_driver = {
788-
.probe = pci_host_common_probe,
794+
.probe = apple_pcie_probe,
789795
.driver = {
790796
.name = "pcie-apple",
791797
.of_match_table = apple_pcie_of_match,

0 commit comments

Comments
 (0)