]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
mtd: fix false positive "Offset exceeds device limit" error
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Wed, 1 Jul 2015 12:35:49 +0000 (21:35 +0900)
committerLothar Waßmann <LW@KARO-electronics.de>
Wed, 9 Sep 2015 11:29:21 +0000 (13:29 +0200)
Since commit 09c3280754f8 (mtd, nand: Move common functions from
cmd_nand.c to common place), NAND commands would not work at all
on large devices.

    => nand read 80000000 10000 10000

    NAND read: Offset exceeds device limit
    => nand erase 100000 100000

    NAND erase: Offset exceeds device limit

The type of the "size" of "struct mtd_info" is uint64_t, while
mtd_arg_off_size() and mtd_arg_off() treat chipsize as int type.
The chipsize is wrapped around if the argument is given with 2GB
or larger.

Acked-by: Heiko Schocher <hs@denx.de>
Acked-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
drivers/mtd/mtd_uboot.c
include/linux/mtd/mtd.h

index 7197007d41b5995c40929c1a8badbe2c56a2101c..c517b9c65d685a6dcb8e7d2197a5a25a8f19f5ca 100644 (file)
@@ -43,7 +43,7 @@ static int get_part(const char *partname, int *idx, loff_t *off, loff_t *size,
 }
 
 int mtd_arg_off(const char *arg, int *idx, loff_t *off, loff_t *size,
-               loff_t *maxsize, int devtype, int chipsize)
+               loff_t *maxsize, int devtype, uint64_t chipsize)
 {
        if (!str2off(arg, off))
                return get_part(arg, idx, off, size, maxsize, devtype);
@@ -59,7 +59,8 @@ int mtd_arg_off(const char *arg, int *idx, loff_t *off, loff_t *size,
 }
 
 int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off,
-                loff_t *size, loff_t *maxsize, int devtype, int chipsize)
+                    loff_t *size, loff_t *maxsize, int devtype,
+                    uint64_t chipsize)
 {
        int ret;
 
index 33669da4ed8a9c2a8f29d389e8ac4bce142292c9..552d4d623ff1845a517445becd2bea2518b002e3 100644 (file)
@@ -484,8 +484,9 @@ int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
 int del_mtd_partitions(struct mtd_info *);
 
 int mtd_arg_off(const char *arg, int *idx, loff_t *off, loff_t *size,
-               loff_t *maxsize, int devtype, int chipsize);
+               loff_t *maxsize, int devtype, uint64_t chipsize);
 int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off,
-                loff_t *size, loff_t *maxsize, int devtype, int chipsize);
+                    loff_t *size, loff_t *maxsize, int devtype,
+                    uint64_t chipsize);
 #endif
 #endif /* __MTD_MTD_H__ */