]> git.sur5r.net Git - u-boot/commitdiff
mtd: nand: Remove nand_info_t typedef
authorScott Wood <oss@buserror.net>
Mon, 30 May 2016 18:57:54 +0000 (13:57 -0500)
committerScott Wood <oss@buserror.net>
Sat, 4 Jun 2016 01:27:48 +0000 (20:27 -0500)
This typedef serves no purpose other than causing confusion with
struct nand_chip.

Signed-off-by: Scott Wood <oss@buserror.net>
15 files changed:
cmd/bootm.c
cmd/jffs2.c
cmd/nand.c
common/env_nand.c
common/fb_nand.c
drivers/dfu/dfu_nand.c
drivers/mtd/nand/am335x_spl_bch.c
drivers/mtd/nand/atmel_nand.c
drivers/mtd/nand/mxs_nand_spl.c
drivers/mtd/nand/nand.c
drivers/mtd/nand/nand_spl_simple.c
drivers/mtd/nand/nand_util.c
fs/jffs2/jffs2_nand_1pass.c
fs/yaffs2/yaffs_uboot_glue.c
include/nand.h

index ee3b460adb09ac7c192a0f32825480455ff5a05f..24f1054f34b633c96b951e4b519cc77552fa8e6c 100644 (file)
@@ -372,8 +372,8 @@ next_bank:  ;
 #endif
 
 #if defined(CONFIG_CMD_IMLS_NAND)
