diff mbox series

[10/14] mtd: rawnand: tegra: Don't skip cleanup after mtd_device_unregister() failed

Message ID 20220603210758.148493-11-u.kleine-koenig@pengutronix.de
State Accepted
Headers show
Series mtd: Fix platform remove callbacks to always return 0 | expand

Commit Message

Uwe Kleine-König June 3, 2022, 9:07 p.m. UTC
If mtd_device_unregister() fails (which it doesn't when used correctly),
the resources bound by the nand chip should be freed anyhow as returning
an error value doesn't prevent the device getting unbound.

Instead use WARN_ON on the return value similar to how other drivers do
it.

This is a preparation for making platform remove callbacks return void.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/mtd/nand/raw/tegra_nand.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Miquel Raynal June 9, 2022, 1:09 p.m. UTC | #1
On Fri, 2022-06-03 at 21:07:54 UTC, =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= wrote:
> If mtd_device_unregister() fails (which it doesn't when used correctly),
> the resources bound by the nand chip should be freed anyhow as returning
> an error value doesn't prevent the device getting unbound.
> 
> Instead use WARN_ON on the return value similar to how other drivers do
> it.
> 
> This is a preparation for making platform remove callbacks return void.
> 
> 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
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/tegra_nand.c b/drivers/mtd/nand/raw/tegra_nand.c
index b36e5260ae27..e12f9f580a15 100644
--- a/drivers/mtd/nand/raw/tegra_nand.c
+++ b/drivers/mtd/nand/raw/tegra_nand.c
@@ -1223,11 +1223,8 @@  static int tegra_nand_remove(struct platform_device *pdev)
 	struct tegra_nand_controller *ctrl = platform_get_drvdata(pdev);
 	struct nand_chip *chip = ctrl->chip;
 	struct mtd_info *mtd = nand_to_mtd(chip);
-	int ret;
 
-	ret = mtd_device_unregister(mtd);
-	if (ret)
-		return ret;
+	WARN_ON(mtd_device_unregister(mtd));
 
 	nand_cleanup(chip);