diff options
-rw-r--r-- | drivers/mtd/bcm47xxpart.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c index 986ab6ef3181..9bcec8f22bbb 100644 --- a/drivers/mtd/bcm47xxpart.c +++ b/drivers/mtd/bcm47xxpart.c | |||
@@ -19,12 +19,6 @@ | |||
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 | |||
28 | /* Magics */ | 22 | /* Magics */ |
29 | #define BOARD_DATA_MAGIC 0x5246504D /* MPFR */ | 23 | #define BOARD_DATA_MAGIC 0x5246504D /* MPFR */ |
30 | #define POT_MAGIC1 0x54544f50 /* POTT */ | 24 | #define POT_MAGIC1 0x54544f50 /* POTT */ |
@@ -63,14 +57,17 @@ static int bcm47xxpart_parse(struct mtd_info *master, | |||
63 | struct trx_header *trx; | 57 | struct trx_header *trx; |
64 | int trx_part = -1; | 58 | int trx_part = -1; |
65 | int last_trx_part = -1; | 59 | int last_trx_part = -1; |
60 | int max_bytes_to_read = 0x8004; | ||
66 | 61 | ||
67 | if (blocksize <= 0x10000) | 62 | if (blocksize <= 0x10000) |
68 | blocksize = 0x10000; | 63 | blocksize = 0x10000; |
64 | if (blocksize == 0x20000) | ||
65 | max_bytes_to_read = 0x18004; | ||
69 | 66 | ||
70 | /* Alloc */ | 67 | /* Alloc */ |
71 | parts = kzalloc(sizeof(struct mtd_partition) * BCM47XXPART_MAX_PARTS, | 68 | parts = kzalloc(sizeof(struct mtd_partition) * BCM47XXPART_MAX_PARTS, |
72 | GFP_KERNEL); | 69 | GFP_KERNEL); |
73 | buf = kzalloc(BCM47XXPART_BYTES_TO_READ, GFP_KERNEL); | 70 | buf = kzalloc(max_bytes_to_read, GFP_KERNEL); |
74 | 71 | ||
75 | /* Parse block by block looking for magics */ | 72 | /* Parse block by block looking for magics */ |
76 | for (offset = 0; offset <= master->size - blocksize; | 73 | for (offset = 0; offset <= master->size - blocksize; |
@@ -85,7 +82,7 @@ static int bcm47xxpart_parse(struct mtd_info *master, | |||
85 | } | 82 | } |
86 | 83 | ||
87 | /* Read beginning of the block */ | 84 | /* Read beginning of the block */ |
88 | if (mtd_read(master, offset, BCM47XXPART_BYTES_TO_READ, | 85 | if (mtd_read(master, offset, max_bytes_to_read, |
89 | &bytes_read, (uint8_t *)buf) < 0) { | 86 | &bytes_read, (uint8_t *)buf) < 0) { |
90 | pr_err("mtd_read error while parsing (offset: 0x%X)!\n", | 87 | pr_err("mtd_read error while parsing (offset: 0x%X)!\n", |
91 | offset); | 88 | offset); |
@@ -100,9 +97,16 @@ static int bcm47xxpart_parse(struct mtd_info *master, | |||
100 | } | 97 | } |
101 | 98 | ||
102 | /* Standard NVRAM */ | 99 | /* Standard NVRAM */ |
103 | if (buf[0x000 / 4] == NVRAM_HEADER) { | 100 | 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))) { | ||
104 | bcm47xxpart_add_part(&parts[curr_part++], "nvram", | 107 | bcm47xxpart_add_part(&parts[curr_part++], "nvram", |
105 | offset, 0); | 108 | offset, 0); |
109 | offset = rounddown(offset, blocksize); | ||
106 | continue; | 110 | continue; |
107 | } | 111 | } |
108 | 112 | ||