/* Remove a device from the list of MTD devices present in the system, and notify each currently active MTD 'user' of its departure. Returns zero on success or 1 on failure, which currently will happen if the requested device does not appear to be present in the list.  */
int del_mtd_device(struct mtd_info *mtd)
/* Remove a device from the list of MTD devices present in the system, and notify each currently active MTD 'user' of its departure. Returns zero on success or 1 on failure, which currently will happen if the requested device does not appear to be present in the list.  */
int del_mtd_device(struct mtd_info *mtd)
{
	int ret;
	mutex_lock(&mtd_table_mutex);
	if (mtd_table[mtd->index] != mtd) {
		ret = -ENODEV;
	} else 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 {
		struct mtd_notifier *not;
		device_unregister(&mtd->dev);
		list_for_each_entry(not, &mtd_notifiers, list)
			not->remove(mtd);
		mtd_table[mtd->index] = NULL;
		module_put(THIS_MODULE);
		ret = 0;
	}
	mutex_unlock(&mtd_table_mutex);
	return ret;
}