fs: ext4: Fix alignment of cache buffers
[oweals/u-boot.git] / fs / jffs2 / jffs2_1pass.c
index f771e94f91eef40846e6264e264f09bcddb8d0a9..5912cde83840f1b997cdb46251286f6912f8813f 100644 (file)
 #include <linux/compiler.h>
 #include <linux/stat.h>
 #include <linux/time.h>
+#include <u-boot/crc.h>
 #include <watchdog.h>
 #include <jffs2/jffs2.h>
 #include <jffs2/jffs2_1pass.h>
 #include <linux/compat.h>
-#include <asm/errno.h>
+#include <linux/errno.h>
 
 #include "jffs2_private.h"
 
@@ -175,10 +176,15 @@ static u32 nand_cache_off = (u32)-1;
 static int read_nand_cached(u32 off, u32 size, u_char *buf)
 {
        struct mtdids *id = current_part->dev->id;
+       struct mtd_info *mtd;
        u32 bytes_read = 0;
        size_t retlen;
        int cpy_bytes;
 
+       mtd = get_nand_dev_by_index(id->num);
+       if (!mtd)
+               return -1;
+
        while (bytes_read < size) {
                if ((off + bytes_read < nand_cache_off) ||
                    (off + bytes_read >= nand_cache_off+NAND_CACHE_SIZE)) {
@@ -195,8 +201,8 @@ static int read_nand_cached(u32 off, u32 size, u_char *buf)
                        }
 
                        retlen = NAND_CACHE_SIZE;
-                       if (nand_read(nand_info[id->num], nand_cache_off,
-                                               &retlen, nand_cache) != 0 ||
+                       if (nand_read(mtd, nand_cache_off,
+                                     &retlen, nand_cache) < 0 ||
                                        retlen != NAND_CACHE_SIZE) {
                                printf("read_nand_cached: error reading nand off %#x size %d bytes\n",
                                                nand_cache_off, NAND_CACHE_SIZE);
@@ -295,7 +301,7 @@ static int read_onenand_cached(u32 off, u32 size, u_char *buf)
 
                        retlen = ONENAND_CACHE_SIZE;
                        if (onenand_read(&onenand_mtd, onenand_cache_off, retlen,
-                                               &retlen, onenand_cache) != 0 ||
+                                               &retlen, onenand_cache) < 0 ||
                                        retlen != ONENAND_CACHE_SIZE) {
                                printf("read_onenand_cached: error reading nand off %#x size %d bytes\n",
                                        onenand_cache_off, ONENAND_CACHE_SIZE);