Linux-Rockchip Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 119/173] ASoC: rockchip: rockchip_i2s: Convert to platform remove callback returning void
       [not found] <20230315150745.67084-1-u.kleine-koenig@pengutronix.de>
@ 2023-03-15 15:06 ` Uwe Kleine-König
  2023-03-15 15:06 ` [PATCH 120/173] ASoC: rockchip: rockchip_i2s_tdm: " Uwe Kleine-König
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2023-03-15 15:06 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Heiko Stuebner
  Cc: alsa-devel, linux-arm-kernel, linux-rockchip, 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>
---
 sound/soc/rockchip/rockchip_i2s.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
index a8758ad68442..79abec24a5a2 100644
--- a/sound/soc/rockchip/rockchip_i2s.c
+++ b/sound/soc/rockchip/rockchip_i2s.c
@@ -850,7 +850,7 @@ static int rockchip_i2s_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int rockchip_i2s_remove(struct platform_device *pdev)
+static void rockchip_i2s_remove(struct platform_device *pdev)
 {
 	struct rk_i2s_dev *i2s = dev_get_drvdata(&pdev->dev);
 
@@ -859,8 +859,6 @@ static int rockchip_i2s_remove(struct platform_device *pdev)
 		i2s_runtime_suspend(&pdev->dev);
 
 	clk_disable_unprepare(i2s->hclk);
-
-	return 0;
 }
 
 static const struct dev_pm_ops rockchip_i2s_pm_ops = {
@@ -870,7 +868,7 @@ static const struct dev_pm_ops rockchip_i2s_pm_ops = {
 
 static struct platform_driver rockchip_i2s_driver = {
 	.probe = rockchip_i2s_probe,
-	.remove = rockchip_i2s_remove,
+	.remove_new = rockchip_i2s_remove,
 	.driver = {
 		.name = DRV_NAME,
 		.of_match_table = of_match_ptr(rockchip_i2s_match),
-- 
2.39.2


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* [PATCH 120/173] ASoC: rockchip: rockchip_i2s_tdm: Convert to platform remove callback returning void
       [not found] <20230315150745.67084-1-u.kleine-koenig@pengutronix.de>
  2023-03-15 15:06 ` [PATCH 119/173] ASoC: rockchip: rockchip_i2s: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-03-15 15:06 ` Uwe Kleine-König
  2023-03-15 16:00   ` Nicolas Frattaroli
  2023-03-15 15:06 ` [PATCH 121/173] ASoC: rockchip: rockchip_pdm: " Uwe Kleine-König
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Uwe Kleine-König @ 2023-03-15 15:06 UTC (permalink / raw)
  To: Nicolas Frattaroli, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Heiko Stuebner
  Cc: linux-rockchip, alsa-devel, linux-arm-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 (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>
---
 sound/soc/rockchip/rockchip_i2s_tdm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/soc/rockchip/rockchip_i2s_tdm.c b/sound/soc/rockchip/rockchip_i2s_tdm.c
index 166257c6ae14..c2e9fd5ab05e 100644
--- a/sound/soc/rockchip/rockchip_i2s_tdm.c
+++ b/sound/soc/rockchip/rockchip_i2s_tdm.c
@@ -1722,14 +1722,12 @@ static int rockchip_i2s_tdm_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int rockchip_i2s_tdm_remove(struct platform_device *pdev)
+static void rockchip_i2s_tdm_remove(struct platform_device *pdev)
 {
 	if (!pm_runtime_status_suspended(&pdev->dev))
 		i2s_tdm_runtime_suspend(&pdev->dev);
 
 	pm_runtime_disable(&pdev->dev);
-
-	return 0;
 }
 
 static int __maybe_unused rockchip_i2s_tdm_suspend(struct device *dev)
@@ -1764,7 +1762,7 @@ static const struct dev_pm_ops rockchip_i2s_tdm_pm_ops = {
 
 static struct platform_driver rockchip_i2s_tdm_driver = {
 	.probe = rockchip_i2s_tdm_probe,
-	.remove = rockchip_i2s_tdm_remove,
+	.remove_new = rockchip_i2s_tdm_remove,
 	.driver = {
 		.name = DRV_NAME,
 		.of_match_table = of_match_ptr(rockchip_i2s_tdm_match),
-- 
2.39.2


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* [PATCH 121/173] ASoC: rockchip: rockchip_pdm: Convert to platform remove callback returning void
       [not found] <20230315150745.67084-1-u.kleine-koenig@pengutronix.de>
  2023-03-15 15:06 ` [PATCH 119/173] ASoC: rockchip: rockchip_i2s: Convert to platform remove callback returning void Uwe Kleine-König
  2023-03-15 15:06 ` [PATCH 120/173] ASoC: rockchip: rockchip_i2s_tdm: " Uwe Kleine-König
@ 2023-03-15 15:06 ` Uwe Kleine-König
  2023-03-15 15:06 ` [PATCH 122/173] ASoC: rockchip: rockchip_rt5645: " Uwe Kleine-König
  2023-03-15 15:06 ` [PATCH 123/173] ASoC: rockchip: rockchip_spdif: " Uwe Kleine-König
  4 siblings, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2023-03-15 15:06 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Heiko Stuebner
  Cc: alsa-devel, linux-arm-kernel, linux-rockchip, 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>
---
 sound/soc/rockchip/rockchip_pdm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/soc/rockchip/rockchip_pdm.c b/sound/soc/rockchip/rockchip_pdm.c
index 6ce92b1db790..52f9aae60be8 100644
--- a/sound/soc/rockchip/rockchip_pdm.c
+++ b/sound/soc/rockchip/rockchip_pdm.c
@@ -661,7 +661,7 @@ static int rockchip_pdm_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int rockchip_pdm_remove(struct platform_device *pdev)
+static void rockchip_pdm_remove(struct platform_device *pdev)
 {
 	struct rk_pdm_dev *pdm = dev_get_drvdata(&pdev->dev);
 
@@ -671,8 +671,6 @@ static int rockchip_pdm_remove(struct platform_device *pdev)
 
 	clk_disable_unprepare(pdm->clk);
 	clk_disable_unprepare(pdm->hclk);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -710,7 +708,7 @@ static const struct dev_pm_ops rockchip_pdm_pm_ops = {
 
 static struct platform_driver rockchip_pdm_driver = {
 	.probe  = rockchip_pdm_probe,
-	.remove = rockchip_pdm_remove,
+	.remove_new = rockchip_pdm_remove,
 	.driver = {
 		.name = "rockchip-pdm",
 		.of_match_table = of_match_ptr(rockchip_pdm_match),
-- 
2.39.2


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* [PATCH 122/173] ASoC: rockchip: rockchip_rt5645: Convert to platform remove callback returning void
       [not found] <20230315150745.67084-1-u.kleine-koenig@pengutronix.de>
                   ` (2 preceding siblings ...)
  2023-03-15 15:06 ` [PATCH 121/173] ASoC: rockchip: rockchip_pdm: " Uwe Kleine-König
@ 2023-03-15 15:06 ` Uwe Kleine-König
  2023-03-15 15:06 ` [PATCH 123/173] ASoC: rockchip: rockchip_spdif: " Uwe Kleine-König
  4 siblings, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2023-03-15 15:06 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Heiko Stuebner
  Cc: alsa-devel, linux-arm-kernel, linux-rockchip, 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>
---
 sound/soc/rockchip/rockchip_rt5645.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/soc/rockchip/rockchip_rt5645.c b/sound/soc/rockchip/rockchip_rt5645.c
index d07cc5c813f2..e73a342b7953 100644
--- a/sound/soc/rockchip/rockchip_rt5645.c
+++ b/sound/soc/rockchip/rockchip_rt5645.c
@@ -206,14 +206,12 @@ static int snd_rk_mc_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int snd_rk_mc_remove(struct platform_device *pdev)
+static void snd_rk_mc_remove(struct platform_device *pdev)
 {
 	of_node_put(rk_dailink.cpus->of_node);
 	rk_dailink.cpus->of_node = NULL;
 	of_node_put(rk_dailink.codecs->of_node);
 	rk_dailink.codecs->of_node = NULL;
-
-	return 0;
 }
 
 static const struct of_device_id rockchip_rt5645_of_match[] = {
@@ -225,7 +223,7 @@ MODULE_DEVICE_TABLE(of, rockchip_rt5645_of_match);
 
 static struct platform_driver snd_rk_mc_driver = {
 	.probe = snd_rk_mc_probe,
-	.remove = snd_rk_mc_remove,
+	.remove_new = snd_rk_mc_remove,
 	.driver = {
 		.name = DRV_NAME,
 		.pm = &snd_soc_pm_ops,
-- 
2.39.2


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* [PATCH 123/173] ASoC: rockchip: rockchip_spdif: Convert to platform remove callback returning void
       [not found] <20230315150745.67084-1-u.kleine-koenig@pengutronix.de>
                   ` (3 preceding siblings ...)
  2023-03-15 15:06 ` [PATCH 122/173] ASoC: rockchip: rockchip_rt5645: " Uwe Kleine-König
@ 2023-03-15 15:06 ` Uwe Kleine-König
  4 siblings, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2023-03-15 15:06 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Heiko Stuebner
  Cc: alsa-devel, linux-arm-kernel, linux-rockchip, 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>
---
 sound/soc/rockchip/rockchip_spdif.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/soc/rockchip/rockchip_spdif.c b/sound/soc/rockchip/rockchip_spdif.c
index 2d937fcf357d..0b73fe94e4bb 100644
--- a/sound/soc/rockchip/rockchip_spdif.c
+++ b/sound/soc/rockchip/rockchip_spdif.c
@@ -367,13 +367,11 @@ static int rk_spdif_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int rk_spdif_remove(struct platform_device *pdev)
+static void rk_spdif_remove(struct platform_device *pdev)
 {
 	pm_runtime_disable(&pdev->dev);
 	if (!pm_runtime_status_suspended(&pdev->dev))
 		rk_spdif_runtime_suspend(&pdev->dev);
-
-	return 0;
 }
 
 static const struct dev_pm_ops rk_spdif_pm_ops = {
@@ -383,7 +381,7 @@ static const struct dev_pm_ops rk_spdif_pm_ops = {
 
 static struct platform_driver rk_spdif_driver = {
 	.probe = rk_spdif_probe,
-	.remove = rk_spdif_remove,
+	.remove_new = rk_spdif_remove,
 	.driver = {
 		.name = "rockchip-spdif",
 		.of_match_table = of_match_ptr(rk_spdif_match),
-- 
2.39.2


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* Re: [PATCH 120/173] ASoC: rockchip: rockchip_i2s_tdm: Convert to platform remove callback returning void
  2023-03-15 15:06 ` [PATCH 120/173] ASoC: rockchip: rockchip_i2s_tdm: " Uwe Kleine-König
@ 2023-03-15 16:00   ` Nicolas Frattaroli
  2023-03-15 16:25     ` Uwe Kleine-König
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Frattaroli @ 2023-03-15 16:00 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Heiko Stuebner, Uwe Kleine-König
  Cc: linux-rockchip, alsa-devel, linux-arm-kernel, kernel

On Mittwoch, 15. März 2023 16:06:52 CET 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>

Hello,

this looks fine, but the commit prefix should either be
"ASoC: rockchip: i2s_tdm:" or "ASoC: rockchip: i2s-tdm" to align
with previous commits. We've already broken convention once before,
hence the two names, and I'd rather not have this convention broken
again.

Kind regards,
Nicolas Frattaroli

> ---
>  sound/soc/rockchip/rockchip_i2s_tdm.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/soc/rockchip/rockchip_i2s_tdm.c b/sound/soc/rockchip/rockchip_i2s_tdm.c
> index 166257c6ae14..c2e9fd5ab05e 100644
> --- a/sound/soc/rockchip/rockchip_i2s_tdm.c
> +++ b/sound/soc/rockchip/rockchip_i2s_tdm.c
> @@ -1722,14 +1722,12 @@ static int rockchip_i2s_tdm_probe(struct platform_device *pdev)
>  	return ret;
>  }
>  
> -static int rockchip_i2s_tdm_remove(struct platform_device *pdev)
> +static void rockchip_i2s_tdm_remove(struct platform_device *pdev)
>  {
>  	if (!pm_runtime_status_suspended(&pdev->dev))
>  		i2s_tdm_runtime_suspend(&pdev->dev);
>  
>  	pm_runtime_disable(&pdev->dev);
> -
> -	return 0;
>  }
>  
>  static int __maybe_unused rockchip_i2s_tdm_suspend(struct device *dev)
> @@ -1764,7 +1762,7 @@ static const struct dev_pm_ops rockchip_i2s_tdm_pm_ops = {
>  
>  static struct platform_driver rockchip_i2s_tdm_driver = {
>  	.probe = rockchip_i2s_tdm_probe,
> -	.remove = rockchip_i2s_tdm_remove,
> +	.remove_new = rockchip_i2s_tdm_remove,
>  	.driver = {
>  		.name = DRV_NAME,
>  		.of_match_table = of_match_ptr(rockchip_i2s_tdm_match),
> 





_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* Re: [PATCH 120/173] ASoC: rockchip: rockchip_i2s_tdm: Convert to platform remove callback returning void
  2023-03-15 16:00   ` Nicolas Frattaroli
@ 2023-03-15 16:25     ` Uwe Kleine-König
  0 siblings, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2023-03-15 16:25 UTC (permalink / raw)
  To: Nicolas Frattaroli
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Heiko Stuebner, linux-rockchip, alsa-devel, kernel,
	linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 1552 bytes --]

On Wed, Mar 15, 2023 at 05:00:49PM +0100, Nicolas Frattaroli wrote:
> On Mittwoch, 15. März 2023 16:06:52 CET 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>
> 
> Hello,
> 
> this looks fine, but the commit prefix should either be
> "ASoC: rockchip: i2s_tdm:" or "ASoC: rockchip: i2s-tdm" to align
> with previous commits. We've already broken convention once before,
> hence the two names, and I'd rather not have this convention broken
> again.

I fixed that in my tree. I assume Mark will skip this patch when
applying and when I come around cleaning up the fall-out I will resend
this one with the subject fixed. (I picked the variant with _ now as
this seems to be the more recent one.)

Thanks for the feedback
Uwe

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

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

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

end of thread, other threads:[~2023-03-15 16:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20230315150745.67084-1-u.kleine-koenig@pengutronix.de>
2023-03-15 15:06 ` [PATCH 119/173] ASoC: rockchip: rockchip_i2s: Convert to platform remove callback returning void Uwe Kleine-König
2023-03-15 15:06 ` [PATCH 120/173] ASoC: rockchip: rockchip_i2s_tdm: " Uwe Kleine-König
2023-03-15 16:00   ` Nicolas Frattaroli
2023-03-15 16:25     ` Uwe Kleine-König
2023-03-15 15:06 ` [PATCH 121/173] ASoC: rockchip: rockchip_pdm: " Uwe Kleine-König
2023-03-15 15:06 ` [PATCH 122/173] ASoC: rockchip: rockchip_rt5645: " Uwe Kleine-König
2023-03-15 15:06 ` [PATCH 123/173] ASoC: rockchip: rockchip_spdif: " 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