diff mbox series

[net-next,41/54] net: ethernet: renesas: Convert to platform remove callback returning void

Message ID 20230918204227.1316886-42-u.kleine-koenig@pengutronix.de (mailing list archive)
State Accepted
Commit 0b4f04e2f60b435ff2457620551957418ac1ee0f
Delegated to: Netdev Maintainers
Headers show
Series net: ethernet: Convert to platform remove callback returning void | expand

Checks

Context Check Description
netdev/series_format fail Series longer than 15 patches (and no cover letter)
netdev/tree_selection success Clearly marked for net-next
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: 1378 this patch: 1378
netdev/cc_maintainers warning 1 maintainers not CCed: f.fainelli@gmail.com
netdev/build_clang success Errors and warnings before: 1363 this patch: 1363
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: 1401 this patch: 1401
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 70 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Uwe Kleine-König Sept. 18, 2023, 8:42 p.m. UTC
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.
To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new() which already returns void. Eventually after all drivers
are converted, .remove_new() is renamed to .remove().

Trivially convert these drivers from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/net/ethernet/renesas/ravb_main.c | 6 ++----
 drivers/net/ethernet/renesas/rswitch.c   | 6 ++----
 drivers/net/ethernet/renesas/sh_eth.c    | 6 ++----
 3 files changed, 6 insertions(+), 12 deletions(-)

Comments

Geert Uytterhoeven Sept. 19, 2023, 6:58 a.m. UTC | #1
On Mon, Sep 18, 2023 at 10:42 PM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is ignored (apart
> from emitting a warning) and this typically results in resource leaks.
> To improve here there is a quest to make the remove callback return
> void. In the first step of this quest all drivers are converted to
> .remove_new() which already returns void. Eventually after all drivers
> are converted, .remove_new() is renamed to .remove().
>
> Trivially convert these drivers from always returning zero in the remove
> callback to the void returning variant.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert
Sergey Shtylyov Sept. 19, 2023, 5:28 p.m. UTC | #2
Hello!

On 9/18/23 11:42 PM, Uwe Kleine-König wrote:

> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is ignored (apart
> from emitting a warning) and this typically results in resource leaks.
> To improve here there is a quest to make the remove callback return
> void. In the first step of this quest all drivers are converted to
> .remove_new() which already returns void. Eventually after all drivers
> are converted, .remove_new() is renamed to .remove().
> 
> Trivially convert these drivers from always returning zero in the remove
> callback to the void returning variant.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
[...]
> diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
> index ea9186178091..3c165b15709f 100644
> --- a/drivers/net/ethernet/renesas/rswitch.c
> +++ b/drivers/net/ethernet/renesas/rswitch.c

   Hm, I still need to do a patch clarifying that I don't do rswitch reviews --
I'm not familiar with that hardware and don't have the manuals ATM...

[...]

Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>

[...]

MBR, Sergey
Yoshihiro Shimoda Sept. 20, 2023, 12:02 a.m. UTC | #3
Hi Uwe,

> From: Uwe Kleine-König, Sent: Tuesday, September 19, 2023 5:42 AM
> 
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is ignored (apart
> from emitting a warning) and this typically results in resource leaks.
> To improve here there is a quest to make the remove callback return
> void. In the first step of this quest all drivers are converted to
> .remove_new() which already returns void. Eventually after all drivers
> are converted, .remove_new() is renamed to .remove().
> 
> Trivially convert these drivers from always returning zero in the remove
> callback to the void returning variant.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Thank you for the patch!

Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Best regards,
Yoshihiro Shimoda

