2023-12-10 22:13:23

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 00/12] hwrng: Convert to platform remove callback returning

Hello,

this series converts all hwrng platform drivers to use .remove_new.
See commit 5c5a7680e67b ("platform: Provide a remove callback that
returns no value") for details and the eventual goal.

All driver conversions are trivial as all their remove callbacks return
0 (as good drivers should do).

All patches are pairwise independant. These patches should go in via the
usual hwrng tree. It's merge window material.

Best regards
Uwe

Uwe Kleine-König (12):
hwrng: atmel - Convert to platform remove callback returning void
hwrng: cctrng - Convert to platform remove callback returning void
hwrng: exynos - Convert to platform remove callback returning void
hwrng: ingenic - Convert to platform remove callback returning void
hwrng: ks-sa - Convert to platform remove callback returning void
hwrng: mxc - Convert to platform remove callback returning void
hwrng: n2 - Convert to platform remove callback returning void
hwrng: npcm - Convert to platform remove callback returning void
hwrng: omap - Convert to platform remove callback returning void
hwrng: stm32 - Convert to platform remove callback returning void
hwrng: timeriomem - Convert to platform remove callback returning void
hwrng: xgene - Convert to platform remove callback returning void

drivers/char/hw_random/atmel-rng.c | 6 ++----
drivers/char/hw_random/cctrng.c | 6 ++----
drivers/char/hw_random/exynos-trng.c | 6 ++----
drivers/char/hw_random/ingenic-rng.c | 6 ++----
drivers/char/hw_random/ks-sa-rng.c | 6 ++----
drivers/char/hw_random/mxc-rnga.c | 6 ++----
drivers/char/hw_random/n2-drv.c | 6 ++----
drivers/char/hw_random/npcm-rng.c | 6 ++----
drivers/char/hw_random/omap-rng.c | 6 ++----
drivers/char/hw_random/stm32-rng.c | 6 ++----
drivers/char/hw_random/timeriomem-rng.c | 6 ++----
drivers/char/hw_random/xgene-rng.c | 6 ++----
12 files changed, 24 insertions(+), 48 deletions(-)


base-commit: bc63de6e6ba0b16652c5fb4b9c9916b9e7ca1f23
--
2.42.0



2023-12-10 22:13:23

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 10/12] hwrng: stm32 - 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/char/hw_random/stm32-rng.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/char/hw_random/stm32-rng.c b/drivers/char/hw_random/stm32-rng.c
index 41e1dbea5d2e..98c92b914cfd 100644
--- a/drivers/char/hw_random/stm32-rng.c
+++ b/drivers/char/hw_random/stm32-rng.c
@@ -362,11 +362,9 @@ static int stm32_rng_init(struct hwrng *rng)
return 0;
}

-static int stm32_rng_remove(struct platform_device *ofdev)
+static void stm32_rng_remove(struct platform_device *ofdev)
{
pm_runtime_disable(&ofdev->dev);
-
- return 0;
}

static int __maybe_unused stm32_rng_runtime_suspend(struct device *dev)
@@ -557,7 +555,7 @@ static struct platform_driver stm32_rng_driver = {
.of_match_table = stm32_rng_match,
},
.probe = stm32_rng_probe,
- .remove = stm32_rng_remove,
+ .remove_new = stm32_rng_remove,
};

module_platform_driver(stm32_rng_driver);
--
2.42.0


2023-12-10 22:13:26

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 03/12] hwrng: exynos - 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/char/hw_random/exynos-trng.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
index 30207b7ac5f4..0ed5d22fe667 100644
--- a/drivers/char/hw_random/exynos-trng.c
+++ b/drivers/char/hw_random/exynos-trng.c
@@ -173,7 +173,7 @@ static int exynos_trng_probe(struct platform_device *pdev)
return ret;
}

-static int exynos_trng_remove(struct platform_device *pdev)
+static void exynos_trng_remove(struct platform_device *pdev)
{
struct exynos_trng_dev *trng = platform_get_drvdata(pdev);

@@ -181,8 +181,6 @@ static int exynos_trng_remove(struct platform_device *pdev)

pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
-
- return 0;
}

static int exynos_trng_suspend(struct device *dev)
@@ -223,7 +221,7 @@ static struct platform_driver exynos_trng_driver = {
.of_match_table = exynos_trng_dt_match,
},
.probe = exynos_trng_probe,
- .remove = exynos_trng_remove,
+ .remove_new = exynos_trng_remove,
};

module_platform_driver(exynos_trng_driver);
--
2.42.0


2023-12-10 22:13:29

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 12/12] hwrng: xgene - 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/char/hw_random/xgene-rng.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/char/hw_random/xgene-rng.c b/drivers/char/hw_random/xgene-rng.c
index 7382724bf501..642d13519464 100644
--- a/drivers/char/hw_random/xgene-rng.c
+++ b/drivers/char/hw_random/xgene-rng.c
@@ -357,15 +357,13 @@ static int xgene_rng_probe(struct platform_device *pdev)
return 0;
}

