diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2013-03-07 03:02:38 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2013-03-08 06:35:10 -0500 |
commit | 5ca1088f10d6179a610067ebedc56edc7d98b986 (patch) | |
tree | 185216e0e0994451aa99e235d6524ac65d634f7a /drivers/mtd/bcm47xxpart.c | |
parent | 48476df99894492a0f7239f2f3c9a2dde4ff38e2 (diff) |
Revert "mtd: bcm47xxpart: improve probing of nvram partition"
This reverts commit be3781b71ac03723b552dc156931620634ef1b22.
Some CFE bootloaders have NVRAM at offset 0x1000. With that patch we
were detecting such a bootloaders as a standard NVRAM partition.
Changing anything in this pseudo-NVRAM resulted in corrupted bootloader
and bricked device!
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/bcm47xxpart.c')
-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 | ||