aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2015-12-06 05:31:38 -0500
committerBrian Norris <computersforpeace@gmail.com>2016-01-23 17:40:47 -0500
commit36bcc0c9c2bc8f56569cd735ba531a51358d7c2b (patch)
tree8da1183657688cdf7fe3cfb30922b042ce360cdc
parent2a36a5c30eab9cd1c9d2d08bd27cd763325d70c5 (diff)
mtd: bcm47xxpart: don't fail because of bit-flips
Bit-flip errors may occur on NAND flashes and are harmless. Handle them gracefully as read content is still reliable and can be parsed. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r--drivers/mtd/bcm47xxpart.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c
index b06d4c4553ed..845dd27d9f41 100644
--- a/drivers/mtd/bcm47xxpart.c
+++ b/drivers/mtd/bcm47xxpart.c
@@ -66,11 +66,13 @@ static const char *bcm47xxpart_trx_data_part_name(struct mtd_info *master,
66{ 66{
67 uint32_t buf; 67 uint32_t buf;
68 size_t bytes_read; 68 size_t bytes_read;
69 int err;
69 70
70 if (mtd_read(master, offset, sizeof(buf), &bytes_read, 71 err = mtd_read(master, offset, sizeof(buf), &bytes_read,
71 (uint8_t *)&buf) < 0) { 72 (uint8_t *)&buf);
72 pr_err("mtd_read error while parsing (offset: 0x%X)!\n", 73 if (err && !mtd_is_bitflip(err)) {
73 offset); 74 pr_err("mtd_read error while parsing (offset: 0x%X): %d\n",
75 offset, err);
74 goto out_default; 76 goto out_default;
75 } 77 }
76 78
@@ -95,6 +97,7 @@ static int bcm47xxpart_parse(struct mtd_info *master,
95 int trx_part = -1; 97 int trx_part = -1;
96 int last_trx_part = -1; 98 int last_trx_part = -1;
97 int possible_nvram_sizes[] = { 0x8000, 0xF000, 0x10000, }; 99 int possible_nvram_sizes[] = { 0x8000, 0xF000, 0x10000, };
100 int err;
98 101
99 /* 102 /*
100 * Some really old flashes (like AT45DB*) had smaller erasesize-s, but 103 * Some really old flashes (like AT45DB*) had smaller erasesize-s, but
@@ -128,10 +131,11 @@ static int bcm47xxpart_parse(struct mtd_info *master,
128 } 131 }
129 132
130 /* Read beginning of the block */ 133 /* Read beginning of the block */
131 if (mtd_read(master, offset, BCM47XXPART_BYTES_TO_READ, 134 err = mtd_read(master, offset, BCM47XXPART_BYTES_TO_READ,
132 &bytes_read, (uint8_t *)buf) < 0) { 135 &bytes_read, (uint8_t *)buf);
133 pr_err("mtd_read error while parsing (offset: 0x%X)!\n", 136 if (err && !mtd_is_bitflip(err)) {
134 offset); 137 pr_err("mtd_read error while parsing (offset: 0x%X): %d\n",
138 offset, err);
135 continue; 139 continue;
136 } 140 }
137 141
@@ -254,10 +258,11 @@ static int bcm47xxpart_parse(struct mtd_info *master,
254 } 258 }
255 259
256 /* Read middle of the block */ 260 /* Read middle of the block */
257 if (mtd_read(master, offset + 0x8000, 0x4, 261 err = mtd_read(master, offset + 0x8000, 0x4, &bytes_read,
258 &bytes_read, (uint8_t *)buf) < 0) { 262 (uint8_t *)buf);
259 pr_err("mtd_read error while parsing (offset: 0x%X)!\n", 263 if (err && !mtd_is_bitflip(err)) {
260 offset); 264 pr_err("mtd_read error while parsing (offset: 0x%X): %d\n",
265 offset, err);
261 continue; 266 continue;
262 } 267 }
263 268
@@ -277,10 +282,11 @@ static int bcm47xxpart_parse(struct mtd_info *master,
277 } 282 }
278 283
279 offset = master->size - possible_nvram_sizes[i]; 284 offset = master->size - possible_nvram_sizes[i];
280 if (mtd_read(master, offset, 0x4, &bytes_read, 285 err = mtd_read(master, offset, 0x4, &bytes_read,
281 (uint8_t *)buf) < 0) { 286 (uint8_t *)buf);
282 pr_err("mtd_read error while reading at offset 0x%X!\n", 287 if (err && !mtd_is_bitflip(err)) {
283 offset); 288 pr_err("mtd_read error while reading (offset 0x%X): %d\n",
289 offset, err);
284 continue; 290 continue;
285 } 291 }
286 292