[MTD] Support combined RedBoot FIS directory and configuration area
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Fri Dec 8 08:59:02 EST 2006
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=f33665d931f33a0baf44fc5d3594b23f8118eb44
Commit: f33665d931f33a0baf44fc5d3594b23f8118eb44
Parent: dd11b8cdf0c455f4cfbc5daa70aabce9dcc6c07b
Author: Rod Whitby <rod at whitby.id.au>
AuthorDate: Wed Dec 6 12:11:15 2006 +1030
Committer: David Woodhouse <dwmw2 at infradead.org>
CommitDate: Fri Dec 8 13:28:26 2006 +0000
[MTD] Support combined RedBoot FIS directory and configuration area
RedBoot supports storing the FIS directory and the RedBoot
configuration area in the same block of flash memory. This is
not the most common RedBoot configuration, but it is used on
commercially available boards supported by the kernel.
A recent patch to mtd/redboot.c (http://lkml.org/lkml/2006/3/20/410)
which corrected the skipping of deleted table entries has exposed the
latent problem of the kernel redboot parser running off the end of the
FIS directory and interpreting the RedBoot configuration information
as table entries.
This patch terminates the table parsing when the first truly empty
entry is found (table entry deletion only clears the first byte of the
name, so two cleared bytes in a row indicates the end of the table),
thereby supporting the combined redboot FIS directory and RedBoot
configuration information flash layout scenario.
Signed-off-by: Rod Whitby <rod at whitby.id.au>
Signed-off-by: David Woodhouse <dwmw2 at infradead.org>
---
drivers/mtd/redboot.c | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c
index b525921..035cd9b 100644
--- a/drivers/mtd/redboot.c
+++ b/drivers/mtd/redboot.c
@@ -96,7 +96,19 @@ #endif
*/
if (swab32(buf[i].size) == master->erasesize) {
int j;
- for (j = 0; j < numslots && buf[j].name[0] != 0xff; ++j) {
+ for (j = 0; j < numslots; ++j) {
+
+ /* A single 0xff denotes a deleted entry.
+ * Two of them in a row is the end of the table.
+ */
+ if (buf[j].name[0] == 0xff) {
+ if (buf[j].name[1] == 0xff) {
+ break;
+ } else {
+ continue;
+ }
+ }
+
/* The unsigned long fields were written with the
* wrong byte sex, name and pad have no byte sex.
*/
@@ -126,8 +138,13 @@ #endif
for (i = 0; i < numslots; i++) {
struct fis_list *new_fl, **prev;
- if (buf[i].name[0] == 0xff)
- continue;
+ if (buf[i].name[0] == 0xff) {
+ if (buf[i].name[1] == 0xff) {
+ break;
+ } else {
+ continue;
+ }
+ }
if (!redboot_checksum(&buf[i]))
break;
More information about the linux-mtd-cvs
mailing list