* [PATCH 00/20] mtd: Convert to platform remove callback returning void
@ 2023-10-08 20:01 Uwe Kleine-König
2023-10-08 20:01 ` [PATCH 06/20] mtd: powernv_flash: " Uwe Kleine-König
2023-10-09 6:07 ` [PATCH 00/20] mtd: " Tudor Ambarus
0 siblings, 2 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2023-10-08 20:01 UTC (permalink / raw)
To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
Cc: David Woodhouse, Hui Tang, Atsushi Nemoto, Li Zetao,
Zheng Yongjun, linux-mtd, Robert Jarzmik, Heiko Stuebner,
Rob Herring, Yangtao Li, Tudor Ambarus, Linus Walleij,
linux-kbuild, Joern Engel, Nicholas Piggin, Vladimir Zapolskiy,
Christophe JAILLET, linux-arm-kernel, Michael Walle, kernel,
Andrew Morton, linuxppc-dev, Pratyush Yadav
Hello,
this series converts all platform drivers below drivers/mtd to use the
.remove_new() callback. Compared to the traditional .remove() callback
.remove_new() returns no value. This is a good thing because the driver
core doesn't (and cannot) cope for errors during remove. The only effect
of a non-zero return value in .remove() is that the driver core emits a
warning. The device is removed anyhow and an early return from .remove()
usually yields resource leaks and/or use-after-free bugs.
All drivers touched here returned zero unconditionally in their remove
callback, so they could all be converted trivially to .remove_new().
See commit 5c5a7680e67b ("platform: Provide a remove callback that
returns no value") for an extended explanation and the eventual goal.
As an added bonus the series starts with a minor fix and a
simplification of the txx9ndfmc driver.
The only interdependencies in this series is between the three txx9ndfmc
patches. As there are still quite a few drivers to convert, I'm happy
about every patch that makes it in. So even if there is a merge conflict
with one patch until you apply (or a different concern that doesn't
apply to all patches), please apply the remainder of this series anyhow.
I'll come back to the part that you (maybe) skipped at a later point.
Best regards
Uwe
Uwe Kleine-König (20):
mtd: rawnand: txx9ndfmc: Mark driver struct with __refdata to prevent
section mismatch warning
mtd: rawnand: txx9ndfmc: Drop if block with always false condition
mtd: bcm47xxsflash: Convert to platform remove callback returning void
mtd: docg3: Convert to platform remove callback returning void
mtd: phram: Convert to platform remove callback returning void
mtd: powernv_flash: Convert to platform remove callback returning void
mtd: spear_smi: Convert to platform remove callback returning void
mtd: st_spi_fsm: Convert to platform remove callback returning void
mtd: hyperbus: hbmc-am654: Convert to platform remove callback
returning void
mtd: hyperbus: rpc-if: Convert to platform remove callback returning
void
mtd: lpddr2_nvm: Convert to platform remove callback returning void
mtd: maps: lantiq-flash: Convert to platform remove callback returning
void
mtd: maps: physmap-core: Convert to platform remove callback returning
void
mtd: maps: plat-ram: Convert to platform remove callback returning
void
mtd: maps: pxa2xx-flash: Convert to platform remove callback returning
void
mtd: maps: sa1100-flash: Convert to platform remove callback returning
void
mtd: maps: sun_uflash: Convert to platform remove callback returning
void
mtd: rawnand: txx9ndfmc: Convert to platform remove callback returning
void
mtd: spi-nor: hisi-sfc: Convert to platform remove callback returning
void
mtd: spi-nor: nxp-spifi: Convert to platform remove callback returning
void
drivers/mtd/devices/bcm47xxsflash.c | 6 ++----
drivers/mtd/devices/docg3.c | 5 ++---
drivers/mtd/devices/phram.c | 6 ++----
drivers/mtd/devices/powernv_flash.c | 6 ++----
drivers/mtd/devices/spear_smi.c | 6 ++----
drivers/mtd/devices/st_spi_fsm.c | 6 ++----
drivers/mtd/hyperbus/hbmc-am654.c | 6 ++----
drivers/mtd/hyperbus/rpc-if.c | 6 ++----
drivers/mtd/lpddr/lpddr2_nvm.c | 6 ++----
drivers/mtd/maps/lantiq-flash.c | 6 ++----
drivers/mtd/maps/physmap-core.c | 5 ++---
drivers/mtd/maps/plat-ram.c | 8 +++-----
drivers/mtd/maps/pxa2xx-flash.c | 5 ++---
drivers/mtd/maps/sa1100-flash.c | 6 ++----
drivers/mtd/maps/sun_uflash.c | 6 ++----
drivers/mtd/nand/raw/txx9ndfmc.c | 15 +++++++++------
drivers/mtd/spi-nor/controllers/hisi-sfc.c | 5 ++---
drivers/mtd/spi-nor/controllers/nxp-spifi.c | 6 ++----
18 files changed, 44 insertions(+), 71 deletions(-)
base-commit: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d
--
2.40.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 06/20] mtd: powernv_flash: Convert to platform remove callback returning void
2023-10-08 20:01 [PATCH 00/20] mtd: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-10-08 20:01 ` Uwe Kleine-König
2023-10-16 9:28 ` Miquel Raynal
2023-10-09 6:07 ` [PATCH 00/20] mtd: " Tudor Ambarus
1 sibling, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2023-10-08 20:01 UTC (permalink / raw)
To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
Cc: linux-mtd, Nicholas Piggin, kernel, linuxppc-dev
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/mtd/devices/powernv_flash.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/devices/powernv_flash.c b/drivers/mtd/devices/powernv_flash.c
index 36e060386e59..66044f4f5bad 100644
--- a/drivers/mtd/devices/powernv_flash.c
+++ b/drivers/mtd/devices/powernv_flash.c
@@ -265,14 +265,12 @@ static int powernv_flash_probe(struct platform_device *pdev)
*
* Returns 0
*/
-static int powernv_flash_release(struct platform_device *pdev)
+static void powernv_flash_release(struct platform_device *pdev)
{
struct powernv_flash *data = dev_get_drvdata(&(pdev->dev));
/* All resources should be freed automatically */
WARN_ON(mtd_device_unregister(&data->mtd));
-
- return 0;
}
static const struct of_device_id powernv_flash_match[] = {
@@ -285,7 +283,7 @@ static struct platform_driver powernv_flash_driver = {
.name = "powernv_flash",
.of_match_table = powernv_flash_match,
},
- .remove = powernv_flash_release,
+ .remove_new = powernv_flash_release,
.probe = powernv_flash_probe,
};
--
2.40.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 00/20] mtd: Convert to platform remove callback returning void
2023-10-08 20:01 [PATCH 00/20] mtd: Convert to platform remove callback returning void Uwe Kleine-König
2023-10-08 20:01 ` [PATCH 06/20] mtd: powernv_flash: " Uwe Kleine-König
@ 2023-10-09 6:07 ` Tudor Ambarus
1 sibling, 0 replies; 4+ messages in thread
From: Tudor Ambarus @ 2023-10-09 6:07 UTC (permalink / raw)
To: Uwe Kleine-König, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra
Cc: David Woodhouse, Hui Tang, Atsushi Nemoto, Li Zetao,
Zheng Yongjun, linux-mtd, Robert Jarzmik, Heiko Stuebner,
Rob Herring, Yangtao Li, Linus Walleij, linux-kbuild, Joern Engel,
Nicholas Piggin, Vladimir Zapolskiy, Christophe JAILLET,
linux-arm-kernel, Michael Walle, kernel, Andrew Morton,
linuxppc-dev, Pratyush Yadav
On 10/8/23 21:01, Uwe Kleine-König wrote:
> Hello,
>
> this series converts all platform drivers below drivers/mtd to use the
> .remove_new() callback. Compared to the traditional .remove() callback
> .remove_new() returns no value. This is a good thing because the driver
> core doesn't (and cannot) cope for errors during remove. The only effect
> of a non-zero return value in .remove() is that the driver core emits a
> warning. The device is removed anyhow and an early return from .remove()
> usually yields resource leaks and/or use-after-free bugs.
>
> All drivers touched here returned zero unconditionally in their remove
> callback, so they could all be converted trivially to .remove_new().
>
> See commit 5c5a7680e67b ("platform: Provide a remove callback that
> returns no value") for an extended explanation and the eventual goal.
>
Acked-by: Tudor Ambarus <tudor.ambarus@linaro.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 06/20] mtd: powernv_flash: Convert to platform remove callback returning void
2023-10-08 20:01 ` [PATCH 06/20] mtd: powernv_flash: " Uwe Kleine-König
@ 2023-10-16 9:28 ` Miquel Raynal
0 siblings, 0 replies; 4+ messages in thread
From: Miquel Raynal @ 2023-10-16 9:28 UTC (permalink / raw)
To: Uwe Kleine-König, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra
Cc: linux-mtd, Nicholas Piggin, kernel, linuxppc-dev
On Sun, 2023-10-08 at 20:01:29 UTC, =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= 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>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-16 9:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-08 20:01 [PATCH 00/20] mtd: Convert to platform remove callback returning void Uwe Kleine-König
2023-10-08 20:01 ` [PATCH 06/20] mtd: powernv_flash: " Uwe Kleine-König
2023-10-16 9:28 ` Miquel Raynal
2023-10-09 6:07 ` [PATCH 00/20] mtd: " Tudor Ambarus
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).