]> git.karo-electronics.de Git - karo-tx-uboot.git/commitdiff
karo: common: fix nand partition loading when bad blocks are encountered
authorLothar Waßmann <LW@KARO-electronics.de>
Wed, 9 Apr 2014 08:16:54 +0000 (10:16 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Wed, 9 Apr 2014 08:16:54 +0000 (10:16 +0200)
board/karo/common/nand.c

index 46fbf76c651bfa6f6f99cf5a87bfc3a5711dd650..c982901c7f265aae46c31ba33dcea94eab9c7305 100644 (file)
@@ -42,7 +42,6 @@ int karo_load_nand_part(const char *part, void *addr, size_t len)
        struct mtd_device *dev;
        struct part_info *part_info;
        u8 part_num;
-       size_t actual;
 
        debug("Initializing mtd_parts\n");
        ret = mtdparts_init();
@@ -59,28 +58,24 @@ int karo_load_nand_part(const char *part, void *addr, size_t len)
        }
        debug("Found partition '%s': offset=%08x size=%08x\n",
                part, part_info->offset, part_info->size);
-       if (part_info->size < len) {
-               printf("Warning: partition '%s' smaller than requested size: %u; truncating data to %u byte\n",
-                       part, len, part_info->size);
+
+       if (part_info->size < len)
                len = part_info->size;
-       }
+
        debug("Reading NAND partition '%s' to %p\n", part, addr);
        ret = nand_read_skip_bad(&nand_info[0], part_info->offset, &len,
-                               &actual, len, addr);
+                               NULL, part_info->size, addr);
        if (ret) {
                printf("Failed to load partition '%s' to %p\n", part, addr);
                return ret;
        }
-       if (actual < len)
-               printf("Read only %u of %u bytes due to bad blocks\n",
-                       actual, len);
 
        debug("Read %u byte from partition '%s' @ offset %08x\n",
                len, part, part_info->offset);
        return 0;
 }
 
-#ifdef CONFIG_SPLASH_SCREEN_
+#if defined(CONFIG_SPLASH_SCREEN) && defined(CONFIG_MTDPARTS)
 static int erase_flash(loff_t offs, size_t len)
 {
        nand_erase_options_t nand_erase_options;
@@ -101,7 +96,6 @@ int do_fbdump(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
        struct part_info *part_info;
        u8 part_num;
        u_char *addr = (u_char *)gd->fb_base;
-       size_t actual;
 
        if (argc > 2)
                return CMD_RET_USAGE;
@@ -117,7 +111,7 @@ int do_fbdump(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
        debug("Initializing mtd_parts\n");
        ret = mtdparts_init();
        if (ret)
-               return ret;
+               return CMD_RET_FAILURE;
 
        debug("Trying to find NAND partition '%s'\n", part);
        ret = find_dev_and_part(part, &dev, &part_num,
@@ -125,8 +119,7 @@ int do_fbdump(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
        if (ret) {
                printf("Failed to find flash partition '%s': %d\n",
                        part, ret);
-
-               return ret;
+               return CMD_RET_FAILURE;
        }
        debug("Found partition '%s': offset=%08x size=%08x\n",
                part, part_info->offset, part_info->size);
@@ -145,15 +138,12 @@ int do_fbdump(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
        }
 
        ret = nand_write_skip_bad(&nand_info[0], part_info->offset,
-                               &fbsize, &actual, part_info->size,
+                               &fbsize, NULL, part_info->size,
                                addr, WITH_DROP_FFS);
        if (ret) {
                printf("Failed to write partition '%s'\n", part);
-               return ret;
+               return CMD_RET_FAILURE;
        }
-       if (actual < fbsize)
-               printf("Wrote only %u of %u bytes due to bad blocks\n",
-                       actual, fbsize);
 
        debug("Wrote %u byte from %p to partition '%s' @ offset %08x\n",
                fbsize, addr, part, part_info->offset);