* [PATCH 1/2] counter: ti-ecap-capture: Convert to platform remove callback returning void
2024-03-10 8:06 [PATCH 0/2] counter: Convert to platform remove callback returning void Uwe Kleine-König
@ 2024-03-10 8:06 ` Uwe Kleine-König
2024-03-10 8:06 ` [PATCH 2/2] counter: ti-eqep: " Uwe Kleine-König
2024-03-18 14:42 ` [PATCH 0/2] counter: " wbg
2 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2024-03-10 8:06 UTC (permalink / raw)
To: William Breathitt Gray
Cc: Vignesh Raghavendra, Julien Panis, linux-iio, linux-omap,
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/counter/ti-ecap-capture.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/counter/ti-ecap-capture.c b/drivers/counter/ti-ecap-capture.c
index fb1cb1774674..d33d35055b91 100644
--- a/drivers/counter/ti-ecap-capture.c
+++ b/drivers/counter/ti-ecap-capture.c
@@ -537,15 +537,13 @@ static int ecap_cnt_probe(struct platform_device *pdev)
return 0;
}
-static int ecap_cnt_remove(struct platform_device *pdev)
+static void ecap_cnt_remove(struct platform_device *pdev)
{
struct counter_device *counter_dev = platform_get_drvdata(pdev);
struct ecap_cnt_dev *ecap_dev = counter_priv(counter_dev);
if (ecap_dev->enabled)
ecap_cnt_capture_disable(counter_dev);
-
- return 0;
}
static int ecap_cnt_suspend(struct device *dev)
@@ -600,7 +598,7 @@ MODULE_DEVICE_TABLE(of, ecap_cnt_of_match);
static struct platform_driver ecap_cnt_driver = {
.probe = ecap_cnt_probe,
- .remove = ecap_cnt_remove,
+ .remove_new = ecap_cnt_remove,
.driver = {
.name = "ecap-capture",
.of_match_table = ecap_cnt_of_match,
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 2/2] counter: ti-eqep: Convert to platform remove callback returning void
2024-03-10 8:06 [PATCH 0/2] counter: Convert to platform remove callback returning void Uwe Kleine-König
2024-03-10 8:06 ` [PATCH 1/2] counter: ti-ecap-capture: " Uwe Kleine-König
@ 2024-03-10 8:06 ` Uwe Kleine-König
2024-03-11 13:57 ` David Lechner
2024-03-18 14:42 ` [PATCH 0/2] counter: " wbg
2 siblings, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2024-03-10 8:06 UTC (permalink / raw)
To: William Breathitt Gray; +Cc: David Lechner, linux-iio, 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/counter/ti-eqep.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/counter/ti-eqep.c b/drivers/counter/ti-eqep.c
index b0f24cf3e891..072b11fd6b32 100644
--- a/drivers/counter/ti-eqep.c
+++ b/drivers/counter/ti-eqep.c
@@ -425,7 +425,7 @@ static int ti_eqep_probe(struct platform_device *pdev)
return 0;
}
-static int ti_eqep_remove(struct platform_device *pdev)
+static void ti_eqep_remove(struct platform_device *pdev)
{
struct counter_device *counter = platform_get_drvdata(pdev);
struct device *dev = &pdev->dev;
@@ -433,8 +433,6 @@ static int ti_eqep_remove(struct platform_device *pdev)
counter_unregister(counter);
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
-
- return 0;
}
static const struct of_device_id ti_eqep_of_match[] = {
@@ -445,7 +443,7 @@ MODULE_DEVICE_TABLE(of, ti_eqep_of_match);
static struct platform_driver ti_eqep_driver = {
.probe = ti_eqep_probe,
- .remove = ti_eqep_remove,
+ .remove_new = ti_eqep_remove,
.driver = {
.name = "ti-eqep-cnt",
.of_match_table = ti_eqep_of_match,
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 2/2] counter: ti-eqep: Convert to platform remove callback returning void
2024-03-10 8:06 ` [PATCH 2/2] counter: ti-eqep: " Uwe Kleine-König
@ 2024-03-11 13:57 ` David Lechner
0 siblings, 0 replies; 5+ messages in thread
From: David Lechner @ 2024-03-11 13:57 UTC (permalink / raw)
To: Uwe Kleine-König, William Breathitt Gray
Cc: linux-iio, linux-kernel, kernel
On 3/10/24 3:06 AM, 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>
> ---
Acked-by: David Lechner <david@lechnology.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] counter: Convert to platform remove callback returning void
2024-03-10 8:06 [PATCH 0/2] counter: Convert to platform remove callback returning void Uwe Kleine-König
2024-03-10 8:06 ` [PATCH 1/2] counter: ti-ecap-capture: " Uwe Kleine-König
2024-03-10 8:06 ` [PATCH 2/2] counter: ti-eqep: " Uwe Kleine-König
@ 2024-03-18 14:42 ` wbg
2 siblings, 0 replies; 5+ messages in thread
From: wbg @ 2024-03-18 14:42 UTC (permalink / raw)
To: William Breathitt Gray, Uwe Kleine-König
Cc: William Breathitt Gray, Vignesh Raghavendra, Julien Panis,
linux-iio, linux-omap, linux-kernel, kernel, David Lechner
From: William Breathitt Gray <wbg@kernel.org>
On Sun, 10 Mar 2024 09:06:05 +0100, Uwe Kleine-König wrote:
> this series converts all platform drivers below drivers/counter to stop
> using struct platform_driver::remove(). See commit 5c5a7680e67b
> ("platform: Provide a remove callback that returns no value") for an
> extended explanation and the eventual goal.
>
> Both conversations are trivial, because the driver's .remove() callbacks
> returned zero unconditionally.
>
> [...]
Applied, thanks!
[1/2] counter: ti-ecap-capture: Convert to platform remove callback returning void
commit: bcc8ced4e1713bc7fa19a422321756788a58512f
[2/2] counter: ti-eqep: Convert to platform remove callback returning void
commit: eca588187f9129300c6e44d64b819545cede463d
Best regards,
--
William Breathitt Gray <wbg@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread