mtd: introduce mtd_block_isbad interface
[sfrench/cifs-2.6.git] / drivers / mtd / redboot.c
index 7a87d07cd79f4bcae8dcf11241d0b052fa765cd9..09bb81ea3a7ebc8a631f8729c729cd70e98d6ddb 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
+#include <linux/module.h>
 
 struct fis_image_desc {
     unsigned char name[16];      // Null terminated name
@@ -56,8 +57,8 @@ static inline int redboot_checksum(struct fis_image_desc *img)
 }
 
 static int parse_redboot_partitions(struct mtd_info *master,
-                             struct mtd_partition **pparts,
-                             unsigned long fis_origin)
+                                   struct mtd_partition **pparts,
+                                   struct mtd_part_parser_data *data)
 {
        int nrparts = 0;
        struct fis_image_desc *buf;
@@ -78,7 +79,7 @@ static int parse_redboot_partitions(struct mtd_info *master,
        if ( directory < 0 ) {
                offset = master->size + directory * master->erasesize;
                while (master->block_isbad && 
-                      master->block_isbad(master, offset)) {
+                      mtd_block_isbad(master, offset)) {
                        if (!offset) {
                        nogood:
                                printk(KERN_NOTICE "Failed to find a non-bad block to check for RedBoot partition table\n");
@@ -89,7 +90,7 @@ static int parse_redboot_partitions(struct mtd_info *master,
        } else {
                offset = directory * master->erasesize;
                while (master->block_isbad && 
-                      master->block_isbad(master, offset)) {
+                      mtd_block_isbad(master, offset)) {
                        offset += master->erasesize;
                        if (offset == master->size)
                                goto nogood;
@@ -103,8 +104,8 @@ static int parse_redboot_partitions(struct mtd_info *master,
        printk(KERN_NOTICE "Searching for RedBoot partition table in %s at offset 0x%lx\n",
               master->name, offset);
 
-       ret = master->read(master, offset,
-                          master->erasesize, &retlen, (void *)buf);
+       ret = mtd_read(master, offset, master->erasesize, &retlen,
+                      (void *)buf);
 
        if (ret)
                goto out;
@@ -197,11 +198,10 @@ static int parse_redboot_partitions(struct mtd_info *master,
                        goto out;
                }
                new_fl->img = &buf[i];
-                if (fis_origin) {
-                        buf[i].flash_base -= fis_origin;
-                } else {
-                        buf[i].flash_base &= master->size-1;
-                }
+               if (data && data->origin)
+                       buf[i].flash_base -= data->origin;
+               else
+                       buf[i].flash_base &= master->size-1;
 
                /* I'm sure the JFFS2 code has done me permanent damage.
                 * I now think the following is _normal_
@@ -297,6 +297,9 @@ static struct mtd_part_parser redboot_parser = {
        .name = "RedBoot",
 };
 
+/* mtd parsers will request the module by parser name */
+MODULE_ALIAS("RedBoot");
+
 static int __init redboot_parser_init(void)
 {
        return register_mtd_parser(&redboot_parser);