]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Followup fixes on the mtdparts spread patchset
authorScott Wood <scottwood@freescale.com>
Thu, 9 Sep 2010 20:40:03 +0000 (15:40 -0500)
committerScott Wood <scottwood@freescale.com>
Mon, 11 Oct 2010 20:11:01 +0000 (15:11 -0500)
Consolidate some code in mtd_get_len_incl_bad(), and fix a condition
where a valid partition could be reported as truncated if it has a
good block at the end of the device (unlikely, since the BBT is usually
there).

Fix mid-block declarations in net_part_size().

Signed-off-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Ben Gardiner <bengardiner@nanometrics.ca>
common/cmd_mtdparts.c
drivers/mtd/mtdcore.c

index 17865b756b4c3ec1244904bb2c50d0b750f4ca2b..5481c885d3ea1bb92303d5396d5f626d7c5337e2 100644 (file)
@@ -1228,15 +1228,16 @@ static int generate_mtdparts_save(char *buf, u32 buflen)
  */
 static uint64_t net_part_size(struct mtd_info *mtd, struct part_info *part)
 {
+       uint64_t i, net_size = 0;
+
        if (!mtd->block_isbad)
                return part->size;
 
-       uint64_t i, net_size = 0;
-
        for (i = 0; i < part->size; i += mtd->erasesize) {
                if (!mtd->block_isbad(mtd, part->offset + i))
                        net_size += mtd->erasesize;
        }
+
        return net_size;
 }
 #endif
index 78f2a085411c48c7c111aff1d11764ef768dd1d2..a195ddab35774a9044f0446e8e0d66d880636c3a 100644 (file)
@@ -162,11 +162,6 @@ void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,
        *truncated = 0;
        *len_incl_bad = 0;
 
-       if (offset >= mtd->size) {
-               *truncated = 1;
-               return;
-       }
-
        if (!mtd->block_isbad) {
                *len_incl_bad = length;
                return;
@@ -176,6 +171,11 @@ void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,
        uint64_t block_len;
 
        while (len_excl_bad < length) {
+               if (offset >= mtd->size) {
+                       *truncated = 1;
+                       return;
+               }
+
                block_len = mtd->erasesize - (offset & (mtd->erasesize - 1));
 
                if (!mtd->block_isbad(mtd, offset & ~(mtd->erasesize - 1)))
@@ -183,11 +183,6 @@ void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,
 
                *len_incl_bad += block_len;
                offset       += block_len;
-
-               if (offset >= mtd->size) {
-                       *truncated = 1;
-                       break;
-               }
        }
 }
 #endif /* defined(CONFIG_CMD_MTDPARTS_SPREAD) */