[PATCHv2 net-next] net: bgmac: use devm for register_netdev

Rosen Penev posted 1 patch 1 month, 2 weeks ago
drivers/net/ethernet/broadcom/bgmac.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCHv2 net-next] net: bgmac: use devm for register_netdev
Posted by Rosen Penev 1 month, 2 weeks ago
Removes need to unregister in _remove.

Tested on ASUS RT-N16. No change in behavior.

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Tested-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 v2: added reviewed/tested-by broadcom.
 drivers/net/ethernet/broadcom/bgmac.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index 6ffdc4229407..2599ffe46e27 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -1546,7 +1546,7 @@ int bgmac_enet_probe(struct bgmac *bgmac)
 
 	bgmac->in_init = false;
 
-	err = register_netdev(bgmac->net_dev);
+	err = devm_register_netdev(bgmac->dev, bgmac->net_dev);
 	if (err) {
 		dev_err(bgmac->dev, "Cannot register net device\n");
 		goto err_phy_disconnect;
@@ -1568,7 +1568,6 @@ EXPORT_SYMBOL_GPL(bgmac_enet_probe);
 
 void bgmac_enet_remove(struct bgmac *bgmac)
 {
-	unregister_netdev(bgmac->net_dev);
 	phy_disconnect(bgmac->net_dev->phydev);
 	netif_napi_del(&bgmac->napi);
 	bgmac_dma_free(bgmac);
-- 
2.47.0
Re: [PATCHv2 net-next] net: bgmac: use devm for register_netdev
Posted by Heiner Kallweit 1 month, 2 weeks ago
On 13.10.2024 23:34, Rosen Penev wrote:
> Removes need to unregister in _remove.
> 
> Tested on ASUS RT-N16. No change in behavior.
> 
This patch changes the order of calls. unregister_netdev() is now called
only after remove(). Shouldn't there be some words about why this is safe
and doesn't e.g. possibly result in race windows?

> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
> Tested-by: Florian Fainelli <florian.fainelli@broadcom.com>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  v2: added reviewed/tested-by broadcom.
>  drivers/net/ethernet/broadcom/bgmac.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
> index 6ffdc4229407..2599ffe46e27 100644
> --- a/drivers/net/ethernet/broadcom/bgmac.c
> +++ b/drivers/net/ethernet/broadcom/bgmac.c
> @@ -1546,7 +1546,7 @@ int bgmac_enet_probe(struct bgmac *bgmac)
>  
>  	bgmac->in_init = false;
>  
> -	err = register_netdev(bgmac->net_dev);
> +	err = devm_register_netdev(bgmac->dev, bgmac->net_dev);
>  	if (err) {
>  		dev_err(bgmac->dev, "Cannot register net device\n");
>  		goto err_phy_disconnect;
> @@ -1568,7 +1568,6 @@ EXPORT_SYMBOL_GPL(bgmac_enet_probe);
>  
>  void bgmac_enet_remove(struct bgmac *bgmac)
>  {
> -	unregister_netdev(bgmac->net_dev);
>  	phy_disconnect(bgmac->net_dev->phydev);
>  	netif_napi_del(&bgmac->napi);
>  	bgmac_dma_free(bgmac);