diff options
Diffstat (limited to 'drivers/mtd/redboot.c')
-rw-r--r-- | drivers/mtd/redboot.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c index 035cd9b0cc08..a61351f88ec0 100644 --- a/drivers/mtd/redboot.c +++ b/drivers/mtd/redboot.c | |||
@@ -94,8 +94,19 @@ 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; |
108 | /* Update numslots based on actual FIS directory size */ | ||
109 | numslots = swab32(buf[i].size) / sizeof (struct fis_image_desc); | ||
99 | for (j = 0; j < numslots; ++j) { | 110 | for (j = 0; j < numslots; ++j) { |
100 | 111 | ||
101 | /* A single 0xff denotes a deleted entry. | 112 | /* A single 0xff denotes a deleted entry. |
@@ -120,11 +131,11 @@ static int parse_redboot_partitions(struct mtd_info *master, | |||
120 | swab32s(&buf[j].desc_cksum); | 131 | swab32s(&buf[j].desc_cksum); |
121 | swab32s(&buf[j].file_cksum); | 132 | swab32s(&buf[j].file_cksum); |
122 | } | 133 | } |
134 | } else if (buf[i].size < master->erasesize) { | ||
135 | /* Update numslots based on actual FIS directory size */ | ||
136 | numslots = buf[i].size / sizeof(struct fis_image_desc); | ||
123 | } | 137 | } |
124 | break; | 138 | break; |
125 | } else { | ||
126 | /* re-calculate of real numslots */ | ||
127 | numslots = buf[i].size / sizeof(struct fis_image_desc); | ||
128 | } | 139 | } |
129 | } | 140 | } |
130 | if (i == numslots) { | 141 | if (i == numslots) { |