]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - fs/jffs2/jffs2_nand_1pass.c
at91sam9263ek: add mmc support
[karo-tx-uboot.git] / fs / jffs2 / jffs2_nand_1pass.c
index ce80a43fa17ef6c4e25bc0f379bcd722e8ab54ff..740f787dd23a384c79124707cf0efdd0ffb22c48 100644 (file)
@@ -1,7 +1,5 @@
 #include <common.h>
 
-#if (CONFIG_COMMANDS & CFG_CMD_JFFS2)
-
 #include <malloc.h>
 #include <linux/stat.h>
 #include <linux/time.h>
 
 #include "jffs2_nand_private.h"
 
-#define        NODE_CHUNK      1024    /* size of memory allocation chunk in b_nodes */
+#define        NODE_CHUNK      1024    /* size of memory allocation chunk in b_nodes */
 
 /* Debugging switches */
 #undef DEBUG_DIRENTS           /* print directory entry list after scan */
 #undef DEBUG_FRAGMENTS         /* print fragment list after scan */
-#undef DEBUG                   /* enable debugging messages */
+#undef DEBUG                   /* enable debugging messages */
 
 #ifdef  DEBUG
 # define DEBUGF(fmt,args...)   printf(fmt ,##args)
@@ -25,7 +23,6 @@
 # define DEBUGF(fmt,args...)
 #endif
 
-static int nanddev = -1; /* nand device of current partition */
 static nand_info_t *nand;
 
 /* Compression names */
@@ -37,9 +34,8 @@ static char *compr_names[] = {
        "COPY",
        "DYNRUBIN",
        "ZLIB",
-#if defined(CONFIG_JFFS2_LZO_LZARI)
+#if defined(CONFIG_JFFS2_LZO)
        "LZO",
-       "LZARI",
 #endif
 };
 
@@ -97,7 +93,7 @@ add_node(struct b_list *list, int size)
 static struct b_node *
 insert_node(struct b_list *list, struct b_node *new)
 {
-#ifdef CFG_JFFS2_SORT_FRAGMENTS
+#ifdef CONFIG_SYS_JFFS2_SORT_FRAGMENTS
        struct b_node *b, *prev;
 
        if (list->listTail != NULL && list->listCompare(new, list->listTail))
@@ -174,7 +170,7 @@ insert_dirent(struct b_list *list, struct jffs2_raw_dirent *node, u32 offset)
        return insert_node(list, (struct b_node *)new);
 }
 
-#ifdef CFG_JFFS2_SORT_FRAGMENTS
+#ifdef CONFIG_SYS_JFFS2_SORT_FRAGMENTS
 /* Sort data entries with the latest version last, so that if there
  * is overlapping data the latest version will be used.
  */
@@ -251,7 +247,7 @@ jffs_init_1pass_list(struct part_info *part)
                pL = (struct b_lists *)part->jffs2_priv;
 
                memset(pL, 0, sizeof(*pL));
-#ifdef CFG_JFFS2_SORT_FRAGMENTS
+#ifdef CONFIG_SYS_JFFS2_SORT_FRAGMENTS
                pL->dir.listCompare = compare_dirents;
                pL->frag.listCompare = compare_inodes;
 #endif
@@ -269,7 +265,7 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 ino, char *dest,
        u32 latestVersion = 0;
        long ret;
 
-#ifdef CFG_JFFS2_SORT_FRAGMENTS
+#ifdef CONFIG_SYS_JFFS2_SORT_FRAGMENTS
        /* Find file size before loading any data, so fragments that
         * start past the end of file can be ignored. A fragment
         * that is partially in the file is loaded, so extra data may
@@ -291,7 +287,7 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 ino, char *dest,
        for (jNode = (struct b_inode *)pL->frag.listHead; jNode; jNode = jNode->next) {
                if ((ino != jNode->ino))
                        continue;
-#ifndef CFG_JFFS2_SORT_FRAGMENTS
+#ifndef CONFIG_SYS_JFFS2_SORT_FRAGMENTS
                /* get actual file length from the newest node */
                if (jNode->version >= latestVersion) {
                        totalSize = jNode->isize;
@@ -347,17 +343,14 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 ino, char *dest,
                        case JFFS2_COMPR_ZLIB:
                                ret = zlib_decompress(src, dst, inode->csize, inode->dsize);
                                break;
-#if defined(CONFIG_JFFS2_LZO_LZARI)
+#if defined(CONFIG_JFFS2_LZO)
                        case JFFS2_COMPR_LZO:
                                ret = lzo_decompress(src, dst, inode->csize, inode->dsize);
                                break;
-                       case JFFS2_COMPR_LZARI:
-                               ret = lzari_decompress(src, dst, inode->csize, inode->dsize);
-                               break;
 #endif
                        default:
                                /* unknown */
-                               putLabeledWord("UNKOWN COMPRESSION METHOD = ", inode->compr);
+                               putLabeledWord("UNKNOWN COMPRESSION METHOD = ", inode->compr);
                                return -1;
                        }
                }
@@ -385,10 +378,10 @@ jffs2_1pass_find_inode(struct b_lists * pL, const char *name, u32 pino)
                                continue;
 
                        if (jDir->version == version && inode != 0) {
-                               /* I'm pretty sure this isn't legal */
+                               /* I'm pretty sure this isn't legal */
                                putstr(" ** ERROR ** ");
-//                             putnstr(jDir->name, jDir->nsize);
-//                             putLabeledWord(" has dup version =", version);
+/*                             putnstr(jDir->name, jDir->nsize); */
+/*                             putLabeledWord(" has dup version =", version); */
                        }
                        inode = jDir->ino;
                        version = jDir->version;
