Skip to content

Commit

Permalink
[MTD] mtdpart: Make ecc_stats more realistic.
Browse files Browse the repository at this point in the history
In the existing implementation, ecc_stats fields are incremented only by
one, regardless of master mtd errors number. For example, if there are N
errors were corrected by ECC, partition ecc_stats.corrected will be
incremented by one.

This commit changes simple increment to sum of old value and parent mtd
error count.

Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
Yauhen Kharuzhy authored and David Woodhouse committed Apr 6, 2009
1 parent 7995c7e commit d8877f1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/mtd/mtdpart.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ static int part_read(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf)
{
struct mtd_part *part = PART(mtd);
struct mtd_ecc_stats stats;
int res;

stats = part->master->ecc_stats;

if (from >= mtd->size)
len = 0;
else if (from + len > mtd->size)
Expand All @@ -58,9 +61,9 @@ static int part_read(struct mtd_info *mtd, loff_t from, size_t len,
len, retlen, buf);
if (unlikely(res)) {
if (res == -EUCLEAN)
mtd->ecc_stats.corrected++;
mtd->ecc_stats.corrected += part->master->ecc_stats.corrected - stats.corrected;
if (res == -EBADMSG)
mtd->ecc_stats.failed++;
mtd->ecc_stats.failed += part->master->ecc_stats.failed - stats.failed;
}
return res;
}
Expand Down

0 comments on commit d8877f1

Please sign in to comment.