Skip to content

Commit e81d00a

Browse files
javiercarrascocruzdavem330
authored andcommitted
net: mvpp2: use port_count to remove ports
As discussed in [1], there is no need to iterate over child nodes to remove the list of ports. Instead, a loop up to `port_count` ports can be used, and is in fact more reliable in case the child node availability changes. The suggested approach removes the need for the `fwnode` and `port_fwnode` variables in mvpp2_remove() as well. Link: https://lore.kernel.org/all/ZqdRgDkK1PzoI2Pf@shell.armlinux.org.uk/ [1] Suggested-by: Russell King <linux@armlinux.org.uk> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 80d021b commit e81d00a

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7655,12 +7655,8 @@ static int mvpp2_probe(struct platform_device *pdev)
76557655
err_port_probe:
76567656
fwnode_handle_put(port_fwnode);
76577657

7658-
i = 0;
7659-
fwnode_for_each_available_child_node(fwnode, port_fwnode) {
7660-
if (priv->port_list[i])
7661-
mvpp2_port_remove(priv->port_list[i]);
7662-
i++;
7663-
}
7658+
for (i = 0; i < priv->port_count; i++)
7659+
mvpp2_port_remove(priv->port_list[i]);
76647660
err_axi_clk:
76657661
clk_disable_unprepare(priv->axi_clk);
76667662
err_mg_core_clk:
@@ -7677,18 +7673,13 @@ static int mvpp2_probe(struct platform_device *pdev)
76777673
static void mvpp2_remove(struct platform_device *pdev)
76787674
{
76797675
struct mvpp2 *priv = platform_get_drvdata(pdev);
7680-
struct fwnode_handle *fwnode = pdev->dev.fwnode;
7681-
int i = 0, poolnum = MVPP2_BM_POOLS_NUM;
7682-
struct fwnode_handle *port_fwnode;
7676+
int i, poolnum = MVPP2_BM_POOLS_NUM;
76837677

76847678
mvpp2_dbgfs_cleanup(priv);
76857679

7686-
fwnode_for_each_available_child_node(fwnode, port_fwnode) {
7687-
if (priv->port_list[i]) {
7688-
mutex_destroy(&priv->port_list[i]->gather_stats_lock);
7689-
mvpp2_port_remove(priv->port_list[i]);
7690-
}
7691-
i++;
7680+
for (i = 0; i < priv->port_count; i++) {
7681+
mutex_destroy(&priv->port_list[i]->gather_stats_lock);
7682+
mvpp2_port_remove(priv->port_list[i]);
76927683
}
76937684

76947685
destroy_workqueue(priv->stats_queue);
@@ -7711,7 +7702,7 @@ static void mvpp2_remove(struct platform_device *pdev)
77117702
aggr_txq->descs_dma);
77127703
}
77137704

7714-
if (is_acpi_node(port_fwnode))
7705+
if (!dev_of_node(&pdev->dev))
77157706
return;
77167707

77177708
clk_disable_unprepare(priv->axi_clk);

0 commit comments

Comments
 (0)