diff options
| -rw-r--r-- | drivers/mtd/bcm47xxpart.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c index 63feb75cc8e0..4552afbad4d0 100644 --- a/drivers/mtd/bcm47xxpart.c +++ b/drivers/mtd/bcm47xxpart.c | |||
| @@ -19,6 +19,12 @@ | |||
| 19 | /* 10 parts were found on sflash on Netgear WNDR4500 */ | 19 | /* 10 parts were found on sflash on Netgear WNDR4500 */ |
| 20 | #define BCM47XXPART_MAX_PARTS 12 | 20 | #define BCM47XXPART_MAX_PARTS 12 |
| 21 | 21 | ||
| 22 | /* | ||
| 23 | * Amount of bytes we read when analyzing each block of flash memory. | ||
| 24 | * Set it big enough to allow detecting partition and reading important data. | ||
| 25 | */ | ||
| 26 | #define BCM47XXPART_BYTES_TO_READ 0x404 | ||
| 27 | |||
| 22 | /* Magics */ | 28 | /* Magics */ |
| 23 | #define BOARD_DATA_MAGIC 0x5246504D /* MPFR */ | 29 | #define BOARD_DATA_MAGIC 0x5246504D /* MPFR */ |
| 24 | #define POT_MAGIC1 0x54544f50 /* POTT */ | 30 | #define POT_MAGIC1 0x54544f50 /* POTT */ |
| @@ -57,17 +63,14 @@ static int bcm47xxpart_parse(struct mtd_info *master, | |||
| 57 | struct trx_header *trx; | 63 | struct trx_header *trx; |
| 58 | int trx_part = -1; | 64 | int trx_part = -1; |
| 59 | int last_trx_part = -1; | 65 | int last_trx_part = -1; |
| 60 | int max_bytes_to_read = 0x8004; | ||
| 61 | 66 | ||
| 62 | if (blocksize <= 0x10000) | 67 | if (blocksize <= 0x10000) |
| 63 | blocksize = 0x10000; | 68 | blocksize = 0x10000; |
| 64 | if (blocksize == 0x20000) | ||
| 65 | max_bytes_to_read = 0x18004; | ||
| 66 | 69 | ||
| 67 | /* Alloc */ | 70 | /* Alloc */ |
| 68 | parts = kzalloc(sizeof(struct mtd_partition) * BCM47XXPART_MAX_PARTS, | 71 | parts = kzalloc(sizeof(struct mtd_partition) * BCM47XXPART_MAX_PARTS, |
| 69 | GFP_KERNEL); | 72 | GFP_KERNEL); |
| 70 | buf = kzalloc(max_bytes_to_read, GFP_KERNEL); | 73 | buf = kzalloc(BCM47XXPART_BYTES_TO_READ, GFP_KERNEL); |
| 71 | 74 | ||
| 72 | /* Parse block by block looking for magics */ | 75 | /* Parse block by block looking for magics */ |
| 73 | for (offset = 0; offset <= master->size - blocksize; | 76 | for (offset = 0; offset <= master->size - blocksize; |
| @@ -82,7 +85,7 @@ static int bcm47xxpart_parse(struct mtd_info *master, | |||
| 82 | } | 85 | } |
| 83 | 86 | ||
| 84 | /* Read beginning of the block */ | 87 | /* Read beginning of the block */ |
| 85 | if (mtd_read(master, offset, max_bytes_to_read, | 88 | if (mtd_read(master, offset, BCM47XXPART_BYTES_TO_READ, |
| 86 | &bytes_read, (uint8_t *)buf) < 0) { | 89 | &bytes_read, (uint8_t *)buf) < 0) { |
| 87 | pr_err("mtd_read error while parsing (offset: 0x%X)!\n", | 90 | pr_err("mtd_read error while parsing (offset: 0x%X)!\n", |
| 88 | offset); | 91 | offset); |
| @@ -97,16 +100,9 @@ static int bcm47xxpart_parse(struct mtd_info *master, | |||
| 97 | } | 100 | } |
| 98 | 101 | ||
| 99 | /* Standard NVRAM */ | 102 | /* Standard NVRAM */ |
| 100 | if (buf[0x000 / 4] == NVRAM_HEADER || | 103 | if (buf[0x000 / 4] == NVRAM_HEADER) { |
| 101 | buf[0x1000 / 4] == NVRAM_HEADER || | ||
| 102 | buf[0x8000 / 4] == NVRAM_HEADER || | ||
| 103 | (blocksize == 0x20000 && ( | ||
| 104 | buf[0x10000 / 4] == NVRAM_HEADER || | ||
| 105 | buf[0x11000 / 4] == NVRAM_HEADER || | ||
| 106 | buf[0x18000 / 4] == NVRAM_HEADER))) { | ||
| 107 | bcm47xxpart_add_part(&parts[curr_part++], "nvram", | 104 | bcm47xxpart_add_part(&parts[curr_part++], "nvram", |
| 108 | offset, 0); | 105 | offset, 0); |
| 109 | offset = rounddown(offset, blocksize); | ||
| 110 | continue; | 106 | continue; |
| 111 | } | 107 | } |
| 112 | 108 | ||
