mtd: bcm47xxpart: find NVRAM partitions in middle blocks

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Wed Oct 15 23:59:06 PDT 2014


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=024629fdca1bbb44a25d40c2362a878a7a67ce3b
Commit:     024629fdca1bbb44a25d40c2362a878a7a67ce3b
Parent:     022a478ce650f5c36d2a9badfd805368a90fb506
Author:     Rafał Miłecki <zajec5 at gmail.com>
AuthorDate: Mon Aug 18 20:20:27 2014 +0200
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Wed Sep 17 23:15:38 2014 -0700

    mtd: bcm47xxpart: find NVRAM partitions in middle blocks
    
    Old devices used to have NVRAM at the very end of flash and they could
    be unaligned (starting at some offset in a block).
    In new devices NVRAM can be located quite randomly, however it seems to
    always start at the beginning of a block. For example Netgear R6250 has
    NVRAM located right after the bootloader, before the kernel partition.
    
    Signed-off-by: Rafał Miłecki <zajec5 at gmail.com>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/bcm47xxpart.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c
index adfa74c..8057f52 100644
--- a/drivers/mtd/bcm47xxpart.c
+++ b/drivers/mtd/bcm47xxpart.c
@@ -199,6 +199,17 @@ static int bcm47xxpart_parse(struct mtd_info *master,
 			continue;
 		}
 
+		/*
+		 * New (ARM?) devices may have NVRAM in some middle block. Last
+		 * block will be checked later, so skip it.
+		 */
+		if (offset != master->size - blocksize &&
+		    buf[0x000 / 4] == NVRAM_HEADER) {
+			bcm47xxpart_add_part(&parts[curr_part++], "nvram",
+					     offset, 0);
+			continue;
+		}
+
 		/* Read middle of the block */
 		if (mtd_read(master, offset + 0x8000, 0x4,
 			     &bytes_read, (uint8_t *)buf) < 0) {



More information about the linux-mtd-cvs mailing list