@@ -574,15 +567,15 @@ jffs2_1pass_resolve_inode(struct b_lists * pL, u32 ino)
        /* we need to search all and return the inode with the highest version */
        for (jDir = (struct b_dirent *)pL->dir.listHead; jDir; jDir = jDir->next) {
                if (ino == jDir->ino) {
-                       if (jDir->version < version)
+                       if (jDir->version < version)
                                continue;
 
                        if (jDir->version == version && jDirFoundType) {
-                               /* I'm pretty sure this isn't legal */
+                               /* I'm pretty sure this isn't legal */
                                putstr(" ** ERROR ** ");
-//                             putnstr(jDir->name, jDir->nsize);
-//                             putLabeledWord(" has dup version (resolve) = ",
-//                                     version);
+/*                             putnstr(jDir->name, jDir->nsize); */
+/*                             putLabeledWord(" has dup version (resolve) = ", */
+/*                                     version); */
                        }
 
                        jDirFoundType = jDir->type;
@@ -686,12 +679,6 @@ jffs2_1pass_rescan_needed(struct part_info *part)
                return 1;
        }
 
-#if defined(CONFIG_JFFS2_NAND) && (CONFIG_COMMANDS & CFG_CMD_NAND)
-       if (nanddev != (int)part->usr_priv - 1) {
-               DEBUGF ("rescan: nand device changed\n");
-               return -1;
-       }
-#endif /* defined(CONFIG_JFFS2_NAND) && (CONFIG_COMMANDS & CFG_CMD_NAND) */
        /* FIXME */
 #if 0
        /* but suppose someone reflashed a partition at the same offset... */
@@ -765,7 +752,7 @@ dump_dirents(struct b_lists *pL)
                putLabeledWord("\tbuild_list: type = ", jDir->type);
                putLabeledWord("\tbuild_list: node_crc = ", jDir->node_crc);
                putLabeledWord("\tbuild_list: name_crc = ", jDir->name_crc);
-               putLabeledWord("\tbuild_list: offset = ", b->offset);   /* FIXME: ? [RS] */
+               putLabeledWord("\tbuild_list: offset = ", b->offset);   /* FIXME: ? [RS] */
                b = b->next;
                put_fl_mem(jDir);
        }
@@ -806,10 +793,8 @@ jffs2_1pass_build_lists(struct part_info * part)
        u32 counterF = 0;
        u32 counterN = 0;
 
-#if defined(CONFIG_JFFS2_NAND) && (CONFIG_COMMANDS & CFG_CMD_NAND)
-       nanddev = (int)part->usr_priv - 1;
-       nand = &nand_info[nanddev];
-#endif /* defined(CONFIG_JFFS2_NAND) && (CONFIG_COMMANDS & CFG_CMD_NAND) */
+       struct mtdids *id = part->dev->id;
+       nand = nand_info + id->num;
 
        /* if we are building a list we need to refresh the cache. */
        jffs_init_1pass_list(part);
@@ -873,16 +858,18 @@ jffs2_1pass_build_lists(struct part_info * part)
                        } else if (node->nodetype == JFFS2_NODETYPE_CLEANMARKER) {
                                if (node->totlen != sizeof(struct jffs2_unknown_node))
                                        printf("OOPS Cleanmarker has bad size "
-                                               "%d != %d\n", node->totlen,
+                                               "%d != %zu\n",
+                                               node->totlen,
                                                sizeof(struct jffs2_unknown_node));
                        } else if (node->nodetype == JFFS2_NODETYPE_PADDING) {
                                if (node->totlen < sizeof(struct jffs2_unknown_node))
                                        printf("OOPS Padding has bad size "
-                                               "%d < %d\n", node->totlen,
+                                               "%d < %zu\n",
+                                               node->totlen,
                                                sizeof(struct jffs2_unknown_node));
                        } else {
-                               printf("Unknown node type: %x len %d "
-                                       "offset 0x%x\n", node->nodetype,
+                               printf("Unknown node type: %x len %d offset 0x%x\n",
+                                       node->nodetype,
                                        node->totlen, offset);
                        }
                        offset += ((node->totlen + 3) & ~3);
@@ -993,7 +980,7 @@ jffs2_1pass_load(char *dest, struct part_info * part, const char *fname)
        long ret = 0;
        u32 inode;
 
-       if (! (pl  = jffs2_get_list(part, "load")))
+       if (! (pl = jffs2_get_list(part, "load")))
                return 0;
 
        if (! (inode = jffs2_1pass_search_inode(pl, fname, 1))) {
@@ -1025,7 +1012,7 @@ jffs2_1pass_info(struct part_info * part)
        struct b_lists *pl;
        int i;
 
-       if (! (pl  = jffs2_get_list(part, "info")))
+       if (! (pl = jffs2_get_list(part, "info")))
                return 0;
 
        jffs2_1pass_fill_info(pl, &info);
@@ -1041,5 +1028,3 @@ jffs2_1pass_info(struct part_info * part)
        }
        return 1;
 }
-
-#endif /* CFG_CMD_JFFS2 */