diff options
Diffstat (limited to 'drivers/mtd/ubi/vtbl.c')
-rw-r--r-- | drivers/mtd/ubi/vtbl.c | 72 |
1 files changed, 36 insertions, 36 deletions
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 | */ |
375 | static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, | 375 | static 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 | */ |
671 | static int check_sv(const struct ubi_volume *vol, | 671 | static 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 | ||
698 | bad: | 698 | bad: |
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, | |||
780 | int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) | 780 | int 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 | } |