aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices/docg3.c
diff options
context:
space:
mode:
authorMike Dunn <mikedunn@newsguy.com>2012-04-25 15:06:11 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-05-14 00:14:23 -0400
commitedbc4540e02c201bdd4f4d498ebb6ed517fd36e2 (patch)
tree403ee7318cb1218a224885d048781e35f2128a22 /drivers/mtd/devices/docg3.c
parente2788c98b98269a3131bffd2b57599280d7abd73 (diff)
mtd: driver _read() returns max_bitflips; mtd_read() returns -EUCLEAN
The drivers' _read() method, absent an error, returns a non-negative integer indicating the maximum number of bit errors that were corrected in any one region comprising an ecc step. MTD returns -EUCLEAN if this is >= bitflip_threshold, 0 otherwise. If bitflip_threshold is zero, the comparison is not made since these devices lack ECC and always return zero in the non-error case (thanks Brian)¹. Note that this is a subtle change to the driver interface. This and the preceding patches in this set were tested with ubi on top of the nandsim and docg4 devices, running the ubi test io_basic from mtd-utils. ¹ http://lists.infradead.org/pipermail/linux-mtd/2012-March/040468.html Signed-off-by: Mike Dunn <mikedunn@newsguy.com> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr> Acked-by: Brian Norris <computersforpeace@gmail.com> Ivan Djelic <ivan.djelic@parrot.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/devices/docg3.c')
-rw-r--r--drivers/mtd/devices/docg3.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
index 8272c02668d6..65d22a0439c6 100644
--- a/drivers/mtd/devices/docg3.c
+++ b/drivers/mtd/devices/docg3.c
@@ -850,6 +850,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
850 u8 *buf = ops->datbuf; 850 u8 *buf = ops->datbuf;
851 size_t len, ooblen, nbdata, nboob; 851 size_t len, ooblen, nbdata, nboob;
852 u8 hwecc[DOC_ECC_BCH_SIZE], eccconf1; 852 u8 hwecc[DOC_ECC_BCH_SIZE], eccconf1;
853 int max_bitflips = 0;
853 854
854 if (buf) 855 if (buf)
855 len = ops->len; 856 len = ops->len;
@@ -876,7 +877,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
876 ret = 0; 877 ret = 0;
877 skip = from % DOC_LAYOUT_PAGE_SIZE; 878 skip = from % DOC_LAYOUT_PAGE_SIZE;
878 mutex_lock(&docg3->cascade->lock); 879 mutex_lock(&docg3->cascade->lock);
879 while (!ret && (len > 0 || ooblen > 0)) { 880 while (ret >= 0 && (len > 0 || ooblen > 0)) {
880 calc_block_sector(from - skip, &block0, &block1, &page, &ofs, 881 calc_block_sector(from - skip, &block0, &block1, &page, &ofs,
881 docg3->reliable); 882 docg3->reliable);
882 nbdata = min_t(size_t, len, DOC_LAYOUT_PAGE_SIZE - skip); 883 nbdata = min_t(size_t, len, DOC_LAYOUT_PAGE_SIZE - skip);
@@ -936,7 +937,8 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
936 } 937 }
937 if (ret > 0) { 938 if (ret > 0) {
938 mtd->ecc_stats.corrected += ret; 939 mtd->ecc_stats.corrected += ret;
939 ret = -EUCLEAN; 940 max_bitflips = max(max_bitflips, ret);
941 ret = max_bitflips;
940 } 942 }
941 } 943 }
942 944