diff mbox series

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

Message ID 20241013213400.9627-1-rosenp@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [PATCHv2,net-next] net: bgmac: use devm for register_netdev | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-14--09-00 (tests: 777)

Commit Message

Rosen Penev Oct. 13, 2024, 9:34 p.m. UTC
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(-)

Comments

Heiner Kallweit Oct. 13, 2024, 10:09 p.m. UTC | #1
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);
diff mbox series

Patch

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);