Skip to content

Commit 7beae69

Browse files
Uwe Kleine-Königmiquelraynal
authored andcommitted
mtd: rawnand: meson: Don't skip cleanup after mtd_device_unregister() failed
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. Then meson_nfc_nand_chip_cleanup() returns 0 unconditionally and can be changed to return void which allows further simplification in the remove callback. This is a preparation for making platform remove callbacks return void. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20220603210758.148493-12-u.kleine-koenig@pengutronix.de
1 parent 413948c commit 7beae69

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

drivers/mtd/nand/raw/meson_nand.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,26 +1293,21 @@ meson_nfc_nand_chip_init(struct device *dev,
12931293
return 0;
12941294
}
12951295

1296-
static int meson_nfc_nand_chip_cleanup(struct meson_nfc *nfc)
1296+
static void meson_nfc_nand_chip_cleanup(struct meson_nfc *nfc)
12971297
{
12981298
struct meson_nfc_nand_chip *meson_chip;
12991299
struct mtd_info *mtd;
1300-
int ret;
13011300

13021301
while (!list_empty(&nfc->chips)) {
13031302
meson_chip = list_first_entry(&nfc->chips,
13041303
struct meson_nfc_nand_chip, node);
13051304
mtd = nand_to_mtd(&meson_chip->nand);
1306-
ret = mtd_device_unregister(mtd);
1307-
if (ret)
1308-
return ret;
1305+
WARN_ON(mtd_device_unregister(mtd));
13091306

13101307
meson_nfc_free_buffer(&meson_chip->nand);
13111308
nand_cleanup(&meson_chip->nand);
13121309
list_del(&meson_chip->node);
13131310
}
1314-
1315-
return 0;
13161311
}
13171312

13181313
static int meson_nfc_nand_chips_init(struct device *dev,
@@ -1445,11 +1440,8 @@ static int meson_nfc_probe(struct platform_device *pdev)
14451440
static int meson_nfc_remove(struct platform_device *pdev)
14461441
{
14471442
struct meson_nfc *nfc = platform_get_drvdata(pdev);
1448-
int ret;
14491443

1450-
ret = meson_nfc_nand_chip_cleanup(nfc);
1451-
if (ret)
1452-
return ret;
1444+
meson_nfc_nand_chip_cleanup(nfc);
14531445

14541446
meson_nfc_disable_clk(nfc);
14551447

0 commit comments

Comments
 (0)