net: bcmasp: streamline early exit in probe

Streamline the bcmasp_probe early exit. As support for other
functionality is added(i.e. ptp), it is easier to keep track of early
exit cleanup when it is all in one place.

Signed-off-by: Justin Chen <justin.chen@broadcom.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20260122194949.1145107-3-justin.chen@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Justin Chen 2026-01-22 11:49:49 -08:00 committed by Jakub Kicinski
parent 9271fc3190
commit 1fd1281250

View File

@ -1317,6 +1317,8 @@ static int bcmasp_probe(struct platform_device *pdev)
bcmasp_core_init_filters(priv);
bcmasp_init_wol(priv);
ports_node = of_find_node_by_name(dev->of_node, "ethernet-ports");
if (!ports_node) {
dev_warn(dev, "No ports found\n");
@ -1328,16 +1330,14 @@ static int bcmasp_probe(struct platform_device *pdev)
intf = bcmasp_interface_create(priv, intf_node, i);
if (!intf) {
dev_err(dev, "Cannot create eth interface %d\n", i);
bcmasp_remove_intfs(priv);
ret = -ENOMEM;
goto of_put_exit;
of_node_put(ports_node);
ret = -EINVAL;
goto err_cleanup;
}
list_add_tail(&intf->list, &priv->intfs);
i++;
}
/* Check and enable WoL */
bcmasp_init_wol(priv);
of_node_put(ports_node);
/* Drop the clock reference count now and let ndo_open()/ndo_close()
* manage it for us from now on.
@ -1352,19 +1352,20 @@ static int bcmasp_probe(struct platform_device *pdev)
list_for_each_entry(intf, &priv->intfs, list) {
ret = register_netdev(intf->ndev);
if (ret) {
netdev_err(intf->ndev,
"failed to register net_device: %d\n", ret);
bcmasp_wol_irq_destroy(priv);
bcmasp_remove_intfs(priv);
goto of_put_exit;
dev_err(dev, "failed to register net_device: %d\n", ret);
goto err_cleanup;
}
count++;
}
dev_info(dev, "Initialized %d port(s)\n", count);
of_put_exit:
of_node_put(ports_node);
return ret;
err_cleanup:
bcmasp_wol_irq_destroy(priv);
bcmasp_remove_intfs(priv);
return ret;
}