Skip to content

Commit 21d9c69

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 ae22157 commit 21d9c69

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
@@ -733,34 +733,14 @@ static void apple_pcie_disable_device(struct pci_host_bridge *bridge, struct pci
733733

734734
static int apple_pcie_init(struct pci_config_window *cfg)
735735
{
736+
struct apple_pcie *pcie = cfg->priv;
736737
struct device *dev = cfg->parent;
737-
struct platform_device *platform = to_platform_device(dev);
738-
struct apple_pcie *pcie;
739738
int ret;
740739

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

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

788794
static struct platform_driver apple_pcie_driver = {
789-
.probe = pci_host_common_probe,
795+
.probe = apple_pcie_probe,
790796
.driver = {
791797
.name = "pcie-apple",
792798
.of_match_table = apple_pcie_of_match,

0 commit comments

Comments
 (0)