Fix some more printf() format problems.
[pandora-u-boot.git] / fs / jffs2 / jffs2_1pass.c
index 6a7d7f7..5c1d265 100644 (file)
@@ -52,7 +52,7 @@
  * for a bootloader as small and simple as possible. Instead of worring about
  * unneccesary data copies, node scans, etc, I just optimized for the known
  * common case, a kernel, which looks like:
- *     (1) most pages are 4096 bytes
+ *     (1) most pages are 4096 bytes
  *     (2) version numbers are somewhat sorted in acsending order
  *     (3) multiple compressed blocks making up one page is uncommon
  *
 #include <malloc.h>
 #include <linux/stat.h>
 #include <linux/time.h>
+#include <watchdog.h>
 
-#if (CONFIG_COMMANDS & CFG_CMD_JFFS2) || defined(CONFIG_CMD_JFFS2)
+#if defined(CONFIG_CMD_JFFS2)
 
 #include <jffs2/jffs2.h>
 #include <jffs2/jffs2_1pass.h>
 #include "jffs2_private.h"
 
 
-#define        NODE_CHUNK      1024    /* size of memory allocation chunk in b_nodes */
-#define        SPIN_BLKSIZE    18      /* spin after having scanned 1<<BLKSIZE bytes */
+#define        NODE_CHUNK      1024    /* size of memory allocation chunk in b_nodes */
+#define        SPIN_BLKSIZE    18      /* spin after having scanned 1<<BLKSIZE bytes */
 
 /* 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
 /* keeps pointer to currentlu processed partition */
 static struct part_info *current_part;
 
-#if (defined(CONFIG_JFFS2_NAND) && ((CONFIG_COMMANDS & CFG_CMD_NAND) || defined(CONFIG_CMD_NAND))
+#if (defined(CONFIG_JFFS2_NAND) && \
+     defined(CONFIG_CMD_NAND) )
 #if defined(CFG_NAND_LEGACY)
 #include <linux/mtd/nand_legacy.h>
 #else
@@ -163,9 +165,6 @@ static struct part_info *current_part;
 /* this one defined in nand_legacy.c */
 int read_jffs2_nand(size_t start, size_t len,
                size_t * retlen, u_char * buf, int nanddev);
-#else
-/* info for NAND chips, defined in drivers/nand/nand.c */
-extern nand_info_t nand_info[];
 #endif
 
 #define NAND_PAGE_SIZE 512
@@ -184,11 +183,7 @@ static int read_nand_cached(u32 off, u32 size, u_char *buf)
 {
        struct mtdids *id = current_part->dev->id;
        u32 bytes_read = 0;
-#if defined(CFG_NAND_LEGACY)
        size_t retlen;
-#else
-       ulong retlen;
-#endif
        int cpy_bytes;
 
        while (bytes_read < size) {
@@ -274,10 +269,10 @@ static void put_fl_mem_nand(void *buf)
 {
        free(buf);
 }
-#endif /* #if defined(CONFIG_JFFS2_NAND) && (CONFIG_COMMANDS & CFG_CMD_NAND) */
+#endif
 
 
-#if (CONFIG_COMMANDS & CFG_CMD_FLASH) || defined(CONFIG_CMD_FLASH)
+#if defined(CONFIG_CMD_FLASH)
 /*
  * Support for jffs2 on top of NOR-flash
  *
@@ -300,7 +295,7 @@ static inline void *get_node_mem_nor(u32 off)
 {
        return (void*)get_fl_mem_nor(off);
 }
-#endif /* #if (CONFIG_COMMANDS & CFG_CMD_FLASH) */
+#endif
 
 
 /*
@@ -311,12 +306,12 @@ static inline void *get_fl_mem(u32 off, u32 size, void *ext_buf)
 {
        struct mtdids *id = current_part->dev->id;
 
-#if (CONFIG_COMMANDS & CFG_CMD_FLASH) || defined(CONFIG_CMD_FLASH)
+#if defined(CONFIG_CMD_FLASH)
        if (id->type == MTD_DEV_TYPE_NOR)
                return get_fl_mem_nor(off);
 #endif
 
-#if defined(CONFIG_JFFS2_NAND) && ((CONFIG_COMMANDS & CFG_CMD_NAND) || defined(CONFIG_CMD_NAND))
+#if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND)
        if (id->type == MTD_DEV_TYPE_NAND)
                return get_fl_mem_nand(off, size, ext_buf);
 #endif
@@ -329,12 +324,13 @@ static inline void *get_node_mem(u32 off)
 {
        struct mtdids *id = current_part->dev->id;
 
-#if (CONFIG_COMMANDS & CFG_CMD_FLASH) || defined(CONFIG_CMD_FLASH)
+#if defined(CONFIG_CMD_FLASH)
        if (id->type == MTD_DEV_TYPE_NOR)
                return get_node_mem_nor(off);
 #endif
 
-#if defined(CONFIG_JFFS2_NAND) && ((CONFIG_COMMANDS & CFG_CMD_NAND) || defined(CONFIG_CMD_NAND)
+#if defined(CONFIG_JFFS2_NAND) && \
+    defined(CONFIG_CMD_NAND)
        if (id->type == MTD_DEV_TYPE_NAND)
                return get_node_mem_nand(off);
 #endif
@@ -345,7 +341,8 @@ static inline void *get_node_mem(u32 off)
 
 static inline void put_fl_mem(void *buf)
 {
-#if defined(CONFIG_JFFS2_NAND) && ((CONFIG_COMMANDS & CFG_CMD_NAND) || defined(CONFIG_CMD_NAND)
+#if defined(CONFIG_JFFS2_NAND) && \
+    defined(CONFIG_CMD_NAND)
        struct mtdids *id = current_part->dev->id;
 
        if (id->type == MTD_DEV_TYPE_NAND)
@@ -742,7 +739,7 @@ jffs2_1pass_find_inode(struct b_lists * pL, const char *name, u32 pino)
                        }
 
                        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);
@@ -960,13 +957,13 @@ jffs2_1pass_resolve_inode(struct b_lists * pL, u32 ino)
        for(b = pL->dir.listHead; b; b = b->next) {
                jDir = (struct jffs2_raw_dirent *) get_node_mem(b->offset);
                if (ino == jDir->ino) {
-                       if (jDir->version < version) {
+                       if (jDir->version < version) {
                                put_fl_mem(jDir);
                                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) = ",
@@ -1152,7 +1149,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);
        }
@@ -1184,11 +1181,13 @@ jffs2_1pass_build_lists(struct part_info * part)
 
        /* start at the beginning of the partition */
        while (offset < max) {
-               if ((oldoffset >> SPIN_BLKSIZE) != (offset >> SPIN_BLKSIZE)) {
+               if ((oldoffset >> SPIN_BLKSIZE) != (offset >> SPIN_BLKSIZE)) {
                        printf("\b\b%c ", spinner[counter++ % sizeof(spinner)]);
                        oldoffset = offset;
                }
 
+               WATCHDOG_RESET();
+
                node = (struct jffs2_unknown_node *) get_node_mem((u32)part->offset + offset);
                if (node->magic == JFFS2_MAGIC_BITMASK && hdr_crc(node)) {
                        /* if its a fragment add it */
@@ -1214,12 +1213,12 @@ 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 != %u\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 < %u\n", node->totlen,
                                                sizeof(struct jffs2_unknown_node));
                        } else {
                                printf("Unknown node type: %x len %d "
@@ -1394,4 +1393,4 @@ jffs2_1pass_info(struct part_info * part)
        return 1;
 }
 
-#endif /* CFG_CMD_JFFS2 */
+#endif