-static int xgene_rng_remove(struct platform_device *pdev)
+static void xgene_rng_remove(struct platform_device *pdev)
{
int rc;

rc = device_init_wakeup(&pdev->dev, 0);
if (rc)
dev_err(&pdev->dev, "RNG init wakeup failed error %d\n", rc);
-
- return 0;
}

static const struct of_device_id xgene_rng_of_match[] = {
@@ -377,7 +375,7 @@ MODULE_DEVICE_TABLE(of, xgene_rng_of_match);

static struct platform_driver xgene_rng_driver = {
.probe = xgene_rng_probe,
- .remove = xgene_rng_remove,
+ .remove_new = xgene_rng_remove,
.driver = {
.name = "xgene-rng",
.of_match_table = xgene_rng_of_match,
--
2.42.0


2023-12-12 09:31:53

by Łukasz Stelmach

[permalink] [raw]
Subject: Re: [PATCH 03/12] hwrng: exynos - Convert to platform remove callback returning void

It was <2023-12-10 nie 23:12>, when 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]>
> ---
> drivers/char/hw_random/exynos-trng.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>

Acked-by: Lukasz Stelmach <[email protected]>

> diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
> index 30207b7ac5f4..0ed5d22fe667 100644
> --- a/drivers/char/hw_random/exynos-trng.c
> +++ b/drivers/char/hw_random/exynos-trng.c
> @@ -173,7 +173,7 @@ static int exynos_trng_probe(struct platform_device *pdev)
> return ret;
> }
>
> -static int exynos_trng_remove(struct platform_device *pdev)
> +static void exynos_trng_remove(struct platform_device *pdev)
> {
> struct exynos_trng_dev *trng = platform_get_drvdata(pdev);
>
> @@ -181,8 +181,6 @@ static int exynos_trng_remove(struct platform_device *pdev)
>
> pm_runtime_put_sync(&pdev->dev);
> pm_runtime_disable(&pdev->dev);
> -
> - return 0;
> }
>
> static int exynos_trng_suspend(struct device *dev)
> @@ -223,7 +221,7 @@ static struct platform_driver exynos_trng_driver = {
> .of_match_table = exynos_trng_dt_match,
> },
> .probe = exynos_trng_probe,
> - .remove = exynos_trng_remove,
> + .remove_new = exynos_trng_remove,
> };
>
> module_platform_driver(exynos_trng_driver);

--
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics


Attachments:
signature.asc (497.00 B)

2023-12-15 09:59:21

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH 00/12] hwrng: Convert to platform remove callback returning

On Sun, Dec 10, 2023 at 11:12:15PM +0100, Uwe Kleine-K?nig wrote:
> Hello,
>
> this series converts all hwrng platform drivers to use .remove_new.
> See commit 5c5a7680e67b ("platform: Provide a remove callback that
> returns no value") for details and the eventual goal.
>
> All driver conversions are trivial as all their remove callbacks return
> 0 (as good drivers should do).
>
> All patches are pairwise independant. These patches should go in via the
> usual hwrng tree. It's merge window material.
>
> Best regards
> Uwe
>
> Uwe Kleine-K?nig (12):
> hwrng: atmel - Convert to platform remove callback returning void
> hwrng: cctrng - Convert to platform remove callback returning void
> hwrng: exynos - Convert to platform remove callback returning void
> hwrng: ingenic - Convert to platform remove callback returning void
> hwrng: ks-sa - Convert to platform remove callback returning void
> hwrng: mxc - Convert to platform remove callback returning void
> hwrng: n2 - Convert to platform remove callback returning void
> hwrng: npcm - Convert to platform remove callback returning void
> hwrng: omap - Convert to platform remove callback returning void
> hwrng: stm32 - Convert to platform remove callback returning void
> hwrng: timeriomem - Convert to platform remove callback returning void
> hwrng: xgene - Convert to platform remove callback returning void
>
> drivers/char/hw_random/atmel-rng.c | 6 ++----
> drivers/char/hw_random/cctrng.c | 6 ++----
> drivers/char/hw_random/exynos-trng.c | 6 ++----
> drivers/char/hw_random/ingenic-rng.c | 6 ++----
> drivers/char/hw_random/ks-sa-rng.c | 6 ++----
> drivers/char/hw_random/mxc-rnga.c | 6 ++----
> drivers/char/hw_random/n2-drv.c | 6 ++----
> drivers/char/hw_random/npcm-rng.c | 6 ++----
> drivers/char/hw_random/omap-rng.c | 6 ++----
> drivers/char/hw_random/stm32-rng.c | 6 ++----
> drivers/char/hw_random/timeriomem-rng.c | 6 ++----
> drivers/char/hw_random/xgene-rng.c | 6 ++----
> 12 files changed, 24 insertions(+), 48 deletions(-)
>
>
> base-commit: bc63de6e6ba0b16652c5fb4b9c9916b9e7ca1f23
> --
> 2.42.0

All applied. Thanks.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt