diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2010-09-03 08:36:12 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2010-10-19 10:19:56 -0400 |
commit | 3fb34124da9d5e37576d9f87d7a5005ba1d82dd7 (patch) | |
tree | 98f4ff2696b1cd480e3fb43b93f637e2b5bc8bd0 /drivers | |
parent | b33215084c1c06258a2d9deb035d343aafa4066e (diff) |
UBI: separate out corrupted list
This patch introduces 'add_corrupted()' function and separates out 'corr' list
manipulation from the common 'add_to_list()' function. This is just a
preparation for further changes - this patch does not change functionality.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/ubi/scan.c | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index 9405e2420055..fba3dc6a97e9 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c | |||
@@ -64,9 +64,9 @@ static struct ubi_vid_hdr *vidh; | |||
64 | * @ec: erase counter of the physical eraseblock | 64 | * @ec: erase counter of the physical eraseblock |
65 | * @list: the list to add to | 65 | * @list: the list to add to |
66 | * | 66 | * |
67 | * This function adds physical eraseblock @pnum to free, erase, corrupted or | 67 | * This function adds physical eraseblock @pnum to free, erase, or alien lists. |
68 | * alien lists. Returns zero in case of success and a negative error code in | 68 | * Returns zero in case of success and a negative error code in case of |
69 | * case of failure. | 69 | * failure. |
70 | */ | 70 | */ |
71 | static int add_to_list(struct ubi_scan_info *si, int pnum, int ec, | 71 | static int add_to_list(struct ubi_scan_info *si, int pnum, int ec, |
72 | struct list_head *list) | 72 | struct list_head *list) |
@@ -79,9 +79,6 @@ static int add_to_list(struct ubi_scan_info *si, int pnum, int ec, | |||
79 | } else if (list == &si->erase) { | 79 | } else if (list == &si->erase) { |
80 | dbg_bld("add to erase: PEB %d, EC %d", pnum, ec); | 80 | dbg_bld("add to erase: PEB %d, EC %d", pnum, ec); |
81 | si->erase_peb_count += 1; | 81 | si->erase_peb_count += 1; |
82 | } else if (list == &si->corr) { | ||
83 | dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec); | ||
84 | si->corr_peb_count += 1; | ||
85 | } else if (list == &si->alien) { | 82 | } else if (list == &si->alien) { |
86 | dbg_bld("add to alien: PEB %d, EC %d", pnum, ec); | 83 | dbg_bld("add to alien: PEB %d, EC %d", pnum, ec); |
87 | si->alien_peb_count += 1; | 84 | si->alien_peb_count += 1; |
@@ -99,6 +96,33 @@ static int add_to_list(struct ubi_scan_info *si, int pnum, int ec, | |||
99 | } | 96 | } |
100 | 97 | ||
101 | /** | 98 | /** |
99 | * add_corrupted - add a corrupted physical eraseblock. | ||
100 | * @si: scanning information | ||
101 | * @pnum: physical eraseblock number to add | ||
102 | * @ec: erase counter of the physical eraseblock | ||
103 | * | ||
104 | * This function adds corrupted physical eraseblock @pnum to the 'corr' list. | ||
105 | * Returns zero in case of success and a negative error code in case of | ||
106 | * failure. | ||
107 | */ | ||
108 | static int add_corrupted(struct ubi_scan_info *si, int pnum, int ec) | ||
109 | { | ||
110 | struct ubi_scan_leb *seb; | ||
111 | |||
112 | dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec); | ||
113 | |||
114 | seb = kmalloc(sizeof(struct ubi_scan_leb), GFP_KERNEL); | ||
115 | if (!seb) | ||
116 | return -ENOMEM; | ||
117 | |||
118 | si->corr_peb_count += 1; | ||
119 | seb->pnum = pnum; | ||
120 | seb->ec = ec; | ||
121 | list_add(&seb->u.list, &si->corr); | ||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | /** | ||
102 | * validate_vid_hdr - check volume identifier header. | 126 | * validate_vid_hdr - check volume identifier header. |
103 | * @vid_hdr: the volume identifier header to check | 127 | * @vid_hdr: the volume identifier header to check |
104 | * @sv: information about the volume this logical eraseblock belongs to | 128 | * @sv: information about the volume this logical eraseblock belongs to |
@@ -464,8 +488,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si, | |||
464 | return err; | 488 | return err; |
465 | 489 | ||
466 | if (cmp_res & 4) | 490 | if (cmp_res & 4) |
467 | err = add_to_list(si, seb->pnum, seb->ec, | 491 | err = add_corrupted(si, seb->pnum, seb->ec); |
468 | &si->corr); | ||
469 | else | 492 | else |
470 | err = add_to_list(si, seb->pnum, seb->ec, | 493 | err = add_to_list(si, seb->pnum, seb->ec, |
471 | &si->erase); | 494 | &si->erase); |
@@ -488,7 +511,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si, | |||
488 | * previously. | 511 | * previously. |
489 | */ | 512 | */ |
490 | if (cmp_res & 4) | 513 | if (cmp_res & 4) |
491 | return add_to_list(si, pnum, ec, &si->corr); | 514 | return add_corrupted(si, pnum, ec); |
492 | else | 515 | else |
493 | return add_to_list(si, pnum, ec, &si->erase); | 516 | return add_to_list(si, pnum, ec, &si->erase); |
494 | } | 517 | } |
@@ -835,13 +858,13 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si, | |||
835 | si->read_err_count += 1; | 858 | si->read_err_count += 1; |
836 | case UBI_IO_BAD_HDR: | 859 | case UBI_IO_BAD_HDR: |
837 | case UBI_IO_FF_BITFLIPS: | 860 | case UBI_IO_FF_BITFLIPS: |
838 | err = add_to_list(si, pnum, ec, &si->corr); | 861 | err = add_corrupted(si, pnum, ec); |
839 | if (err) | 862 | if (err) |
840 | return err; | 863 | return err; |
841 | goto adjust_mean_ec; | 864 | goto adjust_mean_ec; |
842 | case UBI_IO_FF: | 865 | case UBI_IO_FF: |
843 | if (ec_err) | 866 | if (ec_err) |
844 | err = add_to_list(si, pnum, ec, &si->corr); | 867 | err = add_corrupted(si, pnum, ec); |
845 | else | 868 | else |
846 | err = add_to_list(si, pnum, ec, &si->free); | 869 | err = add_to_list(si, pnum, ec, &si->free); |
847 | if (err) | 870 | if (err) |