mtd/drivers/mtd mtd_blkdevs-24.c,1.5,1.6

David Woodhouse dwmw2 at infradead.org
Tue May 20 21:01:36 EDT 2003


Update of /home/cvs/mtd/drivers/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv20742/drivers/mtd

Modified Files:
	mtd_blkdevs-24.c 
Log Message:
Remove unnecessary usecounts in dev and tr

Index: mtd_blkdevs-24.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/mtd_blkdevs-24.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- mtd_blkdevs-24.c	20 May 2003 21:52:08 -0000	1.5
+++ mtd_blkdevs-24.c	21 May 2003 01:01:33 -0000	1.6
@@ -231,13 +231,9 @@
 		goto out_tr;
 
 	dev->mtd->usecount++;
-	dev->usecount++;
-	tr->usecount++;
 
 	ret = 0;
 	if (tr->open && (ret = tr->open(dev, i, f))) {
-		tr->usecount--;
-		dev->usecount--;
 		dev->mtd->usecount--;
 		__MOD_DEC_USE_COUNT(dev->mtd->owner);
 	out_tr:
@@ -276,8 +272,6 @@
 		ret = tr->release(dev, i, f);
 
 	if (!ret) {
-		tr->usecount--;
-		dev->usecount--;
 		dev->mtd->usecount--;
 		__MOD_DEC_USE_COUNT(dev->mtd->owner);
 		__MOD_DEC_USE_COUNT(tr->owner);
@@ -308,11 +302,6 @@
 	   much the Linux block layer sucks? Sledgehammer approach... */
 	down(&mtd_table_mutex);
 
-	if (dev->usecount > 1) {
-		up(&mtd_table_mutex);
-		return -EBUSY;
-	}
-
 	for (i=0; i < (1<<tr->part_bits); i++) {
 		invalidate_device(MKDEV(tr->major, minor+i), 1);
 		gd->part[minor + i].start_sect = 0;
@@ -434,7 +423,6 @@
 	list_add_tail(&new->list, &tr->devs);
  added:
 	spin_unlock(&tr->blkcore_priv->devs_lock);
-	new->usecount = 0;
 
 	if (!tr->writesect)
 		new->readonly = 1;
@@ -483,8 +471,6 @@
 		BUG();
 	}
 
-	if (old->usecount)
-		return -EBUSY;
 #ifdef CONFIG_DEVFS_FS
 	devfs_unregister(old->blkcore_priv);
 #endif
@@ -576,6 +562,8 @@
 	if (ret < 0) {
 		blk_cleanup_queue(BLK_DEFAULT_QUEUE(tr->major));
 		devfs_unregister_blkdev(tr->major, tr->name);
+		kfree(tr->blkcore_priv);
+		up(&mtd_table_mutex);
 		return ret;
 	} 
 
@@ -596,7 +584,6 @@
 
 	add_gendisk(&tr->blkcore_priv->gd);
 
-	tr->usecount = 0;
 	INIT_LIST_HEAD(&tr->devs);
 	list_add(&tr->list, &blktrans_majors);
 
@@ -615,11 +602,6 @@
 
 	down(&mtd_table_mutex);
 
-	if (tr->usecount) {
-		up(&mtd_table_mutex);
-		return -EBUSY;
-	}
-
 	/* Clean up the kernel thread */
 	tr->blkcore_priv->exiting = 1;
 	wake_up(&tr->blkcore_priv->thread_wq);
@@ -633,14 +615,16 @@
 		struct mtd_blktrans_dev *dev = list_entry(this, struct mtd_blktrans_dev, list);
 		tr->remove_dev(dev);
 	}
-	blk_cleanup_queue(BLK_DEFAULT_QUEUE(tr->major));
+
+	devfs_unregister(tr->blkcore_priv->devfs_dir_handle);
+
 	blksize_size[tr->major] = NULL;
 	blk_size[tr->major] = NULL;
 
 	del_gendisk(&tr->blkcore_priv->gd);
 
+	blk_cleanup_queue(BLK_DEFAULT_QUEUE(tr->major));
 	devfs_unregister_blkdev(tr->major, tr->name);
-	devfs_unregister(tr->blkcore_priv->devfs_dir_handle);
 
 	up(&mtd_table_mutex);
 
@@ -660,6 +644,11 @@
 }
 
 module_exit(mtd_blktrans_exit);
+
+EXPORT_SYMBOL_GPL(register_mtd_blktrans);
+EXPORT_SYMBOL_GPL(deregister_mtd_blktrans);
+EXPORT_SYMBOL_GPL(add_mtd_blktrans_dev);
+EXPORT_SYMBOL_GPL(del_mtd_blktrans_dev);
 
 MODULE_AUTHOR("David Woodhouse <dwmw2 at infradead.org>");
 MODULE_LICENSE("GPL");




More information about the linux-mtd-cvs mailing list