[MTD] Improve heuristic for detecting wrong-endian RedBoot partition table
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Sat Feb 10 04:59:01 EST 2007
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=7ca353a428ecbaf77b651fbacfcb2f2f6d813879
Commit: 7ca353a428ecbaf77b651fbacfcb2f2f6d813879
Parent: 11192146e57bc8e58865e7d9c2497f66a4f7e6e7
Author: David Woodhouse <dwmw2 at infradead.org>
AuthorDate: Sat Feb 10 09:58:31 2007 +0000
Committer: David Woodhouse <dwmw2 at infradead.org>
CommitDate: Sat Feb 10 09:58:31 2007 +0000
[MTD] Improve heuristic for detecting wrong-endian RedBoot partition table
Also limit the amount we scan to one eraseblock.
Signed-off-by: David Woodhouse <dwmw2 at infradead.org>
---
drivers/mtd/redboot.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c
index a459ffa..a61351f 100644
--- a/drivers/mtd/redboot.c
+++ b/drivers/mtd/redboot.c
@@ -94,7 +94,16 @@ static int parse_redboot_partitions(struct mtd_info *master,
* (NOTE: this is 'size' not 'data_length'; size is
* the full size of the entry.)
*/
- if (swab32(buf[i].size) == master->erasesize) {
+
+ /* RedBoot can combine the FIS directory and
+ config partitions into a single eraseblock;
+ we assume wrong-endian if either the swapped
+ 'size' matches the eraseblock size precisely,
+ or if the swapped size actually fits in an
+ eraseblock while the unswapped size doesn't. */
+ if (swab32(buf[i].size) == master->erasesize ||
+ (buf[i].size > master->erasesize
+ && swab32(buf[i].size) < master->erasesize)) {
int j;
/* Update numslots based on actual FIS directory size */
numslots = swab32(buf[i].size) / sizeof (struct fis_image_desc);
@@ -122,7 +131,7 @@ static int parse_redboot_partitions(struct mtd_info *master,
swab32s(&buf[j].desc_cksum);
swab32s(&buf[j].file_cksum);
}
- } else {
+ } else if (buf[i].size < master->erasesize) {
/* Update numslots based on actual FIS directory size */
numslots = buf[i].size / sizeof(struct fis_image_desc);
}
More information about the linux-mtd-cvs
mailing list