mtd/drivers/mtd mtdpart.c,1.35,1.36
David Woodhouse
dwmw2 at infradead.org
Fri May 16 12:06:47 EDT 2003
Update of /home/cvs/mtd/drivers/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv24902/drivers/mtd
Modified Files:
mtdpart.c
Log Message:
New partition probing stuff
Index: mtdpart.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/mtdpart.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- mtdpart.c 14 May 2003 22:26:27 -0000 1.35
+++ mtdpart.c 16 May 2003 16:06:44 -0000 1.36
@@ -479,6 +479,75 @@
EXPORT_SYMBOL(add_mtd_partitions);
EXPORT_SYMBOL(del_mtd_partitions);
+static spinlock_t part_parser_lock = SPIN_LOCK_UNLOCKED;
+static LIST_HEAD(part_parsers);
+
+struct mtd_part_parser *get_partition_parser(const char *name)
+{
+ struct list_head *this;
+ void *ret = NULL;
+ spin_lock(&part_parser_lock);
+
+ list_for_each(this, &part_parsers) {
+ struct mtd_part_parser *p = list_entry(this, struct mtd_part_parser, list);
+
+ if (!strcmp(p->name, name) && try_module_get(p->owner)) {
+ ret = p;
+ break;
+ }
+ }
+ spin_unlock(&part_parser_lock);
+
+ return ret;
+}
+
+int register_mtd_parser(struct mtd_part_parser *p)
+{
+ spin_lock(&part_parser_lock);
+ list_add(&p->list, &part_parsers);
+ spin_unlock(&part_parser_lock);
+
+ return 0;
+}
+
+int deregister_mtd_parser(struct mtd_part_parser *p)
+{
+ spin_lock(&part_parser_lock);
+ list_del(&p->list);
+ spin_unlock(&part_parser_lock);
+ return 0;
+}
+
+int parse_mtd_partitions(struct mtd_info *master, const char **types,
+ struct mtd_partition **pparts, unsigned long origin)
+{
+ struct mtd_part_parser *parser;
+ int ret = 0;
+
+ for ( ; ret <= 0 && *types; types++) {
+ parser = get_partition_parser(*types);
+#ifdef CONFIG_KMOD
+ if (!parser && !request_module(*types))
+ parser = get_partition_parser(*types);
+#endif
+ if (!parser) {
+ printk(KERN_NOTICE "%s partition parsing not available\n",
+ *types);
+ continue;
+ }
+ ret = (*parser->parse_fn)(master, pparts, origin);
+ if (ret > 0) {
+ printk(KERN_NOTICE "%d %s partitions found on MTD device %s\n",
+ ret, parser->name, master->name);
+ }
+ put_partition_parser(parser);
+ }
+ return ret;
+}
+
+EXPORT_SYMBOL_GPL(parse_mtd_partitions);
+EXPORT_SYMBOL_GPL(register_mtd_parser);
+EXPORT_SYMBOL_GPL(deregister_mtd_parser);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Nicolas Pitre <nico at cam.org>");
More information about the linux-mtd-cvs
mailing list