aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/redboot.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/redboot.c')
-rw-r--r--drivers/mtd/redboot.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c
index 7b7ca5ab5ae41c..d01b6a9198e0ac 100644
--- a/drivers/mtd/redboot.c
+++ b/drivers/mtd/redboot.c
@@ -89,8 +89,34 @@ static int parse_redboot_partitions(struct mtd_info *master,
i = numslots;
break;
}
- if (!memcmp(buf[i].name, "FIS directory", 14))
+ if (!memcmp(buf[i].name, "FIS directory", 14)) {
+ /* This is apparently the FIS directory entry for the
+ * FIS directory itself. The FIS directory size is
+ * one erase block, if the buf[i].size field is
+ * swab32(erasesize) then we know we are looking at
+ * a byte swapped FIS directory - swap all the entries!
+ * (NOTE: this is 'size' not 'data_length', size is
+ * the full size of the entry.)
+ */
+ if (swab32(buf[i].size) == master->erasesize) {
+ int j;
+ for (j = 0; j < numslots && buf[j].name[0] != 0xff; ++j) {
+ /* The unsigned long fields were written with the
+ * wrong byte sex, name and pad have no byte sex.
+ */
+# define do_swab32(x) (x) = swab32(x)
+ do_swab32(buf[j].flash_base);
+ do_swab32(buf[j].mem_base);
+ do_swab32(buf[j].size);
+ do_swab32(buf[j].entry_point);
+ do_swab32(buf[j].data_length);
+ do_swab32(buf[j].desc_cksum);
+ do_swab32(buf[j].file_cksum);
+# undef do_swab32
+ }
+ }
break;
+ }
}
if (i == numslots) {
/* Didn't find it */