[PATCHv2 net-next 03/10] net: lantiq_etop: use devm for register_netdev

From: Rosen Penev
Date: Tue Oct 01 2024 - 14:47:06 EST


This is the last to be created and so must be the first to be freed.
Simpler to avoid by using devm.

Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
Reviewed-by: Shannon Nelson <shannon.nelson@xxxxxxx>
---
drivers/net/ethernet/lantiq_etop.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
index de4f75ce8d9d..988f204fd89c 100644
--- a/drivers/net/ethernet/lantiq_etop.c
+++ b/drivers/net/ethernet/lantiq_etop.c
@@ -587,7 +587,7 @@ ltq_etop_init(struct net_device *dev)

err = ltq_etop_set_mac_address(dev, &mac);
if (err)
- goto err_netdev;
+ goto err_hw;

/* Set addr_assign_type here, ltq_etop_set_mac_address would reset it. */
if (random_mac)
@@ -596,11 +596,9 @@ ltq_etop_init(struct net_device *dev)
ltq_etop_set_multicast_list(dev);
err = ltq_etop_mdio_init(dev);
if (err)
- goto err_netdev;
+ goto err_hw;
return 0;

-err_netdev:
- unregister_netdev(dev);
err_hw:
ltq_etop_hw_exit(dev);
return err;
@@ -709,7 +707,7 @@ ltq_etop_probe(struct platform_device *pdev)
priv->ch[i].netdev = dev;
}

- err = register_netdev(dev);
+ err = devm_register_netdev(&pdev->dev, dev);
if (err)
goto err_out;

@@ -728,7 +726,6 @@ static void ltq_etop_remove(struct platform_device *pdev)
netif_tx_stop_all_queues(dev);
ltq_etop_hw_exit(dev);
ltq_etop_mdio_cleanup(dev);
- unregister_netdev(dev);
}
}

--
2.46.2