142-mtd-bcm47xxpart-don-t-fail-because-of-bit-flips.patch 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. From dfe4b4c732365fc1d83c2d2fd9cc18054ae850b7 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <[email protected]>
  3. Date: Sun, 6 Dec 2015 11:24:05 +0100
  4. Subject: [PATCH] mtd: bcm47xxpart: don't fail because of bit-flips
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Bit-flip errors may occur on NAND flashes and are harmless. Handle them
  9. gracefully as read content is still reliable and can be parsed.
  10. Signed-off-by: Rafał Miłecki <[email protected]>
  11. ---
  12. drivers/mtd/bcm47xxpart.c | 38 ++++++++++++++++++++++----------------
  13. 1 file changed, 22 insertions(+), 16 deletions(-)
  14. diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c
  15. index 4450e74..1ab3451 100644
  16. --- a/drivers/mtd/bcm47xxpart.c
  17. +++ b/drivers/mtd/bcm47xxpart.c
  18. @@ -66,11 +66,13 @@ static const char *bcm47xxpart_trx_data_part_name(struct mtd_info *master,
  19. {
  20. uint32_t buf;
  21. size_t bytes_read;
  22. + int err;
  23. - if (mtd_read(master, offset, sizeof(buf), &bytes_read,
  24. - (uint8_t *)&buf) < 0) {
  25. - pr_err("mtd_read error while parsing (offset: 0x%X)!\n",
  26. - offset);
  27. + err = mtd_read(master, offset, sizeof(buf), &bytes_read,
  28. + (uint8_t *)&buf);
  29. + if (err && !mtd_is_bitflip(err)) {
  30. + pr_err("mtd_read error while parsing (offset: 0x%X): %d\n",
  31. + offset, err);
  32. goto out_default;
  33. }
  34. @@ -95,6 +97,7 @@ static int bcm47xxpart_parse(struct mtd_info *master,
  35. int trx_part = -1;
  36. int last_trx_part = -1;
  37. int possible_nvram_sizes[] = { 0x8000, 0xF000, 0x10000, };
  38. + int err;
  39. /*
  40. * Some really old flashes (like AT45DB*) had smaller erasesize-s, but
  41. @@ -128,10 +131,11 @@ static int bcm47xxpart_parse(struct mtd_info *master,
  42. }
  43. /* Read beginning of the block */
  44. - if (mtd_read(master, offset, BCM47XXPART_BYTES_TO_READ,
  45. - &bytes_read, (uint8_t *)buf) < 0) {
  46. - pr_err("mtd_read error while parsing (offset: 0x%X)!\n",
  47. - offset);
  48. + err = mtd_read(master, offset, BCM47XXPART_BYTES_TO_READ,
  49. + &bytes_read, (uint8_t *)buf);
  50. + if (err && !mtd_is_bitflip(err)) {
  51. + pr_err("mtd_read error while parsing (offset: 0x%X): %d\n",
  52. + offset, err);
  53. continue;
  54. }
  55. @@ -254,10 +258,11 @@ static int bcm47xxpart_parse(struct mtd_info *master,
  56. }
  57. /* Read middle of the block */
  58. - if (mtd_read(master, offset + 0x8000, 0x4,
  59. - &bytes_read, (uint8_t *)buf) < 0) {
  60. - pr_err("mtd_read error while parsing (offset: 0x%X)!\n",
  61. - offset);
  62. + err = mtd_read(master, offset + 0x8000, 0x4, &bytes_read,
  63. + (uint8_t *)buf);
  64. + if (err && !mtd_is_bitflip(err)) {
  65. + pr_err("mtd_read error while parsing (offset: 0x%X): %d\n",
  66. + offset, err);
  67. continue;
  68. }
  69. @@ -277,10 +282,11 @@ static int bcm47xxpart_parse(struct mtd_info *master,
  70. }
  71. offset = master->size - possible_nvram_sizes[i];
  72. - if (mtd_read(master, offset, 0x4, &bytes_read,
  73. - (uint8_t *)buf) < 0) {
  74. - pr_err("mtd_read error while reading at offset 0x%X!\n",
  75. - offset);
  76. + err = mtd_read(master, offset, 0x4, &bytes_read,
  77. + (uint8_t *)buf);
  78. + if (err && !mtd_is_bitflip(err)) {
  79. + pr_err("mtd_read error while reading (offset 0x%X): %d\n",
  80. + offset, err);
  81. continue;
  82. }
  83. --
  84. 1.8.4.5