# define DEBUGF(fmt,args...)
#endif
-static nand_info_t *nand;
+static struct mtd_info *mtd;
/* Compression names */
static char *compr_names[] = {
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;
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';
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;
}
#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;
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);
pL->partOffset = part->offset;
puts ("Scanning JFFS2 FS: ");
- sectorsize = nand->erasesize;
+ sectorsize = mtd->erasesize;
nr_blocks = part->size / sectorsize;
buf = malloc(sectorsize);
if (!buf)
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;
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;