@@ -499,16 +499,17 @@ 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);