aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/ubi')
-rw-r--r--drivers/mtd/ubi/debug.c22
-rw-r--r--drivers/mtd/ubi/debug.h2
-rw-r--r--drivers/mtd/ubi/eba.c10
-rw-r--r--drivers/mtd/ubi/scan.c240
-rw-r--r--drivers/mtd/ubi/scan.h12
-rw-r--r--drivers/mtd/ubi/vtbl.c72
-rw-r--r--drivers/mtd/ubi/wl.c6
7 files changed, 182 insertions, 182 deletions
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index 84362a802999..9f957c2d48e9 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -171,20 +171,20 @@ void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx)
171} 171}
172 172
173/** 173/**
174 * ubi_dump_sv - dump a &struct ubi_ainf_volume object. 174 * ubi_dump_av - dump a &struct ubi_ainf_volume object.
175 * @sv: the object to dump 175 * @av: the object to dump
176 */ 176 */
177void ubi_dump_sv(const struct ubi_ainf_volume *sv) 177void ubi_dump_av(const struct ubi_ainf_volume *av)
178{ 178{
179 printk(KERN_DEBUG "Volume attaching 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", av->vol_id);
181 printk(KERN_DEBUG "\thighest_lnum %d\n", sv->highest_lnum); 181 printk(KERN_DEBUG "\thighest_lnum %d\n", av->highest_lnum);
182 printk(KERN_DEBUG "\tleb_count %d\n", sv->leb_count); 182 printk(KERN_DEBUG "\tleb_count %d\n", av->leb_count);
183 printk(KERN_DEBUG "\tcompat %d\n", sv->compat); 183 printk(KERN_DEBUG "\tcompat %d\n", av->compat);
184 printk(KERN_DEBUG "\tvol_type %d\n", sv->vol_type); 184 printk(KERN_DEBUG "\tvol_type %d\n", av->vol_type);
185 printk(KERN_DEBUG "\tused_ebs %d\n", sv->used_ebs); 185 printk(KERN_DEBUG "\tused_ebs %d\n", av->used_ebs);
186 printk(KERN_DEBUG "\tlast_data_size %d\n", sv->last_data_size); 186 printk(KERN_DEBUG "\tlast_data_size %d\n", av->last_data_size);
187 printk(KERN_DEBUG "\tdata_pad %d\n", sv->data_pad); 187 printk(KERN_DEBUG "\tdata_pad %d\n", av->data_pad);
188} 188}
189 189
190/** 190/**
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h
index a0911c0c1064..d5d2645b51a7 100644
--- a/drivers/mtd/ubi/debug.h
+++ b/drivers/mtd/ubi/debug.h
@@ -59,7 +59,7 @@ void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr);
59 59
60void ubi_dump_vol_info(const struct ubi_volume *vol); 60void ubi_dump_vol_info(const struct ubi_volume *vol);
61void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx); 61void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx);
62void ubi_dump_sv(const struct ubi_ainf_volume *sv); 62void ubi_dump_av(const struct ubi_ainf_volume *av);
63void ubi_dump_aeb(const struct ubi_ainf_peb *aeb, int type); 63void ubi_dump_aeb(const struct ubi_ainf_peb *aeb, int type);
64void ubi_dump_mkvol_req(const struct ubi_mkvol_req *req); 64void ubi_dump_mkvol_req(const struct ubi_mkvol_req *req);
65int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, 65int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset,
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index 320372715405..572281a9a63c 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -1215,7 +1215,7 @@ static void print_rsvd_warning(struct ubi_device *ubi,
1215int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai) 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 *av;
1219 struct ubi_volume *vol; 1219 struct ubi_volume *vol;
1220 struct ubi_ainf_peb *aeb; 1220 struct ubi_ainf_peb *aeb;
1221 struct rb_node *rb; 1221 struct rb_node *rb;
@@ -1246,17 +1246,17 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai)
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(ai, idx2vol_id(ubi, i)); 1249 av = ubi_scan_find_av(ai, idx2vol_id(ubi, i));
1250 if (!sv) 1250 if (!av)
1251 continue; 1251 continue;
1252 1252
1253 ubi_rb_for_each_entry(rb, aeb, &sv->root, u.rb) { 1253 ubi_rb_for_each_entry(rb, aeb, &av->root, u.rb) {
1254 if (aeb->lnum >= vol->reserved_pebs) 1254 if (aeb->lnum >= vol->reserved_pebs)
1255 /* 1255 /*
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, &ai->erase); 1259 ubi_scan_move_to_list(av, aeb, &ai->erase);
1260 vol->eba_tbl[aeb->lnum] = aeb->pnum; 1260 vol->eba_tbl[aeb->lnum] = aeb->pnum;
1261 } 1261 }
1262 } 1262 }
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 4145a042c8e1..795d5ed70424 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -168,7 +168,7 @@ static int add_corrupted(struct ubi_attach_info *ai, int pnum, int ec)
168/** 168/**
169 * validate_vid_hdr - check volume identifier header. 169 * validate_vid_hdr - check volume identifier header.
170 * @vid_hdr: the volume identifier header to check 170 * @vid_hdr: the volume identifier header to check
171 * @sv: information about the volume this logical eraseblock belongs to 171 * @av: information about the volume this logical eraseblock belongs to
172 * @pnum: physical eraseblock number the VID header came from 172 * @pnum: physical eraseblock number the VID header came from
173 * 173 *
174 * This function checks that data stored in @vid_hdr is consistent. Returns 174 * This function checks that data stored in @vid_hdr is consistent. Returns
@@ -180,15 +180,15 @@ static int add_corrupted(struct ubi_attach_info *ai, int pnum, int ec)
180 * headers of the same volume. 180 * headers of the same volume.
181 */ 181 */
182static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr, 182static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr,
183 const struct ubi_ainf_volume *sv, int pnum) 183 const struct ubi_ainf_volume *av, int pnum)
184{ 184{
185 int vol_type = vid_hdr->vol_type; 185 int vol_type = vid_hdr->vol_type;
186 int vol_id = be32_to_cpu(vid_hdr->vol_id); 186 int vol_id = be32_to_cpu(vid_hdr->vol_id);
187 int used_ebs = be32_to_cpu(vid_hdr->used_ebs); 187 int used_ebs = be32_to_cpu(vid_hdr->used_ebs);
188 int data_pad = be32_to_cpu(vid_hdr->data_pad); 188 int data_pad = be32_to_cpu(vid_hdr->data_pad);
189 189
190 if (sv->leb_count != 0) { 190 if (av->leb_count != 0) {
191 int sv_vol_type; 191 int av_vol_type;
192 192
193 /* 193 /*
194 * This is not the first logical eraseblock belonging to this 194 * This is not the first logical eraseblock belonging to this
@@ -196,27 +196,27 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr,
196 * to the data in previous logical eraseblock headers. 196 * to the data in previous logical eraseblock headers.
197 */ 197 */
198 198
199 if (vol_id != sv->vol_id) { 199 if (vol_id != av->vol_id) {
200 ubi_err("inconsistent vol_id"); 200 ubi_err("inconsistent vol_id");
201 goto bad; 201 goto bad;
202 } 202 }
203 203
204 if (sv->vol_type == UBI_STATIC_VOLUME) 204 if (av->vol_type == UBI_STATIC_VOLUME)
205 sv_vol_type = UBI_VID_STATIC; 205 av_vol_type = UBI_VID_STATIC;
206 else 206 else
207 sv_vol_type = UBI_VID_DYNAMIC; 207 av_vol_type = UBI_VID_DYNAMIC;
208 208
209 if (vol_type != sv_vol_type) { 209 if (vol_type != av_vol_type) {
210 ubi_err("inconsistent vol_type"); 210 ubi_err("inconsistent vol_type");
211 goto bad; 211 goto bad;
212 } 212 }
213 213
214 if (used_ebs != sv->used_ebs) { 214 if (used_ebs != av->used_ebs) {
215 ubi_err("inconsistent used_ebs"); 215 ubi_err("inconsistent used_ebs");
216 goto bad; 216 goto bad;
217 } 217 }
218 218
219 if (data_pad != sv->data_pad) { 219 if (data_pad != av->data_pad) {
220 ubi_err("inconsistent data_pad"); 220 ubi_err("inconsistent data_pad");
221 goto bad; 221 goto bad;
222 } 222 }
@@ -227,7 +227,7 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr,
227bad: 227bad:
228 ubi_err("inconsistent VID header at PEB %d", pnum); 228 ubi_err("inconsistent VID header at PEB %d", pnum);
229 ubi_dump_vid_hdr(vid_hdr); 229 ubi_dump_vid_hdr(vid_hdr);
230 ubi_dump_sv(sv); 230 ubi_dump_av(av);
231 return -EINVAL; 231 return -EINVAL;
232} 232}
233 233
@@ -248,7 +248,7 @@ static 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 *av;
252 struct rb_node **p = &ai->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));
@@ -256,38 +256,38 @@ static struct ubi_ainf_volume *add_volume(struct ubi_attach_info *ai,
256 /* Walk the volume RB-tree to look if this volume is already present */ 256 /* Walk the volume RB-tree to look if this volume is already present */
257 while (*p) { 257 while (*p) {
258 parent = *p; 258 parent = *p;
259 sv = rb_entry(parent, struct ubi_ainf_volume, rb); 259 av = rb_entry(parent, struct ubi_ainf_volume, rb);
260 260
261 if (vol_id == sv->vol_id) 261 if (vol_id == av->vol_id)
262 return sv; 262 return av;
263 263
264 if (vol_id > sv->vol_id) 264 if (vol_id > av->vol_id)
265 p = &(*p)->rb_left; 265 p = &(*p)->rb_left;
266 else 266 else
267 p = &(*p)->rb_right; 267 p = &(*p)->rb_right;
268 } 268 }
269 269
270 /* The volume is absent - add it */ 270 /* The volume is absent - add it */
271 sv = kmalloc(sizeof(struct ubi_ainf_volume), GFP_KERNEL); 271 av = kmalloc(sizeof(struct ubi_ainf_volume), GFP_KERNEL);
272 if (!sv) 272 if (!av)
273 return ERR_PTR(-ENOMEM); 273 return ERR_PTR(-ENOMEM);
274 274
275 sv->highest_lnum = sv->leb_count = 0; 275 av->highest_lnum = av->leb_count = 0;
276 sv->vol_id = vol_id; 276 av->vol_id = vol_id;
277 sv->root = RB_ROOT; 277 av->root = RB_ROOT;
278 sv->used_ebs = be32_to_cpu(vid_hdr->used_ebs); 278 av->used_ebs = be32_to_cpu(vid_hdr->used_ebs);
279 sv->data_pad = be32_to_cpu(vid_hdr->data_pad); 279 av->data_pad = be32_to_cpu(vid_hdr->data_pad);
280 sv->compat = vid_hdr->compat; 280 av->compat = vid_hdr->compat;
281 sv->vol_type = vid_hdr->vol_type == UBI_VID_DYNAMIC ? UBI_DYNAMIC_VOLUME 281 av->vol_type = vid_hdr->vol_type == UBI_VID_DYNAMIC ? UBI_DYNAMIC_VOLUME
282 : UBI_STATIC_VOLUME; 282 : UBI_STATIC_VOLUME;
283 if (vol_id > ai->highest_vol_id) 283 if (vol_id > ai->highest_vol_id)
284 ai->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(&av->rb, parent, p);
287 rb_insert_color(&sv->rb, &ai->volumes); 287 rb_insert_color(&av->rb, &ai->volumes);
288 ai->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 av;
291} 291}
292 292
293/** 293/**
@@ -446,7 +446,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai,
446{ 446{
447 int err, vol_id, lnum; 447 int err, vol_id, lnum;
448 unsigned long long sqnum; 448 unsigned long long sqnum;
449 struct ubi_ainf_volume *sv; 449 struct ubi_ainf_volume *av;
450 struct ubi_ainf_peb *aeb; 450 struct ubi_ainf_peb *aeb;
451 struct rb_node **p, *parent = NULL; 451 struct rb_node **p, *parent = NULL;
452 452
@@ -457,9 +457,9 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai,
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(ai, vol_id, pnum, vid_hdr); 460 av = add_volume(ai, vol_id, pnum, vid_hdr);
461 if (IS_ERR(sv)) 461 if (IS_ERR(av))
462 return PTR_ERR(sv); 462 return PTR_ERR(av);
463 463
464 if (ai->max_sqnum < sqnum) 464 if (ai->max_sqnum < sqnum)
465 ai->max_sqnum = sqnum; 465 ai->max_sqnum = sqnum;
@@ -468,7 +468,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai,
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
469 * if this is the first instance of this logical eraseblock or not. 469 * if this is the first instance of this logical eraseblock or not.
470 */ 470 */
471 p = &sv->root.rb_node; 471 p = &av->root.rb_node;
472 while (*p) { 472 while (*p) {
473 int cmp_res; 473 int cmp_res;
474 474
@@ -524,7 +524,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai,
524 * This logical eraseblock is newer than the one 524 * This logical eraseblock is newer than the one
525 * found earlier. 525 * found earlier.
526 */ 526 */
527 err = validate_vid_hdr(vid_hdr, sv, pnum); 527 err = validate_vid_hdr(vid_hdr, av, pnum);
528 if (err) 528 if (err)
529 return err; 529 return err;
530 530
@@ -539,8 +539,8 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai,
539 aeb->copy_flag = vid_hdr->copy_flag; 539 aeb->copy_flag = vid_hdr->copy_flag;
540 aeb->sqnum = sqnum; 540 aeb->sqnum = sqnum;
541 541
542 if (sv->highest_lnum == lnum) 542 if (av->highest_lnum == lnum)
543 sv->last_data_size = 543 av->last_data_size =
544 be32_to_cpu(vid_hdr->data_size); 544 be32_to_cpu(vid_hdr->data_size);
545 545
546 return 0; 546 return 0;
@@ -559,7 +559,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai,
559 * attaching information. 559 * attaching information.
560 */ 560 */
561 561
562 err = validate_vid_hdr(vid_hdr, sv, pnum); 562 err = validate_vid_hdr(vid_hdr, av, pnum);
563 if (err) 563 if (err)
564 return err; 564 return err;
565 565
@@ -574,38 +574,38 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai,
574 aeb->copy_flag = vid_hdr->copy_flag; 574 aeb->copy_flag = vid_hdr->copy_flag;
575 aeb->sqnum = sqnum; 575 aeb->sqnum = sqnum;
576 576
577 if (sv->highest_lnum <= lnum) { 577 if (av->highest_lnum <= lnum) {
578 sv->highest_lnum = lnum; 578 av->highest_lnum = lnum;
579 sv->last_data_size = be32_to_cpu(vid_hdr->data_size); 579 av->last_data_size = be32_to_cpu(vid_hdr->data_size);
580 } 580 }
581 581
582 sv->leb_count += 1; 582 av->leb_count += 1;
583 rb_link_node(&aeb->u.rb, parent, p); 583 rb_link_node(&aeb->u.rb, parent, p);
584 rb_insert_color(&aeb->u.rb, &sv->root); 584 rb_insert_color(&aeb->u.rb, &av->root);
585 return 0; 585 return 0;
586} 586}
587 587
588/** 588/**
589 * ubi_scan_find_sv - find volume in the attaching information. 589 * ubi_scan_find_av - find volume in the attaching information.
590 * @ai: attaching 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 attaching 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 *ai, 596struct ubi_ainf_volume *ubi_scan_find_av(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 *av;
600 struct rb_node *p = ai->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 av = rb_entry(p, struct ubi_ainf_volume, rb);
604 604
605 if (vol_id == sv->vol_id) 605 if (vol_id == av->vol_id)
606 return sv; 606 return av;
607 607
608 if (vol_id > sv->vol_id) 608 if (vol_id > av->vol_id)
609 p = p->rb_left; 609 p = p->rb_left;
610 else 610 else
611 p = p->rb_right; 611 p = p->rb_right;
@@ -616,17 +616,17 @@ struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *ai,
616 616
617/** 617/**
618 * ubi_scan_find_aeb - find LEB in the volume attaching information. 618 * ubi_scan_find_aeb - find LEB in the volume attaching information.
619 * @sv: a pointer to the volume attaching information 619 * @av: 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
623 * if there are no data about it in the scanning volume information. 623 * if there are no data about it in the scanning volume information.
624 */ 624 */
625struct ubi_ainf_peb *ubi_scan_find_aeb(const struct ubi_ainf_volume *sv, 625struct ubi_ainf_peb *ubi_scan_find_aeb(const struct ubi_ainf_volume *av,
626 int lnum) 626 int lnum)
627{ 627{
628 struct ubi_ainf_peb *aeb; 628 struct ubi_ainf_peb *aeb;
629 struct rb_node *p = sv->root.rb_node; 629 struct rb_node *p = av->root.rb_node;
630 630
631 while (p) { 631 while (p) {
632 aeb = rb_entry(p, struct ubi_ainf_peb, u.rb); 632 aeb = rb_entry(p, struct ubi_ainf_peb, u.rb);
@@ -646,23 +646,23 @@ struct ubi_ainf_peb *ubi_scan_find_aeb(const struct ubi_ainf_volume *sv,
646/** 646/**
647 * ubi_scan_rm_volume - delete attaching information about a volume. 647 * ubi_scan_rm_volume - delete attaching information about a volume.
648 * @ai: attaching information 648 * @ai: attaching information
649 * @sv: the volume attaching information to delete 649 * @av: the volume attaching information to delete
650 */ 650 */
651void ubi_scan_rm_volume(struct ubi_attach_info *ai, struct ubi_ainf_volume *sv) 651void ubi_scan_rm_volume(struct ubi_attach_info *ai, struct ubi_ainf_volume *av)
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 attaching information about volume %d", sv->vol_id); 656 dbg_bld("remove attaching information about volume %d", av->vol_id);
657 657
658 while ((rb = rb_first(&sv->root))) { 658 while ((rb = rb_first(&av->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, &av->root);
661 list_add_tail(&aeb->u.list, &ai->erase); 661 list_add_tail(&aeb->u.list, &ai->erase);
662 } 662 }
663 663
664 rb_erase(&sv->rb, &ai->volumes); 664 rb_erase(&av->rb, &ai->volumes);
665 kfree(sv); 665 kfree(av);
666 ai->vols_found -= 1; 666 ai->vols_found -= 1;
667} 667}
668 668
@@ -1148,7 +1148,7 @@ struct ubi_attach_info *ubi_scan(struct ubi_device *ubi)
1148{ 1148{
1149 int err, pnum; 1149 int err, pnum;
1150 struct rb_node *rb1, *rb2; 1150 struct rb_node *rb1, *rb2;
1151 struct ubi_ainf_volume *sv; 1151 struct ubi_ainf_volume *av;
1152 struct ubi_ainf_peb *aeb; 1152 struct ubi_ainf_peb *aeb;
1153 struct ubi_attach_info *ai; 1153 struct ubi_attach_info *ai;
1154 1154
@@ -1200,8 +1200,8 @@ 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, &ai->volumes, rb) { 1203 ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb) {
1204 ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) 1204 ubi_rb_for_each_entry(rb2, aeb, &av->root, u.rb)
1205 if (aeb->ec == UBI_SCAN_UNKNOWN_EC) 1205 if (aeb->ec == UBI_SCAN_UNKNOWN_EC)
1206 aeb->ec = ai->mean_ec; 1206 aeb->ec = ai->mean_ec;
1207 } 1207 }
@@ -1238,17 +1238,17 @@ out_ai:
1238} 1238}
1239 1239
1240/** 1240/**
1241 * destroy_sv - free the scanning volume information 1241 * destroy_av - free the scanning volume information
1242 * @sv: scanning volume information 1242 * @av: scanning volume information
1243 * @ai: attaching 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 (@av->root) and the scanning
1246 * volume information. 1246 * volume information.
1247 */ 1247 */
1248static void destroy_sv(struct ubi_attach_info *ai, struct ubi_ainf_volume *sv) 1248static void destroy_av(struct ubi_attach_info *ai, struct ubi_ainf_volume *av)
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 = av->root.rb_node;
1252 1252
1253 while (this) { 1253 while (this) {
1254 if (this->rb_left) 1254 if (this->rb_left)
@@ -1268,7 +1268,7 @@ static void destroy_sv(struct ubi_attach_info *ai, struct ubi_ainf_volume *sv)
1268 kmem_cache_free(ai->scan_leb_slab, aeb); 1268 kmem_cache_free(ai->scan_leb_slab, aeb);
1269 } 1269 }
1270 } 1270 }
1271 kfree(sv); 1271 kfree(av);
1272} 1272}
1273 1273
1274/** 1274/**
@@ -1278,7 +1278,7 @@ static void destroy_sv(struct ubi_attach_info *ai, struct ubi_ainf_volume *sv)
1278void ubi_scan_destroy_ai(struct ubi_attach_info *ai) 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 *av;
1282 struct rb_node *rb; 1282 struct rb_node *rb;
1283 1283
1284 list_for_each_entry_safe(aeb, aeb_tmp, &ai->alien, u.list) { 1284 list_for_each_entry_safe(aeb, aeb_tmp, &ai->alien, u.list) {
@@ -1306,17 +1306,17 @@ void ubi_scan_destroy_ai(struct ubi_attach_info *ai)
1306 else if (rb->rb_right) 1306 else if (rb->rb_right)
1307 rb = rb->rb_right; 1307 rb = rb->rb_right;
1308 else { 1308 else {
1309 sv = rb_entry(rb, struct ubi_ainf_volume, rb); 1309 av = rb_entry(rb, struct ubi_ainf_volume, rb);
1310 1310
1311 rb = rb_parent(rb); 1311 rb = rb_parent(rb);
1312 if (rb) { 1312 if (rb) {
1313 if (rb->rb_left == &sv->rb) 1313 if (rb->rb_left == &av->rb)
1314 rb->rb_left = NULL; 1314 rb->rb_left = NULL;
1315 else 1315 else
1316 rb->rb_right = NULL; 1316 rb->rb_right = NULL;
1317 } 1317 }
1318 1318
1319 destroy_sv(ai, sv); 1319 destroy_av(ai, av);
1320 } 1320 }
1321 } 1321 }
1322 1322
@@ -1338,7 +1338,7 @@ static 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;
1341 struct ubi_ainf_volume *sv; 1341 struct ubi_ainf_volume *av;
1342 struct ubi_ainf_peb *aeb, *last_aeb; 1342 struct ubi_ainf_peb *aeb, *last_aeb;
1343 uint8_t *buf; 1343 uint8_t *buf;
1344 1344
@@ -1348,7 +1348,7 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1348 /* 1348 /*
1349 * At first, check that attaching information is OK. 1349 * At first, check that attaching information is OK.
1350 */ 1350 */
1351 ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) { 1351 ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb) {
1352 int leb_count = 0; 1352 int leb_count = 0;
1353 1353
1354 cond_resched(); 1354 cond_resched();
@@ -1357,41 +1357,41 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1357 1357
1358 if (ai->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_av;
1361 } 1361 }
1362 1362
1363 if (sv->vol_id < 0 || sv->highest_lnum < 0 || 1363 if (av->vol_id < 0 || av->highest_lnum < 0 ||
1364 sv->leb_count < 0 || sv->vol_type < 0 || sv->used_ebs < 0 || 1364 av->leb_count < 0 || av->vol_type < 0 || av->used_ebs < 0 ||
1365 sv->data_pad < 0 || sv->last_data_size < 0) { 1365 av->data_pad < 0 || av->last_data_size < 0) {
1366 ubi_err("negative values"); 1366 ubi_err("negative values");
1367 goto bad_sv; 1367 goto bad_av;
1368 } 1368 }
1369 1369
1370 if (sv->vol_id >= UBI_MAX_VOLUMES && 1370 if (av->vol_id >= UBI_MAX_VOLUMES &&
1371 sv->vol_id < UBI_INTERNAL_VOL_START) { 1371 av->vol_id < UBI_INTERNAL_VOL_START) {
1372 ubi_err("bad vol_id"); 1372 ubi_err("bad vol_id");
1373 goto bad_sv; 1373 goto bad_av;
1374 } 1374 }
1375 1375
1376 if (sv->vol_id > ai->highest_vol_id) { 1376 if (av->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 ai->highest_vol_id, sv->vol_id); 1378 ai->highest_vol_id, av->vol_id);
1379 goto out; 1379 goto out;
1380 } 1380 }
1381 1381
1382 if (sv->vol_type != UBI_DYNAMIC_VOLUME && 1382 if (av->vol_type != UBI_DYNAMIC_VOLUME &&
1383 sv->vol_type != UBI_STATIC_VOLUME) { 1383 av->vol_type != UBI_STATIC_VOLUME) {
1384 ubi_err("bad vol_type"); 1384 ubi_err("bad vol_type");
1385 goto bad_sv; 1385 goto bad_av;
1386 } 1386 }
1387 1387
1388 if (sv->data_pad > ubi->leb_size / 2) { 1388 if (av->data_pad > ubi->leb_size / 2) {
1389 ubi_err("bad data_pad"); 1389 ubi_err("bad data_pad");
1390 goto bad_sv; 1390 goto bad_av;
1391 } 1391 }
1392 1392
1393 last_aeb = NULL; 1393 last_aeb = NULL;
1394 ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) { 1394 ubi_rb_for_each_entry(rb2, aeb, &av->root, u.rb) {
1395 cond_resched(); 1395 cond_resched();
1396 1396
1397 last_aeb = aeb; 1397 last_aeb = aeb;
@@ -1420,28 +1420,28 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1420 goto bad_aeb; 1420 goto bad_aeb;
1421 } 1421 }
1422 1422
1423 if (sv->vol_type == UBI_STATIC_VOLUME) { 1423 if (av->vol_type == UBI_STATIC_VOLUME) {
1424 if (aeb->lnum >= sv->used_ebs) { 1424 if (aeb->lnum >= av->used_ebs) {
1425 ubi_err("bad lnum or used_ebs"); 1425 ubi_err("bad lnum or used_ebs");
1426 goto bad_aeb; 1426 goto bad_aeb;
1427 } 1427 }
1428 } else { 1428 } else {
1429 if (sv->used_ebs != 0) { 1429 if (av->used_ebs != 0) {
1430 ubi_err("non-zero used_ebs"); 1430 ubi_err("non-zero used_ebs");
1431 goto bad_aeb; 1431 goto bad_aeb;
1432 } 1432 }
1433 } 1433 }
1434 1434
1435 if (aeb->lnum > sv->highest_lnum) { 1435 if (aeb->lnum > av->highest_lnum) {
1436 ubi_err("incorrect highest_lnum or lnum"); 1436 ubi_err("incorrect highest_lnum or lnum");
1437 goto bad_aeb; 1437 goto bad_aeb;
1438 } 1438 }
1439 } 1439 }
1440 1440
1441 if (sv->leb_count != leb_count) { 1441 if (av->leb_count != leb_count) {
1442 ubi_err("bad leb_count, %d objects in the tree", 1442 ubi_err("bad leb_count, %d objects in the tree",
1443 leb_count); 1443 leb_count);
1444 goto bad_sv; 1444 goto bad_av;
1445 } 1445 }
1446 1446
1447 if (!last_aeb) 1447 if (!last_aeb)
@@ -1449,7 +1449,7 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1449 1449
1450 aeb = last_aeb; 1450 aeb = last_aeb;
1451 1451
1452 if (aeb->lnum != sv->highest_lnum) { 1452 if (aeb->lnum != av->highest_lnum) {
1453 ubi_err("bad highest_lnum"); 1453 ubi_err("bad highest_lnum");
1454 goto bad_aeb; 1454 goto bad_aeb;
1455 } 1455 }
@@ -1462,9 +1462,9 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1462 } 1462 }
1463 1463
1464 /* Check that attaching information is correct */ 1464 /* Check that attaching information is correct */
1465 ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) { 1465 ubi_rb_for_each_entry(rb1, av, &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, &av->root, u.rb) {
1468 int vol_type; 1468 int vol_type;
1469 1469
1470 cond_resched(); 1470 cond_resched();
@@ -1481,7 +1481,7 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1481 1481
1482 vol_type = vidh->vol_type == UBI_VID_DYNAMIC ? 1482 vol_type = vidh->vol_type == UBI_VID_DYNAMIC ?
1483 UBI_DYNAMIC_VOLUME : UBI_STATIC_VOLUME; 1483 UBI_DYNAMIC_VOLUME : UBI_STATIC_VOLUME;
1484 if (sv->vol_type != vol_type) { 1484 if (av->vol_type != vol_type) {
1485 ubi_err("bad vol_type"); 1485 ubi_err("bad vol_type");
1486 goto bad_vid_hdr; 1486 goto bad_vid_hdr;
1487 } 1487 }
@@ -1491,12 +1491,12 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1491 goto bad_vid_hdr; 1491 goto bad_vid_hdr;
1492 } 1492 }
1493 1493
1494 if (sv->vol_id != be32_to_cpu(vidh->vol_id)) { 1494 if (av->vol_id != be32_to_cpu(vidh->vol_id)) {
1495 ubi_err("bad vol_id %d", sv->vol_id); 1495 ubi_err("bad vol_id %d", av->vol_id);
1496 goto bad_vid_hdr; 1496 goto bad_vid_hdr;
1497 } 1497 }
1498 1498
1499 if (sv->compat != vidh->compat) { 1499 if (av->compat != vidh->compat) {
1500 ubi_err("bad compat %d", vidh->compat); 1500 ubi_err("bad compat %d", vidh->compat);
1501 goto bad_vid_hdr; 1501 goto bad_vid_hdr;
1502 } 1502 }
@@ -1506,13 +1506,13 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1506 goto bad_vid_hdr; 1506 goto bad_vid_hdr;
1507 } 1507 }
1508 1508
1509 if (sv->used_ebs != be32_to_cpu(vidh->used_ebs)) { 1509 if (av->used_ebs != be32_to_cpu(vidh->used_ebs)) {
1510 ubi_err("bad used_ebs %d", sv->used_ebs); 1510 ubi_err("bad used_ebs %d", av->used_ebs);
1511 goto bad_vid_hdr; 1511 goto bad_vid_hdr;
1512 } 1512 }
1513 1513
1514 if (sv->data_pad != be32_to_cpu(vidh->data_pad)) { 1514 if (av->data_pad != be32_to_cpu(vidh->data_pad)) {
1515 ubi_err("bad data_pad %d", sv->data_pad); 1515 ubi_err("bad data_pad %d", av->data_pad);
1516 goto bad_vid_hdr; 1516 goto bad_vid_hdr;
1517 } 1517 }
1518 } 1518 }
@@ -1520,13 +1520,13 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1520 if (!last_aeb) 1520 if (!last_aeb)
1521 continue; 1521 continue;
1522 1522
1523 if (sv->highest_lnum != be32_to_cpu(vidh->lnum)) { 1523 if (av->highest_lnum != be32_to_cpu(vidh->lnum)) {
1524 ubi_err("bad highest_lnum %d", sv->highest_lnum); 1524 ubi_err("bad highest_lnum %d", av->highest_lnum);
1525 goto bad_vid_hdr; 1525 goto bad_vid_hdr;
1526 } 1526 }
1527 1527
1528 if (sv->last_data_size != be32_to_cpu(vidh->data_size)) { 1528 if (av->last_data_size != be32_to_cpu(vidh->data_size)) {
1529 ubi_err("bad last_data_size %d", sv->last_data_size); 1529 ubi_err("bad last_data_size %d", av->last_data_size);
1530 goto bad_vid_hdr; 1530 goto bad_vid_hdr;
1531 } 1531 }
1532 } 1532 }
@@ -1548,8 +1548,8 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1548 buf[pnum] = 1; 1548 buf[pnum] = 1;
1549 } 1549 }
1550 1550
1551 ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) 1551 ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb)
1552 ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) 1552 ubi_rb_for_each_entry(rb2, aeb, &av->root, u.rb)
1553 buf[aeb->pnum] = 1; 1553 buf[aeb->pnum] = 1;
1554 1554
1555 list_for_each_entry(aeb, &ai->free, u.list) 1555 list_for_each_entry(aeb, &ai->free, u.list)
@@ -1579,17 +1579,17 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1579bad_aeb: 1579bad_aeb:
1580 ubi_err("bad attaching 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_av(av);
1583 goto out; 1583 goto out;
1584 1584
1585bad_sv: 1585bad_av:
1586 ubi_err("bad attaching information about volume %d", sv->vol_id); 1586 ubi_err("bad attaching information about volume %d", av->vol_id);
1587 ubi_dump_sv(sv); 1587 ubi_dump_av(av);
1588 goto out; 1588 goto out;
1589 1589
1590bad_vid_hdr: 1590bad_vid_hdr:
1591 ubi_err("bad attaching information about volume %d", sv->vol_id); 1591 ubi_err("bad attaching information about volume %d", av->vol_id);
1592 ubi_dump_sv(sv); 1592 ubi_dump_av(av);
1593 ubi_dump_vid_hdr(vidh); 1593 ubi_dump_vid_hdr(vidh);
1594 1594
1595out: 1595out:
diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h
index 0f0725e18b7f..3e19cb665a55 100644
--- a/drivers/mtd/ubi/scan.h
+++ b/drivers/mtd/ubi/scan.h
@@ -145,26 +145,26 @@ 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 attaching information 148 * @av: 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 */
152static inline void ubi_scan_move_to_list(struct ubi_ainf_volume *sv, 152static inline void ubi_scan_move_to_list(struct ubi_ainf_volume *av,
153 struct ubi_ainf_peb *aeb, 153 struct ubi_ainf_peb *aeb,
154 struct list_head *list) 154 struct list_head *list)
155{ 155{
156 rb_erase(&aeb->u.rb, &sv->root); 156 rb_erase(&aeb->u.rb, &av->root);
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 *ai, 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 *ai, 163struct ubi_ainf_volume *ubi_scan_find_av(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 *av,
166 int lnum); 166 int lnum);
167void ubi_scan_rm_volume(struct ubi_attach_info *ai, struct ubi_ainf_volume *sv); 167void ubi_scan_rm_volume(struct ubi_attach_info *ai, struct ubi_ainf_volume *av);
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 *ai); 169 struct ubi_attach_info *ai);
170int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_attach_info *ai, 170int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_attach_info *ai,
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 3e5363c9945e..0ea105b1a68b 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -366,7 +366,7 @@ out_free:
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 * @ai: attaching information 368 * @ai: attaching information
369 * @sv: layout volume attaching information 369 * @av: 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
@@ -374,7 +374,7 @@ out_free:
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 *ai, 376 struct ubi_attach_info *ai,
377 struct ubi_ainf_volume *sv) 377 struct ubi_ainf_volume *av)
378{ 378{
379 int err; 379 int err;
380 struct rb_node *rb; 380 struct rb_node *rb;
@@ -410,7 +410,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
410 dbg_gen("check layout volume"); 410 dbg_gen("check layout volume");
411 411
412 /* Read both LEB 0 and LEB 1 into memory */ 412 /* Read both LEB 0 and LEB 1 into memory */
413 ubi_rb_for_each_entry(rb, aeb, &sv->root, u.rb) { 413 ubi_rb_for_each_entry(rb, aeb, &av->root, u.rb) {
414 leb[aeb->lnum] = vzalloc(ubi->vtbl_size); 414 leb[aeb->lnum] = vzalloc(ubi->vtbl_size);
415 if (!leb[aeb->lnum]) { 415 if (!leb[aeb->lnum]) {
416 err = -ENOMEM; 416 err = -ENOMEM;
@@ -536,7 +536,7 @@ static int init_volumes(struct ubi_device *ubi,
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;
539 struct ubi_ainf_volume *sv; 539 struct ubi_ainf_volume *av;
540 struct ubi_volume *vol; 540 struct ubi_volume *vol;
541 541
542 for (i = 0; i < ubi->vtbl_slots; i++) { 542 for (i = 0; i < ubi->vtbl_slots; i++) {
@@ -592,8 +592,8 @@ 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(ai, i); 595 av = ubi_scan_find_av(ai, i);
596 if (!sv) { 596 if (!av) {
597 /* 597 /*
598 * No eraseblocks belonging to this volume found. We 598 * No eraseblocks belonging to this volume found. We
599 * don't actually know whether this static volume is 599 * don't actually know whether this static volume is
@@ -605,22 +605,22 @@ static int init_volumes(struct ubi_device *ubi,
605 continue; 605 continue;
606 } 606 }
607 607
608 if (sv->leb_count != sv->used_ebs) { 608 if (av->leb_count != av->used_ebs) {
609 /* 609 /*
610 * We found a static volume which misses several 610 * We found a static volume which misses several
611 * eraseblocks. Treat it as corrupted. 611 * eraseblocks. Treat it as corrupted.
612 */ 612 */
613 ubi_warn("static volume %d misses %d LEBs - corrupted", 613 ubi_warn("static volume %d misses %d LEBs - corrupted",
614 sv->vol_id, sv->used_ebs - sv->leb_count); 614 av->vol_id, av->used_ebs - av->leb_count);
615 vol->corrupted = 1; 615 vol->corrupted = 1;
616 continue; 616 continue;
617 } 617 }
618 618
619 vol->used_ebs = sv->used_ebs; 619 vol->used_ebs = av->used_ebs;
620 vol->used_bytes = 620 vol->used_bytes =
621 (long long)(vol->used_ebs - 1) * vol->usable_leb_size; 621 (long long)(vol->used_ebs - 1) * vol->usable_leb_size;
622 vol->used_bytes += sv->last_data_size; 622 vol->used_bytes += av->last_data_size;
623 vol->last_eb_bytes = sv->last_data_size; 623 vol->last_eb_bytes = av->last_data_size;
624 } 624 }
625 625
626 /* And add the layout volume */ 626 /* And add the layout volume */
@@ -661,35 +661,35 @@ static int init_volumes(struct ubi_device *ubi,
661} 661}
662 662
663/** 663/**
664 * check_sv - check volume attaching information. 664 * check_av - check volume attaching information.
665 * @vol: UBI volume description object 665 * @vol: UBI volume description object
666 * @sv: volume attaching information 666 * @av: volume attaching information
667 * 667 *
668 * This function returns zero if the volume attaching 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_av(const struct ubi_volume *vol,
672 const struct ubi_ainf_volume *sv) 672 const struct ubi_ainf_volume *av)
673{ 673{
674 int err; 674 int err;
675 675
676 if (sv->highest_lnum >= vol->reserved_pebs) { 676 if (av->highest_lnum >= vol->reserved_pebs) {
677 err = 1; 677 err = 1;
678 goto bad; 678 goto bad;
679 } 679 }
680 if (sv->leb_count > vol->reserved_pebs) { 680 if (av->leb_count > vol->reserved_pebs) {
681 err = 2; 681 err = 2;
682 goto bad; 682 goto bad;
683 } 683 }
684 if (sv->vol_type != vol->vol_type) { 684 if (av->vol_type != vol->vol_type) {
685 err = 3; 685 err = 3;
686 goto bad; 686 goto bad;
687 } 687 }
688 if (sv->used_ebs > vol->reserved_pebs) { 688 if (av->used_ebs > vol->reserved_pebs) {
689 err = 4; 689 err = 4;
690 goto bad; 690 goto bad;
691 } 691 }
692 if (sv->data_pad != vol->data_pad) { 692 if (av->data_pad != vol->data_pad) {
693 err = 5; 693 err = 5;
694 goto bad; 694 goto bad;
695 } 695 }
@@ -697,7 +697,7 @@ static int check_sv(const struct ubi_volume *vol,
697 697
698bad: 698bad:
699 ubi_err("bad attaching information, error %d", err); 699 ubi_err("bad attaching information, error %d", err);
700 ubi_dump_sv(sv); 700 ubi_dump_av(av);
701 ubi_dump_vol_info(vol); 701 ubi_dump_vol_info(vol);
702 return -EINVAL; 702 return -EINVAL;
703} 703}
@@ -716,7 +716,7 @@ static int check_scanning_info(const struct ubi_device *ubi,
716 struct ubi_attach_info *ai) 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 *av;
720 struct ubi_volume *vol; 720 struct ubi_volume *vol;
721 721
722 if (ai->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) { 722 if (ai->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) {
@@ -735,18 +735,18 @@ static int check_scanning_info(const struct ubi_device *ubi,
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(ai, i); 738 av = ubi_scan_find_av(ai, i);
739 vol = ubi->volumes[i]; 739 vol = ubi->volumes[i];
740 if (!vol) { 740 if (!vol) {
741 if (sv) 741 if (av)
742 ubi_scan_rm_volume(ai, sv); 742 ubi_scan_rm_volume(ai, av);
743 continue; 743 continue;
744 } 744 }
745 745
746 if (vol->reserved_pebs == 0) { 746 if (vol->reserved_pebs == 0) {
747 ubi_assert(i < ubi->vtbl_slots); 747 ubi_assert(i < ubi->vtbl_slots);
748 748
749 if (!sv) 749 if (!av)
750 continue; 750 continue;
751 751
752 /* 752 /*
@@ -756,10 +756,10 @@ static int check_scanning_info(const struct ubi_device *ubi,
756 * reboot while the volume was being removed. Discard 756 * reboot while the volume was being removed. Discard
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", av->vol_id);
760 ubi_scan_rm_volume(ai, sv); 760 ubi_scan_rm_volume(ai, av);
761 } else if (sv) { 761 } else if (av) {
762 err = check_sv(vol, sv); 762 err = check_av(vol, av);
763 if (err) 763 if (err)
764 return err; 764 return err;
765 } 765 }
@@ -780,7 +780,7 @@ static int check_scanning_info(const struct ubi_device *ubi,
780int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) 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 *av;
784 784
785 empty_vtbl_record.crc = cpu_to_be32(0xf116c36b); 785 empty_vtbl_record.crc = cpu_to_be32(0xf116c36b);
786 786
@@ -795,8 +795,8 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai)
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(ai, UBI_LAYOUT_VOLUME_ID); 798 av = ubi_scan_find_av(ai, UBI_LAYOUT_VOLUME_ID);
799 if (!sv) { 799 if (!av) {
800 /* 800 /*
801 * No logical eraseblocks belonging to the layout volume were 801 * No logical eraseblocks belonging to the layout volume were
802 * found. This could mean that the flash is just empty. In 802 * found. This could mean that the flash is just empty. In
@@ -814,14 +814,14 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai)
814 return -EINVAL; 814 return -EINVAL;
815 } 815 }
816 } else { 816 } else {
817 if (sv->leb_count > UBI_LAYOUT_VOLUME_EBS) { 817 if (av->leb_count > UBI_LAYOUT_VOLUME_EBS) {
818 /* This must not happen with proper UBI images */ 818 /* This must not happen with proper UBI images */
819 ubi_err("too many LEBs (%d) in layout volume", 819 ubi_err("too many LEBs (%d) in layout volume",
820 sv->leb_count); 820 av->leb_count);
821 return -EINVAL; 821 return -EINVAL;
822 } 822 }
823 823
824 ubi->vtbl = process_lvol(ubi, ai, sv); 824 ubi->vtbl = process_lvol(ubi, ai, av);
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 }
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 992240dae1b1..72fbae1f0a5d 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1384,7 +1384,7 @@ int 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;
1387 struct ubi_ainf_volume *sv; 1387 struct ubi_ainf_volume *av;
1388 struct ubi_ainf_peb *aeb, *tmp; 1388 struct ubi_ainf_peb *aeb, *tmp;
1389 struct ubi_wl_entry *e; 1389 struct ubi_wl_entry *e;
1390 1390
@@ -1436,8 +1436,8 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai)
1436 ubi->lookuptbl[e->pnum] = e; 1436 ubi->lookuptbl[e->pnum] = e;
1437 } 1437 }
1438 1438
1439 ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) { 1439 ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb) {
1440 ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) { 1440 ubi_rb_for_each_entry(rb2, aeb, &av->root, u.rb) {
1441 cond_resched(); 1441 cond_resched();
1442 1442
1443 e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL); 1443 e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL);