linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] reset: Convert to platform remove callback returning void
@ 2024-03-05 21:32 Uwe Kleine-König
  2024-03-05 21:32 ` [PATCH 1/3] reset: meson-audio-arb: " Uwe Kleine-König
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2024-03-05 21:32 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
	linux-arm-kernel, linux-amlogic, linux-kernel, Nishanth Menon,
	Tero Kristo, Santosh Shilimkar, kernel

Hello,

this series converts all platform drivers below drivers/reset to struct
platform_driver::remove_new(). See commit 5c5a7680e67b ("platform:
Provide a remove callback that returns no value") for an extended
explanation and the eventual goal.

All conversations are trivial, because their .remove() callbacks
returned zero unconditionally.

There are no interdependencies between these patches, so they could be
picked up individually. But I'd hope that they get picked up all
together by Philipp.

Best regards
Uwe

Uwe Kleine-König (3):
  reset: meson-audio-arb: Convert to platform remove callback returning void
  reset: rzg2l-usbphy-ctrl: Convert to platform remove callback returning void
  reset: ti-sci: Convert to platform remove callback returning void

 drivers/reset/reset-meson-audio-arb.c   | 6 ++----
 drivers/reset/reset-rzg2l-usbphy-ctrl.c | 6 ++----
 drivers/reset/reset-ti-sci.c            | 6 ++----
 3 files changed, 6 insertions(+), 12 deletions(-)

base-commit: 11afac187274a6177a7ac82997f8691c0f469e41
-- 
2.43.0


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

* [PATCH 1/3] reset: meson-audio-arb: Convert to platform remove callback returning void
  2024-03-05 21:32 [PATCH 0/3] reset: Convert to platform remove callback returning void Uwe Kleine-König
@ 2024-03-05 21:32 ` Uwe Kleine-König
  2024-03-05 21:32 ` [PATCH 2/3] reset: rzg2l-usbphy-ctrl: " Uwe Kleine-König
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2024-03-05 21:32 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
	linux-arm-kernel, linux-amlogic, linux-kernel, 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 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() will be renamed to .remove().

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/reset/reset-meson-audio-arb.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/reset/reset-meson-audio-arb.c b/drivers/reset/reset-meson-audio-arb.c
index 7891d52fa899..8740f5f6abf8 100644
--- a/drivers/reset/reset-meson-audio-arb.c
+++ b/drivers/reset/reset-meson-audio-arb.c
@@ -120,7 +120,7 @@ static const struct of_device_id meson_audio_arb_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, meson_audio_arb_of_match);
 
-static int meson_audio_arb_remove(struct platform_device *pdev)
+static void meson_audio_arb_remove(struct platform_device *pdev)
 {
 	struct meson_audio_arb_data *arb = platform_get_drvdata(pdev);
 
@@ -130,8 +130,6 @@ static int meson_audio_arb_remove(struct platform_device *pdev)
 	spin_unlock(&arb->lock);
 
 	clk_disable_unprepare(arb->clk);
-
-	return 0;
 }
 
 static int meson_audio_arb_probe(struct platform_device *pdev)
@@ -189,7 +187,7 @@ static int meson_audio_arb_probe(struct platform_device *pdev)
 
 static struct platform_driver meson_audio_arb_pdrv = {
 	.probe = meson_audio_arb_probe,
-	.remove = meson_audio_arb_remove,
+	.remove_new = meson_audio_arb_remove,
 	.driver = {
 		.name = "meson-audio-arb-reset",
 		.of_match_table = meson_audio_arb_of_match,
-- 
2.43.0


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

* [PATCH 2/3] reset: rzg2l-usbphy-ctrl: Convert to platform remove callback returning void
  2024-03-05 21:32 [PATCH 0/3] reset: Convert to platform remove callback returning void Uwe Kleine-König
  2024-03-05 21:32 ` [PATCH 1/3] reset: meson-audio-arb: " Uwe Kleine-König
