static int read_nand_cached(u32 off, u32 size, u_char *buf)
{
struct mtdids *id = current_part->dev->id;
+ struct mtd_info *mtd;
u32 bytes_read = 0;
size_t retlen;
int cpy_bytes;
+ mtd = get_nand_dev_by_index(id->num);
+ if (!mtd)
+ return -1;
+
while (bytes_read < size) {
if ((off + bytes_read < nand_cache_off) ||
(off + bytes_read >= nand_cache_off+NAND_CACHE_SIZE)) {
}
retlen = NAND_CACHE_SIZE;
- if (nand_read(nand_info[id->num], nand_cache_off,
- &retlen, nand_cache) != 0 ||
+ if (nand_read(mtd, nand_cache_off,
+ &retlen, nand_cache) != 0 ||
retlen != NAND_CACHE_SIZE) {
printf("read_nand_cached: error reading nand off %#x size %d bytes\n",
nand_cache_off, NAND_CACHE_SIZE);
u32 counterN = 0;
struct mtdids *id = part->dev->id;
- mtd = nand_info[id->num];
+ mtd = get_nand_dev_by_index(id->num);
+ if (!mtd) {
+ error("\nno NAND devices available\n");
+ return 0;
+ }
/* if we are building a list we need to refresh the cache. */
jffs_init_1pass_list(part);
char *mp = NULL;
struct nand_chip *chip;
+ mtd = get_nand_dev_by_index(flash_dev);
+ if (!mtd) {
+ error("\nno NAND devices available\n");
+ return;
+ }
+
dev = calloc(1, sizeof(*dev));
mp = strdup(_mp);
- mtd = nand_info[flash_dev];
-
if (!dev || !mp) {
/* Alloc error */
printf("Failed to allocate memory\n");