> ---
>  drivers/net/ethernet/renesas/ravb_main.c | 6 ++----
>  drivers/net/ethernet/renesas/rswitch.c   | 6 ++----
>  drivers/net/ethernet/renesas/sh_eth.c    | 6 ++----
>  3 files changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 7df9f9f8e134..e62391180032 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -2878,7 +2878,7 @@ static int ravb_probe(struct platform_device *pdev)
>  	return error;
>  }
> 
> -static int ravb_remove(struct platform_device *pdev)
> +static void ravb_remove(struct platform_device *pdev)
>  {
>  	struct net_device *ndev = platform_get_drvdata(pdev);
>  	struct ravb_private *priv = netdev_priv(ndev);
> @@ -2905,8 +2905,6 @@ static int ravb_remove(struct platform_device *pdev)
>  	reset_control_assert(priv->rstc);
>  	free_netdev(ndev);
>  	platform_set_drvdata(pdev, NULL);
> -
> -	return 0;
>  }
> 
>  static int ravb_wol_setup(struct net_device *ndev)
> @@ -3044,7 +3042,7 @@ static const struct dev_pm_ops ravb_dev_pm_ops = {
> 
>  static struct platform_driver ravb_driver = {
>  	.probe		= ravb_probe,
> -	.remove		= ravb_remove,
> +	.remove_new	= ravb_remove,
>  	.driver = {
>  		.name	= "ravb",
>  		.pm	= &ravb_dev_pm_ops,
> diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
> index ea9186178091..3c165b15709f 100644
> --- a/drivers/net/ethernet/renesas/rswitch.c
> +++ b/drivers/net/ethernet/renesas/rswitch.c
> @@ -1968,7 +1968,7 @@ static void rswitch_deinit(struct rswitch_private *priv)
>  	rswitch_clock_disable(priv);
>  }
> 
> -static int renesas_eth_sw_remove(struct platform_device *pdev)
> +static void renesas_eth_sw_remove(struct platform_device *pdev)
>  {
>  	struct rswitch_private *priv = platform_get_drvdata(pdev);
> 
> @@ -1978,13 +1978,11 @@ static int renesas_eth_sw_remove(struct platform_device *pdev)
>  	pm_runtime_disable(&pdev->dev);
> 
>  	platform_set_drvdata(pdev, NULL);
> -
> -	return 0;
>  }
> 
>  static struct platform_driver renesas_eth_sw_driver_platform = {
>  	.probe = renesas_eth_sw_probe,
> -	.remove = renesas_eth_sw_remove,
> +	.remove_new = renesas_eth_sw_remove,
>  	.driver = {
>  		.name = "renesas_eth_sw",
>  		.of_match_table = renesas_eth_sw_of_table,
> diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
> index 274ea16c0a1f..475e1e8c1d35 100644
> --- a/drivers/net/ethernet/renesas/sh_eth.c
> +++ b/drivers/net/ethernet/renesas/sh_eth.c
> @@ -3431,7 +3431,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
>  	return ret;
>  }
> 
> -static int sh_eth_drv_remove(struct platform_device *pdev)
> +static void sh_eth_drv_remove(struct platform_device *pdev)
>  {
>  	struct net_device *ndev = platform_get_drvdata(pdev);
>  	struct sh_eth_private *mdp = netdev_priv(ndev);
> @@ -3441,8 +3441,6 @@ static int sh_eth_drv_remove(struct platform_device *pdev)
>  	sh_mdio_release(mdp);
>  	pm_runtime_disable(&pdev->dev);
>  	free_netdev(ndev);
> -
> -	return 0;
>  }
> 
>  #ifdef CONFIG_PM
> @@ -3562,7 +3560,7 @@ MODULE_DEVICE_TABLE(platform, sh_eth_id_table);
> 
>  static struct platform_driver sh_eth_driver = {
>  	.probe = sh_eth_drv_probe,
> -	.remove = sh_eth_drv_remove,
> +	.remove_new = sh_eth_drv_remove,
>  	.id_table = sh_eth_id_table,
>  	.driver = {
>  		   .name = CARDNAME,
> --
> 2.40.1
diff mbox series

Patch

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 7df9f9f8e134..e62391180032 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2878,7 +2878,7 @@  static int ravb_probe(struct platform_device *pdev)
 	return error;
 }
 
-static int ravb_remove(struct platform_device *pdev)
+static void ravb_remove(struct platform_device *pdev)
 {
 	struct net_device *ndev = platform_get_drvdata(pdev);
 	struct ravb_private *priv = netdev_priv(ndev);
@@ -2905,8 +2905,6 @@  static int ravb_remove(struct platform_device *pdev)
 	reset_control_assert(priv->rstc);
 	free_netdev(ndev);
 	platform_set_drvdata(pdev, NULL);
-
-	return 0;
 }
 
 static int ravb_wol_setup(struct net_device *ndev)
@@ -3044,7 +3042,7 @@  static const struct dev_pm_ops ravb_dev_pm_ops = {
 
 static struct platform_driver ravb_driver = {
 	.probe		= ravb_probe,
-	.remove		= ravb_remove,
+	.remove_new	= ravb_remove,
 	.driver = {
 		.name	= "ravb",
 		.pm	= &ravb_dev_pm_ops,
diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
index ea9186178091..3c165b15709f 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -1968,7 +1968,7 @@  static void rswitch_deinit(struct rswitch_private *priv)
 	rswitch_clock_disable(priv);
 }
 
-static int renesas_eth_sw_remove(struct platform_device *pdev)
+static void renesas_eth_sw_remove(struct platform_device *pdev)
 {
 	struct rswitch_private *priv = platform_get_drvdata(pdev);
 
@@ -1978,13 +1978,11 @@  static int renesas_eth_sw_remove(struct platform_device *pdev)
 	pm_runtime_disable(&pdev->dev);
 
 	platform_set_drvdata(pdev, NULL);
-
-	return 0;
 }
 
 static struct platform_driver renesas_eth_sw_driver_platform = {
 	.probe = renesas_eth_sw_probe,
-	.remove = renesas_eth_sw_remove,
+	.remove_new = renesas_eth_sw_remove,
 	.driver = {
 		.name = "renesas_eth_sw",
 		.of_match_table = renesas_eth_sw_of_table,
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 274ea16c0a1f..475e1e8c1d35 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -3431,7 +3431,7 @@  static int sh_eth_drv_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int sh_eth_drv_remove(struct platform_device *pdev)
+static void sh_eth_drv_remove(struct platform_device *pdev)
 {
 	struct net_device *ndev = platform_get_drvdata(pdev);
 	struct sh_eth_private *mdp = netdev_priv(ndev);
@@ -3441,8 +3441,6 @@  static int sh_eth_drv_remove(struct platform_device *pdev)
 	sh_mdio_release(mdp);
 	pm_runtime_disable(&pdev->dev);
 	free_netdev(ndev);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM
@@ -3562,7 +3560,7 @@  MODULE_DEVICE_TABLE(platform, sh_eth_id_table);
 
 static struct platform_driver sh_eth_driver = {
 	.probe = sh_eth_drv_probe,
-	.remove = sh_eth_drv_remove,
+	.remove_new = sh_eth_drv_remove,
 	.id_table = sh_eth_id_table,
 	.driver = {
 		   .name = CARDNAME,