[PATCH 4/5] mtd: Don't unconditionally execute remove notifiers
Richard Weinberger
richard at nod.at
Mon Jul 4 15:06:22 PDT 2016
Only call them when we're really removing the MTD.
Signed-off-by: Richard Weinberger <richard at nod.at>
---
drivers/mtd/mtdcore.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 36e5fb0..f49e103 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -499,16 +499,16 @@ int del_mtd_device(struct mtd_info *mtd)
goto out_error;
}
- /* No need to get a refcount on the module containing
- the notifier, since we hold the mtd_table_mutex */
- list_for_each_entry(not, &mtd_notifiers, list)
- not->remove(mtd);
-
if (mtd->usecount) {
printk(KERN_NOTICE "Removing MTD device #%d (%s) with use count %d\n",
mtd->index, mtd->name, mtd->usecount);
ret = -EBUSY;
} else {
+ /* No need to get a refcount on the module containing
+ the notifier, since we hold the mtd_table_mutex */
+ list_for_each_entry(not, &mtd_notifiers, list)
+ not->remove(mtd);
+
device_unregister(&mtd->dev);
idr_remove(&mtd_idr, mtd->index);
--
2.7.3
More information about the linux-mtd
mailing list