Merge git://git.denx.de/u-boot-fsl-qoriq
[oweals/u-boot.git] / fs / jffs2 / jffs2_nand_1pass.c
index 3982003a4215d0c3902f6e1c9665af9b07f8ac81..b16005e6045ffda2cdb6176bd856066be10b1556 100644 (file)
@@ -23,7 +23,7 @@
 # define DEBUGF(fmt,args...)
 #endif
 
-static nand_info_t *nand;
+static struct mtd_info *mtd;
 
 /* Compression names */
 static char *compr_names[] = {
@@ -304,7 +304,7 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 ino, char *dest,
                        len = sizeof(struct jffs2_raw_inode);
                        if (dest)
                                len += jNode->csize;
-                       nand_read(nand, jNode->offset, &len, inode);
+                       nand_read(mtd, jNode->offset, &len, inode);
                        /* ignore data behind latest known EOF */
                        if (inode->offset > totalSize)
                                continue;
@@ -350,7 +350,7 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 ino, char *dest,
 #endif
                        default:
                                /* unknown */
-                               putLabeledWord("UNKOWN COMPRESSION METHOD = ", inode->compr);
+                               putLabeledWord("UNKNOWN COMPRESSION METHOD = ", inode->compr);
                                return -1;
                        }
                }
@@ -450,7 +450,7 @@ dump_inode(struct b_lists *pL, struct b_dirent *d, struct b_inode *i)
 
        if(!d || !i) return -1;
        len = d->nsize;
-       nand_read(nand, d->offset + sizeof(struct jffs2_raw_dirent),
+       nand_read(mtd, d->offset + sizeof(struct jffs2_raw_dirent),
                  &len, &fname);
        fname[d->nsize] = '\0';
 
@@ -592,7 +592,9 @@ jffs2_1pass_resolve_inode(struct b_lists * pL, u32 ino)
        for (jNode = (struct b_inode *)pL->frag.listHead; jNode; jNode = jNode->next) {
                if (jNode->ino == jDirFoundIno) {
                        size_t len = jNode->csize;
-                       nand_read(nand, jNode->offset + sizeof(struct jffs2_raw_inode), &len, &tmp);
+                       nand_read(mtd,
+                                 jNode->offset + sizeof(struct jffs2_raw_inode),
+                                 &len, &tmp);
                        tmp[jNode->csize] = '\0';
                        break;
                }
@@ -760,14 +762,14 @@ dump_dirents(struct b_lists *pL)
 #endif
 
 static int
-jffs2_fill_scan_buf(nand_info_t *nand, unsigned char *buf,
+jffs2_fill_scan_buf(struct mtd_info *mtd, unsigned char *buf,
                    unsigned ofs, unsigned len)
 {
        int ret;
        unsigned olen;
 
        olen = len;
-       ret = nand_read(nand, ofs, &olen, buf);
+       ret = nand_read(mtd, ofs, &olen, buf);
        if (ret) {
                printf("nand_read(0x%x bytes from 0x%x) returned %d\n", len, ofs, ret);
                return ret;
@@ -794,7 +796,11 @@ jffs2_1pass_build_lists(struct part_info * part)
        u32 counterN = 0;
 
        struct mtdids *id = part->dev->id;
-       nand = nand_info + id->num;
+       mtd = get_nand_dev_by_index(id->num);
+       if (!mtd) {
+               pr_err("\nno NAND devices available\n");
+               return 0;
+       }
 
        /* if we are building a list we need to refresh the cache. */
        jffs_init_1pass_list(part);
@@ -802,7 +808,7 @@ jffs2_1pass_build_lists(struct part_info * part)
        pL->partOffset = part->offset;
        puts ("Scanning JFFS2 FS:   ");
 
-       sectorsize = nand->erasesize;
+       sectorsize = mtd->erasesize;
        nr_blocks = part->size / sectorsize;
        buf = malloc(sectorsize);
        if (!buf)
@@ -813,10 +819,10 @@ jffs2_1pass_build_lists(struct part_info * part)
 
                offset = part->offset + i * sectorsize;
 
-               if (nand_block_isbad(nand, offset))
+               if (nand_block_isbad(mtd, offset))
                        continue;
 
-               if (jffs2_fill_scan_buf(nand, buf, offset, EMPTY_SCAN_SIZE))
+               if (jffs2_fill_scan_buf(mtd, buf, offset, EMPTY_SCAN_SIZE))
                        return 0;
 
                ofs = 0;
@@ -826,7 +832,7 @@ jffs2_1pass_build_lists(struct part_info * part)
                if (ofs == EMPTY_SCAN_SIZE)
                        continue;
 
-               if (jffs2_fill_scan_buf(nand, buf + EMPTY_SCAN_SIZE, offset + EMPTY_SCAN_SIZE, sectorsize - EMPTY_SCAN_SIZE))
+               if (jffs2_fill_scan_buf(mtd, buf + EMPTY_SCAN_SIZE, offset + EMPTY_SCAN_SIZE, sectorsize - EMPTY_SCAN_SIZE))
                        return 0;
                offset += ofs;