@ 2024-03-05 21:32 ` Uwe Kleine-König
  2024-03-05 21:32 ` [PATCH 3/3] reset: ti-sci: " Uwe Kleine-König
  2024-03-12  8:47 ` [PATCH 0/3] reset: " Philipp Zabel
  3 siblings, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2024-03-05 21:32 UTC (permalink / raw)
  To: Philipp Zabel; +Cc: linux-kernel, 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 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() will be renamed to .remove().

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/reset/reset-rzg2l-usbphy-ctrl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/reset/reset-rzg2l-usbphy-ctrl.c b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
index a8dde4606360..8f6fbd978591 100644
--- a/drivers/reset/reset-rzg2l-usbphy-ctrl.c
+++ b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
@@ -156,15 +156,13 @@ static int rzg2l_usbphy_ctrl_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int rzg2l_usbphy_ctrl_remove(struct platform_device *pdev)
+static void rzg2l_usbphy_ctrl_remove(struct platform_device *pdev)
 {
 	struct rzg2l_usbphy_ctrl_priv *priv = dev_get_drvdata(&pdev->dev);
 
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 	reset_control_assert(priv->rstc);
-
-	return 0;
 }
 
 static struct platform_driver rzg2l_usbphy_ctrl_driver = {
@@ -173,7 +171,7 @@ static struct platform_driver rzg2l_usbphy_ctrl_driver = {
 		.of_match_table	= rzg2l_usbphy_ctrl_match_table,
 	},
 	.probe	= rzg2l_usbphy_ctrl_probe,
-	.remove	= rzg2l_usbphy_ctrl_remove,
+	.remove_new = rzg2l_usbphy_ctrl_remove,
 };
 module_platform_driver(rzg2l_usbphy_ctrl_driver);
 
-- 
2.43.0


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

* [PATCH 3/3] reset: ti-sci: Convert to platform remove callback returning void
  2024-03-05 21:32 [PATCH 0/3] reset: Convert to platform remove callback returning void Uwe Kleine-König
  2024-03-05 21:32 ` [PATCH 1/3] reset: meson-audio-arb: " Uwe Kleine-König
  2024-03-05 21:32 ` [PATCH 2/3] reset: rzg2l-usbphy-ctrl: " Uwe Kleine-König
@ 2024-03-05 21:32 ` Uwe Kleine-König
  2024-03-06 20:49   ` Nishanth Menon
  2024-03-12  8:47 ` [PATCH 0/3] reset: " Philipp Zabel
  3 siblings, 1 reply; 7+ messages in thread
From: Uwe Kleine-König @ 2024-03-05 21:32 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Nishanth Menon, Tero Kristo, Santosh Shilimkar, linux-arm-kernel,
	linux-kernel, 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 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() will be renamed to .remove().

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/reset/reset-ti-sci.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/reset/reset-ti-sci.c b/drivers/reset/reset-ti-sci.c
index cc01fa5b0bea..d384da0982fa 100644
--- a/drivers/reset/reset-ti-sci.c
+++ b/drivers/reset/reset-ti-sci.c
@@ -235,20 +235,18 @@ static int ti_sci_reset_probe(struct platform_device *pdev)
 	return reset_controller_register(&data->rcdev);
 }
 
