Skip to content

Commit

Permalink
PCI: mvebu: increment nports only for registered ports
Browse files Browse the repository at this point in the history
The number of ports is probed by counting the number of available child nodes.
Later on, the registration of a port can fail and cause a mismatch between
the ->nports counter and registered ports. This patch modifies the counting
strategy, to make ->nports represent the number of registered ports instead
of the number of available childs.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
  • Loading branch information
Sebastian Hesselbarth authored and Jason Cooper committed Sep 30, 2013
1 parent b42285f commit bf09b6a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/pci/host/pci-mvebu.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,13 +842,14 @@ static int __init mvebu_pcie_probe(struct platform_device *pdev)
return ret;
}

i = 0;
for_each_child_of_node(pdev->dev.of_node, child) {
if (!of_device_is_available(child))
continue;
pcie->nports++;
i++;
}

pcie->ports = devm_kzalloc(&pdev->dev, pcie->nports *
pcie->ports = devm_kzalloc(&pdev->dev, i *
sizeof(struct mvebu_pcie_port),
GFP_KERNEL);
if (!pcie->ports)
Expand Down Expand Up @@ -935,8 +936,8 @@ static int __init mvebu_pcie_probe(struct platform_device *pdev)
i++;
}

pcie->nports = i;
mvebu_pcie_msi_enable(pcie);

mvebu_pcie_enable(pcie);

return 0;
Expand Down

0 comments on commit bf09b6a

Please sign in to comment.