Commit 8a8a9e89 authored by Sean Wang's avatar Sean Wang Committed by David S. Miller

net: ethernet: mediatek: cleanup error path inside mtk_hw_init

This cleans up the error path inside mtk_hw_init call, causing it able
to exit appropriately when something fails and also includes refactoring
mtk_cleanup call to make the partial logic reusable on the error path.
Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bf253fb7
...@@ -1567,17 +1567,36 @@ static void mtk_pending_work(struct work_struct *work) ...@@ -1567,17 +1567,36 @@ static void mtk_pending_work(struct work_struct *work)
rtnl_unlock(); rtnl_unlock();
} }
static int mtk_cleanup(struct mtk_eth *eth) static int mtk_free_dev(struct mtk_eth *eth)
{ {
int i; int i;
for (i = 0; i < MTK_MAC_COUNT; i++) { for (i = 0; i < MTK_MAC_COUNT; i++) {
if (!eth->netdev[i]) if (!eth->netdev[i])
continue; continue;
free_netdev(eth->netdev[i]);
}
return 0;
}
static int mtk_unreg_dev(struct mtk_eth *eth)
{
int i;
for (i = 0; i < MTK_MAC_COUNT; i++) {
if (!eth->netdev[i])
continue;
unregister_netdev(eth->netdev[i]); unregister_netdev(eth->netdev[i]);
free_netdev(eth->netdev[i]);
} }
return 0;
}
static int mtk_cleanup(struct mtk_eth *eth)
{
mtk_unreg_dev(eth);
mtk_free_dev(eth);
cancel_work_sync(&eth->pending_work); cancel_work_sync(&eth->pending_work);
return 0; return 0;
...@@ -1875,7 +1894,7 @@ static int mtk_probe(struct platform_device *pdev) ...@@ -1875,7 +1894,7 @@ static int mtk_probe(struct platform_device *pdev)
err = mtk_add_mac(eth, mac_np); err = mtk_add_mac(eth, mac_np);
if (err) if (err)
goto err_free_dev; goto err_deinit_hw;
} }
err = devm_request_irq(eth->dev, eth->irq[1], mtk_handle_irq_tx, 0, err = devm_request_irq(eth->dev, eth->irq[1], mtk_handle_irq_tx, 0,
...@@ -1899,7 +1918,7 @@ static int mtk_probe(struct platform_device *pdev) ...@@ -1899,7 +1918,7 @@ static int mtk_probe(struct platform_device *pdev)
err = register_netdev(eth->netdev[i]); err = register_netdev(eth->netdev[i]);
if (err) { if (err) {
dev_err(eth->dev, "error bringing up device\n"); dev_err(eth->dev, "error bringing up device\n");
goto err_free_dev; goto err_deinit_mdio;
} else } else
netif_info(eth, probe, eth->netdev[i], netif_info(eth, probe, eth->netdev[i],
"mediatek frame engine at 0x%08lx, irq %d\n", "mediatek frame engine at 0x%08lx, irq %d\n",
...@@ -1919,8 +1938,13 @@ static int mtk_probe(struct platform_device *pdev) ...@@ -1919,8 +1938,13 @@ static int mtk_probe(struct platform_device *pdev)
return 0; return 0;
err_deinit_mdio:
mtk_mdio_cleanup(eth);
err_free_dev: err_free_dev:
mtk_cleanup(eth); mtk_free_dev(eth);
err_deinit_hw:
mtk_hw_deinit(eth);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment