aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--drivers/mtd/ubi/build.c32
-rw-r--r--drivers/mtd/ubi/debug.c4
-rw-r--r--drivers/mtd/ubi/eba.c18
-rw-r--r--drivers/mtd/ubi/scan.c346
-rw-r--r--drivers/mtd/ubi/scan.h14
-rw-r--r--drivers/mtd/ubi/ubi.h6
-rw-r--r--drivers/mtd/ubi/vtbl.c86
-rw-r--r--drivers/mtd/ubi/wl.c14
8 files changed, 260 insertions, 260 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 4e715df8bd00..1ae3cfa30809 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -583,32 +583,32 @@ static void free_internal_volumes(struct ubi_device *ubi)
583static int attach_by_scanning(struct ubi_device *ubi) 583static int attach_by_scanning(struct ubi_device *ubi)
584{ 584{
585 int err; 585 int err;
586 struct ubi_attach_info *si; 586 struct ubi_attach_info *ai;
587 587
588 si = ubi_scan(ubi); 588 ai = ubi_scan(ubi);
589 if (IS_ERR(si)) 589 if (IS_ERR(ai))
590 return PTR_ERR(si); 590 return PTR_ERR(ai);
591 591
592 ubi->bad_peb_count = si->bad_peb_count; 592 ubi->bad_peb_count = ai->bad_peb_count;
593 ubi->good_peb_count = ubi->peb_count - ubi->bad_peb_count; 593 ubi->good_peb_count = ubi->peb_count - ubi->bad_peb_count;
594 ubi->corr_peb_count = si->corr_peb_count; 594 ubi->corr_peb_count = ai->corr_peb_count;
595 ubi->max_ec = si->max_ec; 595 ubi->max_ec = ai->max_ec;
596 ubi->mean_ec = si->mean_ec; 596 ubi->mean_ec = ai->mean_ec;
597 ubi_msg("max. sequence number: %llu", si->max_sqnum); 597 ubi_msg("max. sequence number: %llu", ai->max_sqnum);
598 598
599 err = ubi_read_volume_table(ubi, si); 599 err = ubi_read_volume_table(ubi, ai);
600 if (err) 600 if (err)
601 goto out_si; 601 goto out_ai;
602 602
603 err = ubi_wl_init_scan(ubi, si); 603 err = ubi_wl_init_scan(ubi, ai);
604 if (err) 604 if (err)
605 goto out_vtbl; 605 goto out_vtbl;
606 606
607 err = ubi_eba_init_scan(ubi, si); 607 err = ubi_eba_init_scan(ubi, ai);
608 if (err) 608 if (err)
609 goto out_wl; 609 goto out_wl;
610 610
611 ubi_scan_destroy_si(si); 611 ubi_scan_destroy_ai(ai);
612 return 0; 612 return 0;
613 613
614out_wl: 614out_wl:
@@ -616,8 +616,8 @@ out_wl:
616out_vtbl: 616out_vtbl:
617 free_internal_volumes(ubi); 617 free_internal_volumes(ubi);
618 vfree(ubi->vtbl); 618 vfree(ubi->vtbl);
619out_si: 619out_ai:
620 ubi_scan_destroy_si(si); 620 ubi_scan_destroy_ai(ai);
621 return err; 621 return err;
622} 622}
623 623
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index e73b1fef897d..84362a802999 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -176,7 +176,7 @@ void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx)
176 */ 176 */
177void ubi_dump_sv(const struct ubi_ainf_volume *sv) 177void ubi_dump_sv(const struct ubi_ainf_volume *sv)
178{ 178{
179 printk(KERN_DEBUG "Volume scanning information dump:\n"); 179 printk(KERN_DEBUG "Volume attaching information dump:\n");
180 printk(KERN_DEBUG "\tvol_id %d\n", sv->vol_id); 180 printk(KERN_DEBUG "\tvol_id %d\n", sv->vol_id);
181 printk(KERN_DEBUG "\thighest_lnum %d\n", sv->highest_lnum); 181 printk(KERN_DEBUG "\thighest_lnum %d\n", sv->highest_lnum);
182 printk(KERN_DEBUG "\tleb_count %d\n", sv->leb_count); 182 printk(KERN_DEBUG "\tleb_count %d\n", sv->leb_count);
@@ -194,7 +194,7 @@ void ubi_dump_sv(const struct ubi_ainf_volume *sv)
194 */ 194 */
195void ubi_dump_aeb(const struct ubi_ainf_peb *aeb, int type) 195void ubi_dump_aeb(const struct ubi_ainf_peb *aeb, int type)
196{ 196{
197 printk(KERN_DEBUG "eraseblock scanning information dump:\n"); 197 printk(KERN_DEBUG "eraseblock attaching information dump:\n");
198 printk(KERN_DEBUG "\tec %d\n", aeb->ec); 198 printk(KERN_DEBUG "\tec %d\n", aeb->ec);
199 printk(KERN_DEBUG "\tpnum %d\n", aeb->pnum); 199 printk(KERN_DEBUG "\tpnum %d\n", aeb->pnum);
200 if (type == 0) { 200 if (type == 0) {
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index 25095026617d..320372715405 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -1182,13 +1182,13 @@ out_unlock_leb:
1182 * reported by real users. 1182 * reported by real users.
1183 */ 1183 */
1184static void print_rsvd_warning(struct ubi_device *ubi, 1184static void print_rsvd_warning(struct ubi_device *ubi,
1185 struct ubi_attach_info *si) 1185 struct ubi_attach_info *ai)
1186{ 1186{
1187 /* 1187 /*
1188 * The 1 << 18 (256KiB) number is picked randomly, just a reasonably 1188 * The 1 << 18 (256KiB) number is picked randomly, just a reasonably
1189 * large number to distinguish between newly flashed and used images. 1189 * large number to distinguish between newly flashed and used images.
1190 */ 1190 */
1191 if (si->max_sqnum > (1 << 18)) { 1191 if (ai->max_sqnum > (1 << 18)) {
1192 int min = ubi->beb_rsvd_level / 10; 1192 int min = ubi->beb_rsvd_level / 10;
1193 1193
1194 if (!min) 1194 if (!min)
@@ -1205,14 +1205,14 @@ static void print_rsvd_warning(struct ubi_device *ubi,
1205} 1205}
1206 1206
1207/** 1207/**
1208 * ubi_eba_init_scan - initialize the EBA sub-system using scanning information. 1208 * ubi_eba_init_scan - initialize the EBA sub-system using attaching information.
1209 * @ubi: UBI device description object 1209 * @ubi: UBI device description object
1210 * @si: scanning information 1210 * @ai: attaching information
1211 * 1211 *
1212 * This function returns zero in case of success and a negative error code in 1212 * This function returns zero in case of success and a negative error code in
1213 * case of failure. 1213 * case of failure.
1214 */ 1214 */
1215int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) 1215int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai)
1216{ 1216{
1217 int i, j, err, num_volumes; 1217 int i, j, err, num_volumes;
1218 struct ubi_ainf_volume *sv; 1218 struct ubi_ainf_volume *sv;
@@ -1226,7 +1226,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si)
1226 mutex_init(&ubi->alc_mutex); 1226 mutex_init(&ubi->alc_mutex);
1227 ubi->ltree = RB_ROOT; 1227 ubi->ltree = RB_ROOT;
1228 1228
1229 ubi->global_sqnum = si->max_sqnum + 1; 1229 ubi->global_sqnum = ai->max_sqnum + 1;
1230 num_volumes = ubi->vtbl_slots + UBI_INT_VOL_COUNT; 1230 num_volumes = ubi->vtbl_slots + UBI_INT_VOL_COUNT;
1231 1231
1232 for (i = 0; i < num_volumes; i++) { 1232 for (i = 0; i < num_volumes; i++) {
@@ -1246,7 +1246,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si)
1246 for (j = 0; j < vol->reserved_pebs; j++) 1246 for (j = 0; j < vol->reserved_pebs; j++)
1247 vol->eba_tbl[j] = UBI_LEB_UNMAPPED; 1247 vol->eba_tbl[j] = UBI_LEB_UNMAPPED;
1248 1248
1249 sv = ubi_scan_find_sv(si, idx2vol_id(ubi, i)); 1249 sv = ubi_scan_find_sv(ai, idx2vol_id(ubi, i));
1250 if (!sv) 1250 if (!sv)
1251 continue; 1251 continue;
1252 1252
@@ -1256,7 +1256,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si)
1256 * This may happen in case of an unclean reboot 1256 * This may happen in case of an unclean reboot
1257 * during re-size. 1257 * during re-size.
1258 */ 1258 */
1259 ubi_scan_move_to_list(sv, aeb, &si->erase); 1259 ubi_scan_move_to_list(sv, aeb, &ai->erase);
1260 vol->eba_tbl[aeb->lnum] = aeb->pnum; 1260 vol->eba_tbl[aeb->lnum] = aeb->pnum;
1261 } 1261 }
1262 } 1262 }
@@ -1279,7 +1279,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si)
1279 if (ubi->avail_pebs < ubi->beb_rsvd_level) { 1279 if (ubi->avail_pebs < ubi->beb_rsvd_level) {
1280 /* No enough free physical eraseblocks */ 1280 /* No enough free physical eraseblocks */
1281 ubi->beb_rsvd_pebs = ubi->avail_pebs; 1281 ubi->beb_rsvd_pebs = ubi->avail_pebs;
1282 print_rsvd_warning(ubi, si); 1282 print_rsvd_warning(ubi, ai);
1283 } else 1283 } else
1284 ubi->beb_rsvd_pebs = ubi->beb_rsvd_level; 1284 ubi->beb_rsvd_pebs = ubi->beb_rsvd_level;
1285 1285
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
diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h
index 7e20a85b8c31..0f0725e18b7f 100644
--- a/drivers/mtd/ubi/scan.h
+++ b/drivers/mtd/ubi/scan.h
@@ -145,7 +145,7 @@ struct ubi_vid_hdr;
145/* 145/*
146 * ubi_scan_move_to_list - move a PEB from the volume tree to a list. 146 * ubi_scan_move_to_list - move a PEB from the volume tree to a list.
147 * 147 *
148 * @sv: volume scanning information 148 * @sv: volume attaching information
149 * @aeb: scanning eraseblock information 149 * @aeb: scanning eraseblock information
150 * @list: the list to move to 150 * @list: the list to move to
151 */ 151 */
@@ -157,19 +157,19 @@ static inline void ubi_scan_move_to_list(struct ubi_ainf_volume *sv,
157 list_add_tail(&aeb->u.list, list); 157 list_add_tail(&aeb->u.list, list);
158} 158}
159 159
160int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, 160int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai,
161 int pnum, int ec, const struct ubi_vid_hdr *vid_hdr, 161 int pnum, int ec, const struct ubi_vid_hdr *vid_hdr,
162 int bitflips); 162 int bitflips);
163struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *si, 163struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *ai,
164 int vol_id); 164 int vol_id);
165struct ubi_ainf_peb *ubi_scan_find_aeb(const struct ubi_ainf_volume *sv, 165struct ubi_ainf_peb *ubi_scan_find_aeb(const struct ubi_ainf_volume *sv,
166 int lnum); 166 int lnum);
167void ubi_scan_rm_volume(struct ubi_attach_info *si, struct ubi_ainf_volume *sv); 167void ubi_scan_rm_volume(struct ubi_attach_info *ai, struct ubi_ainf_volume *sv);
168struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, 168struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi,
169 struct ubi_attach_info *si); 169 struct ubi_attach_info *ai);
170int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_attach_info *si, 170int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_attach_info *ai,
171 int pnum, int ec); 171 int pnum, int ec);
172struct ubi_attach_info *ubi_scan(struct ubi_device *ubi); 172struct ubi_attach_info *ubi_scan(struct ubi_device *ubi);
173void ubi_scan_destroy_si(struct ubi_attach_info *si); 173void ubi_scan_destroy_ai(struct ubi_attach_info *ai);
174 174
175#endif /* !__UBI_SCAN_H__ */ 175#endif /* !__UBI_SCAN_H__ */
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 0f206517d811..faaf72933bcb 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -489,7 +489,7 @@ int ubi_change_vtbl_record(struct ubi_device *ubi, int idx,
489 struct ubi_vtbl_record *vtbl_rec); 489 struct ubi_vtbl_record *vtbl_rec);
490int ubi_vtbl_rename_volumes(struct ubi_device *ubi, 490int ubi_vtbl_rename_volumes(struct ubi_device *ubi,
491 struct list_head *rename_list); 491 struct list_head *rename_list);
492int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si); 492int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai);
493 493
494/* vmt.c */ 494/* vmt.c */
495int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req); 495int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req);
@@ -529,14 +529,14 @@ int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol,
529 int lnum, const void *buf, int len); 529 int lnum, const void *buf, int len);
530int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, 530int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
531 struct ubi_vid_hdr *vid_hdr); 531 struct ubi_vid_hdr *vid_hdr);
532int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si); 532int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai);
533 533
534/* wl.c */ 534/* wl.c */
535int ubi_wl_get_peb(struct ubi_device *ubi); 535int ubi_wl_get_peb(struct ubi_device *ubi);
536int ubi_wl_put_peb(struct ubi_device *ubi, int pnum, int torture); 536int ubi_wl_put_peb(struct ubi_device *ubi, int pnum, int torture);
537int ubi_wl_flush(struct ubi_device *ubi); 537int ubi_wl_flush(struct ubi_device *ubi);
538int ubi_wl_scrub_peb(struct ubi_device *ubi, int pnum); 538int ubi_wl_scrub_peb(struct ubi_device *ubi, int pnum);
539int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si); 539int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai);
540void ubi_wl_close(struct ubi_device *ubi); 540void ubi_wl_close(struct ubi_device *ubi);
541int ubi_thread(void *u); 541int ubi_thread(void *u);
542 542
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 800958de64e8..3e5363c9945e 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -291,14 +291,14 @@ bad:
291/** 291/**
292 * create_vtbl - create a copy of volume table. 292 * create_vtbl - create a copy of volume table.
293 * @ubi: UBI device description object 293 * @ubi: UBI device description object
294 * @si: scanning information 294 * @ai: attaching information
295 * @copy: number of the volume table copy 295 * @copy: number of the volume table copy
296 * @vtbl: contents of the volume table 296 * @vtbl: contents of the volume table
297 * 297 *
298 * This function returns zero in case of success and a negative error code in 298 * This function returns zero in case of success and a negative error code in
299 * case of failure. 299 * case of failure.
300 */ 300 */
301static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si, 301static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *ai,
302 int copy, void *vtbl) 302 int copy, void *vtbl)
303{ 303{
304 int err, tries = 0; 304 int err, tries = 0;
@@ -312,7 +312,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si,
312 return -ENOMEM; 312 return -ENOMEM;
313 313
314retry: 314retry:
315 new_aeb = ubi_scan_get_free_peb(ubi, si); 315 new_aeb = ubi_scan_get_free_peb(ubi, ai);
316 if (IS_ERR(new_aeb)) { 316 if (IS_ERR(new_aeb)) {
317 err = PTR_ERR(new_aeb); 317 err = PTR_ERR(new_aeb);
318 goto out_free; 318 goto out_free;
@@ -324,7 +324,7 @@ retry:
324 vid_hdr->data_size = vid_hdr->used_ebs = 324 vid_hdr->data_size = vid_hdr->used_ebs =
325 vid_hdr->data_pad = cpu_to_be32(0); 325 vid_hdr->data_pad = cpu_to_be32(0);
326 vid_hdr->lnum = cpu_to_be32(copy); 326 vid_hdr->lnum = cpu_to_be32(copy);
327 vid_hdr->sqnum = cpu_to_be64(++si->max_sqnum); 327 vid_hdr->sqnum = cpu_to_be64(++ai->max_sqnum);
328 328
329 /* The EC header is already there, write the VID header */ 329 /* The EC header is already there, write the VID header */
330 err = ubi_io_write_vid_hdr(ubi, new_aeb->pnum, vid_hdr); 330 err = ubi_io_write_vid_hdr(ubi, new_aeb->pnum, vid_hdr);
@@ -337,10 +337,10 @@ retry:
337 goto write_error; 337 goto write_error;
338 338
339 /* 339 /*
340 * And add it to the scanning information. Don't delete the old version 340 * And add it to the attaching information. Don't delete the old version
341 * of this LEB as it will be deleted and freed in 'ubi_scan_add_used()'. 341 * of this LEB as it will be deleted and freed in 'ubi_scan_add_used()'.
342 */ 342 */
343 err = ubi_scan_add_used(ubi, si, new_aeb->pnum, new_aeb->ec, 343 err = ubi_scan_add_used(ubi, ai, new_aeb->pnum, new_aeb->ec,
344 vid_hdr, 0); 344 vid_hdr, 0);
345 kfree(new_aeb); 345 kfree(new_aeb);
346 ubi_free_vid_hdr(ubi, vid_hdr); 346 ubi_free_vid_hdr(ubi, vid_hdr);
@@ -352,7 +352,7 @@ write_error:
352 * Probably this physical eraseblock went bad, try to pick 352 * Probably this physical eraseblock went bad, try to pick
353 * another one. 353 * another one.
354 */ 354 */
355 list_add(&new_aeb->u.list, &si->erase); 355 list_add(&new_aeb->u.list, &ai->erase);
356 goto retry; 356 goto retry;
357 } 357 }
358 kfree(new_aeb); 358 kfree(new_aeb);
@@ -365,15 +365,15 @@ out_free:
365/** 365/**
366 * process_lvol - process the layout volume. 366 * process_lvol - process the layout volume.
367 * @ubi: UBI device description object 367 * @ubi: UBI device description object
368 * @si: scanning information 368 * @ai: attaching information
369 * @sv: layout volume scanning information 369 * @sv: layout volume attaching information
370 * 370 *
371 * This function is responsible for reading the layout volume, ensuring it is 371 * This function is responsible for reading the layout volume, ensuring it is
372 * not corrupted, and recovering from corruptions if needed. Returns volume 372 * not corrupted, and recovering from corruptions if needed. Returns volume
373 * table in case of success and a negative error code in case of failure. 373 * table in case of success and a negative error code in case of failure.
374 */ 374 */
375static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, 375static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
376 struct ubi_attach_info *si, 376 struct ubi_attach_info *ai,
377 struct ubi_ainf_volume *sv) 377 struct ubi_ainf_volume *sv)
378{ 378{
379 int err; 379 int err;
@@ -449,7 +449,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
449 ubi->vtbl_size); 449 ubi->vtbl_size);
450 if (leb_corrupted[1]) { 450 if (leb_corrupted[1]) {
451 ubi_warn("volume table copy #2 is corrupted"); 451 ubi_warn("volume table copy #2 is corrupted");
452 err = create_vtbl(ubi, si, 1, leb[0]); 452 err = create_vtbl(ubi, ai, 1, leb[0]);
453 if (err) 453 if (err)
454 goto out_free; 454 goto out_free;
455 ubi_msg("volume table was restored"); 455 ubi_msg("volume table was restored");
@@ -472,7 +472,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
472 } 472 }
473 473
474 ubi_warn("volume table copy #1 is corrupted"); 474 ubi_warn("volume table copy #1 is corrupted");
475 err = create_vtbl(ubi, si, 0, leb[1]); 475 err = create_vtbl(ubi, ai, 0, leb[1]);
476 if (err) 476 if (err)
477 goto out_free; 477 goto out_free;
478 ubi_msg("volume table was restored"); 478 ubi_msg("volume table was restored");
@@ -490,13 +490,13 @@ out_free:
490/** 490/**
491 * create_empty_lvol - create empty layout volume. 491 * create_empty_lvol - create empty layout volume.
492 * @ubi: UBI device description object 492 * @ubi: UBI device description object
493 * @si: scanning information 493 * @ai: attaching information
494 * 494 *
495 * This function returns volume table contents in case of success and a 495 * This function returns volume table contents in case of success and a
496 * negative error code in case of failure. 496 * negative error code in case of failure.
497 */ 497 */
498static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, 498static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi,
499 struct ubi_attach_info *si) 499 struct ubi_attach_info *ai)
500{ 500{
501 int i; 501 int i;
502 struct ubi_vtbl_record *vtbl; 502 struct ubi_vtbl_record *vtbl;
@@ -511,7 +511,7 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi,
511 for (i = 0; i < UBI_LAYOUT_VOLUME_EBS; i++) { 511 for (i = 0; i < UBI_LAYOUT_VOLUME_EBS; i++) {
512 int err; 512 int err;
513 513
514 err = create_vtbl(ubi, si, i, vtbl); 514 err = create_vtbl(ubi, ai, i, vtbl);
515 if (err) { 515 if (err) {
516 vfree(vtbl); 516 vfree(vtbl);
517 return ERR_PTR(err); 517 return ERR_PTR(err);
@@ -524,7 +524,7 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi,
524/** 524/**
525 * init_volumes - initialize volume information for existing volumes. 525 * init_volumes - initialize volume information for existing volumes.
526 * @ubi: UBI device description object 526 * @ubi: UBI device description object
527 * @si: scanning information 527 * @ai: scanning information
528 * @vtbl: volume table 528 * @vtbl: volume table
529 * 529 *
530 * This function allocates volume description objects for existing volumes. 530 * This function allocates volume description objects for existing volumes.
@@ -532,7 +532,7 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi,
532 * failure. 532 * failure.
533 */ 533 */
534static int init_volumes(struct ubi_device *ubi, 534static int init_volumes(struct ubi_device *ubi,
535 const struct ubi_attach_info *si, 535 const struct ubi_attach_info *ai,
536 const struct ubi_vtbl_record *vtbl) 536 const struct ubi_vtbl_record *vtbl)
537{ 537{
538 int i, reserved_pebs = 0; 538 int i, reserved_pebs = 0;
@@ -592,7 +592,7 @@ static int init_volumes(struct ubi_device *ubi,
592 } 592 }
593 593
594 /* Static volumes only */ 594 /* Static volumes only */
595 sv = ubi_scan_find_sv(si, i); 595 sv = ubi_scan_find_sv(ai, i);
596 if (!sv) { 596 if (!sv) {
597 /* 597 /*
598 * No eraseblocks belonging to this volume found. We 598 * No eraseblocks belonging to this volume found. We
@@ -661,11 +661,11 @@ static int init_volumes(struct ubi_device *ubi,
661} 661}
662 662
663/** 663/**
664 * check_sv - check volume scanning information. 664 * check_sv - check volume attaching information.
665 * @vol: UBI volume description object 665 * @vol: UBI volume description object
666 * @sv: volume scanning information 666 * @sv: volume attaching information
667 * 667 *
668 * This function returns zero if the volume scanning information is consistent 668 * This function returns zero if the volume attaching information is consistent
669 * to the data read from the volume tabla, and %-EINVAL if not. 669 * to the data read from the volume tabla, and %-EINVAL if not.
670 */ 670 */
671static int check_sv(const struct ubi_volume *vol, 671static int check_sv(const struct ubi_volume *vol,
@@ -696,50 +696,50 @@ static int check_sv(const struct ubi_volume *vol,
696 return 0; 696 return 0;
697 697
698bad: 698bad:
699 ubi_err("bad scanning information, error %d", err); 699 ubi_err("bad attaching information, error %d", err);
700 ubi_dump_sv(sv); 700 ubi_dump_sv(sv);
701 ubi_dump_vol_info(vol); 701 ubi_dump_vol_info(vol);
702 return -EINVAL; 702 return -EINVAL;
703} 703}
704 704
705/** 705/**
706 * check_scanning_info - check that scanning information. 706 * check_scanning_info - check that attaching information.
707 * @ubi: UBI device description object 707 * @ubi: UBI device description object
708 * @si: scanning information 708 * @ai: attaching information
709 * 709 *
710 * Even though we protect on-flash data by CRC checksums, we still don't trust 710 * Even though we protect on-flash data by CRC checksums, we still don't trust
711 * the media. This function ensures that scanning information is consistent to 711 * the media. This function ensures that attaching information is consistent to
712 * the information read from the volume table. Returns zero if the scanning 712 * the information read from the volume table. Returns zero if the scanning
713 * information is OK and %-EINVAL if it is not. 713 * information is OK and %-EINVAL if it is not.
714 */ 714 */
715static int check_scanning_info(const struct ubi_device *ubi, 715static int check_scanning_info(const struct ubi_device *ubi,
716 struct ubi_attach_info *si) 716 struct ubi_attach_info *ai)
717{ 717{
718 int err, i; 718 int err, i;
719 struct ubi_ainf_volume *sv; 719 struct ubi_ainf_volume *sv;
720 struct ubi_volume *vol; 720 struct ubi_volume *vol;
721 721
722 if (si->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) { 722 if (ai->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) {
723 ubi_err("scanning found %d volumes, maximum is %d + %d", 723 ubi_err("scanning found %d volumes, maximum is %d + %d",
724 si->vols_found, UBI_INT_VOL_COUNT, ubi->vtbl_slots); 724 ai->vols_found, UBI_INT_VOL_COUNT, ubi->vtbl_slots);
725 return -EINVAL; 725 return -EINVAL;
726 } 726 }
727 727
728 if (si->highest_vol_id >= ubi->vtbl_slots + UBI_INT_VOL_COUNT && 728 if (ai->highest_vol_id >= ubi->vtbl_slots + UBI_INT_VOL_COUNT &&
729 si->highest_vol_id < UBI_INTERNAL_VOL_START) { 729 ai->highest_vol_id < UBI_INTERNAL_VOL_START) {
730 ubi_err("too large volume ID %d found by scanning", 730 ubi_err("too large volume ID %d found by scanning",
731 si->highest_vol_id); 731 ai->highest_vol_id);
732 return -EINVAL; 732 return -EINVAL;
733 } 733 }
734 734
735 for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) { 735 for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) {
736 cond_resched(); 736 cond_resched();
737 737
738 sv = ubi_scan_find_sv(si, i); 738 sv = ubi_scan_find_sv(ai, i);
739 vol = ubi->volumes[i]; 739 vol = ubi->volumes[i];
740 if (!vol) { 740 if (!vol) {
741 if (sv) 741 if (sv)
742 ubi_scan_rm_volume(si, sv); 742 ubi_scan_rm_volume(ai, sv);
743 continue; 743 continue;
744 } 744 }
745 745
@@ -757,7 +757,7 @@ static int check_scanning_info(const struct ubi_device *ubi,
757 * these eraseblocks. 757 * these eraseblocks.
758 */ 758 */
759 ubi_msg("finish volume %d removal", sv->vol_id); 759 ubi_msg("finish volume %d removal", sv->vol_id);
760 ubi_scan_rm_volume(si, sv); 760 ubi_scan_rm_volume(ai, sv);
761 } else if (sv) { 761 } else if (sv) {
762 err = check_sv(vol, sv); 762 err = check_sv(vol, sv);
763 if (err) 763 if (err)
@@ -771,13 +771,13 @@ static int check_scanning_info(const struct ubi_device *ubi,
771/** 771/**
772 * ubi_read_volume_table - read the volume table. 772 * ubi_read_volume_table - read the volume table.
773 * @ubi: UBI device description object 773 * @ubi: UBI device description object
774 * @si: scanning information 774 * @ai: attaching information
775 * 775 *
776 * This function reads volume table, checks it, recover from errors if needed, 776 * This function reads volume table, checks it, recover from errors if needed,
777 * or creates it if needed. Returns zero in case of success and a negative 777 * or creates it if needed. Returns zero in case of success and a negative
778 * error code in case of failure. 778 * error code in case of failure.
779 */ 779 */
780int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si) 780int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai)
781{ 781{
782 int i, err; 782 int i, err;
783 struct ubi_ainf_volume *sv; 783 struct ubi_ainf_volume *sv;
@@ -795,7 +795,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si)
795 ubi->vtbl_size = ubi->vtbl_slots * UBI_VTBL_RECORD_SIZE; 795 ubi->vtbl_size = ubi->vtbl_slots * UBI_VTBL_RECORD_SIZE;
796 ubi->vtbl_size = ALIGN(ubi->vtbl_size, ubi->min_io_size); 796 ubi->vtbl_size = ALIGN(ubi->vtbl_size, ubi->min_io_size);
797 797
798 sv = ubi_scan_find_sv(si, UBI_LAYOUT_VOLUME_ID); 798 sv = ubi_scan_find_sv(ai, UBI_LAYOUT_VOLUME_ID);
799 if (!sv) { 799 if (!sv) {
800 /* 800 /*
801 * No logical eraseblocks belonging to the layout volume were 801 * No logical eraseblocks belonging to the layout volume were
@@ -805,8 +805,8 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si)
805 * But if flash is not empty this must be a corruption or the 805 * But if flash is not empty this must be a corruption or the
806 * MTD device just contains garbage. 806 * MTD device just contains garbage.
807 */ 807 */
808 if (si->is_empty) { 808 if (ai->is_empty) {
809 ubi->vtbl = create_empty_lvol(ubi, si); 809 ubi->vtbl = create_empty_lvol(ubi, ai);
810 if (IS_ERR(ubi->vtbl)) 810 if (IS_ERR(ubi->vtbl))
811 return PTR_ERR(ubi->vtbl); 811 return PTR_ERR(ubi->vtbl);
812 } else { 812 } else {
@@ -821,7 +821,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si)
821 return -EINVAL; 821 return -EINVAL;
822 } 822 }
823 823
824 ubi->vtbl = process_lvol(ubi, si, sv); 824 ubi->vtbl = process_lvol(ubi, ai, sv);
825 if (IS_ERR(ubi->vtbl)) 825 if (IS_ERR(ubi->vtbl))
826 return PTR_ERR(ubi->vtbl); 826 return PTR_ERR(ubi->vtbl);
827 } 827 }
@@ -832,15 +832,15 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si)
832 * The layout volume is OK, initialize the corresponding in-RAM data 832 * The layout volume is OK, initialize the corresponding in-RAM data
833 * structures. 833 * structures.
834 */ 834 */
835 err = init_volumes(ubi, si, ubi->vtbl); 835 err = init_volumes(ubi, ai, ubi->vtbl);
836 if (err) 836 if (err)
837 goto out_free; 837 goto out_free;
838 838
839 /* 839 /*
840 * Make sure that the scanning information is consistent to the 840 * Make sure that the attaching information is consistent to the
841 * information stored in the volume table. 841 * information stored in the volume table.
842 */ 842 */
843 err = check_scanning_info(ubi, si); 843 err = check_scanning_info(ubi, ai);
844 if (err) 844 if (err)
845 goto out_free; 845 goto out_free;
846 846
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index fb870f4fc924..992240dae1b1 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1373,14 +1373,14 @@ static void cancel_pending(struct ubi_device *ubi)
1373} 1373}
1374 1374
1375/** 1375/**
1376 * ubi_wl_init_scan - initialize the WL sub-system using scanning information. 1376 * ubi_wl_init_scan - initialize the WL sub-system using attaching information.
1377 * @ubi: UBI device description object 1377 * @ubi: UBI device description object
1378 * @si: scanning information 1378 * @ai: attaching information
1379 * 1379 *
1380 * This function returns zero in case of success, and a negative error code in 1380 * This function returns zero in case of success, and a negative error code in
1381 * case of failure. 1381 * case of failure.
1382 */ 1382 */
1383int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) 1383int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai)
1384{ 1384{
1385 int err, i; 1385 int err, i;
1386 struct rb_node *rb1, *rb2; 1386 struct rb_node *rb1, *rb2;
@@ -1392,7 +1392,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si)
1392 spin_lock_init(&ubi->wl_lock); 1392 spin_lock_init(&ubi->wl_lock);
1393 mutex_init(&ubi->move_mutex); 1393 mutex_init(&ubi->move_mutex);
1394 init_rwsem(&ubi->work_sem); 1394 init_rwsem(&ubi->work_sem);
1395 ubi->max_ec = si->max_ec; 1395 ubi->max_ec = ai->max_ec;
1396 INIT_LIST_HEAD(&ubi->works); 1396 INIT_LIST_HEAD(&ubi->works);
1397 1397
1398 sprintf(ubi->bgt_name, UBI_BGT_NAME_PATTERN, ubi->ubi_num); 1398 sprintf(ubi->bgt_name, UBI_BGT_NAME_PATTERN, ubi->ubi_num);
@@ -1406,7 +1406,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si)
1406 INIT_LIST_HEAD(&ubi->pq[i]); 1406 INIT_LIST_HEAD(&ubi->pq[i]);
1407 ubi->pq_head = 0; 1407 ubi->pq_head = 0;
1408 1408
1409 list_for_each_entry_safe(aeb, tmp, &si->erase, u.list) { 1409 list_for_each_entry_safe(aeb, tmp, &ai->erase, u.list) {
1410 cond_resched(); 1410 cond_resched();
1411 1411
1412 e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL); 1412 e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL);
@@ -1422,7 +1422,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si)
1422 } 1422 }
1423 } 1423 }
1424 1424
1425 list_for_each_entry(aeb, &si->free, u.list) { 1425 list_for_each_entry(aeb, &ai->free, u.list) {
1426 cond_resched(); 1426 cond_resched();
1427 1427
1428 e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL); 1428 e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL);
@@ -1436,7 +1436,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si)
1436 ubi->lookuptbl[e->pnum] = e; 1436 ubi->lookuptbl[e->pnum] = e;
1437 } 1437 }
1438 1438
1439 ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) { 1439 ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) {
1440 ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) { 1440 ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) {
1441 cond_resched(); 1441 cond_resched();
1442 1442