Skip to content

Commit bb82365

Browse files
Uwe Kleine-Königmiquelraynal
authored andcommitted
mtd: physmap: 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. 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-14-u.kleine-koenig@pengutronix.de
1 parent 43adab7 commit bb82365

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

drivers/mtd/maps/physmap-core.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static int physmap_flash_remove(struct platform_device *dev)
6666
{
6767
struct physmap_flash_info *info;
6868
struct physmap_flash_data *physmap_data;
69-
int i, err = 0;
69+
int i;
7070

7171
info = platform_get_drvdata(dev);
7272
if (!info) {
@@ -75,9 +75,7 @@ static int physmap_flash_remove(struct platform_device *dev)
7575
}
7676

7777
if (info->cmtd) {
78-
err = mtd_device_unregister(info->cmtd);
79-
if (err)
80-
goto out;
78+
WARN_ON(mtd_device_unregister(info->cmtd));
8179

8280
if (info->cmtd != info->mtds[0])
8381
mtd_concat_destroy(info->cmtd);
@@ -92,10 +90,9 @@ static int physmap_flash_remove(struct platform_device *dev)
9290
if (physmap_data && physmap_data->exit)
9391
physmap_data->exit(dev);
9492

95-
out:
9693
pm_runtime_put(&dev->dev);
9794
pm_runtime_disable(&dev->dev);
98-
return err;
95+
return 0;
9996
}
10097

10198
static void physmap_set_vpp(struct map_info *map, int state)

0 commit comments

Comments
 (0)