-static int ti_sci_reset_remove(struct platform_device *pdev)
+static void ti_sci_reset_remove(struct platform_device *pdev)
 {
 	struct ti_sci_reset_data *data = platform_get_drvdata(pdev);
 
 	reset_controller_unregister(&data->rcdev);
 
 	idr_destroy(&data->idr);
-
-	return 0;
 }
 
 static struct platform_driver ti_sci_reset_driver = {
 	.probe = ti_sci_reset_probe,
-	.remove = ti_sci_reset_remove,
+	.remove_new = ti_sci_reset_remove,
 	.driver = {
 		.name = "ti-sci-reset",
 		.of_match_table = ti_sci_reset_of_match,
-- 
2.43.0


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

* Re: [PATCH 3/3] reset: ti-sci: Convert to platform remove callback returning void
  2024-03-05 21:32 ` [PATCH 3/3] reset: ti-sci: " Uwe Kleine-König
@ 2024-03-06 20:49   ` Nishanth Menon
  0 siblings, 0 replies; 7+ messages in thread
From: Nishanth Menon @ 2024-03-06 20:49 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Philipp Zabel, Tero Kristo, Santosh Shilimkar, linux-arm-kernel,
	linux-kernel, kernel

On 22:32-20240305, 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() will be renamed to .remove().
> 
> 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>
> ---

Thanks.

Reviewed-by: Nishanth Menon <nm@ti.com>

>  drivers/reset/reset-ti-sci.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/reset/reset-ti-sci.c b/drivers/reset/reset-ti-sci.c
> index cc01fa5b0bea..d384da0982fa 100644
> --- a/drivers/reset/reset-ti-sci.c
> +++ b/drivers/reset/reset-ti-sci.c
> @@ -235,20 +235,18 @@ static int ti_sci_reset_probe(struct platform_device *pdev)
>  	return reset_controller_register(&data->rcdev);
>  }
>  
> -static int ti_sci_reset_remove(struct platform_device *pdev)
> +static void ti_sci_reset_remove(struct platform_device *pdev)
>  {
>  	struct ti_sci_reset_data *data = platform_get_drvdata(pdev);
>  
>  	reset_controller_unregister(&data->rcdev);
>  
>  	idr_destroy(&data->idr);
> -
> -	return 0;
>  }
>  
>  static struct platform_driver ti_sci_reset_driver = {
>  	.probe = ti_sci_reset_probe,
> -	.remove = ti_sci_reset_remove,
> +	.remove_new = ti_sci_reset_remove,
>  	.driver = {
>  		.name = "ti-sci-reset",
>  		.of_match_table = ti_sci_reset_of_match,
> -- 
> 2.43.0
> 

-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D

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

* Re: [PATCH 0/3] reset: Convert to platform remove callback returning void
  2024-03-05 21:32 [PATCH 0/3] reset: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (2 preceding siblings ...)
  2024-03-05 21:32 ` [PATCH 3/3] reset: ti-sci: " Uwe Kleine-König
@ 2024-03-12  8:47 ` Philipp Zabel
  2024-05-25 10:14   ` Uwe Kleine-König
  3 siblings, 1 reply; 7+ messages in thread
From: Philipp Zabel @ 2024-03-12  8:47 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
	linux-arm-kernel, linux-amlogic, linux-kernel, Nishanth Menon,
	Tero Kristo, Santosh Shilimkar, kernel

On Di, 2024-03-05 at 22:32 +0100, Uwe Kleine-König wrote:
> Hello,
> 
> this series converts all platform drivers below drivers/reset to struct
> platform_driver::remove_new(). See commit 5c5a7680e67b ("platform:
> Provide a remove callback that returns no value") for an extended
> explanation and the eventual goal.
> 
> All conversations are trivial, because their .remove() callbacks
> returned zero unconditionally.
> 
> There are no interdependencies between these patches, so they could be
> picked up individually. But I'd hope that they get picked up all
> together by Philipp.

Thank you, I'll pick them up.

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp

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

* Re: [PATCH 0/3] reset: Convert to platform remove callback returning void
  2024-03-12  8:47 ` [PATCH 0/3] reset: " Philipp Zabel
@ 2024-05-25 10:14   ` Uwe Kleine-König
  0 siblings, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2024-05-25 10:14 UTC (permalink / raw)
  To: Philipp Zabel, Greg Kroah-Hartman
  Cc: Nishanth Menon, Neil Armstrong, Tero Kristo, Martin Blumenstingl,
	Kevin Hilman, linux-kernel, kernel, Santosh Shilimkar,
	linux-amlogic, linux-arm-kernel, Jerome Brunet

[-- Attachment #1: Type: text/plain, Size: 1348 bytes --]

Hello Philipp,

On Tue, Mar 12, 2024 at 09:47:24AM +0100, Philipp Zabel wrote:
> On Di, 2024-03-05 at 22:32 +0100, Uwe Kleine-König wrote:
> > this series converts all platform drivers below drivers/reset to struct
> > platform_driver::remove_new(). See commit 5c5a7680e67b ("platform:
> > Provide a remove callback that returns no value") for an extended
> > explanation and the eventual goal.
> > 
> > All conversations are trivial, because their .remove() callbacks
> > returned zero unconditionally.
> > 
> > There are no interdependencies between these patches, so they could be
> > picked up individually. But I'd hope that they get picked up all
> > together by Philipp.
> 
> Thank you, I'll pick them up.
> 
> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

These patches made it into next (as v6.9-rc1..6d89df61650d), but not yet
into Linus's tree for v6.10-rc1. I intend to send a PR to Greg early
next week changing platform_driver::remove to match remove_new to cook
long in next for v6.11-rc1. If these reset commits don't make it in in time,
I'll be so bold and just include the commits from your for-next branch
in my PR.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2024-05-25 10:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-05 21:32 [PATCH 0/3] reset: Convert to platform remove callback returning void Uwe Kleine-König
2024-03-05 21:32 ` [PATCH 1/3] reset: meson-audio-arb: " Uwe Kleine-König
2024-03-05 21:32 ` [PATCH 2/3] reset: rzg2l-usbphy-ctrl: " Uwe Kleine-König
2024-03-05 21:32 ` [PATCH 3/3] reset: ti-sci: " Uwe Kleine-König
2024-03-06 20:49   ` Nishanth Menon
2024-03-12  8:47 ` [PATCH 0/3] reset: " Philipp Zabel
2024-05-25 10:14   ` 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).