aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/scan.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-05-17 07:38:34 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-05-20 13:26:02 -0400
commit517af48c0540e61bbe0ebbb5f463afe937b73894 (patch)
treee97c38c582bf92682a254d6f5bc823c86d0572d5 /drivers/mtd/ubi/scan.c
parenta4e6042f1d073073f88e0ad6d2a7450da9a3937d (diff)
UBI: rename sv to av
After re-naming the 'struct ubi_scan_volume' we should adjust all variables named 'sv' to something else, because 'sv' stands for "scanning volume". Let's rename it to 'av' which stands for "attaching volume" which is a bit more consistent and has the same length, which makes re-naming easy. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd/ubi/scan.c')
-rw-r--r--drivers/mtd/ubi/scan.c240
1 files changed, 120 insertions, 120 deletions
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: