linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: media: tegra-video: Convert to platform remove callback returning void
@ 2023-10-26 21:47 Uwe Kleine-König
  2023-10-27  8:11 ` Luca Ceresoli
  2023-11-20 21:23 ` Uwe Kleine-König
  0 siblings, 2 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2023-10-26 21:47 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Sowjanya Komatineni,
	Luca Ceresoli, Mauro Carvalho Chehab
  Cc: Greg Kroah-Hartman, linux-media, linux-tegra, linux-staging,
	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 the three tegra-video 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/staging/media/tegra-video/csi.c | 6 ++----
 drivers/staging/media/tegra-video/vi.c  | 6 ++----
 drivers/staging/media/tegra-video/vip.c | 6 ++----
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/media/tegra-video/csi.c b/drivers/staging/media/tegra-video/csi.c
index 9aa72863c213..0d94115b9bbb 100644
--- a/drivers/staging/media/tegra-video/csi.c
+++ b/drivers/staging/media/tegra-video/csi.c
@@ -818,15 +818,13 @@ static int tegra_csi_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int tegra_csi_remove(struct platform_device *pdev)
+static void tegra_csi_remove(struct platform_device *pdev)
 {
 	struct tegra_csi *csi = platform_get_drvdata(pdev);
 
 	host1x_client_unregister(&csi->client);
 
 	pm_runtime_disable(&pdev->dev);
-
-	return 0;
 }
 
 #if defined(CONFIG_ARCH_TEGRA_210_SOC)
@@ -852,5 +850,5 @@ struct platform_driver tegra_csi_driver = {
 		.pm		= &tegra_csi_pm_ops,
 	},
 	.probe			= tegra_csi_probe,
-	.remove			= tegra_csi_remove,
+	.remove_new		= tegra_csi_remove,
 };
diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c
index 94171e62dee9..61169ff13ec5 100644
--- a/drivers/staging/media/tegra-video/vi.c
+++ b/drivers/staging/media/tegra-video/vi.c
@@ -1944,7 +1944,7 @@ static int tegra_vi_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int tegra_vi_remove(struct platform_device *pdev)
+static void tegra_vi_remove(struct platform_device *pdev)
 {
 	struct tegra_vi *vi = platform_get_drvdata(pdev);
 
@@ -1953,8 +1953,6 @@ static int tegra_vi_remove(struct platform_device *pdev)
 	if (vi->ops->vi_enable)
 		vi->ops->vi_enable(vi, false);
 	pm_runtime_disable(&pdev->dev);
-
-	return 0;
 }
 
 static const struct of_device_id tegra_vi_of_id_table[] = {
@@ -1979,5 +1977,5 @@ struct platform_driver tegra_vi_driver = {
 		.pm = &tegra_vi_pm_ops,
 	},
 	.probe = tegra_vi_probe,
-	.remove = tegra_vi_remove,
+	.remove_new = tegra_vi_remove,
 };
diff --git a/drivers/staging/media/tegra-video/vip.c b/drivers/staging/media/tegra-video/vip.c
index e95cc7bb190e..8504b9ea9cea 100644
--- a/drivers/staging/media/tegra-video/vip.c
+++ b/drivers/staging/media/tegra-video/vip.c
@@ -254,15 +254,13 @@ static int tegra_vip_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int tegra_vip_remove(struct platform_device *pdev)
+static void tegra_vip_remove(struct platform_device *pdev)
 {
 	struct tegra_vip *vip = platform_get_drvdata(pdev);
 
 	host1x_client_unregister(&vip->client);
 
 	pm_runtime_disable(&pdev->dev);
-
-	return 0;
 }
 
 #if defined(CONFIG_ARCH_TEGRA_2x_SOC)
@@ -283,5 +281,5 @@ struct platform_driver tegra_vip_driver = {
 		.of_match_table	= tegra_vip_of_id_table,
 	},
 	.probe			= tegra_vip_probe,
-	.remove			= tegra_vip_remove,
+	.remove_new		= tegra_vip_remove,
 };

base-commit: 2ef7141596eed0b4b45ef18b3626f428a6b0a822
-- 
2.42.0


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

* Re: [PATCH] staging: media: tegra-video: Convert to platform remove callback returning void
  2023-10-26 21:47 [PATCH] staging: media: tegra-video: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-10-27  8:11 ` Luca Ceresoli
  2023-11-20 21:23 ` Uwe Kleine-König
  1 sibling, 0 replies; 3+ messages in thread
From: Luca Ceresoli @ 2023-10-27  8:11 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Thierry Reding, Jonathan Hunter, Sowjanya Komatineni,
	Mauro Carvalho Chehab, Greg Kroah-Hartman, linux-media,
	linux-tegra, linux-staging, kernel

Hello Uwe,

On Thu, 26 Oct 2023 23:47:40 +0200
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() will be renamed to .remove().
> 
> Trivially convert the three tegra-video 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: Luca Ceresoli <luca.ceresoli@bootlin.com>

-- 
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH] staging: media: tegra-video: Convert to platform remove callback returning void
  2023-10-26 21:47 [PATCH] staging: media: tegra-video: Convert to platform remove callback returning void Uwe Kleine-König
  2023-10-27  8:11 ` Luca Ceresoli
@ 2023-11-20 21:23 ` Uwe Kleine-König
  1 sibling, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2023-11-20 21:23 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Sowjanya Komatineni,
	Luca Ceresoli, Mauro Carvalho Chehab
  Cc: linux-tegra, Greg Kroah-Hartman, linux-staging, kernel,
	linux-media

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

Hello,

On Thu, Oct 26, 2023 at 11:47:40PM +0200, 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 the three tegra-video 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>

who feels responsible to pick up this patch?

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] 3+ messages in thread

end of thread, other threads:[~2023-11-20 21:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-26 21:47 [PATCH] staging: media: tegra-video: Convert to platform remove callback returning void Uwe Kleine-König
2023-10-27  8:11 ` Luca Ceresoli
2023-11-20 21:23 ` 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).