Skip to content

Commit ec185b1

Browse files
Uwe Kleine-Königmiquelraynal
authored andcommitted
mtd: nand: 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 (mostly) ignored 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. Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Acked-by: Tudor Ambarus <tudor.ambarus@linaro.org> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> # atmel Reviewed-by: Paul Cercueil <paul@crapouillou.net> # ingenic Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> # ingenic Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> # intel Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> # meson Acked-by: Roger Quadros <rogerq@kernel.org> # omap_elm Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> # renesas Reviewed-by: Heiko Stuebner <heiko@sntech.de> # rockchip Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> # sunxi Acked-by: Thierry Reding <treding@nvidia.com> # tegra 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/20230411113816.3472237-1-u.kleine-koenig@pengutronix.de
1 parent 94b8f77 commit ec185b1

49 files changed

Lines changed: 99 additions & 191 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

drivers/mtd/nand/ecc-mxic.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -847,13 +847,11 @@ static int mxic_ecc_probe(struct platform_device *pdev)
847847
return 0;
848848
}
849849

850-
static int mxic_ecc_remove(struct platform_device *pdev)
850+
static void mxic_ecc_remove(struct platform_device *pdev)
851851
{
852852
struct mxic_ecc_engine *mxic = platform_get_drvdata(pdev);
853853

854854
nand_ecc_unregister_on_host_hw_engine(&mxic->external_engine);
855-
856-
return 0;
857855
}
858856

859857
static const struct of_device_id mxic_ecc_of_ids[] = {
@@ -870,7 +868,7 @@ static struct platform_driver mxic_ecc_driver = {
870868
.of_match_table = mxic_ecc_of_ids,
871869
},
872870
.probe = mxic_ecc_probe,
873-
.remove = mxic_ecc_remove,
871+
.remove_new = mxic_ecc_remove,
874872
};
875873
module_platform_driver(mxic_ecc_driver);
876874

drivers/mtd/nand/onenand/generic.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static int generic_onenand_probe(struct platform_device *pdev)
8585
return err;
8686
}
8787

88-
static int generic_onenand_remove(struct platform_device *pdev)
88+
static void generic_onenand_remove(struct platform_device *pdev)
8989
{
9090
struct onenand_info *info = platform_get_drvdata(pdev);
9191
struct resource *res = pdev->resource;
@@ -97,16 +97,14 @@ static int generic_onenand_remove(struct platform_device *pdev)
9797
iounmap(info->onenand.base);
9898
kfree(info);
9999
}
100-
101-
return 0;
102100
}
103101

104102
static struct platform_driver generic_onenand_driver = {
105103
.driver = {
106104
.name = DRIVER_NAME,
107105
},
108106
.probe = generic_onenand_probe,
109-
.remove = generic_onenand_remove,
107+
.remove_new = generic_onenand_remove,
110108
};
111109

112110
module_platform_driver(generic_onenand_driver);

drivers/mtd/nand/onenand/onenand_omap2.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -581,16 +581,14 @@ static int omap2_onenand_probe(struct platform_device *pdev)
581581
return r;
582582
}
583583

584-
static int omap2_onenand_remove(struct platform_device *pdev)
584+
static void omap2_onenand_remove(struct platform_device *pdev)
585585
{
586586
struct omap2_onenand *c = dev_get_drvdata(&pdev->dev);
587587

588588
onenand_release(&c->mtd);
589589
if (c->dma_chan)
590590
dma_release_channel(c->dma_chan);
591591
omap2_onenand_shutdown(pdev);
592-
593-
return 0;
594592
}
595593

