summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2010-09-09 15:40:03 -0500
committerScott Wood <scottwood@freescale.com>2010-10-11 15:11:01 -0500
commit36650ca9f16ac507bb0926d3a3ec5340986fcce0 (patch)
tree58a54ad1fe45b7f51df8f9a04e640f04a6cf8e47 /drivers
parent59a50d2de1f9c037166a6f86e6e6cdc1670aa155 (diff)
downloadu-boot-imx-36650ca9f16ac507bb0926d3a3ec5340986fcce0.zip
u-boot-imx-36650ca9f16ac507bb0926d3a3ec5340986fcce0.tar.gz
u-boot-imx-36650ca9f16ac507bb0926d3a3ec5340986fcce0.tar.bz2
Followup fixes on the mtdparts spread patchset
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/mtdcore.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 78f2a08..a195dda 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -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) */