aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2007-02-10 04:58:31 -0500
committerDavid Woodhouse <dwmw2@infradead.org>2007-02-10 04:58:31 -0500
commit7ca353a428ecbaf77b651fbacfcb2f2f6d813879 (patch)
tree94e8338e3fdec701e2d9d6ce2ad38089dbf78ab4 /drivers/mtd
parent11192146e57bc8e58865e7d9c2497f66a4f7e6e7 (diff)
[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@infradead.org>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/redboot.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c
index a459ffa1e676..a61351f88ec0 100644
--- a/drivers/mtd/redboot.c
+++ b/drivers/mtd/redboot.c
@@ -94,7 +94,16 @@ static int parse_redboot_partitions(struct mtd_info *master,
94 * (NOTE: this is 'size' not 'data_length'; size is 94 * (NOTE: this is 'size' not 'data_length'; size is
95 * the full size of the entry.) 95 * the full size of the entry.)
96 */ 96 */
97 if (swab32(buf[i].size) == master->erasesize) { 97
98 /* RedBoot can combine the FIS directory and
99 config partitions into a single eraseblock;
100 we assume wrong-endian if either the swapped
101 'size' matches the eraseblock size precisely,
102 or if the swapped size actually fits in an
103 eraseblock while the unswapped size doesn't. */
104 if (swab32(buf[i].size) == master->erasesize ||
105 (buf[i].size > master->erasesize
106 && swab32(buf[i].size) < master->erasesize)) {
98 int j; 107 int j;
99 /* Update numslots based on actual FIS directory size */ 108 /* Update numslots based on actual FIS directory size */
100 numslots = swab32(buf[i].size) / sizeof (struct fis_image_desc); 109 numslots = swab32(buf[i].size) / sizeof (struct fis_image_desc);
@@ -122,7 +131,7 @@ static int parse_redboot_partitions(struct mtd_info *master,
122 swab32s(&buf[j].desc_cksum); 131 swab32s(&buf[j].desc_cksum);
123 swab32s(&buf[j].file_cksum); 132 swab32s(&buf[j].file_cksum);
124 } 133 }
125 } else { 134 } else if (buf[i].size < master->erasesize) {
126 /* Update numslots based on actual FIS directory size */ 135 /* Update numslots based on actual FIS directory size */
127 numslots = buf[i].size / sizeof(struct fis_image_desc); 136 numslots = buf[i].size / sizeof(struct fis_image_desc);
128 } 137 }