596594
static const struct of_device_id omap2_onenand_id_table[] = {
@@ -601,7 +599,7 @@ MODULE_DEVICE_TABLE(of, omap2_onenand_id_table);
601599

602600
static struct platform_driver omap2_onenand_driver = {
603601
.probe = omap2_onenand_probe,
604-
.remove = omap2_onenand_remove,
602+
.remove_new = omap2_onenand_remove,
605603
.shutdown = omap2_onenand_shutdown,
606604
.driver = {
607605
.name = DRIVER_NAME,

drivers/mtd/nand/onenand/onenand_samsung.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -943,13 +943,11 @@ static int s3c_onenand_probe(struct platform_device *pdev)
943943
return 0;
944944
}
945945

946-
static int s3c_onenand_remove(struct platform_device *pdev)
946+
static void s3c_onenand_remove(struct platform_device *pdev)
947947
{
948948
struct mtd_info *mtd = platform_get_drvdata(pdev);
949949

950950
onenand_release(mtd);
951-
952-
return 0;
953951
}
954952

955953
static int s3c_pm_ops_suspend(struct device *dev)
@@ -996,7 +994,7 @@ static struct platform_driver s3c_onenand_driver = {
996994
},
997995
.id_table = s3c_onenand_driver_ids,
998996
.probe = s3c_onenand_probe,
999-
.remove = s3c_onenand_remove,
997+
.remove_new = s3c_onenand_remove,
1000998
};
1001999

10021000
module_platform_driver(s3c_onenand_driver);

drivers/mtd/nand/raw/ams-delta.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ static int gpio_nand_probe(struct platform_device *pdev)
397397
/*
398398
* Clean up routine
399399
*/
400-
static int gpio_nand_remove(struct platform_device *pdev)
400+
static void gpio_nand_remove(struct platform_device *pdev)
401401
{
402402
struct gpio_nand *priv = platform_get_drvdata(pdev);
403403
struct mtd_info *mtd = nand_to_mtd(&priv->nand_chip);
@@ -410,8 +410,6 @@ static int gpio_nand_remove(struct platform_device *pdev)
410410
ret = mtd_device_unregister(mtd);
411411
WARN_ON(ret);
412412
nand_cleanup(mtd_to_nand(mtd));
413-
414-
return 0;
415413
}
416414

417415
#ifdef CONFIG_OF
@@ -434,7 +432,7 @@ MODULE_DEVICE_TABLE(platform, gpio_nand_plat_id_table);
434432

435433
static struct platform_driver gpio_nand_driver = {
436434
.probe = gpio_nand_probe,
437-
.remove = gpio_nand_remove,
435+
.remove_new = gpio_nand_remove,
438436
.id_table = gpio_nand_plat_id_table,
439437
.driver = {
440438
.name = "ams-delta-nand",

drivers/mtd/nand/raw/arasan-nand-controller.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,16 +1496,14 @@ static int anfc_probe(struct platform_device *pdev)
14961496
return ret;
14971497
}
14981498

1499-
static int anfc_remove(struct platform_device *pdev)
1499+
static void anfc_remove(struct platform_device *pdev)
15001500
{
15011501
struct arasan_nfc *nfc = platform_get_drvdata(pdev);
15021502

15031503
anfc_chips_cleanup(nfc);
15041504

15051505
clk_disable_unprepare(nfc->bus_clk);
15061506
clk_disable_unprepare(nfc->controller_clk);
1507-
1508-
return 0;
15091507
}
15101508

15111509
static const struct of_device_id anfc_ids[] = {
@@ -1525,7 +1523,7 @@ static struct platform_driver anfc_driver = {
15251523
.of_match_table = anfc_ids,
15261524
},
15271525
.probe = anfc_probe,
1528-
.remove = anfc_remove,
1526+
.remove_new = anfc_remove,
15291527
};
15301528
module_platform_driver(anfc_driver);
15311529

drivers/mtd/nand/raw/atmel/nand-controller.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,13 +2626,11 @@ static int atmel_nand_controller_probe(struct platform_device *pdev)
26262626
return caps->ops->probe(pdev, caps);
26272627
}
26282628

2629-
static int atmel_nand_controller_remove(struct platform_device *pdev)
2629+
static void atmel_nand_controller_remove(struct platform_device *pdev)
26302630
{
26312631
struct atmel_nand_controller *nc = platform_get_drvdata(pdev);
26322632

26332633
WARN_ON(nc->caps->ops->remove(nc));
2634-
2635-
return 0;
26362634
}
26372635

26382636
static __maybe_unused int atmel_nand_controller_resume(struct device *dev)
@@ -2663,7 +2661,7 @@ static struct platform_driver atmel_nand_controller_driver = {
26632661
.pm = &atmel_nand_controller_pm_ops,
26642662
},
26652663
.probe = atmel_nand_controller_probe,
2666-
.remove = atmel_nand_controller_remove,
2664+
.remove_new = atmel_nand_controller_remove,
26672665
};
26682666
module_platform_driver(atmel_nand_controller_driver);
26692667

