diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2013-03-07 03:02:39 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2013-03-08 06:36:00 -0500 |
commit | 91d542f4dcc231749c36114ed8e26bb27d4521e4 (patch) | |
tree | 53996b08552bef0f7e78df30f856066e07708ea9 | |
parent | 5ca1088f10d6179a610067ebedc56edc7d98b986 (diff) |
mtd: bcm47xxpart: look for NVRAM at the end of device
NVRAM is always placed at the end of device and it does not have to
start at the beginning of a block, so check few possible offsets.
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r-- | drivers/mtd/bcm47xxpart.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c index 4552afbad4d0..9279a9174f84 100644 --- a/drivers/mtd/bcm47xxpart.c +++ b/drivers/mtd/bcm47xxpart.c | |||
@@ -63,6 +63,7 @@ static int bcm47xxpart_parse(struct mtd_info *master, | |||
63 | struct trx_header *trx; | 63 | struct trx_header *trx; |
64 | int trx_part = -1; | 64 | int trx_part = -1; |
65 | int last_trx_part = -1; | 65 | int last_trx_part = -1; |
66 | int possible_nvram_sizes[] = { 0x8000, 0xF000, 0x10000, }; | ||
66 | 67 | ||
67 | if (blocksize <= 0x10000) | 68 | if (blocksize <= 0x10000) |
68 | blocksize = 0x10000; | 69 | blocksize = 0x10000; |
@@ -99,13 +100,6 @@ static int bcm47xxpart_parse(struct mtd_info *master, | |||
99 | continue; | 100 | continue; |
100 | } | 101 | } |
101 | 102 | ||
102 | /* Standard NVRAM */ | ||
103 | if (buf[0x000 / 4] == NVRAM_HEADER) { | ||
104 | bcm47xxpart_add_part(&parts[curr_part++], "nvram", | ||
105 | offset, 0); | ||
106 | continue; | ||
107 | } | ||
108 | |||
109 | /* | 103 | /* |
110 | * board_data starts with board_id which differs across boards, | 104 | * board_data starts with board_id which differs across boards, |
111 | * but we can use 'MPFR' (hopefully) magic at 0x100 | 105 | * but we can use 'MPFR' (hopefully) magic at 0x100 |
@@ -174,6 +168,30 @@ static int bcm47xxpart_parse(struct mtd_info *master, | |||
174 | continue; | 168 | continue; |
175 | } | 169 | } |
176 | } | 170 | } |
171 | |||
172 | /* Look for NVRAM at the end of the last block. */ | ||
173 | for (i = 0; i < ARRAY_SIZE(possible_nvram_sizes); i++) { | ||
174 | if (curr_part > BCM47XXPART_MAX_PARTS) { | ||
175 | pr_warn("Reached maximum number of partitions, scanning stopped!\n"); | ||
176 | break; | ||
177 | } | ||
178 | |||
179 | offset = master->size - possible_nvram_sizes[i]; | ||
180 | if (mtd_read(master, offset, 0x4, &bytes_read, | ||
181 | (uint8_t *)buf) < 0) { | ||
182 | pr_err("mtd_read error while reading at offset 0x%X!\n", | ||
183 | offset); | ||
184 | continue; | ||
185 | } | ||
186 | |||
187 | /* Standard NVRAM */ | ||
188 | if (buf[0] == NVRAM_HEADER) { | ||
189 | bcm47xxpart_add_part(&parts[curr_part++], "nvram", | ||
190 | master->size - blocksize, 0); | ||
191 | break; | ||
192 | } | ||
193 | } | ||
194 | |||
177 | kfree(buf); | 195 | kfree(buf); |
178 | 196 | ||
179 | /* | 197 | /* |