tizen 2.3.1 release
[platform/kernel/u-boot.git] / fs / jffs2 / jffs2_1pass.c
index 3fb5db3..c4f7445 100644 (file)
 #include <common.h>
 #include <config.h>
 #include <malloc.h>
-#include <div64.h>
 #include <linux/stat.h>
 #include <linux/time.h>
 #include <watchdog.h>
 #include <jffs2/jffs2.h>
 #include <jffs2/jffs2_1pass.h>
-#include <linux/compat.h>
+#include <linux/mtd/compat.h>
 #include <asm/errno.h>
 
 #include "jffs2_private.h"
@@ -697,6 +696,7 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 inode, char *dest)
        u32 latestVersion = 0;
        uchar *lDest;
        uchar *src;
+       long ret;
        int i;
        u32 counter = 0;
 #ifdef CONFIG_SYS_JFFS2_SORT_FRAGMENTS
@@ -768,30 +768,33 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 inode, char *dest)
 #endif
                                switch (jNode->compr) {
                                case JFFS2_COMPR_NONE:
-                                       ldr_memcpy(lDest, src, jNode->dsize);
+                                       ret = (unsigned long) ldr_memcpy(lDest, src, jNode->dsize);
                                        break;
                                case JFFS2_COMPR_ZERO:
+                                       ret = 0;
                                        for (i = 0; i < jNode->dsize; i++)
                                                *(lDest++) = 0;
                                        break;
                                case JFFS2_COMPR_RTIME:
+                                       ret = 0;
                                        rtime_decompress(src, lDest, jNode->csize, jNode->dsize);
                                        break;
                                case JFFS2_COMPR_DYNRUBIN:
                                        /* this is slow but it works */
+                                       ret = 0;
                                        dynrubin_decompress(src, lDest, jNode->csize, jNode->dsize);
                                        break;
                                case JFFS2_COMPR_ZLIB:
-                                       zlib_decompress(src, lDest, jNode->csize, jNode->dsize);
+                                       ret = zlib_decompress(src, lDest, jNode->csize, jNode->dsize);
                                        break;
 #if defined(CONFIG_JFFS2_LZO)
                                case JFFS2_COMPR_LZO:
-                                       lzo_decompress(src, lDest, jNode->csize, jNode->dsize);
+                                       ret = lzo_decompress(src, lDest, jNode->csize, jNode->dsize);
                                        break;
 #endif
                                default:
                                        /* unknown */
-                                       putLabeledWord("UNKNOWN COMPRESSION METHOD = ", jNode->compr);
+                                       putLabeledWord("UNKOWN COMPRESSION METHOD = ", jNode->compr);
                                        put_fl_mem(jNode, pL->readbuf);
                                        return -1;
                                        break;
@@ -800,6 +803,7 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 inode, char *dest)
 
 #if 0
                        putLabeledWord("read_inode: totalSize = ", totalSize);
+                       putLabeledWord("read_inode: compr ret = ", ret);
 #endif
                }
                counter++;
@@ -1439,7 +1443,7 @@ jffs2_1pass_build_lists(struct part_info * part)
 {
        struct b_lists *pL;
        struct jffs2_unknown_node *node;
-       u32 nr_sectors;
+       u32 nr_sectors = part->size/part->sector_size;
        u32 i;
        u32 counter4 = 0;
        u32 counterF = 0;
@@ -1448,7 +1452,6 @@ jffs2_1pass_build_lists(struct part_info * part)
        u32 buf_size = DEFAULT_EMPTY_SCAN_SIZE;
        char *buf;
 
-       nr_sectors = lldiv(part->size, part->sector_size);
        /* turn off the lcd.  Refreshing the lcd adds 50% overhead to the */
        /* jffs2 list building enterprise nope.  in newer versions the overhead is */
        /* only about 5 %.  not enough to inconvenience people for. */
@@ -1572,8 +1575,9 @@ jffs2_1pass_build_lists(struct part_info * part)
 
                        if (*(uint32_t *)(&buf[ofs-buf_ofs]) == 0xffffffff) {
                                uint32_t inbuf_ofs;
-                               uint32_t scan_end;
+                               uint32_t empty_start, scan_end;
 
+                               empty_start = ofs;
                                ofs += 4;
                                scan_end = min_t(uint32_t, EMPTY_SCAN_SIZE(
                                                        part->sector_size)/8,