mtd/drivers/mtd/chips chipreg.c,1.13,1.14

David Woodhouse dwmw2 at infradead.org
Wed May 21 07:42:10 EDT 2003


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

Modified Files:
	chipreg.c 
Log Message:
Take map_destroy() out of line, fix up module count stuff for 2.5


Index: chipreg.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/chipreg.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- chipreg.c	21 Feb 2002 08:26:58 -0000	1.13
+++ chipreg.c	21 May 2003 11:42:06 -0000	1.14
@@ -9,7 +9,6 @@
 #include <linux/config.h>
 #include <linux/kmod.h>
 #include <linux/spinlock.h>
-#include <linux/mtd/compatmac.h>
 #include <linux/mtd/map.h>
 
 spinlock_t chip_drvs_lock = SPIN_LOCK_UNLOCKED;
@@ -44,10 +43,8 @@
 			break;
 		}
 	}
-	if (ret && !try_inc_mod_count(ret->module)) {
-		/* Eep. Failed. */
+	if (ret && !try_module_get(ret->module))
 		ret = NULL;
-	}
 
 	spin_unlock(&chip_drvs_lock);
 
@@ -71,25 +68,39 @@
 		return NULL;
 
 	ret = drv->probe(map);
-#ifdef CONFIG_MODULES
+
 	/* We decrease the use count here. It may have been a 
 	   probe-only module, which is no longer required from this
 	   point, having given us a handle on (and increased the use
 	   count of) the actual driver code.
 	*/
-	if(drv->module)
-		__MOD_DEC_USE_COUNT(drv->module);
-#endif
+	module_put(drv->module);
 
 	if (ret)
 		return ret;
 	
 	return NULL;
 }
+/*
+ * Destroy an MTD device which was created for a map device.
+ * Make sure the MTD device is already unregistered before calling this
+ */
+void map_destroy(struct mtd_info *mtd)
+{
+	struct map_info *map = mtd->priv;
+
+	if (map->fldrv->destroy)
+		map->fldrv->destroy(mtd);
+
+	module_put(map->fldrv->module);
+
+	kfree(mtd);
+}
 
 EXPORT_SYMBOL(register_mtd_chip_driver);
 EXPORT_SYMBOL(unregister_mtd_chip_driver);
 EXPORT_SYMBOL(do_map_probe);
+EXPORT_SYMBOL(map_destroy);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("David Woodhouse <dwmw2 at infradead.org>");




More information about the linux-mtd-cvs mailing list