aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/scan.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2010-04-30 05:31:26 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2010-06-04 04:30:43 -0400
commit33789fb9d4470e27d18596c0966339e2ca8865a9 (patch)
tree82b5025c7e0b40289977f1ccc9173c1702a4b036 /drivers/mtd/ubi/scan.c
parenteb89580e1a8388d206bf143c6c39d001095106ba (diff)
UBI: introduce eraseblock counter variables
This is just a preparation patch which introduces several 'struct ubi_scan_info' fields which count eraseblocks of different types. This will be used later on to decide whether it is safe to format the flash or not. No functional changes so far. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Reviewed-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Tested-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Diffstat (limited to 'drivers/mtd/ubi/scan.c')
-rw-r--r--drivers/mtd/ubi/scan.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index c45900744107..a20f278d0c6c 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -72,16 +72,19 @@ static int add_to_list(struct ubi_scan_info *si, int pnum, int ec,
72{ 72{
73 struct ubi_scan_leb *seb; 73 struct ubi_scan_leb *seb;
74 74
75 if (list == &si->free) 75 if (list == &si->free) {
76 dbg_bld("add to free: PEB %d, EC %d", pnum, ec); 76 dbg_bld("add to free: PEB %d, EC %d", pnum, ec);
77 else if (list == &si->erase) 77 si->free_peb_count += 1;
78 } else if (list == &si->erase) {
78 dbg_bld("add to erase: PEB %d, EC %d", pnum, ec); 79 dbg_bld("add to erase: PEB %d, EC %d", pnum, ec);
79 else if (list == &si->corr) { 80 si->erase_peb_count += 1;
81 } else if (list == &si->corr) {
80 dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec); 82 dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec);
81 si->corr_count += 1; 83 si->corr_peb_count += 1;
82 } else if (list == &si->alien) 84 } else if (list == &si->alien) {
83 dbg_bld("add to alien: PEB %d, EC %d", pnum, ec); 85 dbg_bld("add to alien: PEB %d, EC %d", pnum, ec);
84 else 86 si->alien_peb_count += 1;
87 } else
85 BUG(); 88 BUG();
86 89
87 seb = kmalloc(sizeof(struct ubi_scan_leb), GFP_KERNEL); 90 seb = kmalloc(sizeof(struct ubi_scan_leb), GFP_KERNEL);
@@ -517,6 +520,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si,
517 sv->leb_count += 1; 520 sv->leb_count += 1;
518 rb_link_node(&seb->u.rb, parent, p); 521 rb_link_node(&seb->u.rb, parent, p);
519 rb_insert_color(&seb->u.rb, &sv->root); 522 rb_insert_color(&seb->u.rb, &sv->root);
523 si->used_peb_count += 1;
520 return 0; 524 return 0;
521} 525}
522 526
@@ -751,7 +755,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
751 * corrupted. Set %bitflips flag in order to make this PEB be 755 * corrupted. Set %bitflips flag in order to make this PEB be
752 * moved and EC be re-created. 756 * moved and EC be re-created.
753 */ 757 */
754 ec_corr = 1; 758 ec_corr = err;
755 ec = UBI_SCAN_UNKNOWN_EC; 759 ec = UBI_SCAN_UNKNOWN_EC;
756 bitflips = 1; 760 bitflips = 1;
757 } 761 }
@@ -816,6 +820,9 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
816 else if (err == UBI_IO_BAD_HDR_READ || err == UBI_IO_BAD_HDR || 820 else if (err == UBI_IO_BAD_HDR_READ || err == UBI_IO_BAD_HDR ||
817 (err == UBI_IO_PEB_FREE && ec_corr)) { 821 (err == UBI_IO_PEB_FREE && ec_corr)) {
818 /* VID header is corrupted */ 822 /* VID header is corrupted */
823 if (err == UBI_IO_BAD_HDR_READ ||
824 ec_corr == UBI_IO_BAD_HDR_READ)
825 si->read_err_count += 1;
819 err = add_to_list(si, pnum, ec, &si->corr); 826 err = add_to_list(si, pnum, ec, &si->corr);
820 if (err) 827 if (err)
821 return err; 828 return err;
@@ -855,7 +862,6 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
855 err = add_to_list(si, pnum, ec, &si->alien); 862 err = add_to_list(si, pnum, ec, &si->alien);
856 if (err) 863 if (err)
857 return err; 864 return err;
858 si->alien_peb_count += 1;
859 return 0; 865 return 0;
860 866
861 case UBI_COMPAT_REJECT: 867 case UBI_COMPAT_REJECT:
@@ -943,8 +949,9 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi)
943 * unclean reboots. However, many of them may indicate some problems 949 * unclean reboots. However, many of them may indicate some problems
944 * with the flash HW or driver. Print a warning in this case. 950 * with the flash HW or driver. Print a warning in this case.
945 */ 951 */
946 if (si->corr_count >= 8 || si->corr_count >= ubi->peb_count / 4) { 952 if (si->corr_peb_count >= 8 ||
947 ubi_warn("%d PEBs are corrupted", si->corr_count); 953 si->corr_peb_count >= ubi->peb_count / 4) {
954 ubi_warn("%d PEBs are corrupted", si->corr_peb_count);
948 printk(KERN_WARNING "corrupted PEBs are:"); 955 printk(KERN_WARNING "corrupted PEBs are:");
949 list_for_each_entry(seb, &si->corr, u.list) 956 list_for_each_entry(seb, &si->corr, u.list)
950 printk(KERN_CONT " %d", seb->pnum); 957 printk(KERN_CONT " %d", seb->pnum);