openbmc.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 03/87] spi: aspeed-smc: Convert to platform remove callback returning void
       [not found] <20230303172041.2103336-1-u.kleine-koenig@pengutronix.de>
@ 2023-03-03 17:19 ` Uwe Kleine-König
  2023-03-03 21:52   ` Cédric Le Goater
  2023-03-03 17:19 ` [PATCH 45/87] spi: npcm-fiu: " Uwe Kleine-König
  2023-03-03 17:20 ` [PATCH 46/87] spi: npcm-pspi: " Uwe Kleine-König
  2 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2023-03-03 17:19 UTC (permalink / raw)
  To: Chin-Ting Kuo, Cédric Le Goater, Mark Brown, Joel Stanley
  Cc: linux-aspeed, Andrew Jeffery, openbmc, linux-spi, kernel,
	linux-arm-kernel

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 (mostly) ignored
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.

Trivially convert this driver 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/spi/spi-aspeed-smc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
index 873ff2cf72c9..3f2548860317 100644
--- a/drivers/spi/spi-aspeed-smc.c
+++ b/drivers/spi/spi-aspeed-smc.c
@@ -787,13 +787,12 @@ static int aspeed_spi_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int aspeed_spi_remove(struct platform_device *pdev)
+static void aspeed_spi_remove(struct platform_device *pdev)
 {
 	struct aspeed_spi *aspi = platform_get_drvdata(pdev);
 
 	aspeed_spi_enable(aspi, false);
 	clk_disable_unprepare(aspi->clk);
-	return 0;
 }
 
 /*
@@ -1201,7 +1200,7 @@ MODULE_DEVICE_TABLE(of, aspeed_spi_matches);
 
 static struct platform_driver aspeed_spi_driver = {
 	.probe			= aspeed_spi_probe,
-	.remove			= aspeed_spi_remove,
+	.remove_new		= aspeed_spi_remove,
 	.driver	= {
 		.name		= DEVICE_NAME,
 		.of_match_table = aspeed_spi_matches,
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 45/87] spi: npcm-fiu: Convert to platform remove callback returning void
       [not found] <20230303172041.2103336-1-u.kleine-koenig@pengutronix.de>
  2023-03-03 17:19 ` [PATCH 03/87] spi: aspeed-smc: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-03-03 17:19 ` Uwe Kleine-König
  2023-03-03 17:20 ` [PATCH 46/87] spi: npcm-pspi: " Uwe Kleine-König
  2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2023-03-03 17:19 UTC (permalink / raw)
  To: Avi Fishman, Tomer Maimon, Tali Perry, Mark Brown
  Cc: Benjamin Fair, Patrick Venture, openbmc, linux-spi, kernel

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 (mostly) ignored
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.

Trivially convert this driver 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/spi/spi-npcm-fiu.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-npcm-fiu.c b/drivers/spi/spi-npcm-fiu.c
index 559d3a5b4062..8d7698d167ef 100644
--- a/drivers/spi/spi-npcm-fiu.c
+++ b/drivers/spi/spi-npcm-fiu.c
@@ -762,12 +762,11 @@ static int npcm_fiu_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int npcm_fiu_remove(struct platform_device *pdev)
+static void npcm_fiu_remove(struct platform_device *pdev)
 {
 	struct npcm_fiu_spi *fiu = platform_get_drvdata(pdev);
 
 	clk_disable_unprepare(fiu->clk);
-	return 0;
 }
 
 MODULE_DEVICE_TABLE(of, npcm_fiu_dt_ids);
@@ -779,7 +778,7 @@ static struct platform_driver npcm_fiu_driver = {
 		.of_match_table = npcm_fiu_dt_ids,
 	},
 	.probe      = npcm_fiu_probe,
-	.remove	    = npcm_fiu_remove,
+	.remove_new	    = npcm_fiu_remove,
 };
 module_platform_driver(npcm_fiu_driver);
 
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 46/87] spi: npcm-pspi: Convert to platform remove callback returning void
       [not found] <20230303172041.2103336-1-u.kleine-koenig@pengutronix.de>
  2023-03-03 17:19 ` [PATCH 03/87] spi: aspeed-smc: Convert to platform remove callback returning void Uwe Kleine-König
  2023-03-03 17:19 ` [PATCH 45/87] spi: npcm-fiu: " Uwe Kleine-König
@ 2023-03-03 17:20 ` Uwe Kleine-König
  2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2023-03-03 17:20 UTC (permalink / raw)
  To: Avi Fishman, Tomer Maimon, Tali Perry, Mark Brown
  Cc: Benjamin Fair, Patrick Venture, openbmc, linux-spi, kernel

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 (mostly) ignored
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.

Trivially convert this driver 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/spi/spi-npcm-pspi.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-npcm-pspi.c b/drivers/spi/spi-npcm-pspi.c
index 7f2e4d1b0d43..64585c2a25c5 100644
--- a/drivers/spi/spi-npcm-pspi.c
+++ b/drivers/spi/spi-npcm-pspi.c
@@ -430,15 +430,13 @@ static int npcm_pspi_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int npcm_pspi_remove(struct platform_device *pdev)
+static void npcm_pspi_remove(struct platform_device *pdev)
 {
 	struct spi_master *master = platform_get_drvdata(pdev);
 	struct npcm_pspi *priv = spi_master_get_devdata(master);
 
 	npcm_pspi_reset_hw(priv);
 	clk_disable_unprepare(priv->clk);
-
-	return 0;
 }
 
 static const struct of_device_id npcm_pspi_match[] = {
@@ -454,7 +452,7 @@ static struct platform_driver npcm_pspi_driver = {
 		.of_match_table	= npcm_pspi_match,
 	},
 	.probe		= npcm_pspi_probe,
-	.remove		= npcm_pspi_remove,
+	.remove_new	= npcm_pspi_remove,
 };
 module_platform_driver(npcm_pspi_driver);
 
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 03/87] spi: aspeed-smc: Convert to platform remove callback returning void
  2023-03-03 17:19 ` [PATCH 03/87] spi: aspeed-smc: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-03-03 21:52   ` Cédric Le Goater
  0 siblings, 0 replies; 4+ messages in thread
From: Cédric Le Goater @ 2023-03-03 21:52 UTC (permalink / raw)
  To: Uwe Kleine-König, Chin-Ting Kuo, Mark Brown, Joel Stanley
  Cc: linux-aspeed, Andrew Jeffery, openbmc, linux-spi, kernel,
	linux-arm-kernel

On 3/3/23 18:19, 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 (mostly) ignored
> 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.
> 
> Trivially convert this driver 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>

Acked-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.

> ---
>   drivers/spi/spi-aspeed-smc.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
> index 873ff2cf72c9..3f2548860317 100644
> --- a/drivers/spi/spi-aspeed-smc.c
> +++ b/drivers/spi/spi-aspeed-smc.c
> @@ -787,13 +787,12 @@ static int aspeed_spi_probe(struct platform_device *pdev)
>   	return ret;
>   }
>   
> -static int aspeed_spi_remove(struct platform_device *pdev)
> +static void aspeed_spi_remove(struct platform_device *pdev)
>   {
>   	struct aspeed_spi *aspi = platform_get_drvdata(pdev);
>   
>   	aspeed_spi_enable(aspi, false);
>   	clk_disable_unprepare(aspi->clk);
> -	return 0;
>   }
>   
>   /*
> @@ -1201,7 +1200,7 @@ MODULE_DEVICE_TABLE(of, aspeed_spi_matches);
>   
>   static struct platform_driver aspeed_spi_driver = {
>   	.probe			= aspeed_spi_probe,
> -	.remove			= aspeed_spi_remove,
> +	.remove_new		= aspeed_spi_remove,
>   	.driver	= {
>   		.name		= DEVICE_NAME,
>   		.of_match_table = aspeed_spi_matches,


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-03-03 22:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20230303172041.2103336-1-u.kleine-koenig@pengutronix.de>
2023-03-03 17:19 ` [PATCH 03/87] spi: aspeed-smc: Convert to platform remove callback returning void Uwe Kleine-König
2023-03-03 21:52   ` Cédric Le Goater
2023-03-03 17:19 ` [PATCH 45/87] spi: npcm-fiu: " Uwe Kleine-König
2023-03-03 17:20 ` [PATCH 46/87] spi: npcm-pspi: " Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).