aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd')
-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 7b7ca5ab5ae4..d01b6a9198e0 100644
--- a/drivers/mtd/redboot.c
+++ b/drivers/mtd/redboot.c
@@ -89,8 +89,34 @@ static int parse_redboot_partitions(struct mtd_info *master,
89 i = numslots; 89 i = numslots;
90 break; 90 break;
91 } 91 }
92 if (!memcmp(buf[i].name, "FIS directory", 14)) 92 if (!memcmp(buf[i].name, "FIS directory", 14)) {
93 /* This is apparently the FIS directory entry for the
94 * FIS directory itself. The FIS directory size is
95 * one erase block, if the buf[i].size field is
96 * swab32(erasesize) then we know we are looking at
97 * a byte swapped FIS directory - swap all the entries!
98 * (NOTE: this is 'size' not 'data_length', size is
99 * the full size of the entry.)
100 */
101 if (swab32(buf[i].size) == master->erasesize) {
102 int j;
103 for (j = 0; j < numslots && buf[j].name[0] != 0xff; ++j) {
104 /* The unsigned long fields were written with the
105 * wrong byte sex, name and pad have no byte sex.
106 */
107# define do_swab32(x) (x) = swab32(x)
108 do_swab32(buf[j].flash_base);
109 do_swab32(buf[j].mem_base);
110 do_swab32(buf[j].size);
111 do_swab32(buf[j].entry_point);
112 do_swab32(buf[j].data_length);
113 do_swab32(buf[j].desc_cksum);
114 do_swab32(buf[j].file_cksum);
115# undef do_swab32
116 }
117 }
93 break; 118 break;
119 }
94 } 120 }
95 if (i == numslots) { 121 if (i == numslots) {
96 /* Didn't find it */ 122 /* Didn't find it */