]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - fs/jffs2/jffs2_1pass.c
Merge branch 'u-boot-sh/rmobile' into 'u-boot-arm/master'
[karo-tx-uboot.git] / fs / jffs2 / jffs2_1pass.c
index 93651f53e9242d9c2e51672383c9a69d234f6c18..b1d647021928897855166f34c421f5aac680c491 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/mtd/compat.h>
+#include <linux/compat.h>
 #include <asm/errno.h>
 
 #include "jffs2_private.h"
@@ -398,23 +399,26 @@ static inline void *get_fl_mem(u32 off, u32 size, void *ext_buf)
 {
        struct mtdids *id = current_part->dev->id;
 
+       switch(id->type) {
 #if defined(CONFIG_CMD_FLASH)
-       if (id->type == MTD_DEV_TYPE_NOR) {
+       case MTD_DEV_TYPE_NOR:
                return get_fl_mem_nor(off, size, ext_buf);
-       }
+               break;
 #endif
-
 #if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND)
-       if (id->type == MTD_DEV_TYPE_NAND)
+       case MTD_DEV_TYPE_NAND:
                return get_fl_mem_nand(off, size, ext_buf);
+               break;
 #endif
-
 #if defined(CONFIG_CMD_ONENAND)
-       if (id->type == MTD_DEV_TYPE_ONENAND)
+       case MTD_DEV_TYPE_ONENAND:
                return get_fl_mem_onenand(off, size, ext_buf);
+               break;
 #endif
-
-       printf("get_fl_mem: unknown device type, using raw offset!\n");
+       default:
+               printf("get_fl_mem: unknown device type, " \
+                       "using raw offset!\n");
+       }
        return (void*)off;
 }
 
@@ -422,23 +426,27 @@ static inline void *get_node_mem(u32 off, void *ext_buf)
 {
        struct mtdids *id = current_part->dev->id;
 
+       switch(id->type) {
 #if defined(CONFIG_CMD_FLASH)
-       if (id->type == MTD_DEV_TYPE_NOR)
+       case MTD_DEV_TYPE_NOR:
                return get_node_mem_nor(off, ext_buf);
+               break;
 #endif
-
 #if defined(CONFIG_JFFS2_NAND) && \
     defined(CONFIG_CMD_NAND)
-       if (id->type == MTD_DEV_TYPE_NAND)
+       case MTD_DEV_TYPE_NAND:
                return get_node_mem_nand(off, ext_buf);
+               break;
 #endif
-
 #if defined(CONFIG_CMD_ONENAND)
-       if (id->type == MTD_DEV_TYPE_ONENAND)
+       case MTD_DEV_TYPE_ONENAND:
                return get_node_mem_onenand(off, ext_buf);
+               break;
 #endif
-
-       printf("get_node_mem: unknown device type, using raw offset!\n");
+       default:
+               printf("get_fl_mem: unknown device type, " \
+                       "using raw offset!\n");
+       }
        return (void*)off;
 }
 
@@ -689,7 +697,6 @@ 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
@@ -717,7 +724,7 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 inode, char *dest)
        for (b = pL->frag.listHead; b != NULL; b = b->next) {
                jNode = (struct jffs2_raw_inode *) get_node_mem(b->offset,
                                                                pL->readbuf);
-               if ((inode == jNode->ino)) {
+               if (inode == jNode->ino) {
 #if 0
                        putLabeledWord("\r\n\r\nread_inode: totlen = ", jNode->totlen);
                        putLabeledWord("read_inode: inode = ", jNode->ino);
@@ -761,33 +768,30 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 inode, char *dest)
 #endif
                                switch (jNode->compr) {
                                case JFFS2_COMPR_NONE:
-                                       ret = (unsigned long) ldr_memcpy(lDest, src, jNode->dsize);
+                                       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:
-                                       ret = zlib_decompress(src, lDest, jNode->csize, jNode->dsize);
+                                       zlib_decompress(src, lDest, jNode->csize, jNode->dsize);
                                        break;
 #if defined(CONFIG_JFFS2_LZO)
                                case JFFS2_COMPR_LZO:
-                                       ret = lzo_decompress(src, lDest, jNode->csize, jNode->dsize);
+                                       lzo_decompress(src, lDest, jNode->csize, jNode->dsize);
                                        break;
 #endif
                                default:
                                        /* unknown */
-                                       putLabeledWord("UNKOWN COMPRESSION METHOD = ", jNode->compr);
+                                       putLabeledWord("UNKNOWN COMPRESSION METHOD = ", jNode->compr);
                                        put_fl_mem(jNode, pL->readbuf);
                                        return -1;
                                        break;
@@ -796,7 +800,6 @@ 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++;
@@ -1436,7 +1439,7 @@ jffs2_1pass_build_lists(struct part_info * part)
 {
        struct b_lists *pL;
        struct jffs2_unknown_node *node;
-       u32 nr_sectors = part->size/part->sector_size;
+       u32 nr_sectors;
        u32 i;
        u32 counter4 = 0;
        u32 counterF = 0;
@@ -1445,6 +1448,7 @@ 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. */
@@ -1568,9 +1572,8 @@ jffs2_1pass_build_lists(struct part_info * part)
 
                        if (*(uint32_t *)(&buf[ofs-buf_ofs]) == 0xffffffff) {
                                uint32_t inbuf_ofs;
-                               uint32_t empty_start, scan_end;
+                               uint32_t scan_end;
 
-                               empty_start = ofs;
                                ofs += 4;
                                scan_end = min_t(uint32_t, EMPTY_SCAN_SIZE(
                                                        part->sector_size)/8,