aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/vtbl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/ubi/vtbl.c')
-rw-r--r--drivers/mtd/ubi/vtbl.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 07cac5f9ffb8..1931dffe87b0 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -190,7 +190,7 @@ static int vtbl_check(const struct ubi_device *ubi,
190 190
191 crc = crc32(UBI_CRC32_INIT, &vtbl[i], UBI_VTBL_RECORD_SIZE_CRC); 191 crc = crc32(UBI_CRC32_INIT, &vtbl[i], UBI_VTBL_RECORD_SIZE_CRC);
192 if (be32_to_cpu(vtbl[i].crc) != crc) { 192 if (be32_to_cpu(vtbl[i].crc) != crc) {
193 ubi_err("bad CRC at record %u: %#08x, not %#08x", 193 ubi_err(ubi, "bad CRC at record %u: %#08x, not %#08x",
194 i, crc, be32_to_cpu(vtbl[i].crc)); 194 i, crc, be32_to_cpu(vtbl[i].crc));
195 ubi_dump_vtbl_record(&vtbl[i], i); 195 ubi_dump_vtbl_record(&vtbl[i], i);
196 return 1; 196 return 1;
@@ -224,7 +224,7 @@ static int vtbl_check(const struct ubi_device *ubi,
224 224
225 n = ubi->leb_size % alignment; 225 n = ubi->leb_size % alignment;
226 if (data_pad != n) { 226 if (data_pad != n) {
227 ubi_err("bad data_pad, has to be %d", n); 227 ubi_err(ubi, "bad data_pad, has to be %d", n);
228 err = 6; 228 err = 6;
229 goto bad; 229 goto bad;
230 } 230 }
@@ -240,7 +240,7 @@ static int vtbl_check(const struct ubi_device *ubi,
240 } 240 }
241 241
242 if (reserved_pebs > ubi->good_peb_count) { 242 if (reserved_pebs > ubi->good_peb_count) {
243 ubi_err("too large reserved_pebs %d, good PEBs %d", 243 ubi_err(ubi, "too large reserved_pebs %d, good PEBs %d",
244 reserved_pebs, ubi->good_peb_count); 244 reserved_pebs, ubi->good_peb_count);
245 err = 9; 245 err = 9;
246 goto bad; 246 goto bad;
@@ -270,7 +270,7 @@ static int vtbl_check(const struct ubi_device *ubi,
270 270
271 if (len1 > 0 && len1 == len2 && 271 if (len1 > 0 && len1 == len2 &&
272 !strncmp(vtbl[i].name, vtbl[n].name, len1)) { 272 !strncmp(vtbl[i].name, vtbl[n].name, len1)) {
273 ubi_err("volumes %d and %d have the same name \"%s\"", 273 ubi_err(ubi, "volumes %d and %d have the same name \"%s\"",
274 i, n, vtbl[i].name); 274 i, n, vtbl[i].name);
275 ubi_dump_vtbl_record(&vtbl[i], i); 275 ubi_dump_vtbl_record(&vtbl[i], i);
276 ubi_dump_vtbl_record(&vtbl[n], n); 276 ubi_dump_vtbl_record(&vtbl[n], n);
@@ -282,7 +282,7 @@ static int vtbl_check(const struct ubi_device *ubi,
282 return 0; 282 return 0;
283 283
284bad: 284bad:
285 ubi_err("volume table check failed: record %d, error %d", i, err); 285 ubi_err(ubi, "volume table check failed: record %d, error %d", i, err);
286 ubi_dump_vtbl_record(&vtbl[i], i); 286 ubi_dump_vtbl_record(&vtbl[i], i);
287 return -EINVAL; 287 return -EINVAL;
288} 288}
@@ -446,11 +446,11 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
446 leb_corrupted[1] = memcmp(leb[0], leb[1], 446 leb_corrupted[1] = memcmp(leb[0], leb[1],
447 ubi->vtbl_size); 447 ubi->vtbl_size);
448 if (leb_corrupted[1]) { 448 if (leb_corrupted[1]) {
449 ubi_warn("volume table copy #2 is corrupted"); 449 ubi_warn(ubi, "volume table copy #2 is corrupted");
450 err = create_vtbl(ubi, ai, 1, leb[0]); 450 err = create_vtbl(ubi, ai, 1, leb[0]);
451 if (err) 451 if (err)
452 goto out_free; 452 goto out_free;
453 ubi_msg("volume table was restored"); 453 ubi_msg(ubi, "volume table was restored");
454 } 454 }
455 455
456 /* Both LEB 1 and LEB 2 are OK and consistent */ 456 /* Both LEB 1 and LEB 2 are OK and consistent */
@@ -465,15 +465,15 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
465 } 465 }
466 if (leb_corrupted[1]) { 466 if (leb_corrupted[1]) {
467 /* Both LEB 0 and LEB 1 are corrupted */ 467 /* Both LEB 0 and LEB 1 are corrupted */
468 ubi_err("both volume tables are corrupted"); 468 ubi_err(ubi, "both volume tables are corrupted");
469 goto out_free; 469 goto out_free;
470 } 470 }
471 471
472 ubi_warn("volume table copy #1 is corrupted"); 472 ubi_warn(ubi, "volume table copy #1 is corrupted");
473 err = create_vtbl(ubi, ai, 0, leb[1]); 473 err = create_vtbl(ubi, ai, 0, leb[1]);
474 if (err) 474 if (err)
475 goto out_free; 475 goto out_free;
476 ubi_msg("volume table was restored"); 476 ubi_msg(ubi, "volume table was restored");
477 477
478 vfree(leb[0]); 478 vfree(leb[0]);
479 return leb[1]; 479 return leb[1];
@@ -562,7 +562,7 @@ static int init_volumes(struct ubi_device *ubi,
562 if (vtbl[i].flags & UBI_VTBL_AUTORESIZE_FLG) { 562 if (vtbl[i].flags & UBI_VTBL_AUTORESIZE_FLG) {
563 /* Auto re-size flag may be set only for one volume */ 563 /* Auto re-size flag may be set only for one volume */
564 if (ubi->autoresize_vol_id != -1) { 564 if (ubi->autoresize_vol_id != -1) {
565 ubi_err("more than one auto-resize volume (%d and %d)", 565 ubi_err(ubi, "more than one auto-resize volume (%d and %d)",
566 ubi->autoresize_vol_id, i); 566 ubi->autoresize_vol_id, i);
567 kfree(vol); 567 kfree(vol);
568 return -EINVAL; 568 return -EINVAL;
@@ -608,7 +608,7 @@ static int init_volumes(struct ubi_device *ubi,
608 * We found a static volume which misses several 608 * We found a static volume which misses several
609 * eraseblocks. Treat it as corrupted. 609 * eraseblocks. Treat it as corrupted.
610 */ 610 */
611 ubi_warn("static volume %d misses %d LEBs - corrupted", 611 ubi_warn(ubi, "static volume %d misses %d LEBs - corrupted",
612 av->vol_id, av->used_ebs - av->leb_count); 612 av->vol_id, av->used_ebs - av->leb_count);
613 vol->corrupted = 1; 613 vol->corrupted = 1;
614 continue; 614 continue;
@@ -646,10 +646,10 @@ static int init_volumes(struct ubi_device *ubi,
646 vol->ubi = ubi; 646 vol->ubi = ubi;
647 647
648 if (reserved_pebs > ubi->avail_pebs) { 648 if (reserved_pebs > ubi->avail_pebs) {
649 ubi_err("not enough PEBs, required %d, available %d", 649 ubi_err(ubi, "not enough PEBs, required %d, available %d",
650 reserved_pebs, ubi->avail_pebs); 650 reserved_pebs, ubi->avail_pebs);
651 if (ubi->corr_peb_count) 651 if (ubi->corr_peb_count)
652 ubi_err("%d PEBs are corrupted and not used", 652 ubi_err(ubi, "%d PEBs are corrupted and not used",
653 ubi->corr_peb_count); 653 ubi->corr_peb_count);
654 } 654 }
655 ubi->rsvd_pebs += reserved_pebs; 655 ubi->rsvd_pebs += reserved_pebs;
@@ -660,13 +660,14 @@ static int init_volumes(struct ubi_device *ubi,
660 660
661/** 661/**
662 * check_av - check volume attaching information. 662 * check_av - check volume attaching information.
663 * @ubi: UBI device description object
663 * @vol: UBI volume description object 664 * @vol: UBI volume description object
664 * @av: volume attaching information 665 * @av: volume attaching information
665 * 666 *
666 * This function returns zero if the volume attaching information is consistent 667 * This function returns zero if the volume attaching information is consistent
667 * to the data read from the volume tabla, and %-EINVAL if not. 668 * to the data read from the volume tabla, and %-EINVAL if not.
668 */ 669 */
669static int check_av(const struct ubi_volume *vol, 670static int check_av(const struct ubi_device *ubi, const struct ubi_volume *vol,
670 const struct ubi_ainf_volume *av) 671 const struct ubi_ainf_volume *av)
671{ 672{
672 int err; 673 int err;
@@ -694,7 +695,7 @@ static int check_av(const struct ubi_volume *vol,
694 return 0; 695 return 0;
695 696
696bad: 697bad:
697 ubi_err("bad attaching information, error %d", err); 698 ubi_err(ubi, "bad attaching information, error %d", err);
698 ubi_dump_av(av); 699 ubi_dump_av(av);
699 ubi_dump_vol_info(vol); 700 ubi_dump_vol_info(vol);
700 return -EINVAL; 701 return -EINVAL;
@@ -718,14 +719,15 @@ static int check_attaching_info(const struct ubi_device *ubi,
718 struct ubi_volume *vol; 719 struct ubi_volume *vol;
719 720
720 if (ai->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) { 721 if (ai->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) {
721 ubi_err("found %d volumes while attaching, maximum is %d + %d", 722 ubi_err(ubi, "found %d volumes while attaching, maximum is %d + %d",
722 ai->vols_found, UBI_INT_VOL_COUNT, ubi->vtbl_slots); 723 ai->vols_found, UBI_INT_VOL_COUNT, ubi->vtbl_slots);
723 return -EINVAL; 724 return -EINVAL;
724 } 725 }
725 726
726 if (ai->highest_vol_id >= ubi->vtbl_slots + UBI_INT_VOL_COUNT && 727 if (ai->highest_vol_id >= ubi->vtbl_slots + UBI_INT_VOL_COUNT &&
727 ai->highest_vol_id < UBI_INTERNAL_VOL_START) { 728 ai->highest_vol_id < UBI_INTERNAL_VOL_START) {
728 ubi_err("too large volume ID %d found", ai->highest_vol_id); 729 ubi_err(ubi, "too large volume ID %d found",
730 ai->highest_vol_id);
729 return -EINVAL; 731 return -EINVAL;
730 } 732 }
731 733
@@ -753,10 +755,10 @@ static int check_attaching_info(const struct ubi_device *ubi,
753 * reboot while the volume was being removed. Discard 755 * reboot while the volume was being removed. Discard
754 * these eraseblocks. 756 * these eraseblocks.
755 */ 757 */
756 ubi_msg("finish volume %d removal", av->vol_id); 758 ubi_msg(ubi, "finish volume %d removal", av->vol_id);
757 ubi_remove_av(ai, av); 759 ubi_remove_av(ai, av);
758 } else if (av) { 760 } else if (av) {
759 err = check_av(vol, av); 761 err = check_av(ubi, vol, av);
760 if (err) 762 if (err)
761 return err; 763 return err;
762 } 764 }
@@ -807,13 +809,13 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai)
807 if (IS_ERR(ubi->vtbl)) 809 if (IS_ERR(ubi->vtbl))
808 return PTR_ERR(ubi->vtbl); 810 return PTR_ERR(ubi->vtbl);
809 } else { 811 } else {
810 ubi_err("the layout volume was not found"); 812 ubi_err(ubi, "the layout volume was not found");
811 return -EINVAL; 813 return -EINVAL;
812 } 814 }
813 } else { 815 } else {
814 if (av->leb_count > UBI_LAYOUT_VOLUME_EBS) { 816 if (av->leb_count > UBI_LAYOUT_VOLUME_EBS) {
815 /* This must not happen with proper UBI images */ 817 /* This must not happen with proper UBI images */
816 ubi_err("too many LEBs (%d) in layout volume", 818 ubi_err(ubi, "too many LEBs (%d) in layout volume",
817 av->leb_count); 819 av->leb_count);
818 return -EINVAL; 820 return -EINVAL;
819 } 821 }
@@ -862,7 +864,7 @@ static void self_vtbl_check(const struct ubi_device *ubi)
862 return; 864 return;
863 865
864 if (vtbl_check(ubi, ubi->vtbl)) { 866 if (vtbl_check(ubi, ubi->vtbl)) {
865 ubi_err("self-check failed"); 867 ubi_err(ubi, "self-check failed");
866 BUG(); 868 BUG();
867 } 869 }
868} 870}