-static int nand_imls_legacyimage(nand_info_t *nand, int nand_dev, loff_t off,
-               size_t len)
+static int nand_imls_legacyimage(struct mtd_info *mtd, int nand_dev,
+                                loff_t off, size_t len)
 {
        void *imgdata;
        int ret;
@@ -386,8 +386,7 @@ static int nand_imls_legacyimage(nand_info_t *nand, int nand_dev, loff_t off,
                return -ENOMEM;
        }
 
-       ret = nand_read_skip_bad(nand, off, &len,
-                       imgdata);
+       ret = nand_read_skip_bad(mtd, off, &len, imgdata);
        if (ret < 0 && ret != -EUCLEAN) {
                free(imgdata);
                return ret;
@@ -413,8 +412,8 @@ static int nand_imls_legacyimage(nand_info_t *nand, int nand_dev, loff_t off,
        return 0;
 }
 
-static int nand_imls_fitimage(nand_info_t *nand, int nand_dev, loff_t off,
-               size_t len)
+static int nand_imls_fitimage(struct mtd_info *mtd, int nand_dev, loff_t off,
+                             size_t len)
 {
        void *imgdata;
        int ret;
@@ -427,8 +426,7 @@ static int nand_imls_fitimage(nand_info_t *nand, int nand_dev, loff_t off,
                return -ENOMEM;
        }
 
-       ret = nand_read_skip_bad(nand, off, &len,
-                       imgdata);
+       ret = nand_read_skip_bad(mtd, off, &len, imgdata);
        if (ret < 0 && ret != -EUCLEAN) {
                free(imgdata);
                return ret;
@@ -449,7 +447,7 @@ static int nand_imls_fitimage(nand_info_t *nand, int nand_dev, loff_t off,
 
 static int do_imls_nand(void)
 {
-       nand_info_t *nand;
+       struct mtd_info *mtd;
        int nand_dev = nand_curr_device;
        size_t len;
        loff_t off;
@@ -463,20 +461,20 @@ static int do_imls_nand(void)
        printf("\n");
 
        for (nand_dev = 0; nand_dev < CONFIG_SYS_MAX_NAND_DEVICE; nand_dev++) {
-               nand = &nand_info[nand_dev];
-               if (!nand->name || !nand->size)
+               mtd = &nand_info[nand_dev];
+               if (!mtd->name || !mtd->size)
                        continue;
 
-               for (off = 0; off < nand->size; off += nand->erasesize) {
+               for (off = 0; off < mtd->size; off += mtd->erasesize) {
                        const image_header_t *header;
                        int ret;
 
-                       if (nand_block_isbad(nand, off))
+                       if (nand_block_isbad(mtd, off))
                                continue;
 
                        len = sizeof(buffer);
 
-                       ret = nand_read(nand, off, &len, (u8 *)buffer);
+                       ret = nand_read(mtd, off, &len, (u8 *)buffer);
                        if (ret < 0 && ret != -EUCLEAN) {
                                printf("NAND read error %d at offset %08llX\n",
                                                ret, off);
@@ -489,13 +487,13 @@ static int do_imls_nand(void)
                                header = (const image_header_t *)buffer;
 
                                len = image_get_image_size(header);
-                               nand_imls_legacyimage(nand, nand_dev, off, len);
+                               nand_imls_legacyimage(mtd, nand_dev, off, len);
                                break;
 #endif
 #if defined(CONFIG_FIT)
                        case IMAGE_FORMAT_FIT:
                                len = fit_get_size(buffer);
-                               nand_imls_fitimage(nand, nand_dev, off, len);
+                               nand_imls_fitimage(mtd, nand_dev, off, len);
                                break;
 #endif
                        }
index 0b2eefa195436d3e5faaaa428ad2677e83a0e77c..e4eaa48c1f578f9991fdf66c148bfdc95dc8cd1e 100644 (file)
@@ -242,11 +242,11 @@ static int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *d
 static inline u32 get_part_sector_size_nand(struct mtdids *id)
 {
 #if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND)
-       nand_info_t *nand;
+       struct mtd_info *mtd;
 
-       nand = &nand_info[id->num];
+       mtd = &nand_info[id->num];
 
-       return nand->erasesize;
+       return mtd->erasesize;
 #else
        BUG();
        return 0;
index a6b67e29f1cd349c4b21ba03103b2c7abd69a86e..0439607d682e42576e9334bd6af62b9e8667bfe5 100644 (file)
@@ -38,7 +38,8 @@ int find_dev_and_part(const char *id, struct mtd_device **dev,
                      u8 *part_num, struct part_info **part);
 #endif
 
-static int nand_dump(nand_info_t *nand, ulong off, int only_oob, int repeat)
+static int nand_dump(struct mtd_info *mtd, ulong off, int only_oob,
+                    int repeat)
 {
        int i;
        u_char *datbuf, *oobbuf, *p;
@@ -46,32 +47,32 @@ static int nand_dump(nand_info_t *nand, ulong off, int only_oob, int repeat)
        int ret = 0;
 
        if (repeat)
-               off = last + nand->writesize;
+               off = last + mtd->writesize;
 
        last = off;
 
-       datbuf = memalign(ARCH_DMA_MINALIGN, nand->writesize);
+       datbuf = memalign(ARCH_DMA_MINALIGN, mtd->writesize);
        if (!datbuf) {
                puts("No memory for page buffer\n");
                return 1;
        }
 
-       oobbuf = memalign(ARCH_DMA_MINALIGN, nand->oobsize);
+       oobbuf = memalign(ARCH_DMA_MINALIGN, mtd->oobsize);
        if (!oobbuf) {
                puts("No memory for page buffer\n");
                ret = 1;
                goto free_dat;
        }
-       off &= ~(nand->writesize - 1);
+       off &= ~(mtd->writesize - 1);
        loff_t addr = (loff_t) off;
        struct mtd_oob_ops ops;
        memset(&ops, 0, sizeof(ops));
        ops.datbuf = datbuf;
        ops.oobbuf = oobbuf;
-       ops.len = nand->writesize;
-       ops.ooblen = nand->oobsize;
+       ops.len = mtd->writesize;
+       ops.ooblen = mtd->oobsize;
        ops.mode = MTD_OPS_RAW;
-       i = mtd_read_oob(nand, addr, &ops);
+       i = mtd_read_oob(mtd, addr, &ops);
        if (i < 0) {
                printf("Error (%d) reading page %08lx\n", i, off);
                ret = 1;
@@ -80,7 +81,7 @@ static int nand_dump(nand_info_t *nand, ulong off, int only_oob, int repeat)
        printf("Page %08lx dump:\n", off);
 
        if (!only_oob) {
-               i = nand->writesize >> 4;
+               i = mtd->writesize >> 4;
                p = datbuf;
 
                while (i--) {
@@ -94,7 +95,7 @@ static int nand_dump(nand_info_t *nand, ulong off, int only_oob, int repeat)
        }
 
        puts("OOB:\n");
-       i = nand->oobsize >> 3;
+       i = mtd->oobsize >> 3;
        p = oobbuf;
        while (i--) {
                printf("\t%02x %02x %02x %02x %02x %02x %02x %02x\n",
@@ -152,32 +153,32 @@ static void print_status(ulong start, ulong end, ulong erasesize, int status)
                ((status & NAND_LOCK_STATUS_UNLOCK) ?  "UNLOCK " : ""));
 }
 
-static void do_nand_status(nand_info_t *nand)
+static void do_nand_status(struct mtd_info *mtd)
 {
        ulong block_start = 0;
        ulong off;
        int last_status = -1;
 
-       struct nand_chip *nand_chip = nand->priv;
+       struct nand_chip *nand_chip = mtd->priv;
        /* check the WP bit */
-       nand_chip->cmdfunc(nand, NAND_CMD_STATUS, -1, -1);
+       nand_chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
        printf("device is %swrite protected\n",
-               (nand_chip->read_byte(nand) & 0x80 ?
-               "NOT " : ""));
+               (nand_chip->read_byte(mtd) & 0x80 ?
+                "NOT " : ""));
 
-       for (off = 0; off < nand->size; off += nand->erasesize) {
-               int s = nand_get_lock_status(nand, off);
+       for (off = 0; off < mtd->size; off += mtd->erasesize) {
+               int s = nand_get_lock_status(mtd, off);
 
                /* print message only if status has changed */
                if (s != last_status && off != 0) {
-                       print_status(block_start, off, nand->erasesize,
+                       print_status(block_start, off, mtd->erasesize,
                                        last_status);
                        block_start = off;
                }
                last_status = s;
        }
        /* Print the last block info */
-       print_status(block_start, off, nand->erasesize, last_status);
+       print_status(block_start, off, mtd->erasesize, last_status);
 }
 #endif
 
@@ -188,10 +189,10 @@ int do_nand_env_oob(cmd_tbl_t *cmdtp, int argc, char *const argv[])
 {
        int ret;
        uint32_t oob_buf[ENV_OFFSET_SIZE/sizeof(uint32_t)];
-       nand_info_t *nand = &nand_info[0];
+       struct mtd_info *mtd = &nand_info[0];
        char *cmd = argv[1];
 
-       if (CONFIG_SYS_MAX_NAND_DEVICE == 0 || !nand->name) {
+       if (CONFIG_SYS_MAX_NAND_DEVICE == 0 || !mtd->name) {
                puts("no devices available\n");
                return 1;
        }
@@ -199,7 +200,7 @@ int do_nand_env_oob(cmd_tbl_t *cmdtp, int argc, char *const argv[])
        set_dev(0);
 
        if (!strcmp(cmd, "get")) {
-               ret = get_nand_env_oob(nand, &nand_env_oob_offset);
+               ret = get_nand_env_oob(mtd, &nand_env_oob_offset);
                if (ret)
                        return 1;
 
@@ -229,15 +230,15 @@ int do_nand_env_oob(cmd_tbl_t *cmdtp, int argc, char *const argv[])
                        return 1;
                }
 
-               if (nand->oobavail < ENV_OFFSET_SIZE) {
+               if (mtd->oobavail < ENV_OFFSET_SIZE) {
                        printf("Insufficient available OOB bytes:\n"
                               "%d OOB bytes available but %d required for "
                               "env.oob support\n",
-                              nand->oobavail, ENV_OFFSET_SIZE);
+                              mtd->oobavail, ENV_OFFSET_SIZE);
                        return 1;
                }
 
-               if ((addr & (nand->erasesize - 1)) != 0) {
+               if ((addr & (mtd->erasesize - 1)) != 0) {
                        printf("Environment offset must be block-aligned\n");
                        return 1;
                }
@@ -249,15 +250,15 @@ int do_nand_env_oob(cmd_tbl_t *cmdtp, int argc, char *const argv[])
                ops.oobbuf = (void *) oob_buf;
 
                oob_buf[0] = ENV_OOB_MARKER;
-               oob_buf[1] = addr / nand->erasesize;
+               oob_buf[1] = addr / mtd->erasesize;
 
-               ret = nand->write_oob(nand, ENV_OFFSET_SIZE, &ops);
+               ret = mtd->write_oob(mtd, ENV_OFFSET_SIZE, &ops);
                if (ret) {
                        printf("Error writing OOB block 0\n");
                        return ret;
                }
 
-               ret = get_nand_env_oob(nand, &nand_env_oob_offset);
+               ret = get_nand_env_oob(mtd, &nand_env_oob_offset);
                if (ret) {
                        printf("Error reading env offset in OOB\n");
                        return ret;
@@ -283,29 +284,29 @@ usage:
 
 static void nand_print_and_set_info(int idx)
 {
-       nand_info_t *nand = &nand_info[idx];
-       struct nand_chip *chip = nand->priv;
+       struct mtd_info *mtd = &nand_info[idx];
+       struct nand_chip *chip = mtd->priv;
 
        printf("Device %d: ", idx);
        if (chip->numchips > 1)
                printf("%dx ", chip->numchips);
        printf("%s, sector size %u KiB\n",
-              nand->name, nand->erasesize >> 10);
-       printf("  Page size   %8d b\n", nand->writesize);
-       printf("  OOB size    %8d b\n", nand->oobsize);
-       printf("  Erase size  %8d b\n", nand->erasesize);
+              mtd->name, mtd->erasesize >> 10);
+       printf("  Page size   %8d b\n", mtd->writesize);
+       printf("  OOB size    %8d b\n", mtd->oobsize);
+       printf("  Erase size  %8d b\n", mtd->erasesize);
        printf("  subpagesize %8d b\n", chip->subpagesize);
        printf("  options     0x%8x\n", chip->options);
        printf("  bbt options 0x%8x\n", chip->bbt_options);
 
        /* Set geometry info */
-       setenv_hex("nand_writesize", nand->writesize);
-       setenv_hex("nand_oobsize", nand->oobsize);
-       setenv_hex("nand_erasesize", nand->erasesize);
+       setenv_hex("nand_writesize", mtd->writesize);
+       setenv_hex("nand_oobsize", mtd->oobsize);
+       setenv_hex("nand_erasesize", mtd->erasesize);
 }
 
-static int raw_access(nand_info_t *nand, ulong addr, loff_t off, ulong count,
-                       int read)
+static int raw_access(struct mtd_info *mtd, ulong addr, loff_t off,
+                     ulong count, int read)
 {
        int ret = 0;
 
@@ -313,18 +314,18 @@ static int raw_access(nand_info_t *nand, ulong addr, loff_t off, ulong count,
                /* Raw access */
                mtd_oob_ops_t ops = {
                        .datbuf = (u8 *)addr,
-                       .oobbuf = ((u8 *)addr) + nand->writesize,
-                       .len = nand->writesize,
-                       .ooblen = nand->oobsize,
+                       .oobbuf = ((u8 *)addr) + mtd->writesize,
+                       .len = mtd->writesize,
+                       .ooblen = mtd->oobsize,
                        .mode = MTD_OPS_RAW
                };
 
                if (read) {
-                       ret = mtd_read_oob(nand, off, &ops);
+                       ret = mtd_read_oob(mtd, off, &ops);
                } else {
-                       ret = mtd_write_oob(nand, off, &ops);
+                       ret = mtd_write_oob(mtd, off, &ops);
                        if (!ret)
-                               ret = nand_verify_page_oob(nand, &ops, off);
+                               ret = nand_verify_page_oob(mtd, &ops, off);
                }
 
                if (ret) {
@@ -333,8 +334,8 @@ static int raw_access(nand_info_t *nand, ulong addr, loff_t off, ulong count,
                        break;
                }
 
-               addr += nand->writesize + nand->oobsize;
-               off += nand->writesize;
+               addr += mtd->writesize + mtd->oobsize;
+               off += mtd->writesize;
        }
 
        return ret;
@@ -348,18 +349,18 @@ static void adjust_size_for_badblocks(loff_t *size, loff_t offset, int dev)
        /* We grab the nand info object here fresh because this is usually
         * called after arg_off_size() which can change the value of dev.
         */
-       nand_info_t *nand = &nand_info[dev];
+       struct mtd_info *mtd = &nand_info[dev];
        loff_t maxoffset = offset + *size;
        int badblocks = 0;
 
        /* count badblocks in NAND from offset to offset + size */
-       for (; offset < maxoffset; offset += nand->erasesize) {
-               if (nand_block_isbad(nand, offset))
+       for (; offset < maxoffset; offset += mtd->erasesize) {
+               if (nand_block_isbad(mtd, offset))
                        badblocks++;
        }
        /* adjust size if any bad blocks found */
        if (badblocks) {
-               *size -= badblocks * nand->erasesize;
+               *size -= badblocks * mtd->erasesize;
                printf("size adjusted to 0x%llx (%d bad blocks)\n",
                       (unsigned long long)*size, badblocks);
        }
@@ -371,7 +372,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        ulong addr;
        loff_t off, size, maxsize;
        char *cmd, *s;
-       nand_info_t *nand;
+       struct mtd_info *mtd;
 #ifdef CONFIG_SYS_NAND_QUIET
        int quiet = CONFIG_SYS_NAND_QUIET;
 #else
@@ -437,12 +438,12 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                puts("\nno devices available\n");
                return 1;
        }
-       nand = &nand_info[dev];
+       mtd = &nand_info[dev];
 
        if (strcmp(cmd, "bad") == 0) {
                printf("\nDevice %d bad blocks:\n", dev);
-               for (off = 0; off < nand->size; off += nand->erasesize)
-                       if (nand_block_isbad(nand, off))
+               for (off = 0; off < mtd->size; off += mtd->erasesize)
+                       if (nand_block_isbad(mtd, off))
                                printf("  %08llx\n", (unsigned long long)off);
                return 0;
        }
@@ -502,7 +503,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                if (set_dev(dev))
                        return 1;
 
-               nand = &nand_info[dev];
+               mtd = &nand_info[dev];
 
                memset(&opts, 0, sizeof(opts));
                opts.offset = off;
@@ -524,7 +525,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                                }
                        }
                }
-               ret = nand_erase_opts(nand, &opts);
+               ret = nand_erase_opts(mtd, &opts);
                printf("%s\n", ret ? "ERROR" : "OK");
 
                return ret == 0 ? 0 : 1;
@@ -535,7 +536,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        goto usage;
 
                off = (int)simple_strtoul(argv[2], NULL, 16);
-               ret = nand_dump(nand, off, !strcmp(&cmd[4], ".oob"), repeat);
+               ret = nand_dump(mtd, off, !strcmp(&cmd[4], ".oob"), repeat);
 
                return ret == 0 ? 1 : 0;
        }
@@ -567,19 +568,19 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        if (set_dev(dev))
                                return 1;
 
-                       nand = &nand_info[dev];
+                       mtd = &nand_info[dev];
 
                        if (argc > 4 && !str2long(argv[4], &pagecount)) {
                                printf("'%s' is not a number\n", argv[4]);
                                return 1;
                        }
 
-                       if (pagecount * nand->writesize > size) {
+                       if (pagecount * mtd->writesize > size) {
                                puts("Size exceeds partition or device limit\n");
                                return -1;
                        }
 
-                       rwsize = pagecount * (nand->writesize + nand->oobsize);
+                       rwsize = pagecount * (mtd->writesize + mtd->oobsize);
                } else {
                        if (mtd_arg_off_size(argc - 3, argv + 3, &dev, &off,
                                             &size, &maxsize,
@@ -596,16 +597,16 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        rwsize = size;
                }
 
-               nand = &nand_info[dev];
+               mtd = &nand_info[dev];
 
                if (!s || !strcmp(s, ".jffs2") ||
                    !strcmp(s, ".e") || !strcmp(s, ".i")) {
                        if (read)
-                               ret = nand_read_skip_bad(nand, off, &rwsize,
+                               ret = nand_read_skip_bad(mtd, off, &rwsize,
                                                         NULL, maxsize,
                                                         (u_char *)addr);
                        else
-                               ret = nand_write_skip_bad(nand, off, &rwsize,
+                               ret = nand_write_skip_bad(mtd, off, &rwsize,
                                                          NULL, maxsize,
                                                          (u_char *)addr,
                                                          WITH_WR_VERIFY);
@@ -615,7 +616,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                                printf("Unknown nand command suffix '%s'\n", s);
                                return 1;
                        }
-                       ret = nand_write_skip_bad(nand, off, &rwsize, NULL,
+                       ret = nand_write_skip_bad(mtd, off, &rwsize, NULL,
                                                maxsize, (u_char *)addr,
                                                WITH_DROP_FFS | WITH_WR_VERIFY);
 #endif
@@ -628,11 +629,11 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        };
 
                        if (read)
-                               ret = mtd_read_oob(nand, off, &ops);
+                               ret = mtd_read_oob(mtd, off, &ops);
                        else
-                               ret = mtd_write_oob(nand, off, &ops);
+                               ret = mtd_write_oob(mtd, off, &ops);
                } else if (raw) {
-                       ret = raw_access(nand, addr, off, pagecount, read);
+                       ret = raw_access(mtd, addr, off, pagecount, read);
                } else {
                        printf("Unknown nand command suffix '%s'.\n", s);
                        return 1;
@@ -655,8 +656,8 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                }
 
                printf("\nNAND torture: device %d offset 0x%llx size 0x%x\n",
-                       dev, off, nand->erasesize);
-               ret = nand_torture(nand, off);
+                       dev, off, mtd->erasesize);
+               ret = nand_torture(mtd, off);
                printf(" %s\n", ret ? "Failed" : "Passed");
 
                return ret == 0 ? 0 : 1;
@@ -673,7 +674,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                while (argc > 0) {
                        addr = simple_strtoul(*argv, NULL, 16);
 
-                       if (mtd_block_markbad(nand, addr)) {
+                       if (mtd_block_markbad(mtd, addr)) {
                                printf("block 0x%08lx NOT marked "
                                        "as bad! ERROR %d\n",
                                        addr, ret);
@@ -705,9 +706,9 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                                status = 1;
                }
                if (status) {
-                       do_nand_status(nand);
+                       do_nand_status(mtd);
                } else {
-                       if (!nand_lock(nand, tight)) {
+                       if (!nand_lock(mtd, tight)) {
                                puts("NAND flash successfully locked\n");
                        } else {
                                puts("Error locking NAND flash\n");
@@ -801,7 +802,7 @@ U_BOOT_CMD(
        "NAND sub-system", nand_help_text
 );
 
-static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
+static int nand_load_image(cmd_tbl_t *cmdtp, struct mtd_info *mtd,
                           ulong offset, ulong addr, char *cmd)
 {
        int r;
@@ -822,11 +823,11 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
                return 1;
        }
 
-       printf("\nLoading from %s, offset 0x%lx\n", nand->name, offset);
+       printf("\nLoading from %s, offset 0x%lx\n", mtd->name, offset);
 
-       cnt = nand->writesize;
-       r = nand_read_skip_bad(nand, offset, &cnt, NULL, nand->size,
-                       (u_char *)addr);
+       cnt = mtd->writesize;
+       r = nand_read_skip_bad(mtd, offset, &cnt, NULL, mtd->size,
+                              (u_char *)addr);
        if (r) {
                puts("** Read error\n");
                bootstage_error(BOOTSTAGE_ID_NAND_HDR_READ);
@@ -860,8 +861,8 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
        }
        bootstage_mark(BOOTSTAGE_ID_NAND_TYPE);
 
-       r = nand_read_skip_bad(nand, offset, &cnt, NULL, nand->size,
-                       (u_char *)addr);
+       r = nand_read_skip_bad(mtd, offset, &cnt, NULL, mtd->size,
+                              (u_char *)addr);
        if (r) {
                puts("** Read error\n");
                bootstage_error(BOOTSTAGE_ID_NAND_READ);
index b32eeac9d7673c0137c3554dfd378f9ed2449bf4..0debc2c1926e0c37aa3a96c93de5d58157d4a25c 100644 (file)
@@ -276,7 +276,7 @@ static int readenv(size_t offset, u_char *buf)
 #endif /* #if defined(CONFIG_SPL_BUILD) */
 
 #ifdef CONFIG_ENV_OFFSET_OOB
-int get_nand_env_oob(nand_info_t *nand, unsigned long *result)
+int get_nand_env_oob(struct mtd_info *mtd, unsigned long *result)
 {
        struct mtd_oob_ops ops;
        uint32_t oob_buf[ENV_OFFSET_SIZE / sizeof(uint32_t)];
@@ -288,14 +288,14 @@ int get_nand_env_oob(nand_info_t *nand, unsigned long *result)
        ops.ooblen      = ENV_OFFSET_SIZE;
        ops.oobbuf      = (void *)oob_buf;
 
-       ret = nand->read_oob(nand, ENV_OFFSET_SIZE, &ops);
+       ret = mtd->read_oob(mtd, ENV_OFFSET_SIZE, &ops);
        if (ret) {
                printf("error reading OOB block 0\n");
                return ret;
        }
 
        if (oob_buf[0] == ENV_OOB_MARKER) {
-               *result = oob_buf[1] * nand->erasesize;
+               *result = oob_buf[1] * mtd->erasesize;
        } else if (oob_buf[0] == ENV_OOB_MARKER_OLD) {
                *result = oob_buf[1];
        } else {
index 9ca8602a73ecbab5abdbf86cb6cd1dc1ec2b334e..c770effd799a5e27ea4bf16d7166cabec6a5af81 100644 (file)
@@ -19,7 +19,7 @@
 static char *response_str;
 
 struct fb_nand_sparse {
-       nand_info_t             *nand;
+       struct mtd_info         *nand;
        struct part_info        *part;
 };
 
@@ -34,7 +34,7 @@ __weak int board_fastboot_write_partition_setup(char *name)
 }
 
 static int fb_nand_lookup(const char *partname, char *response,
-                         nand_info_t **nand,
+                         struct mtd_info **nand,
                          struct part_info **part)
 {
        struct mtd_device *dev;
@@ -62,12 +62,12 @@ static int fb_nand_lookup(const char *partname, char *response,
                return -EINVAL;
        }
 
-       *nand = &nand_info[dev->id->num];
+       *mtd = &nand_info[dev->id->num];
 
        return 0;
 }
 
-static int _fb_nand_erase(nand_info_t *nand, struct part_info *part)
+static int _fb_nand_erase(struct mtd_info *mtd, struct part_info *part)
 {
        nand_erase_options_t opts;
        int ret;
@@ -80,7 +80,7 @@ static int _fb_nand_erase(nand_info_t *nand, struct part_info *part)
        printf("Erasing blocks 0x%llx to 0x%llx\n",
               part->offset, part->offset + part->size);
 
-       ret = nand_erase_opts(nand, &opts);
+       ret = nand_erase_opts(mtd, &opts);
        if (ret)
                return ret;
 
@@ -90,7 +90,7 @@ static int _fb_nand_erase(nand_info_t *nand, struct part_info *part)
        return 0;
 }
 
-static int _fb_nand_write(nand_info_t *nand, struct part_info *part,
+static int _fb_nand_write(struct mtd_info *mtd, struct part_info *part,
                          void *buffer, unsigned int offset,
                          unsigned int length, size_t *written)
 {
@@ -100,7 +100,7 @@ static int _fb_nand_write(nand_info_t *nand, struct part_info *part,
        flags |= WITH_DROP_FFS;
 #endif
 
-       return nand_write_skip_bad(nand, offset, &length, written,
+       return nand_write_skip_bad(mtd, offset, &length, written,
                                   part->size - (offset - part->offset),
                                   buffer, flags);
 }
@@ -131,13 +131,13 @@ void fb_nand_flash_write(const char *partname, unsigned int session_id,
                         char *response)
 {
        struct part_info *part;
-       nand_info_t *nand = NULL;
+       struct mtd_info *mtd = NULL;
        int ret;
 
        /* initialize the response buffer */
        response_str = response;
 
-       ret = fb_nand_lookup(partname, response, &nand, &part);
+       ret = fb_nand_lookup(partname, response, &mtd, &part);
        if (ret) {
                error("invalid NAND device");
                fastboot_fail(response_str, "invalid NAND device");
@@ -152,10 +152,10 @@ void fb_nand_flash_write(const char *partname, unsigned int session_id,
                struct fb_nand_sparse sparse_priv;
                sparse_storage_t sparse;
 
-               sparse_priv.nand = nand;
+               sparse_priv.nand = mtd;
                sparse_priv.part = part;
 
-               sparse.block_sz = nand->writesize;
+               sparse.block_sz = mtd->writesize;
                sparse.start = part->offset / sparse.block_sz;
                sparse.size = part->size  / sparse.block_sz;
                sparse.name = part->name;
@@ -167,7 +167,7 @@ void fb_nand_flash_write(const char *partname, unsigned int session_id,
                printf("Flashing raw image at offset 0x%llx\n",
                       part->offset);
 
-               ret = _fb_nand_write(nand, part, download_buffer, part->offset,
+               ret = _fb_nand_write(mtd, part, download_buffer, part->offset,
                                     download_bytes, NULL);
 
                printf("........ wrote %u bytes to '%s'\n",
@@ -185,13 +185,13 @@ void fb_nand_flash_write(const char *partname, unsigned int session_id,
 void fb_nand_erase(const char *partname, char *response)
 {
        struct part_info *part;
-       nand_info_t *nand = NULL;
+       struct mtd_info *mtd = NULL;
        int ret;
 
        /* initialize the response buffer */
        response_str = response;
 
-       ret = fb_nand_lookup(partname, response, &nand, &part);
+       ret = fb_nand_lookup(partname, response, &mtd, &part);
        if (ret) {
                error("invalid NAND device");
                fastboot_fail(response_str, "invalid NAND device");
@@ -202,9 +202,9 @@ void fb_nand_erase(const char *partname, char *response)
        if (ret)
                return;
 
-       ret = _fb_nand_erase(nand, part);
+       ret = _fb_nand_erase(mtd, part);
        if (ret) {
-               error("failed erasing from device %s", nand->name);
+               error("failed erasing from device %s", mtd->name);
                fastboot_fail(response_str, "failed erasing from device");
                return;
        }
index a9754922e8d63ec4df950dd7c947bf189090c086..4652541aeff8dd6bfcfc5dd0f3a6c9deded68416 100644 (file)
@@ -25,7 +25,7 @@ static int nand_block_op(enum dfu_op op, struct dfu_entity *dfu,
        loff_t start, lim;
        size_t count, actual;
        int ret;
-       nand_info_t *nand;
+       struct mtd_info *mtd;
 
        /* if buf == NULL return total size of the area */
        if (buf == NULL) {
@@ -44,11 +44,11 @@ static int nand_block_op(enum dfu_op op, struct dfu_entity *dfu,
                return -1;
        }
 
-       nand = &nand_info[nand_curr_device];
+       mtd = &nand_info[nand_curr_device];
 
        if (op == DFU_OP_READ) {
-               ret = nand_read_skip_bad(nand, start, &count, &actual,
-                               lim, buf);
+               ret = nand_read_skip_bad(mtd, start, &count, &actual,
+                                        lim, buf);
        } else {
                nand_erase_options_t opts;
 
@@ -59,12 +59,12 @@ static int nand_block_op(enum dfu_op op, struct dfu_entity *dfu,
                opts.quiet = 1;
                opts.lim = lim;
                /* first erase */
-               ret = nand_erase_opts(nand, &opts);
+               ret = nand_erase_opts(mtd, &opts);
                if (ret)
                        return ret;
                /* then write */
-               ret = nand_write_skip_bad(nand, start, &count, &actual,
-                               lim, buf, WITH_WR_VERIFY);
+               ret = nand_write_skip_bad(mtd, start, &count, &actual,
+                                         lim, buf, WITH_WR_VERIFY);
        }
 
        if (ret != 0) {
@@ -142,7 +142,7 @@ static int dfu_flush_medium_nand(struct dfu_entity *dfu)
 
        /* in case of ubi partition, erase rest of the partition */
        if (dfu->data.nand.ubi) {
-               nand_info_t *nand;
+               struct mtd_info *mtd;
                nand_erase_options_t opts;
 
                if (nand_curr_device < 0 ||
@@ -152,14 +152,14 @@ static int dfu_flush_medium_nand(struct dfu_entity *dfu)
                        return -1;
                }
 
-               nand = &nand_info[nand_curr_device];
+               mtd = &nand_info[nand_curr_device];
 
                memset(&opts, 0, sizeof(opts));
                opts.offset = dfu->data.nand.start + dfu->offset +
                                dfu->bad_skip;
                opts.length = dfu->data.nand.start +
                                dfu->data.nand.size - opts.offset;
-               ret = nand_erase_opts(nand, &opts);
+               ret = nand_erase_opts(mtd, &opts);
                if (ret != 0)
                        printf("Failure erase: %d\n", ret);
        }
index 31c78258b987cc189fadb4e1637beb26427df9cc..b8f68c0ea925e78f4d3b09bd99d93701edab5395 100644 (file)
@@ -16,7 +16,7 @@
 #include <linux/mtd/nand_ecc.h>
 
 static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS;
-nand_info_t nand_info[1];
+struct mtd_info nand_info[1];
 static struct nand_chip nand_chip;
 
 #define ECCSTEPS       (CONFIG_SYS_NAND_PAGE_SIZE / \
index 7cc1de03134c52fed826ce2e51336d6e986a33d3..e6b3fe8b2b112b1a7b6bf5aaaecaad2625855272 100644 (file)
@@ -1238,7 +1238,7 @@ static int at91_nand_ready(struct mtd_info *mtd)
 
 #ifdef CONFIG_SPL_BUILD
 /* The following code is for SPL */
-static nand_info_t mtd;
+static struct mtd_info mtd;
 static struct nand_chip nand_chip;
 
 static int nand_command(int block, int page, uint32_t offs, u8 cmd)
index 0e7c364a220ca9d0dacd2b1c72fbd5ba06d4fb2a..4d691d1a32c984df364fa72672abc1a2ab687318 100644 (file)
@@ -8,7 +8,7 @@
 #include <nand.h>
 #include <malloc.h>
 
-static nand_info_t mtd;
+static struct mtd_info mtd;
 static struct nand_chip nand_chip;
 
 static void mxs_nand_command(struct mtd_info *mtd, unsigned int command,
index 8f0a9210ec3683727bd673d485388da69fd61fef..46f2654102cc7e62344977ccbd3bcb44025f6d74 100644 (file)
@@ -19,7 +19,7 @@ DECLARE_GLOBAL_DATA_PTR;
 int nand_curr_device = -1;
 
 
-nand_info_t nand_info[CONFIG_SYS_MAX_NAND_DEVICE];
+struct mtd_info nand_info[CONFIG_SYS_MAX_NAND_DEVICE];
 
 #ifndef CONFIG_SYS_NAND_SELF_INIT
 static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
index e69f66226da3c116f9b367ec664484387ddbfa47..b3978e97556ba00e516d7d8d3ce5075079d206dc 100644 (file)
@@ -11,7 +11,7 @@
 #include <linux/mtd/nand_ecc.h>
 
 static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS;
-static nand_info_t mtd;
+static struct mtd_info mtd;
 static struct nand_chip nand_chip;
 
 #define ECCSTEPS       (CONFIG_SYS_NAND_PAGE_SIZE / \
index 71285b6669416b1402ebd8b03f7b9957b47a37a4..90bf798ac00b14a769ff0aae1b30eab523ad32c4 100644 (file)
@@ -42,25 +42,26 @@ typedef struct mtd_info             mtd_info_t;
  * nand_erase_opts: - erase NAND flash with support for various options
  *                   (jffs2 formatting)
  *
- * @param meminfo      NAND device to erase
+ * @param mtd          nand mtd instance to erase
  * @param opts         options,  @see struct nand_erase_options
  * @return             0 in case of success
  *
  * This code is ported from flash_eraseall.c from Linux mtd utils by
  * Arcom Control System Ltd.
  */
-int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
+int nand_erase_opts(struct mtd_info *mtd,
+                   const nand_erase_options_t *opts)
 {
        struct jffs2_unknown_node cleanmarker;
        erase_info_t erase;
        unsigned long erase_length, erased_length; /* in blocks */
        int result;
        int percent_complete = -1;
-       const char *mtd_device = meminfo->name;
+       const char *mtd_device = mtd->name;
        struct mtd_oob_ops oob_opts;
-       struct nand_chip *chip = meminfo->priv;
+       struct nand_chip *chip = mtd->priv;
 
-       if ((opts->offset & (meminfo->erasesize - 1)) != 0) {
+       if ((opts->offset & (mtd->erasesize - 1)) != 0) {
                printf("Attempt to erase non block-aligned data\n");
                return -1;
        }
@@ -68,11 +69,11 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
        memset(&erase, 0, sizeof(erase));
        memset(&oob_opts, 0, sizeof(oob_opts));
 
-       erase.mtd = meminfo;
-       erase.len  = meminfo->erasesize;
+       erase.mtd = mtd;
+       erase.len = mtd->erasesize;
        erase.addr = opts->offset;
-       erase_length = lldiv(opts->length + meminfo->erasesize - 1,
-                            meminfo->erasesize);
+       erase_length = lldiv(opts->length + mtd->erasesize - 1,
+                            mtd->erasesize);
 
        cleanmarker.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
        cleanmarker.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER);
@@ -97,7 +98,7 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
 
        for (erased_length = 0;
             erased_length < erase_length;
-            erase.addr += meminfo->erasesize) {
+            erase.addr += mtd->erasesize) {
 
                WATCHDOG_RESET();
 
@@ -106,7 +107,7 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
                        return -EFBIG;
                }
                if (!opts->scrub) {
-                       int ret = mtd_block_isbad(meminfo, erase.addr);
+                       int ret = mtd_block_isbad(mtd, erase.addr);
                        if (ret > 0) {
                                if (!opts->quiet)
                                        printf("\rSkipping bad block at  "
@@ -129,7 +130,7 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
 
                erased_length++;
 
-               result = mtd_erase(meminfo, &erase);
+               result = mtd_erase(mtd, &erase);
                if (result != 0) {
                        printf("\n%s: MTD Erase failure: %d\n",
                               mtd_device, result);
@@ -145,9 +146,7 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
                        ops.ooboffs = 0;
                        ops.mode = MTD_OPS_AUTO_OOB;
 
-                       result = mtd_write_oob(meminfo,
-                                                   erase.addr,
-                                                   &ops);
+                       result = mtd_write_oob(mtd, erase.addr, &ops);
                        if (result != 0) {
                                printf("\n%s: MTD writeoob failure: %d\n",
                                       mtd_device, result);
@@ -303,7 +302,7 @@ int nand_get_lock_status(struct mtd_info *mtd, loff_t offset)
  * @param mtd          nand mtd instance
  * @param start                start byte address
  * @param length       number of bytes to unlock (must be a multiple of
- *                     page size nand->writesize)
+ *                     page size mtd->writesize)
  * @param allexcept    if set, unlock everything not selected
  *
  * @return             0 on success, -1 in case of error
@@ -399,7 +398,7 @@ int nand_unlock(struct mtd_info *mtd, loff_t start, size_t length,
  * Check if there are any bad blocks, and whether length including bad
  * blocks fits into device
  *
- * @param nand NAND device
+ * @param mtd nand mtd instance
  * @param offset offset in flash
  * @param length image length
  * @param used length of flash needed for the requested length
@@ -407,8 +406,8 @@ int nand_unlock(struct mtd_info *mtd, loff_t start, size_t length,
  *         1 if the image fits, but there are bad blocks
  *        -1 if the image does not fit
  */
-static int check_skip_len(nand_info_t *nand, loff_t offset, size_t length,
-               size_t *used)
+static int check_skip_len(struct mtd_info *mtd, loff_t offset, size_t length,
+                         size_t *used)
 {
        size_t len_excl_bad = 0;
        int ret = 0;
@@ -417,14 +416,14 @@ static int check_skip_len(nand_info_t *nand, loff_t offset, size_t length,
                size_t block_len, block_off;
                loff_t block_start;
 
-               if (offset >= nand->size)
+               if (offset >= mtd->size)
                        return -1;
 
-               block_start = offset & ~(loff_t)(nand->erasesize - 1);
-               block_off = offset & (nand->erasesize - 1);
-               block_len = nand->erasesize - block_off;
+               block_start = offset & ~(loff_t)(mtd->erasesize - 1);
+               block_off = offset & (mtd->erasesize - 1);
+               block_len = mtd->erasesize - block_off;
 
-               if (!nand_block_isbad(nand, block_start))
+               if (!nand_block_isbad(mtd, block_start))
                        len_excl_bad += block_len;
                else
                        ret = 1;
@@ -441,7 +440,7 @@ static int check_skip_len(nand_info_t *nand, loff_t offset, size_t length,
 }
 
 #ifdef CONFIG_CMD_NAND_TRIMFFS
-static size_t drop_ffs(const nand_info_t *nand, const u_char *buf,
+static size_t drop_ffs(const struct mtd_info *mtd, const u_char *buf,
                        const size_t *len)
 {
        size_t l = *len;
@@ -453,8 +452,8 @@ static size_t drop_ffs(const nand_info_t *nand, const u_char *buf,
 
        /* The resulting length must be aligned to the minimum flash I/O size */
        l = i + 1;
-       l = (l + nand->writesize - 1) / nand->writesize;
-       l *=  nand->writesize;
+       l = (l + mtd->writesize - 1) / mtd->writesize;
+       l *=  mtd->writesize;
 
        /*
         * since the input length may be unaligned, prevent access past the end
@@ -471,16 +470,17 @@ static size_t drop_ffs(const nand_info_t *nand, const u_char *buf,
  * Reads page of NAND and verifies the contents and OOB against the
  * values in ops.
  *
- * @param nand         NAND device
+ * @param mtd          nand mtd instance
  * @param ops          MTD operations, including data to verify
  * @param ofs          offset in flash
  * @return             0 in case of success
  */
-int nand_verify_page_oob(nand_info_t *nand, struct mtd_oob_ops *ops, loff_t ofs)
+int nand_verify_page_oob(struct mtd_info *mtd, struct mtd_oob_ops *ops,
+                        loff_t ofs)
 {
        int rval;
        struct mtd_oob_ops vops;
-       size_t verlen = nand->writesize + nand->oobsize;
+       size_t verlen = mtd->writesize + mtd->oobsize;
 
        memcpy(&vops, ops, sizeof(vops));
 
@@ -489,9 +489,9 @@ int nand_verify_page_oob(nand_info_t *nand, struct mtd_oob_ops *ops, loff_t ofs)
        if (!vops.datbuf)
                return -ENOMEM;
 
-       vops.oobbuf = vops.datbuf + nand->writesize;
+       vops.oobbuf = vops.datbuf + mtd->writesize;
 
-       rval = mtd_read_oob(nand, ofs, &vops);
+       rval = mtd_read_oob(mtd, ofs, &vops);
        if (!rval)
                rval = memcmp(ops->datbuf, vops.datbuf, vops.len);
        if (!rval)
@@ -510,17 +510,17 @@ int nand_verify_page_oob(nand_info_t *nand, struct mtd_oob_ops *ops, loff_t ofs)
  * the contents of a buffer.  The offset into the NAND must be
  * page-aligned, and the function doesn't handle skipping bad blocks.
  *
- * @param nand         NAND device
+ * @param mtd          nand mtd instance
  * @param ofs          offset in flash
  * @param len          buffer length
  * @param buf          buffer to read from
  * @return             0 in case of success
  */
-int nand_verify(nand_info_t *nand, loff_t ofs, size_t len, u_char *buf)
+int nand_verify(struct mtd_info *mtd, loff_t ofs, size_t len, u_char *buf)
 {
        int rval = 0;
        size_t verofs;
-       size_t verlen = nand->writesize;
+       size_t verlen = mtd->writesize;
        uint8_t *verbuf = memalign(ARCH_DMA_MINALIGN, verlen);
 
        if (!verbuf)
@@ -529,8 +529,8 @@ int nand_verify(nand_info_t *nand, loff_t ofs, size_t len, u_char *buf)
        /* Read the NAND back in page-size groups to limit malloc size */
        for (verofs = ofs; verofs < ofs + len;
             verofs += verlen, buf += verlen) {
-               verlen = min(nand->writesize, (uint32_t)(ofs + len - verofs));
-               rval = nand_read(nand, verofs, &verlen, verbuf);
+               verlen = min(mtd->writesize, (uint32_t)(ofs + len - verofs));
+               rval = nand_read(mtd, verofs, &verlen, verbuf);
                if (!rval || (rval == -EUCLEAN))
                        rval = memcmp(buf, verbuf, verlen);
 
@@ -558,7 +558,7 @@ int nand_verify(nand_info_t *nand, loff_t ofs, size_t len, u_char *buf)
  * beyond the limit we are passed, length is set to 0 and actual is set
  * to the required length.
  *
- * @param nand         NAND device
+ * @param mtd          nand mtd instance
  * @param offset       offset in flash
  * @param length       buffer length
  * @param actual       set to size required to write length worth of
@@ -569,8 +569,8 @@ int nand_verify(nand_info_t *nand, loff_t ofs, size_t len, u_char *buf)
  * @param flags                flags modifying the behaviour of the write to NAND
  * @return             0 in case of success
  */
-int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
-               size_t *actual, loff_t lim, u_char *buffer, int flags)
+int nand_write_skip_bad(struct mtd_info *mtd, loff_t offset, size_t *length,
+                       size_t *actual, loff_t lim, u_char *buffer, int flags)
 {
        int rval = 0, blocksize;
        size_t left_to_write = *length;
@@ -581,7 +581,7 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
        if (actual)
                *actual = 0;
 
-       blocksize = nand->erasesize;
+       blocksize = mtd->erasesize;
 
        /*
         * nand_write() handles unaligned, partial page writes.
@@ -594,13 +594,13 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
         * you should only start a block skipping access at a
         * partition boundary).  So don't try to handle that.
         */
-       if ((offset & (nand->writesize - 1)) != 0) {
+       if ((offset & (mtd->writesize - 1)) != 0) {
                printf("Attempt to write non page-aligned data\n");
                *length = 0;
                return -EINVAL;
        }
 
-       need_skip = check_skip_len(nand, offset, *length, &used_for_write);
+       need_skip = check_skip_len(mtd, offset, *length, &used_for_write);
 
        if (actual)
                *actual = used_for_write;
@@ -618,10 +618,10 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
        }
 
        if (!need_skip && !(flags & WITH_DROP_FFS)) {
-               rval = nand_write(nand, offset, length, buffer);
+               rval = nand_write(mtd, offset, length, buffer);
 
                if ((flags & WITH_WR_VERIFY) && !rval)
-                       rval = nand_verify(nand, offset, *length, buffer);
+                       rval = nand_verify(mtd, offset, *length, buffer);
 
                if (rval == 0)
                        return 0;
@@ -633,15 +633,15 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
        }
 
        while (left_to_write > 0) {
-               size_t block_offset = offset & (nand->erasesize - 1);
+               size_t block_offset = offset & (mtd->erasesize - 1);
                size_t write_size, truncated_write_size;
 
                WATCHDOG_RESET();
 
-               if (nand_block_isbad(nand, offset & ~(nand->erasesize - 1))) {
+               if (nand_block_isbad(mtd, offset & ~(mtd->erasesize - 1))) {
                        printf("Skip bad block 0x%08llx\n",
-                               offset & ~(nand->erasesize - 1));
-                       offset += nand->erasesize - block_offset;
+                               offset & ~(mtd->erasesize - 1));
+                       offset += mtd->erasesize - block_offset;
                        continue;
                }
 
@@ -653,15 +653,15 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
                truncated_write_size = write_size;
 #ifdef CONFIG_CMD_NAND_TRIMFFS
                if (flags & WITH_DROP_FFS)
-                       truncated_write_size = drop_ffs(nand, p_buffer,
+                       truncated_write_size = drop_ffs(mtd, p_buffer,
                                        &write_size);
 #endif
 
-               rval = nand_write(nand, offset, &truncated_write_size,
+               rval = nand_write(mtd, offset, &truncated_write_size,
                                p_buffer);
 
                if ((flags & WITH_WR_VERIFY) && !rval)
-                       rval = nand_verify(nand, offset,
+                       rval = nand_verify(mtd, offset,
                                truncated_write_size, p_buffer);
 
                offset += write_size;
@@ -693,7 +693,7 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
  * the limit we are passed, length is set to 0 and actual is set to the
  * required length.
  *
- * @param nand NAND device
+ * @param mtd nand mtd instance
  * @param offset offset in flash
  * @param length buffer length, on return holds number of read bytes
  * @param actual set to size required to read length worth of buffer or 0
@@ -703,8 +703,8 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
  * @param buffer buffer to write to
  * @return 0 in case of success
  */
-int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
-               size_t *actual, loff_t lim, u_char *buffer)
+int nand_read_skip_bad(struct mtd_info *mtd, loff_t offset, size_t *length,
+                      size_t *actual, loff_t lim, u_char *buffer)
 {
        int rval;
        size_t left_to_read = *length;
@@ -712,7 +712,7 @@ int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
        u_char *p_buffer = buffer;
        int need_skip;
 
-       if ((offset & (nand->writesize - 1)) != 0) {
+       if ((offset & (mtd->writesize - 1)) != 0) {
                printf("Attempt to read non page-aligned data\n");
                *length = 0;
                if (actual)
@@ -720,7 +720,7 @@ int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
                return -EINVAL;
        }
 
-       need_skip = check_skip_len(nand, offset, *length, &used_for_read);
+       need_skip = check_skip_len(mtd, offset, *length, &used_for_read);
 
        if (actual)
                *actual = used_for_read;
@@ -738,7 +738,7 @@ int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
        }
 
        if (!need_skip) {
-               rval = nand_read(nand, offset, length, buffer);
+               rval = nand_read(mtd, offset, length, buffer);
                if (!rval || rval == -EUCLEAN)
                        return 0;
 
@@ -749,24 +749,24 @@ int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
        }
 
        while (left_to_read > 0) {
-               size_t block_offset = offset & (nand->erasesize - 1);
+               size_t block_offset = offset & (mtd->erasesize - 1);
                size_t read_length;
 
                WATCHDOG_RESET();
 
-               if (nand_block_isbad(nand, offset & ~(nand->erasesize - 1))) {
+               if (nand_block_isbad(mtd, offset & ~(mtd->erasesize - 1))) {
                        printf("Skipping bad block 0x%08llx\n",
-                               offset & ~(nand->erasesize - 1));
-                       offset += nand->erasesize - block_offset;
+                               offset & ~(mtd->erasesize - 1));
+                       offset += mtd->erasesize - block_offset;
                        continue;
                }
 
-               if (left_to_read < (nand->erasesize - block_offset))
+               if (left_to_read < (mtd->erasesize - block_offset))
                        read_length = left_to_read;
                else
-                       read_length = nand->erasesize - block_offset;
+                       read_length = mtd->erasesize - block_offset;
 
-               rval = nand_read(nand, offset, &read_length, p_buffer);
+               rval = nand_read(mtd, offset, &read_length, p_buffer);
                if (rval && rval != -EUCLEAN) {
                        printf("NAND read from offset %llx failed %d\n",
                                offset, rval);
@@ -812,57 +812,57 @@ static int check_pattern(const u_char *buf, u_char patt, int size)
  * This is useful to determine if a block that caused a write error is still
  * good or should be marked as bad.
  *
- * @param nand NAND device
+ * @param mtd nand mtd instance
  * @param offset offset in flash
  * @return 0 if the block is still good
  */
-int nand_torture(nand_info_t *nand, loff_t offset)
+int nand_torture(struct mtd_info *mtd, loff_t offset)
 {
        u_char patterns[] = {0xa5, 0x5a, 0x00};
        struct erase_info instr = {
                .mtd = nand,
                .addr = offset,
-               .len = nand->erasesize,
+               .len = mtd->erasesize,
        };
        size_t retlen;
        int err, ret = -1, i, patt_count;
        u_char *buf;
 
-       if ((offset & (nand->erasesize - 1)) != 0) {
+       if ((offset & (mtd->erasesize - 1)) != 0) {
                puts("Attempt to torture a block at a non block-aligned offset\n");
                return -EINVAL;
        }
 
-       if (offset + nand->erasesize > nand->size) {
+       if (offset + mtd->erasesize > mtd->size) {
                puts("Attempt to torture a block outside the flash area\n");
                return -EINVAL;
        }
 
        patt_count = ARRAY_SIZE(patterns);
 
-       buf = malloc_cache_aligned(nand->erasesize);
+       buf = malloc_cache_aligned(mtd->erasesize);
        if (buf == NULL) {
                puts("Out of memory for erase block buffer\n");
                return -ENOMEM;
        }
 
        for (i = 0; i < patt_count; i++) {
-               err = nand->erase(nand, &instr);
+               err = mtd->erase(mtd, &instr);
                if (err) {
                        printf("%s: erase() failed for block at 0x%llx: %d\n",
-                               nand->name, instr.addr, err);
+                               mtd->name, instr.addr, err);
                        goto out;
                }
 
                /* Make sure the block contains only 0xff bytes */
-               err = nand->read(nand, offset, nand->erasesize, &retlen, buf);
-               if ((err && err != -EUCLEAN) || retlen != nand->erasesize) {
+               err = mtd->read(mtd, offset, mtd->erasesize, &retlen, buf);
+               if ((err && err != -EUCLEAN) || retlen != mtd->erasesize) {
                        printf("%s: read() failed for block at 0x%llx: %d\n",
-                               nand->name, instr.addr, err);
+                               mtd->name, instr.addr, err);
                        goto out;
                }
 
-               err = check_pattern(buf, 0xff, nand->erasesize);
+               err = check_pattern(buf, 0xff, mtd->erasesize);
                if (!err) {
                        printf("Erased block at 0x%llx, but a non-0xff byte was found\n",
                                offset);
@@ -871,22 +871,22 @@ int nand_torture(nand_info_t *nand, loff_t offset)
                }
 
                /* Write a pattern and check it */
-               memset(buf, patterns[i], nand->erasesize);
-               err = nand->write(nand, offset, nand->erasesize, &retlen, buf);
-               if (err || retlen != nand->erasesize) {
+               memset(buf, patterns[i], mtd->erasesize);
+               err = mtd->write(mtd, offset, mtd->erasesize, &retlen, buf);
+               if (err || retlen != mtd->erasesize) {
                        printf("%s: write() failed for block at 0x%llx: %d\n",
-                               nand->name, instr.addr, err);
+                               mtd->name, instr.addr, err);
                        goto out;
                }
 
-               err = nand->read(nand, offset, nand->erasesize, &retlen, buf);
-               if ((err && err != -EUCLEAN) || retlen != nand->erasesize) {
+               err = mtd->read(mtd, offset, mtd->erasesize, &retlen, buf);
+               if ((err && err != -EUCLEAN) || retlen != mtd->erasesize) {
                        printf("%s: read() failed for block at 0x%llx: %d\n",
-                               nand->name, instr.addr, err);
+                               mtd->name, instr.addr, err);
                        goto out;
                }
 
-               err = check_pattern(buf, patterns[i], nand->erasesize);
+               err = check_pattern(buf, patterns[i], mtd->erasesize);
                if (!err) {
                        printf("Pattern 0x%.2x checking failed for block at "
                                        "0x%llx\n", patterns[i], offset);
index 740f787dd23a384c79124707cf0efdd0ffb22c48..9b7af09fe3998e4b1bb369d704dd52ef67a1a348 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;
@@ -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,7 @@ jffs2_1pass_build_lists(struct part_info * part)
        u32 counterN = 0;
 
        struct mtdids *id = part->dev->id;
-       nand = nand_info + id->num;
+       mtd = nand_info + id->num;
 
        /* if we are building a list we need to refresh the cache. */
        jffs_init_1pass_list(part);
@@ -802,7 +804,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 +815,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 +828,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;
 
index 50000a135b54f229e4aa914939ab6c554bdab0c4..5e9902519a7d35d5c05a011b5f8daa9ed47e5de1 100644 (file)
@@ -141,7 +141,7 @@ static const char *yaffs_error_str(void)
        }
 }
 
-extern nand_info_t nand_info[];
+extern struct mtd_info nand_info[];
 
 void cmd_yaffs_tracemask(unsigned set, unsigned mask)
 {
index 7cbbbd327a61e3b3ad93263add43c10582fdb497..eb2d76dbc64b1f5f21bc658daadde0007e991775 100644 (file)
@@ -40,27 +40,27 @@ int nand_register(int devnum);
 extern int board_nand_init(struct nand_chip *nand);
 #endif
 
-typedef struct mtd_info nand_info_t;
-
 extern int nand_curr_device;
-extern nand_info_t nand_info[];
+extern struct mtd_info nand_info[];
 
-static inline int nand_read(nand_info_t *info, loff_t ofs, size_t *len, u_char *buf)
+static inline int nand_read(struct mtd_info *info, loff_t ofs, size_t *len,
+                           u_char *buf)
 {
        return mtd_read(info, ofs, *len, (size_t *)len, buf);
 }
 
-static inline int nand_write(nand_info_t *info, loff_t ofs, size_t *len, u_char *buf)
+static inline int nand_write(struct mtd_info *info, loff_t ofs, size_t *len,
+                            u_char *buf)
 {
        return mtd_write(info, ofs, *len, (size_t *)len, buf);
 }
 
-static inline int nand_block_isbad(nand_info_t *info, loff_t ofs)
+static inline int nand_block_isbad(struct mtd_info *info, loff_t ofs)
 {
        return mtd_block_isbad(info, ofs);
 }
 
-static inline int nand_erase(nand_info_t *info, loff_t off, size_t size)
+static inline int nand_erase(struct mtd_info *info, loff_t off, size_t size)
 {
        struct erase_info instr;
 
@@ -96,27 +96,28 @@ struct nand_erase_options {
 
 typedef struct nand_erase_options nand_erase_options_t;
 
-int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
+int nand_read_skip_bad(struct mtd_info *mtd, loff_t offset, size_t *length,
                       size_t *actual, loff_t lim, u_char *buffer);
 
 #define WITH_DROP_FFS  (1 << 0) /* drop trailing all-0xff pages */
 #define WITH_WR_VERIFY (1 << 1) /* verify data was written correctly */
 
-int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
+int nand_write_skip_bad(struct mtd_info *mtd, loff_t offset, size_t *length,
                        size_t *actual, loff_t lim, u_char *buffer, int flags);
-int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts);
-int nand_torture(nand_info_t *nand, loff_t offset);
-int nand_verify_page_oob(nand_info_t *nand, struct mtd_oob_ops *ops,
-                       loff_t ofs);
-int nand_verify(nand_info_t *nand, loff_t ofs, size_t len, u_char *buf);
+int nand_erase_opts(struct mtd_info *mtd,
+                   const nand_erase_options_t *opts);
+int nand_torture(struct mtd_info *mtd, loff_t offset);
+int nand_verify_page_oob(struct mtd_info *mtd, struct mtd_oob_ops *ops,
+                        loff_t ofs);
+int nand_verify(struct mtd_info *mtd, loff_t ofs, size_t len, u_char *buf);
 
 #define NAND_LOCK_STATUS_TIGHT 0x01
 #define NAND_LOCK_STATUS_UNLOCK 0x04
 
-int nand_lock(nand_info_t *meminfo, int tight);
-int nand_unlock(nand_info_t *meminfo, loff_t start, size_t length,
-       int allexcept);
-int nand_get_lock_status(nand_info_t *meminfo, loff_t offset);
+int nand_lock(struct mtd_info *mtd, int tight);
+int nand_unlock(struct mtd_info *mtd, loff_t start, size_t length,
+               int allexcept);
+int nand_get_lock_status(struct mtd_info *mtd, loff_t offset);
 
 int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst);
 void nand_deselect(void);
@@ -135,6 +136,6 @@ __attribute__((noreturn)) void nand_boot(void);
 #define ENV_OOB_MARKER_OLD 0x30564e45 /*"ENV0" in little-endian -- offset is
                                        stored as byte number */
 #define ENV_OFFSET_SIZE 8
-int get_nand_env_oob(nand_info_t *nand, unsigned long *result);
+int get_nand_env_oob(struct mtd_info *mtd, unsigned long *result);
 #endif
 int spl_nand_erase_one(int block, int page);