2024-03-10 08:06:42

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 0/2] counter: Convert to platform remove callback returning void

Hello,

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.

There are no interdependencies between these patches, still I'd expect
them to be picked up together.

Best regards
Uwe

Uwe Kleine-König (2):
counter: ti-ecap-capture: Convert to platform remove callback
returning void
counter: ti-eqep: Convert to platform remove callback returning void

drivers/counter/ti-ecap-capture.c | 6 ++----
drivers/counter/ti-eqep.c | 6 ++----
2 files changed, 4 insertions(+), 8 deletions(-)

base-commit: 8ffc8b1bbd505e27e2c8439d326b6059c906c9dd
--
2.43.0



2024-03-10 08:06:48

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 2/2] counter: ti-eqep: Convert to platform remove callback returning void

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 <[email protected]>
---
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


2024-03-10 08:06:54

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 1/2] counter: ti-ecap-capture: Convert to platform remove callback returning void

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 <[email protected]>
---
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


2024-03-11 13:58:02

by David Lechner

[permalink] [raw]
Subject: Re: [PATCH 2/2] counter: ti-eqep: Convert to platform remove callback returning void

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 <[email protected]>
> ---

Acked-by: David Lechner <[email protected]>



2024-03-18 14:42:38

by William Breathitt Gray

[permalink] [raw]
Subject: Re: [PATCH 0/2] counter: Convert to platform remove callback returning void

From: William Breathitt Gray <[email protected]>


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 <[email protected]>