| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | --- a/drivers/mtd/parsers/bcm47xxpart.c |
| 2 | +++ b/drivers/mtd/parsers/bcm47xxpart.c |
| 3 | @@ -98,6 +98,7 @@ static int bcm47xxpart_parse(struct mtd_ |
| 4 | int trx_num = 0; /* Number of found TRX partitions */ |
| 5 | int possible_nvram_sizes[] = { 0x8000, 0xF000, 0x10000, }; |
| 6 | int err; |
| 7 | + bool found_nvram = false; |
| 8 | |
| 9 | /* |
| 10 | * Some really old flashes (like AT45DB*) had smaller erasesize-s, but |
| 11 | @@ -279,12 +280,23 @@ static int bcm47xxpart_parse(struct mtd_ |
| 12 | if (buf[0] == NVRAM_HEADER) { |
| 13 | bcm47xxpart_add_part(&parts[curr_part++], "nvram", |
| 14 | master->size - blocksize, 0); |
| 15 | + found_nvram = true; |
| 16 | break; |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | kfree(buf); |
| 21 | |
| 22 | + if (!found_nvram) { |
| 23 | + pr_err("can not find a nvram partition reserve last block\n"); |
| 24 | + bcm47xxpart_add_part(&parts[curr_part++], "nvram_guess", |
| 25 | + master->size - blocksize * 2, MTD_WRITEABLE); |
| 26 | + for (i = 0; i < curr_part; i++) { |
| 27 | + if (parts[i].size + parts[i].offset == master->size) |
| 28 | + parts[i].offset -= blocksize * 2; |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | /* |
| 33 | * Assume that partitions end at the beginning of the one they are |
| 34 | * followed by. |