drivers/mtd/nand/raw/au1550nd.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static int au1550nd_probe(struct platform_device *pdev)
337337
return ret;
338338
}
339339

340-
static int au1550nd_remove(struct platform_device *pdev)
340+
static void au1550nd_remove(struct platform_device *pdev)
341341
{
342342
struct au1550nd_ctx *ctx = platform_get_drvdata(pdev);
343343
struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -350,15 +350,14 @@ static int au1550nd_remove(struct platform_device *pdev)
350350
iounmap(ctx->base);
351351
release_mem_region(r->start, 0x1000);
352352
kfree(ctx);
353-
return 0;
354353
}
355354

356355
static struct platform_driver au1550nd_driver = {
357356
.driver = {
358357
.name = "au1550-nand",
359358
},
360359
.probe = au1550nd_probe,
361-
.remove = au1550nd_remove,
360+
.remove_new = au1550nd_remove,
362361
};
363362

364363
module_platform_driver(au1550nd_driver);

drivers/mtd/nand/raw/bcm47xxnflash/main.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static int bcm47xxnflash_probe(struct platform_device *pdev)
5757
return 0;
5858
}
5959

60-
static int bcm47xxnflash_remove(struct platform_device *pdev)
60+
static void bcm47xxnflash_remove(struct platform_device *pdev)
6161
{
6262
struct bcm47xxnflash *nflash = platform_get_drvdata(pdev);
6363
struct nand_chip *chip = &nflash->nand_chip;
@@ -66,13 +66,11 @@ static int bcm47xxnflash_remove(struct platform_device *pdev)
6666
ret = mtd_device_unregister(nand_to_mtd(chip));
6767
WARN_ON(ret);
6868
nand_cleanup(chip);
69-
70-
return 0;
7169
}
7270

7371
static struct platform_driver bcm47xxnflash_driver = {
7472
.probe = bcm47xxnflash_probe,
75-
.remove = bcm47xxnflash_remove,
73+
.remove_new = bcm47xxnflash_remove,
7674
.driver = {
7775
.name = "bcma_nflash",
7876
},

drivers/mtd/nand/raw/cadence-nand-controller.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3055,18 +3055,16 @@ static int cadence_nand_dt_probe(struct platform_device *ofdev)
30553055
return 0;
30563056
}
30573057

3058-
static int cadence_nand_dt_remove(struct platform_device *ofdev)
3058+
static void cadence_nand_dt_remove(struct platform_device *ofdev)
30593059
{
30603060
struct cadence_nand_dt *dt = platform_get_drvdata(ofdev);
30613061

30623062
cadence_nand_remove(&dt->cdns_ctrl);
3063-
3064-
return 0;
30653063
}
30663064

30673065
static struct platform_driver cadence_nand_dt_driver = {
30683066
.probe = cadence_nand_dt_probe,
3069-
.remove = cadence_nand_dt_remove,
3067+
.remove_new = cadence_nand_dt_remove,
30703068
.driver = {
30713069
.name = "cadence-nand-controller",
30723070
.of_match_table = cadence_nand_dt_ids,

0 commit comments

Comments
 (0)