aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/scan.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@linux.intel.com>2012-05-17 06:09:08 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-05-20 13:26:02 -0400
commita4e6042f1d073073f88e0ad6d2a7450da9a3937d (patch)
treec9849fa560e49308275254ce65603c909566131b /drivers/mtd/ubi/scan.c
parent2c5ec5ce66c0170829c5c128b9235429936442ac (diff)
UBI: rename si to ai
After re-naming the 'struct ubi_scan_info' we should adjust all variables named 'si' to something else, because 'si' stands for "scanning info". Let's rename it to 'ai' which stands for "attaching info" which is a bit more consistent and has the same length, which makes re-naming easy. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd/ubi/scan.c')
-rw-r--r--drivers/mtd/ubi/scan.c346
1 files changed, 173 insertions, 173 deletions
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index c53ef5d9b134..4145a042c8e1 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -24,10 +24,10 @@
24 * This sub-system is responsible for scanning the flash media, checking UBI 24 * This sub-system is responsible for scanning the flash media, checking UBI
25 * headers and providing complete information about the UBI flash image. 25 * headers and providing complete information about the UBI flash image.
26 * 26 *
27 * The scanning information is represented by a &struct ubi_attach_info' object. 27 * The attaching information is represented by a &struct ubi_attach_info'
28 * Information about found volumes is represented by &struct ubi_ainf_volume 28 * object. Information about found volumes is represented by
29 * objects which are kept in volume RB-tree with root at the @volumes field. 29 * &struct ubi_ainf_volume objects which are kept in volume RB-tree with root
30 * The RB-tree is indexed by the volume ID. 30 * at the @volumes field. The RB-tree is indexed by the volume ID.
31 * 31 *
32 * Scanned logical eraseblocks are represented by &struct ubi_ainf_peb objects. 32 * Scanned logical eraseblocks are represented by &struct ubi_ainf_peb objects.
33 * These objects are kept in per-volume RB-trees with the root at the 33 * These objects are kept in per-volume RB-trees with the root at the
@@ -88,7 +88,7 @@
88#include <linux/random.h> 88#include <linux/random.h>
89#include "ubi.h" 89#include "ubi.h"
90 90
91static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si); 91static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai);
92 92
93/* Temporary variables used during scanning */ 93/* Temporary variables used during scanning */
94static struct ubi_ec_hdr *ech; 94static struct ubi_ec_hdr *ech;
@@ -96,7 +96,7 @@ static struct ubi_vid_hdr *vidh;
96 96
97/** 97/**
98 * add_to_list - add physical eraseblock to a list. 98 * add_to_list - add physical eraseblock to a list.
99 * @si: scanning information 99 * @ai: attaching information
100 * @pnum: physical eraseblock number to add 100 * @pnum: physical eraseblock number to add
101 * @ec: erase counter of the physical eraseblock 101 * @ec: erase counter of the physical eraseblock
102 * @to_head: if not zero, add to the head of the list 102 * @to_head: if not zero, add to the head of the list
@@ -110,22 +110,22 @@ static struct ubi_vid_hdr *vidh;
110 * returns zero in case of success and a negative error code in case of 110 * returns zero in case of success and a negative error code in case of
111 * failure. 111 * failure.
112 */ 112 */
113static int add_to_list(struct ubi_attach_info *si, int pnum, int ec, 113static int add_to_list(struct ubi_attach_info *ai, int pnum, int ec,
114 int to_head, struct list_head *list) 114 int to_head, struct list_head *list)
115{ 115{
116 struct ubi_ainf_peb *aeb; 116 struct ubi_ainf_peb *aeb;
117 117
118 if (list == &si->free) { 118 if (list == &ai->free) {
119 dbg_bld("add to free: PEB %d, EC %d", pnum, ec); 119 dbg_bld("add to free: PEB %d, EC %d", pnum, ec);
120 } else if (list == &si->erase) { 120 } else if (list == &ai->erase) {
121 dbg_bld("add to erase: PEB %d, EC %d", pnum, ec); 121 dbg_bld("add to erase: PEB %d, EC %d", pnum, ec);
122 } else if (list == &si->alien) { 122 } else if (list == &ai->alien) {
123 dbg_bld("add to alien: PEB %d, EC %d", pnum, ec); 123 dbg_bld("add to alien: PEB %d, EC %d", pnum, ec);
124 si->alien_peb_count += 1; 124 ai->alien_peb_count += 1;
125 } else 125 } else
126 BUG(); 126 BUG();
127 127
128 aeb = kmem_cache_alloc(si->scan_leb_slab, GFP_KERNEL); 128 aeb = kmem_cache_alloc(ai->scan_leb_slab, GFP_KERNEL);
129 if (!aeb) 129 if (!aeb)
130 return -ENOMEM; 130 return -ENOMEM;
131 131
@@ -140,7 +140,7 @@ static int add_to_list(struct ubi_attach_info *si, int pnum, int ec,
140 140
141/** 141/**
142 * add_corrupted - add a corrupted physical eraseblock. 142 * add_corrupted - add a corrupted physical eraseblock.
143 * @si: scanning information 143 * @ai: attaching information
144 * @pnum: physical eraseblock number to add 144 * @pnum: physical eraseblock number to add
145 * @ec: erase counter of the physical eraseblock 145 * @ec: erase counter of the physical eraseblock
146 * 146 *
@@ -148,20 +148,20 @@ static int add_to_list(struct ubi_attach_info *si, int pnum, int ec,
148 * The corruption was presumably not caused by a power cut. Returns zero in 148 * The corruption was presumably not caused by a power cut. Returns zero in
149 * case of success and a negative error code in case of failure. 149 * case of success and a negative error code in case of failure.
150 */ 150 */
151static int add_corrupted(struct ubi_attach_info *si, int pnum, int ec) 151static int add_corrupted(struct ubi_attach_info *ai, int pnum, int ec)
152{ 152{
153 struct ubi_ainf_peb *aeb; 153 struct ubi_ainf_peb *aeb;
154 154
155 dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec); 155 dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec);
156 156
157 aeb = kmem_cache_alloc(si->scan_leb_slab, GFP_KERNEL); 157 aeb = kmem_cache_alloc(ai->scan_leb_slab, GFP_KERNEL);
158 if (!aeb) 158 if (!aeb)
159 return -ENOMEM; 159 return -ENOMEM;
160 160
161 si->corr_peb_count += 1; 161 ai->corr_peb_count += 1;
162 aeb->pnum = pnum; 162 aeb->pnum = pnum;
163 aeb->ec = ec; 163 aeb->ec = ec;
164 list_add(&aeb->u.list, &si->corr); 164 list_add(&aeb->u.list, &ai->corr);
165 return 0; 165 return 0;
166} 166}
167 167
@@ -232,24 +232,24 @@ bad:
232} 232}
233 233
234/** 234/**
235 * add_volume - add volume to the scanning information. 235 * add_volume - add volume to the attaching information.
236 * @si: scanning information 236 * @ai: attaching information
237 * @vol_id: ID of the volume to add 237 * @vol_id: ID of the volume to add
238 * @pnum: physical eraseblock number 238 * @pnum: physical eraseblock number
239 * @vid_hdr: volume identifier header 239 * @vid_hdr: volume identifier header
240 * 240 *
241 * If the volume corresponding to the @vid_hdr logical eraseblock is already 241 * If the volume corresponding to the @vid_hdr logical eraseblock is already
242 * present in the scanning information, this function does nothing. Otherwise 242 * present in the attaching information, this function does nothing. Otherwise
243 * it adds corresponding volume to the scanning information. Returns a pointer 243 * it adds corresponding volume to the attaching information. Returns a pointer
244 * to the scanning volume object in case of success and a negative error code 244 * to the scanning volume object in case of success and a negative error code
245 * in case of failure. 245 * in case of failure.
246 */ 246 */
247static struct ubi_ainf_volume *add_volume(struct ubi_attach_info *si, 247static struct ubi_ainf_volume *add_volume(struct ubi_attach_info *ai,
248 int vol_id, int pnum, 248 int vol_id, int pnum,
249 const struct ubi_vid_hdr *vid_hdr) 249 const struct ubi_vid_hdr *vid_hdr)
250{ 250{
251 struct ubi_ainf_volume *sv; 251 struct ubi_ainf_volume *sv;
252 struct rb_node **p = &si->volumes.rb_node, *parent = NULL; 252 struct rb_node **p = &ai->volumes.rb_node, *parent = NULL;
253 253
254 ubi_assert(vol_id == be32_to_cpu(vid_hdr->vol_id)); 254 ubi_assert(vol_id == be32_to_cpu(vid_hdr->vol_id));
255 255
@@ -280,12 +280,12 @@ static struct ubi_ainf_volume *add_volume(struct ubi_attach_info *si,
280 sv->compat = vid_hdr->compat; 280 sv->compat = vid_hdr->compat;
281 sv->vol_type = vid_hdr->vol_type == UBI_VID_DYNAMIC ? UBI_DYNAMIC_VOLUME 281 sv->vol_type = vid_hdr->vol_type == UBI_VID_DYNAMIC ? UBI_DYNAMIC_VOLUME
282 : UBI_STATIC_VOLUME; 282 : UBI_STATIC_VOLUME;
283 if (vol_id > si->highest_vol_id) 283 if (vol_id > ai->highest_vol_id)
284 si->highest_vol_id = vol_id; 284 ai->highest_vol_id = vol_id;
285 285
286 rb_link_node(&sv->rb, parent, p); 286 rb_link_node(&sv->rb, parent, p);
287 rb_insert_color(&sv->rb, &si->volumes); 287 rb_insert_color(&sv->rb, &ai->volumes);
288 si->vols_found += 1; 288 ai->vols_found += 1;
289 dbg_bld("added volume %d", vol_id); 289 dbg_bld("added volume %d", vol_id);
290 return sv; 290 return sv;
291} 291}
@@ -425,9 +425,9 @@ out_free_vidh:
425} 425}
426 426
427/** 427/**
428 * ubi_scan_add_used - add physical eraseblock to the scanning information. 428 * ubi_scan_add_used - add physical eraseblock to the attaching information.
429 * @ubi: UBI device description object 429 * @ubi: UBI device description object
430 * @si: scanning information 430 * @ai: attaching information
431 * @pnum: the physical eraseblock number 431 * @pnum: the physical eraseblock number
432 * @ec: erase counter 432 * @ec: erase counter
433 * @vid_hdr: the volume identifier header 433 * @vid_hdr: the volume identifier header
@@ -440,7 +440,7 @@ out_free_vidh:
440 * to be picked, while the older one has to be dropped. This function returns 440 * to be picked, while the older one has to be dropped. This function returns
441 * zero in case of success and a negative error code in case of failure. 441 * zero in case of success and a negative error code in case of failure.
442 */ 442 */
443int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, 443int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai,
444 int pnum, int ec, const struct ubi_vid_hdr *vid_hdr, 444 int pnum, int ec, const struct ubi_vid_hdr *vid_hdr,
445 int bitflips) 445 int bitflips)
446{ 446{
@@ -457,12 +457,12 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si,
457 dbg_bld("PEB %d, LEB %d:%d, EC %d, sqnum %llu, bitflips %d", 457 dbg_bld("PEB %d, LEB %d:%d, EC %d, sqnum %llu, bitflips %d",
458 pnum, vol_id, lnum, ec, sqnum, bitflips); 458 pnum, vol_id, lnum, ec, sqnum, bitflips);
459 459
460 sv = add_volume(si, vol_id, pnum, vid_hdr); 460 sv = add_volume(ai, vol_id, pnum, vid_hdr);
461 if (IS_ERR(sv)) 461 if (IS_ERR(sv))
462 return PTR_ERR(sv); 462 return PTR_ERR(sv);
463 463
464 if (si->max_sqnum < sqnum) 464 if (ai->max_sqnum < sqnum)
465 si->max_sqnum = sqnum; 465 ai->max_sqnum = sqnum;
466 466
467 /* 467 /*
468 * Walk the RB-tree of logical eraseblocks of volume @vol_id to look 468 * Walk the RB-tree of logical eraseblocks of volume @vol_id to look
@@ -528,8 +528,8 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si,
528 if (err) 528 if (err)
529 return err; 529 return err;
530 530
531 err = add_to_list(si, aeb->pnum, aeb->ec, cmp_res & 4, 531 err = add_to_list(ai, aeb->pnum, aeb->ec, cmp_res & 4,
532 &si->erase); 532 &ai->erase);
533 if (err) 533 if (err)
534 return err; 534 return err;
535 535
@@ -549,21 +549,21 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si,
549 * This logical eraseblock is older than the one found 549 * This logical eraseblock is older than the one found
550 * previously. 550 * previously.
551 */ 551 */
552 return add_to_list(si, pnum, ec, cmp_res & 4, 552 return add_to_list(ai, pnum, ec, cmp_res & 4,
553 &si->erase); 553 &ai->erase);
554 } 554 }
555 } 555 }
556 556
557 /* 557 /*
558 * We've met this logical eraseblock for the first time, add it to the 558 * We've met this logical eraseblock for the first time, add it to the
559 * scanning information. 559 * attaching information.
560 */ 560 */
561 561
562 err = validate_vid_hdr(vid_hdr, sv, pnum); 562 err = validate_vid_hdr(vid_hdr, sv, pnum);
563 if (err) 563 if (err)
564 return err; 564 return err;
565 565
566 aeb = kmem_cache_alloc(si->scan_leb_slab, GFP_KERNEL); 566 aeb = kmem_cache_alloc(ai->scan_leb_slab, GFP_KERNEL);
567 if (!aeb) 567 if (!aeb)
568 return -ENOMEM; 568 return -ENOMEM;
569 569
@@ -586,18 +586,18 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si,
586} 586}
587 587
588/** 588/**
589 * ubi_scan_find_sv - find volume in the scanning information. 589 * ubi_scan_find_sv - find volume in the attaching information.
590 * @si: scanning information 590 * @ai: attaching information
591 * @vol_id: the requested volume ID 591 * @vol_id: the requested volume ID
592 * 592 *
593 * This function returns a pointer to the volume description or %NULL if there 593 * This function returns a pointer to the volume description or %NULL if there
594 * are no data about this volume in the scanning information. 594 * are no data about this volume in the attaching information.
595 */ 595 */
596struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *si, 596struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *ai,
597 int vol_id) 597 int vol_id)
598{ 598{
599 struct ubi_ainf_volume *sv; 599 struct ubi_ainf_volume *sv;
600 struct rb_node *p = si->volumes.rb_node; 600 struct rb_node *p = ai->volumes.rb_node;
601 601
602 while (p) { 602 while (p) {
603 sv = rb_entry(p, struct ubi_ainf_volume, rb); 603 sv = rb_entry(p, struct ubi_ainf_volume, rb);
@@ -615,8 +615,8 @@ struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *si,
615} 615}
616 616
617/** 617/**
618 * ubi_scan_find_aeb - find LEB in the volume scanning information. 618 * ubi_scan_find_aeb - find LEB in the volume attaching information.
619 * @sv: a pointer to the volume scanning information 619 * @sv: a pointer to the volume attaching information
620 * @lnum: the requested logical eraseblock 620 * @lnum: the requested logical eraseblock
621 * 621 *
622 * This function returns a pointer to the scanning logical eraseblock or %NULL 622 * This function returns a pointer to the scanning logical eraseblock or %NULL
@@ -644,32 +644,32 @@ struct ubi_ainf_peb *ubi_scan_find_aeb(const struct ubi_ainf_volume *sv,
644} 644}
645 645
646/** 646/**
647 * ubi_scan_rm_volume - delete scanning information about a volume. 647 * ubi_scan_rm_volume - delete attaching information about a volume.
648 * @si: scanning information 648 * @ai: attaching information
649 * @sv: the volume scanning information to delete 649 * @sv: the volume attaching information to delete
650 */ 650 */
651void ubi_scan_rm_volume(struct ubi_attach_info *si, struct ubi_ainf_volume *sv) 651void ubi_scan_rm_volume(struct ubi_attach_info *ai, struct ubi_ainf_volume *sv)
652{ 652{
653 struct rb_node *rb; 653 struct rb_node *rb;
654 struct ubi_ainf_peb *aeb; 654 struct ubi_ainf_peb *aeb;
655 655
656 dbg_bld("remove scanning information about volume %d", sv->vol_id); 656 dbg_bld("remove attaching information about volume %d", sv->vol_id);
657 657
658 while ((rb = rb_first(&sv->root))) { 658 while ((rb = rb_first(&sv->root))) {
659 aeb = rb_entry(rb, struct ubi_ainf_peb, u.rb); 659 aeb = rb_entry(rb, struct ubi_ainf_peb, u.rb);
660 rb_erase(&aeb->u.rb, &sv->root); 660 rb_erase(&aeb->u.rb, &sv->root);
661 list_add_tail(&aeb->u.list, &si->erase); 661 list_add_tail(&aeb->u.list, &ai->erase);
662 } 662 }
663 663
664 rb_erase(&sv->rb, &si->volumes); 664 rb_erase(&sv->rb, &ai->volumes);
665 kfree(sv); 665 kfree(sv);
666 si->vols_found -= 1; 666 ai->vols_found -= 1;
667} 667}
668 668
669/** 669/**
670 * ubi_scan_erase_peb - erase a physical eraseblock. 670 * ubi_scan_erase_peb - erase a physical eraseblock.
671 * @ubi: UBI device description object 671 * @ubi: UBI device description object
672 * @si: scanning information 672 * @ai: attaching information
673 * @pnum: physical eraseblock number to erase; 673 * @pnum: physical eraseblock number to erase;
674 * @ec: erase counter value to write (%UBI_SCAN_UNKNOWN_EC if it is unknown) 674 * @ec: erase counter value to write (%UBI_SCAN_UNKNOWN_EC if it is unknown)
675 * 675 *
@@ -679,7 +679,7 @@ void ubi_scan_rm_volume(struct ubi_attach_info *si, struct ubi_ainf_volume *sv)
679 * This function returns zero in case of success and a negative error code in 679 * This function returns zero in case of success and a negative error code in
680 * case of failure. 680 * case of failure.
681 */ 681 */
682int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_attach_info *si, 682int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_attach_info *ai,
683 int pnum, int ec) 683 int pnum, int ec)
684{ 684{
685 int err; 685 int err;
@@ -714,7 +714,7 @@ out_free:
714/** 714/**
715 * ubi_scan_get_free_peb - get a free physical eraseblock. 715 * ubi_scan_get_free_peb - get a free physical eraseblock.
716 * @ubi: UBI device description object 716 * @ubi: UBI device description object
717 * @si: scanning information 717 * @ai: attaching information
718 * 718 *
719 * This function returns a free physical eraseblock. It is supposed to be 719 * This function returns a free physical eraseblock. It is supposed to be
720 * called on the UBI initialization stages when the wear-leveling sub-system is 720 * called on the UBI initialization stages when the wear-leveling sub-system is
@@ -726,13 +726,13 @@ out_free:
726 * success and an error code in case of failure. 726 * success and an error code in case of failure.
727 */ 727 */
728struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, 728struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi,
729 struct ubi_attach_info *si) 729 struct ubi_attach_info *ai)
730{ 730{
731 int err = 0; 731 int err = 0;
732 struct ubi_ainf_peb *aeb, *tmp_aeb; 732 struct ubi_ainf_peb *aeb, *tmp_aeb;
733 733
734 if (!list_empty(&si->free)) { 734 if (!list_empty(&ai->free)) {
735 aeb = list_entry(si->free.next, struct ubi_ainf_peb, u.list); 735 aeb = list_entry(ai->free.next, struct ubi_ainf_peb, u.list);
736 list_del(&aeb->u.list); 736 list_del(&aeb->u.list);
737 dbg_bld("return free PEB %d, EC %d", aeb->pnum, aeb->ec); 737 dbg_bld("return free PEB %d, EC %d", aeb->pnum, aeb->ec);
738 return aeb; 738 return aeb;
@@ -744,11 +744,11 @@ struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi,
744 * so forth. We don't want to take care about bad eraseblocks here - 744 * so forth. We don't want to take care about bad eraseblocks here -
745 * they'll be handled later. 745 * they'll be handled later.
746 */ 746 */
747 list_for_each_entry_safe(aeb, tmp_aeb, &si->erase, u.list) { 747 list_for_each_entry_safe(aeb, tmp_aeb, &ai->erase, u.list) {
748 if (aeb->ec == UBI_SCAN_UNKNOWN_EC) 748 if (aeb->ec == UBI_SCAN_UNKNOWN_EC)
749 aeb->ec = si->mean_ec; 749 aeb->ec = ai->mean_ec;
750 750
751 err = ubi_scan_erase_peb(ubi, si, aeb->pnum, aeb->ec+1); 751 err = ubi_scan_erase_peb(ubi, ai, aeb->pnum, aeb->ec+1);
752 if (err) 752 if (err)
753 continue; 753 continue;
754 754
@@ -823,15 +823,15 @@ out_unlock:
823} 823}
824 824
825/** 825/**
826 * process_eb - read, check UBI headers, and add them to scanning information. 826 * process_eb - read, check UBI headers, and add them to attaching information.
827 * @ubi: UBI device description object 827 * @ubi: UBI device description object
828 * @si: scanning information 828 * @ai: attaching information
829 * @pnum: the physical eraseblock number 829 * @pnum: the physical eraseblock number
830 * 830 *
831 * This function returns a zero if the physical eraseblock was successfully 831 * This function returns a zero if the physical eraseblock was successfully
832 * handled and a negative error code in case of failure. 832 * handled and a negative error code in case of failure.
833 */ 833 */
834static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *si, 834static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *ai,
835 int pnum) 835 int pnum)
836{ 836{
837 long long uninitialized_var(ec); 837 long long uninitialized_var(ec);
@@ -849,7 +849,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *si,
849 * initialize this, but MTD does not provide enough 849 * initialize this, but MTD does not provide enough
850 * information. 850 * information.
851 */ 851 */
852 si->bad_peb_count += 1; 852 ai->bad_peb_count += 1;
853 return 0; 853 return 0;
854 } 854 }
855 855
@@ -863,13 +863,13 @@ static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *si,
863 bitflips = 1; 863 bitflips = 1;
864 break; 864 break;
865 case UBI_IO_FF: 865 case UBI_IO_FF:
866 si->empty_peb_count += 1; 866 ai->empty_peb_count += 1;
867 return add_to_list(si, pnum, UBI_SCAN_UNKNOWN_EC, 0, 867 return add_to_list(ai, pnum, UBI_SCAN_UNKNOWN_EC, 0,
868 &si->erase); 868 &ai->erase);
869 case UBI_IO_FF_BITFLIPS: 869 case UBI_IO_FF_BITFLIPS:
870 si->empty_peb_count += 1; 870 ai->empty_peb_count += 1;
871 return add_to_list(si, pnum, UBI_SCAN_UNKNOWN_EC, 1, 871 return add_to_list(ai, pnum, UBI_SCAN_UNKNOWN_EC, 1,
872 &si->erase); 872 &ai->erase);
873 case UBI_IO_BAD_HDR_EBADMSG: 873 case UBI_IO_BAD_HDR_EBADMSG:
874 case UBI_IO_BAD_HDR: 874 case UBI_IO_BAD_HDR:
875 /* 875 /*
@@ -953,7 +953,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *si,
953 * PEB, bit it is not marked as bad yet. This may also 953 * PEB, bit it is not marked as bad yet. This may also
954 * be a result of power cut during erasure. 954 * be a result of power cut during erasure.
955 */ 955 */
956 si->maybe_bad_peb_count += 1; 956 ai->maybe_bad_peb_count += 1;
957 case UBI_IO_BAD_HDR: 957 case UBI_IO_BAD_HDR:
958 if (ec_err) 958 if (ec_err)
959 /* 959 /*
@@ -980,23 +980,23 @@ static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *si,
980 return err; 980 return err;
981 else if (!err) 981 else if (!err)
982 /* This corruption is caused by a power cut */ 982 /* This corruption is caused by a power cut */
983 err = add_to_list(si, pnum, ec, 1, &si->erase); 983 err = add_to_list(ai, pnum, ec, 1, &ai->erase);
984 else 984 else
985 /* This is an unexpected corruption */ 985 /* This is an unexpected corruption */
986 err = add_corrupted(si, pnum, ec); 986 err = add_corrupted(ai, pnum, ec);
987 if (err) 987 if (err)
988 return err; 988 return err;
989 goto adjust_mean_ec; 989 goto adjust_mean_ec;
990 case UBI_IO_FF_BITFLIPS: 990 case UBI_IO_FF_BITFLIPS:
991 err = add_to_list(si, pnum, ec, 1, &si->erase); 991 err = add_to_list(ai, pnum, ec, 1, &ai->erase);
992 if (err) 992 if (err)
993 return err; 993 return err;
994 goto adjust_mean_ec; 994 goto adjust_mean_ec;
995 case UBI_IO_FF: 995 case UBI_IO_FF:
996 if (ec_err) 996 if (ec_err)
997 err = add_to_list(si, pnum, ec, 1, &si->erase); 997 err = add_to_list(ai, pnum, ec, 1, &ai->erase);
998 else 998 else
999 err = add_to_list(si, pnum, ec, 0, &si->free); 999 err = add_to_list(ai, pnum, ec, 0, &ai->free);
1000 if (err) 1000 if (err)
1001 return err; 1001 return err;
1002 goto adjust_mean_ec; 1002 goto adjust_mean_ec;
@@ -1015,7 +1015,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *si,
1015 case UBI_COMPAT_DELETE: 1015 case UBI_COMPAT_DELETE:
1016 ubi_msg("\"delete\" compatible internal volume %d:%d" 1016 ubi_msg("\"delete\" compatible internal volume %d:%d"
1017 " found, will remove it", vol_id, lnum); 1017 " found, will remove it", vol_id, lnum);
1018 err = add_to_list(si, pnum, ec, 1, &si->erase); 1018 err = add_to_list(ai, pnum, ec, 1, &ai->erase);
1019 if (err) 1019 if (err)
1020 return err; 1020 return err;
1021 return 0; 1021 return 0;
@@ -1030,7 +1030,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *si,
1030 case UBI_COMPAT_PRESERVE: 1030 case UBI_COMPAT_PRESERVE:
1031 ubi_msg("\"preserve\" compatible internal volume %d:%d" 1031 ubi_msg("\"preserve\" compatible internal volume %d:%d"
1032 " found", vol_id, lnum); 1032 " found", vol_id, lnum);
1033 err = add_to_list(si, pnum, ec, 0, &si->alien); 1033 err = add_to_list(ai, pnum, ec, 0, &ai->alien);
1034 if (err) 1034 if (err)
1035 return err; 1035 return err;
1036 return 0; 1036 return 0;
@@ -1045,18 +1045,18 @@ static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *si,
1045 if (ec_err) 1045 if (ec_err)
1046 ubi_warn("valid VID header but corrupted EC header at PEB %d", 1046 ubi_warn("valid VID header but corrupted EC header at PEB %d",
1047 pnum); 1047 pnum);
1048 err = ubi_scan_add_used(ubi, si, pnum, ec, vidh, bitflips); 1048 err = ubi_scan_add_used(ubi, ai, pnum, ec, vidh, bitflips);
1049 if (err) 1049 if (err)
1050 return err; 1050 return err;
1051 1051
1052adjust_mean_ec: 1052adjust_mean_ec:
1053 if (!ec_err) { 1053 if (!ec_err) {
1054 si->ec_sum += ec; 1054 ai->ec_sum += ec;
1055 si->ec_count += 1; 1055 ai->ec_count += 1;
1056 if (ec > si->max_ec) 1056 if (ec > ai->max_ec)
1057 si->max_ec = ec; 1057 ai->max_ec = ec;
1058 if (ec < si->min_ec) 1058 if (ec < ai->min_ec)
1059 si->min_ec = ec; 1059 ai->min_ec = ec;
1060 } 1060 }
1061 1061
1062 return 0; 1062 return 0;
@@ -1065,7 +1065,7 @@ adjust_mean_ec:
1065/** 1065/**
1066 * check_what_we_have - check what PEB were found by scanning. 1066 * check_what_we_have - check what PEB were found by scanning.
1067 * @ubi: UBI device description object 1067 * @ubi: UBI device description object
1068 * @si: scanning information 1068 * @ai: attaching information
1069 * 1069 *
1070 * This is a helper function which takes a look what PEBs were found by 1070 * This is a helper function which takes a look what PEBs were found by
1071 * scanning, and decides whether the flash is empty and should be formatted and 1071 * scanning, and decides whether the flash is empty and should be formatted and
@@ -1074,12 +1074,12 @@ adjust_mean_ec:
1074 * and %-EINVAL if we should not. 1074 * and %-EINVAL if we should not.
1075 */ 1075 */
1076static int check_what_we_have(struct ubi_device *ubi, 1076static int check_what_we_have(struct ubi_device *ubi,
1077 struct ubi_attach_info *si) 1077 struct ubi_attach_info *ai)
1078{ 1078{
1079 struct ubi_ainf_peb *aeb; 1079 struct ubi_ainf_peb *aeb;
1080 int max_corr, peb_count; 1080 int max_corr, peb_count;
1081 1081
1082 peb_count = ubi->peb_count - si->bad_peb_count - si->alien_peb_count; 1082 peb_count = ubi->peb_count - ai->bad_peb_count - ai->alien_peb_count;
1083 max_corr = peb_count / 20 ?: 8; 1083 max_corr = peb_count / 20 ?: 8;
1084 1084
1085 /* 1085 /*
@@ -1087,11 +1087,11 @@ static int check_what_we_have(struct ubi_device *ubi,
1087 * unclean reboots. However, many of them may indicate some problems 1087 * unclean reboots. However, many of them may indicate some problems
1088 * with the flash HW or driver. 1088 * with the flash HW or driver.
1089 */ 1089 */
1090 if (si->corr_peb_count) { 1090 if (ai->corr_peb_count) {
1091 ubi_err("%d PEBs are corrupted and preserved", 1091 ubi_err("%d PEBs are corrupted and preserved",
1092 si->corr_peb_count); 1092 ai->corr_peb_count);
1093 printk(KERN_ERR "Corrupted PEBs are:"); 1093 printk(KERN_ERR "Corrupted PEBs are:");
1094 list_for_each_entry(aeb, &si->corr, u.list) 1094 list_for_each_entry(aeb, &ai->corr, u.list)
1095 printk(KERN_CONT " %d", aeb->pnum); 1095 printk(KERN_CONT " %d", aeb->pnum);
1096 printk(KERN_CONT "\n"); 1096 printk(KERN_CONT "\n");
1097 1097
@@ -1099,13 +1099,13 @@ static int check_what_we_have(struct ubi_device *ubi,
1099 * If too many PEBs are corrupted, we refuse attaching, 1099 * If too many PEBs are corrupted, we refuse attaching,
1100 * otherwise, only print a warning. 1100 * otherwise, only print a warning.
1101 */ 1101 */
1102 if (si->corr_peb_count >= max_corr) { 1102 if (ai->corr_peb_count >= max_corr) {
1103 ubi_err("too many corrupted PEBs, refusing"); 1103 ubi_err("too many corrupted PEBs, refusing");
1104 return -EINVAL; 1104 return -EINVAL;
1105 } 1105 }
1106 } 1106 }
1107 1107
1108 if (si->empty_peb_count + si->maybe_bad_peb_count == peb_count) { 1108 if (ai->empty_peb_count + ai->maybe_bad_peb_count == peb_count) {
1109 /* 1109 /*
1110 * All PEBs are empty, or almost all - a couple PEBs look like 1110 * All PEBs are empty, or almost all - a couple PEBs look like
1111 * they may be bad PEBs which were not marked as bad yet. 1111 * they may be bad PEBs which were not marked as bad yet.
@@ -1121,8 +1121,8 @@ static int check_what_we_have(struct ubi_device *ubi,
1121 * 2. Flash contains non-UBI data and we do not want to format 1121 * 2. Flash contains non-UBI data and we do not want to format
1122 * it and destroy possibly important information. 1122 * it and destroy possibly important information.
1123 */ 1123 */
1124 if (si->maybe_bad_peb_count <= 2) { 1124 if (ai->maybe_bad_peb_count <= 2) {
1125 si->is_empty = 1; 1125 ai->is_empty = 1;
1126 ubi_msg("empty MTD device detected"); 1126 ubi_msg("empty MTD device detected");
1127 get_random_bytes(&ubi->image_seq, 1127 get_random_bytes(&ubi->image_seq,
1128 sizeof(ubi->image_seq)); 1128 sizeof(ubi->image_seq));
@@ -1150,28 +1150,28 @@ struct ubi_attach_info *ubi_scan(struct ubi_device *ubi)
1150 struct rb_node *rb1, *rb2; 1150 struct rb_node *rb1, *rb2;
1151 struct ubi_ainf_volume *sv; 1151 struct ubi_ainf_volume *sv;
1152 struct ubi_ainf_peb *aeb; 1152 struct ubi_ainf_peb *aeb;
1153 struct ubi_attach_info *si; 1153 struct ubi_attach_info *ai;
1154 1154
1155 si = kzalloc(sizeof(struct ubi_attach_info), GFP_KERNEL); 1155 ai = kzalloc(sizeof(struct ubi_attach_info), GFP_KERNEL);
1156 if (!si) 1156 if (!ai)
1157 return ERR_PTR(-ENOMEM); 1157 return ERR_PTR(-ENOMEM);
1158 1158
1159 INIT_LIST_HEAD(&si->corr); 1159 INIT_LIST_HEAD(&ai->corr);
1160 INIT_LIST_HEAD(&si->free); 1160 INIT_LIST_HEAD(&ai->free);
1161 INIT_LIST_HEAD(&si->erase); 1161 INIT_LIST_HEAD(&ai->erase);
1162 INIT_LIST_HEAD(&si->alien); 1162 INIT_LIST_HEAD(&ai->alien);
1163 si->volumes = RB_ROOT; 1163 ai->volumes = RB_ROOT;
1164 1164
1165 err = -ENOMEM; 1165 err = -ENOMEM;
1166 si->scan_leb_slab = kmem_cache_create("ubi_scan_leb_slab", 1166 ai->scan_leb_slab = kmem_cache_create("ubi_scan_leb_slab",
1167 sizeof(struct ubi_ainf_peb), 1167 sizeof(struct ubi_ainf_peb),
1168 0, 0, NULL); 1168 0, 0, NULL);
1169 if (!si->scan_leb_slab) 1169 if (!ai->scan_leb_slab)
1170 goto out_si; 1170 goto out_ai;
1171 1171
1172 ech = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL); 1172 ech = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL);
1173 if (!ech) 1173 if (!ech)
1174 goto out_si; 1174 goto out_ai;
1175 1175
1176 vidh = ubi_zalloc_vid_hdr(ubi, GFP_KERNEL); 1176 vidh = ubi_zalloc_vid_hdr(ubi, GFP_KERNEL);
1177 if (!vidh) 1177 if (!vidh)
@@ -1181,7 +1181,7 @@ struct ubi_attach_info *ubi_scan(struct ubi_device *ubi)
1181 cond_resched(); 1181 cond_resched();
1182 1182
1183 dbg_gen("process PEB %d", pnum); 1183 dbg_gen("process PEB %d", pnum);
1184 err = process_eb(ubi, si, pnum); 1184 err = process_eb(ubi, ai, pnum);
1185 if (err < 0) 1185 if (err < 0)
1186 goto out_vidh; 1186 goto out_vidh;
1187 } 1187 }
@@ -1189,10 +1189,10 @@ struct ubi_attach_info *ubi_scan(struct ubi_device *ubi)
1189 dbg_msg("scanning is finished"); 1189 dbg_msg("scanning is finished");
1190 1190
1191 /* Calculate mean erase counter */ 1191 /* Calculate mean erase counter */
1192 if (si->ec_count) 1192 if (ai->ec_count)
1193 si->mean_ec = div_u64(si->ec_sum, si->ec_count); 1193 ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count);
1194 1194
1195 err = check_what_we_have(ubi, si); 1195 err = check_what_we_have(ubi, ai);
1196 if (err) 1196 if (err)
1197 goto out_vidh; 1197 goto out_vidh;
1198 1198
@@ -1200,52 +1200,52 @@ struct ubi_attach_info *ubi_scan(struct ubi_device *ubi)
1200 * In case of unknown erase counter we use the mean erase counter 1200 * In case of unknown erase counter we use the mean erase counter
1201 * value. 1201 * value.
1202 */ 1202 */
1203 ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) { 1203 ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) {
1204 ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) 1204 ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb)
1205 if (aeb->ec == UBI_SCAN_UNKNOWN_EC) 1205 if (aeb->ec == UBI_SCAN_UNKNOWN_EC)
1206 aeb->ec = si->mean_ec; 1206 aeb->ec = ai->mean_ec;
1207 } 1207 }
1208 1208
1209 list_for_each_entry(aeb, &si->free, u.list) { 1209 list_for_each_entry(aeb, &ai->free, u.list) {
1210 if (aeb->ec == UBI_SCAN_UNKNOWN_EC) 1210 if (aeb->ec == UBI_SCAN_UNKNOWN_EC)
1211 aeb->ec = si->mean_ec; 1211 aeb->ec = ai->mean_ec;
1212 } 1212 }
1213 1213
1214 list_for_each_entry(aeb, &si->corr, u.list) 1214 list_for_each_entry(aeb, &ai->corr, u.list)
1215 if (aeb->ec == UBI_SCAN_UNKNOWN_EC) 1215 if (aeb->ec == UBI_SCAN_UNKNOWN_EC)
1216 aeb->ec = si->mean_ec; 1216 aeb->ec = ai->mean_ec;
1217 1217
1218 list_for_each_entry(aeb, &si->erase, u.list) 1218 list_for_each_entry(aeb, &ai->erase, u.list)
1219 if (aeb->ec == UBI_SCAN_UNKNOWN_EC) 1219 if (aeb->ec == UBI_SCAN_UNKNOWN_EC)
1220 aeb->ec = si->mean_ec; 1220 aeb->ec = ai->mean_ec;
1221 1221
1222 err = self_check_si(ubi, si); 1222 err = self_check_ai(ubi, ai);
1223 if (err) 1223 if (err)
1224 goto out_vidh; 1224 goto out_vidh;
1225 1225
1226 ubi_free_vid_hdr(ubi, vidh); 1226 ubi_free_vid_hdr(ubi, vidh);
1227 kfree(ech); 1227 kfree(ech);
1228 1228
1229 return si; 1229 return ai;
1230 1230
1231out_vidh: 1231out_vidh:
1232 ubi_free_vid_hdr(ubi, vidh); 1232 ubi_free_vid_hdr(ubi, vidh);
1233out_ech: 1233out_ech:
1234 kfree(ech); 1234 kfree(ech);
1235out_si: 1235out_ai:
1236 ubi_scan_destroy_si(si); 1236 ubi_scan_destroy_ai(ai);
1237 return ERR_PTR(err); 1237 return ERR_PTR(err);
1238} 1238}
1239 1239
1240/** 1240/**
1241 * destroy_sv - free the scanning volume information 1241 * destroy_sv - free the scanning volume information
1242 * @sv: scanning volume information 1242 * @sv: scanning volume information
1243 * @si: scanning information 1243 * @ai: attaching information
1244 * 1244 *
1245 * This function destroys the volume RB-tree (@sv->root) and the scanning 1245 * This function destroys the volume RB-tree (@sv->root) and the scanning
1246 * volume information. 1246 * volume information.
1247 */ 1247 */
1248static void destroy_sv(struct ubi_attach_info *si, struct ubi_ainf_volume *sv) 1248static void destroy_sv(struct ubi_attach_info *ai, struct ubi_ainf_volume *sv)
1249{ 1249{
1250 struct ubi_ainf_peb *aeb; 1250 struct ubi_ainf_peb *aeb;
1251 struct rb_node *this = sv->root.rb_node; 1251 struct rb_node *this = sv->root.rb_node;
@@ -1265,41 +1265,41 @@ static void destroy_sv(struct ubi_attach_info *si, struct ubi_ainf_volume *sv)
1265 this->rb_right = NULL; 1265 this->rb_right = NULL;
1266 } 1266 }
1267 1267
1268 kmem_cache_free(si->scan_leb_slab, aeb); 1268 kmem_cache_free(ai->scan_leb_slab, aeb);
1269 } 1269 }
1270 } 1270 }
1271 kfree(sv); 1271 kfree(sv);
1272} 1272}
1273 1273
1274/** 1274/**
1275 * ubi_scan_destroy_si - destroy scanning information. 1275 * ubi_scan_destroy_ai - destroy attaching information.
1276 * @si: scanning information 1276 * @ai: attaching information
1277 */ 1277 */
1278void ubi_scan_destroy_si(struct ubi_attach_info *si) 1278void ubi_scan_destroy_ai(struct ubi_attach_info *ai)
1279{ 1279{
1280 struct ubi_ainf_peb *aeb, *aeb_tmp; 1280 struct ubi_ainf_peb *aeb, *aeb_tmp;
1281 struct ubi_ainf_volume *sv; 1281 struct ubi_ainf_volume *sv;
1282 struct rb_node *rb; 1282 struct rb_node *rb;
1283 1283
1284 list_for_each_entry_safe(aeb, aeb_tmp, &si->alien, u.list) { 1284 list_for_each_entry_safe(aeb, aeb_tmp, &ai->alien, u.list) {
1285 list_del(&aeb->u.list); 1285 list_del(&aeb->u.list);
1286 kmem_cache_free(si->scan_leb_slab, aeb); 1286 kmem_cache_free(ai->scan_leb_slab, aeb);
1287 } 1287 }
1288 list_for_each_entry_safe(aeb, aeb_tmp, &si->erase, u.list) { 1288 list_for_each_entry_safe(aeb, aeb_tmp, &ai->erase, u.list) {
1289 list_del(&aeb->u.list); 1289 list_del(&aeb->u.list);
1290 kmem_cache_free(si->scan_leb_slab, aeb); 1290 kmem_cache_free(ai->scan_leb_slab, aeb);
1291 } 1291 }
1292 list_for_each_entry_safe(aeb, aeb_tmp, &si->corr, u.list) { 1292 list_for_each_entry_safe(aeb, aeb_tmp, &ai->corr, u.list) {
1293 list_del(&aeb->u.list); 1293 list_del(&aeb->u.list);
1294 kmem_cache_free(si->scan_leb_slab, aeb); 1294 kmem_cache_free(ai->scan_leb_slab, aeb);
1295 } 1295 }
1296 list_for_each_entry_safe(aeb, aeb_tmp, &si->free, u.list) { 1296 list_for_each_entry_safe(aeb, aeb_tmp, &ai->free, u.list) {
1297 list_del(&aeb->u.list); 1297 list_del(&aeb->u.list);
1298 kmem_cache_free(si->scan_leb_slab, aeb); 1298 kmem_cache_free(ai->scan_leb_slab, aeb);
1299 } 1299 }
1300 1300
1301 /* Destroy the volume RB-tree */ 1301 /* Destroy the volume RB-tree */
1302 rb = si->volumes.rb_node; 1302 rb = ai->volumes.rb_node;
1303 while (rb) { 1303 while (rb) {
1304 if (rb->rb_left) 1304 if (rb->rb_left)
1305 rb = rb->rb_left; 1305 rb = rb->rb_left;
@@ -1316,25 +1316,25 @@ void ubi_scan_destroy_si(struct ubi_attach_info *si)
1316 rb->rb_right = NULL; 1316 rb->rb_right = NULL;
1317 } 1317 }
1318 1318
1319 destroy_sv(si, sv); 1319 destroy_sv(ai, sv);
1320 } 1320 }
1321 } 1321 }
1322 1322
1323 if (si->scan_leb_slab) 1323 if (ai->scan_leb_slab)
1324 kmem_cache_destroy(si->scan_leb_slab); 1324 kmem_cache_destroy(ai->scan_leb_slab);
1325 1325
1326 kfree(si); 1326 kfree(ai);
1327} 1327}
1328 1328
1329/** 1329/**
1330 * self_check_si - check the scanning information. 1330 * self_check_ai - check the attaching information.
1331 * @ubi: UBI device description object 1331 * @ubi: UBI device description object
1332 * @si: scanning information 1332 * @ai: attaching information
1333 * 1333 *
1334 * This function returns zero if the scanning information is all right, and a 1334 * This function returns zero if the attaching information is all right, and a
1335 * negative error code if not or if an error occurred. 1335 * negative error code if not or if an error occurred.
1336 */ 1336 */
1337static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) 1337static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1338{ 1338{
1339 int pnum, err, vols_found = 0; 1339 int pnum, err, vols_found = 0;
1340 struct rb_node *rb1, *rb2; 1340 struct rb_node *rb1, *rb2;
@@ -1346,16 +1346,16 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si)
1346 return 0; 1346 return 0;
1347 1347
1348 /* 1348 /*
1349 * At first, check that scanning information is OK. 1349 * At first, check that attaching information is OK.
1350 */ 1350 */
1351 ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) { 1351 ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) {
1352 int leb_count = 0; 1352 int leb_count = 0;
1353 1353
1354 cond_resched(); 1354 cond_resched();
1355 1355
1356 vols_found += 1; 1356 vols_found += 1;
1357 1357
1358 if (si->is_empty) { 1358 if (ai->is_empty) {
1359 ubi_err("bad is_empty flag"); 1359 ubi_err("bad is_empty flag");
1360 goto bad_sv; 1360 goto bad_sv;
1361 } 1361 }
@@ -1373,9 +1373,9 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si)
1373 goto bad_sv; 1373 goto bad_sv;
1374 } 1374 }
1375 1375
1376 if (sv->vol_id > si->highest_vol_id) { 1376 if (sv->vol_id > ai->highest_vol_id) {
1377 ubi_err("highest_vol_id is %d, but vol_id %d is there", 1377 ubi_err("highest_vol_id is %d, but vol_id %d is there",
1378 si->highest_vol_id, sv->vol_id); 1378 ai->highest_vol_id, sv->vol_id);
1379 goto out; 1379 goto out;
1380 } 1380 }
1381 1381
@@ -1402,15 +1402,15 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si)
1402 goto bad_aeb; 1402 goto bad_aeb;
1403 } 1403 }
1404 1404
1405 if (aeb->ec < si->min_ec) { 1405 if (aeb->ec < ai->min_ec) {
1406 ubi_err("bad si->min_ec (%d), %d found", 1406 ubi_err("bad ai->min_ec (%d), %d found",
1407 si->min_ec, aeb->ec); 1407 ai->min_ec, aeb->ec);
1408 goto bad_aeb; 1408 goto bad_aeb;
1409 } 1409 }
1410 1410
1411 if (aeb->ec > si->max_ec) { 1411 if (aeb->ec > ai->max_ec) {
1412 ubi_err("bad si->max_ec (%d), %d found", 1412 ubi_err("bad ai->max_ec (%d), %d found",
1413 si->max_ec, aeb->ec); 1413 ai->max_ec, aeb->ec);
1414 goto bad_aeb; 1414 goto bad_aeb;
1415 } 1415 }
1416 1416
@@ -1455,14 +1455,14 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si)
1455 } 1455 }
1456 } 1456 }
1457 1457
1458 if (vols_found != si->vols_found) { 1458 if (vols_found != ai->vols_found) {
1459 ubi_err("bad si->vols_found %d, should be %d", 1459 ubi_err("bad ai->vols_found %d, should be %d",
1460 si->vols_found, vols_found); 1460 ai->vols_found, vols_found);
1461 goto out; 1461 goto out;
1462 } 1462 }
1463 1463
1464 /* Check that scanning information is correct */ 1464 /* Check that attaching information is correct */
1465 ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) { 1465 ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) {
1466 last_aeb = NULL; 1466 last_aeb = NULL;
1467 ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) { 1467 ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) {
1468 int vol_type; 1468 int vol_type;
@@ -1548,20 +1548,20 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si)
1548 buf[pnum] = 1; 1548 buf[pnum] = 1;
1549 } 1549 }
1550 1550
1551 ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) 1551 ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb)
1552 ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) 1552 ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb)
1553 buf[aeb->pnum] = 1; 1553 buf[aeb->pnum] = 1;
1554 1554
1555 list_for_each_entry(aeb, &si->free, u.list) 1555 list_for_each_entry(aeb, &ai->free, u.list)
1556 buf[aeb->pnum] = 1; 1556 buf[aeb->pnum] = 1;
1557 1557
1558 list_for_each_entry(aeb, &si->corr, u.list) 1558 list_for_each_entry(aeb, &ai->corr, u.list)
1559 buf[aeb->pnum] = 1; 1559 buf[aeb->pnum] = 1;
1560 1560
1561 list_for_each_entry(aeb, &si->erase, u.list) 1561 list_for_each_entry(aeb, &ai->erase, u.list)
1562 buf[aeb->pnum] = 1; 1562 buf[aeb->pnum] = 1;
1563 1563
1564 list_for_each_entry(aeb, &si->alien, u.list) 1564 list_for_each_entry(aeb, &ai->alien, u.list)
1565 buf[aeb->pnum] = 1; 1565 buf[aeb->pnum] = 1;
1566 1566
1567 err = 0; 1567 err = 0;
@@ -1577,18 +1577,18 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si)
1577 return 0; 1577 return 0;
1578 1578
1579bad_aeb: 1579bad_aeb:
1580 ubi_err("bad scanning information about LEB %d", aeb->lnum); 1580 ubi_err("bad attaching information about LEB %d", aeb->lnum);
1581 ubi_dump_aeb(aeb, 0); 1581 ubi_dump_aeb(aeb, 0);
1582 ubi_dump_sv(sv); 1582 ubi_dump_sv(sv);
1583 goto out; 1583 goto out;
1584 1584
1585bad_sv: 1585bad_sv:
1586 ubi_err("bad scanning information about volume %d", sv->vol_id); 1586 ubi_err("bad attaching information about volume %d", sv->vol_id);
1587 ubi_dump_sv(sv); 1587 ubi_dump_sv(sv);
1588 goto out; 1588 goto out;
1589 1589
1590bad_vid_hdr: 1590bad_vid_hdr:
1591 ubi_err("bad scanning information about volume %d", sv->vol_id); 1591 ubi_err("bad attaching information about volume %d", sv->vol_id);
1592 ubi_dump_sv(sv); 1592 ubi_dump_sv(sv);
1593 ubi_dump_vid_hdr(vidh); 1593 ubi_dump_vid_hdr(vidh);
1594 1594