aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/attach.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/ubi/attach.c')
-rw-r--r--drivers/mtd/ubi/attach.c126
1 files changed, 66 insertions, 60 deletions
diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c
index 6f27d9a1be3b..9d2e16f3150a 100644
--- a/drivers/mtd/ubi/attach.c
+++ b/drivers/mtd/ubi/attach.c
@@ -176,6 +176,7 @@ static int add_corrupted(struct ubi_attach_info *ai, int pnum, int ec)
176 176
177/** 177/**
178 * validate_vid_hdr - check volume identifier header. 178 * validate_vid_hdr - check volume identifier header.
179 * @ubi: UBI device description object
179 * @vid_hdr: the volume identifier header to check 180 * @vid_hdr: the volume identifier header to check
180 * @av: information about the volume this logical eraseblock belongs to 181 * @av: information about the volume this logical eraseblock belongs to
181 * @pnum: physical eraseblock number the VID header came from 182 * @pnum: physical eraseblock number the VID header came from
@@ -188,7 +189,8 @@ static int add_corrupted(struct ubi_attach_info *ai, int pnum, int ec)
188 * information in the VID header is consistent to the information in other VID 189 * information in the VID header is consistent to the information in other VID
189 * headers of the same volume. 190 * headers of the same volume.
190 */ 191 */
191static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr, 192static int validate_vid_hdr(const struct ubi_device *ubi,
193 const struct ubi_vid_hdr *vid_hdr,
192 const struct ubi_ainf_volume *av, int pnum) 194 const struct ubi_ainf_volume *av, int pnum)
193{ 195{
194 int vol_type = vid_hdr->vol_type; 196 int vol_type = vid_hdr->vol_type;
@@ -206,7 +208,7 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr,
206 */ 208 */
207 209
208 if (vol_id != av->vol_id) { 210 if (vol_id != av->vol_id) {
209 ubi_err("inconsistent vol_id"); 211 ubi_err(ubi, "inconsistent vol_id");
210 goto bad; 212 goto bad;
211 } 213 }
212 214
@@ -216,17 +218,17 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr,
216 av_vol_type = UBI_VID_DYNAMIC; 218 av_vol_type = UBI_VID_DYNAMIC;
217 219
218 if (vol_type != av_vol_type) { 220 if (vol_type != av_vol_type) {
219 ubi_err("inconsistent vol_type"); 221 ubi_err(ubi, "inconsistent vol_type");
220 goto bad; 222 goto bad;
221 } 223 }
222 224
223 if (used_ebs != av->used_ebs) { 225 if (used_ebs != av->used_ebs) {
224 ubi_err("inconsistent used_ebs"); 226 ubi_err(ubi, "inconsistent used_ebs");
225 goto bad; 227 goto bad;
226 } 228 }
227 229
228 if (data_pad != av->data_pad) { 230 if (data_pad != av->data_pad) {
229 ubi_err("inconsistent data_pad"); 231 ubi_err(ubi, "inconsistent data_pad");
230 goto bad; 232 goto bad;
231 } 233 }
232 } 234 }
@@ -234,7 +236,7 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr,
234 return 0; 236 return 0;
235 237
236bad: 238bad:
237 ubi_err("inconsistent VID header at PEB %d", pnum); 239 ubi_err(ubi, "inconsistent VID header at PEB %d", pnum);
238 ubi_dump_vid_hdr(vid_hdr); 240 ubi_dump_vid_hdr(vid_hdr);
239 ubi_dump_av(av); 241 ubi_dump_av(av);
240 return -EINVAL; 242 return -EINVAL;
@@ -336,7 +338,7 @@ int ubi_compare_lebs(struct ubi_device *ubi, const struct ubi_ainf_peb *aeb,
336 * support these images anymore. Well, those images still work, 338 * support these images anymore. Well, those images still work,
337 * but only if no unclean reboots happened. 339 * but only if no unclean reboots happened.
338 */ 340 */
339 ubi_err("unsupported on-flash UBI format"); 341 ubi_err(ubi, "unsupported on-flash UBI format");
340 return -EINVAL; 342 return -EINVAL;
341 } 343 }
342 344
@@ -377,7 +379,7 @@ int ubi_compare_lebs(struct ubi_device *ubi, const struct ubi_ainf_peb *aeb,
377 if (err == UBI_IO_BITFLIPS) 379 if (err == UBI_IO_BITFLIPS)
378 bitflips = 1; 380 bitflips = 1;
379 else { 381 else {
380 ubi_err("VID of PEB %d header is bad, but it was OK earlier, err %d", 382 ubi_err(ubi, "VID of PEB %d header is bad, but it was OK earlier, err %d",
381 pnum, err); 383 pnum, err);
382 if (err > 0) 384 if (err > 0)
383 err = -EIO; 385 err = -EIO;
@@ -507,7 +509,7 @@ int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum,
507 * logical eraseblocks because there was an unclean reboot. 509 * logical eraseblocks because there was an unclean reboot.
508 */ 510 */
509 if (aeb->sqnum == sqnum && sqnum != 0) { 511 if (aeb->sqnum == sqnum && sqnum != 0) {
510 ubi_err("two LEBs with same sequence number %llu", 512 ubi_err(ubi, "two LEBs with same sequence number %llu",
511 sqnum); 513 sqnum);
512 ubi_dump_aeb(aeb, 0); 514 ubi_dump_aeb(aeb, 0);
513 ubi_dump_vid_hdr(vid_hdr); 515 ubi_dump_vid_hdr(vid_hdr);
@@ -527,7 +529,7 @@ int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum,
527 * This logical eraseblock is newer than the one 529 * This logical eraseblock is newer than the one
528 * found earlier. 530 * found earlier.
529 */ 531 */
530 err = validate_vid_hdr(vid_hdr, av, pnum); 532 err = validate_vid_hdr(ubi, vid_hdr, av, pnum);
531 if (err) 533 if (err)
532 return err; 534 return err;
533 535
@@ -565,7 +567,7 @@ int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum,
565 * attaching information. 567 * attaching information.
566 */ 568 */
567 569
568 err = validate_vid_hdr(vid_hdr, av, pnum); 570 err = validate_vid_hdr(ubi, vid_hdr, av, pnum);
569 if (err) 571 if (err)
570 return err; 572 return err;
571 573
@@ -668,7 +670,8 @@ static int early_erase_peb(struct ubi_device *ubi,
668 * Erase counter overflow. Upgrade UBI and use 64-bit 670 * Erase counter overflow. Upgrade UBI and use 64-bit
669 * erase counters internally. 671 * erase counters internally.
670 */ 672 */
671 ubi_err("erase counter overflow at PEB %d, EC %d", pnum, ec); 673 ubi_err(ubi, "erase counter overflow at PEB %d, EC %d",
674 pnum, ec);
672 return -EINVAL; 675 return -EINVAL;
673 } 676 }
674 677
@@ -736,7 +739,7 @@ struct ubi_ainf_peb *ubi_early_get_peb(struct ubi_device *ubi,
736 return aeb; 739 return aeb;
737 } 740 }
738 741
739 ubi_err("no free eraseblocks"); 742 ubi_err(ubi, "no free eraseblocks");
740 return ERR_PTR(-ENOSPC); 743 return ERR_PTR(-ENOSPC);
741} 744}
742 745
@@ -785,9 +788,9 @@ static int check_corruption(struct ubi_device *ubi, struct ubi_vid_hdr *vid_hdr,
785 if (ubi_check_pattern(ubi->peb_buf, 0xFF, ubi->leb_size)) 788 if (ubi_check_pattern(ubi->peb_buf, 0xFF, ubi->leb_size))
786 goto out_unlock; 789 goto out_unlock;
787 790
788 ubi_err("PEB %d contains corrupted VID header, and the data does not contain all 0xFF", 791 ubi_err(ubi, "PEB %d contains corrupted VID header, and the data does not contain all 0xFF",
789 pnum); 792 pnum);
790 ubi_err("this may be a non-UBI PEB or a severe VID header corruption which requires manual inspection"); 793 ubi_err(ubi, "this may be a non-UBI PEB or a severe VID header corruption which requires manual inspection");
791 ubi_dump_vid_hdr(vid_hdr); 794 ubi_dump_vid_hdr(vid_hdr);
792 pr_err("hexdump of PEB %d offset %d, length %d", 795 pr_err("hexdump of PEB %d offset %d, length %d",
793 pnum, ubi->leb_start, ubi->leb_size); 796 pnum, ubi->leb_start, ubi->leb_size);
@@ -859,7 +862,8 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
859 bitflips = 1; 862 bitflips = 1;
860 break; 863 break;
861 default: 864 default:
862 ubi_err("'ubi_io_read_ec_hdr()' returned unknown code %d", err); 865 ubi_err(ubi, "'ubi_io_read_ec_hdr()' returned unknown code %d",
866 err);
863 return -EINVAL; 867 return -EINVAL;
864 } 868 }
865 869
@@ -868,7 +872,7 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
868 872
869 /* Make sure UBI version is OK */ 873 /* Make sure UBI version is OK */
870 if (ech->version != UBI_VERSION) { 874 if (ech->version != UBI_VERSION) {
871 ubi_err("this UBI version is %d, image version is %d", 875 ubi_err(ubi, "this UBI version is %d, image version is %d",
872 UBI_VERSION, (int)ech->version); 876 UBI_VERSION, (int)ech->version);
873 return -EINVAL; 877 return -EINVAL;
874 } 878 }
@@ -882,7 +886,7 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
882 * flash. Upgrade UBI and use 64-bit erase counters 886 * flash. Upgrade UBI and use 64-bit erase counters
883 * internally. 887 * internally.
884 */ 888 */
885 ubi_err("erase counter overflow, max is %d", 889 ubi_err(ubi, "erase counter overflow, max is %d",
886 UBI_MAX_ERASECOUNTER); 890 UBI_MAX_ERASECOUNTER);
887 ubi_dump_ec_hdr(ech); 891 ubi_dump_ec_hdr(ech);
888 return -EINVAL; 892 return -EINVAL;
@@ -903,7 +907,7 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
903 if (!ubi->image_seq) 907 if (!ubi->image_seq)
904 ubi->image_seq = image_seq; 908 ubi->image_seq = image_seq;
905 if (image_seq && ubi->image_seq != image_seq) { 909 if (image_seq && ubi->image_seq != image_seq) {
906 ubi_err("bad image sequence number %d in PEB %d, expected %d", 910 ubi_err(ubi, "bad image sequence number %d in PEB %d, expected %d",
907 image_seq, pnum, ubi->image_seq); 911 image_seq, pnum, ubi->image_seq);
908 ubi_dump_ec_hdr(ech); 912 ubi_dump_ec_hdr(ech);
909 return -EINVAL; 913 return -EINVAL;
@@ -981,7 +985,7 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
981 return err; 985 return err;
982 goto adjust_mean_ec; 986 goto adjust_mean_ec;
983 default: 987 default:
984 ubi_err("'ubi_io_read_vid_hdr()' returned unknown code %d", 988 ubi_err(ubi, "'ubi_io_read_vid_hdr()' returned unknown code %d",
985 err); 989 err);
986 return -EINVAL; 990 return -EINVAL;
987 } 991 }
@@ -999,7 +1003,7 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
999 case UBI_COMPAT_DELETE: 1003 case UBI_COMPAT_DELETE:
1000 if (vol_id != UBI_FM_SB_VOLUME_ID 1004 if (vol_id != UBI_FM_SB_VOLUME_ID
1001 && vol_id != UBI_FM_DATA_VOLUME_ID) { 1005 && vol_id != UBI_FM_DATA_VOLUME_ID) {
1002 ubi_msg("\"delete\" compatible internal volume %d:%d found, will remove it", 1006 ubi_msg(ubi, "\"delete\" compatible internal volume %d:%d found, will remove it",
1003 vol_id, lnum); 1007 vol_id, lnum);
1004 } 1008 }
1005 err = add_to_list(ai, pnum, vol_id, lnum, 1009 err = add_to_list(ai, pnum, vol_id, lnum,
@@ -1009,13 +1013,13 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
1009 return 0; 1013 return 0;
1010 1014
1011 case UBI_COMPAT_RO: 1015 case UBI_COMPAT_RO:
1012 ubi_msg("read-only compatible internal volume %d:%d found, switch to read-only mode", 1016 ubi_msg(ubi, "read-only compatible internal volume %d:%d found, switch to read-only mode",
1013 vol_id, lnum); 1017 vol_id, lnum);
1014 ubi->ro_mode = 1; 1018 ubi->ro_mode = 1;
1015 break; 1019 break;
1016 1020
1017 case UBI_COMPAT_PRESERVE: 1021 case UBI_COMPAT_PRESERVE:
1018 ubi_msg("\"preserve\" compatible internal volume %d:%d found", 1022 ubi_msg(ubi, "\"preserve\" compatible internal volume %d:%d found",
1019 vol_id, lnum); 1023 vol_id, lnum);
1020 err = add_to_list(ai, pnum, vol_id, lnum, 1024 err = add_to_list(ai, pnum, vol_id, lnum,
1021 ec, 0, &ai->alien); 1025 ec, 0, &ai->alien);
@@ -1024,14 +1028,14 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
1024 return 0; 1028 return 0;
1025 1029
1026 case UBI_COMPAT_REJECT: 1030 case UBI_COMPAT_REJECT:
1027 ubi_err("incompatible internal volume %d:%d found", 1031 ubi_err(ubi, "incompatible internal volume %d:%d found",
1028 vol_id, lnum); 1032 vol_id, lnum);
1029 return -EINVAL; 1033 return -EINVAL;
1030 } 1034 }
1031 } 1035 }
1032 1036
1033 if (ec_err) 1037 if (ec_err)
1034 ubi_warn("valid VID header but corrupted EC header at PEB %d", 1038 ubi_warn(ubi, "valid VID header but corrupted EC header at PEB %d",
1035 pnum); 1039 pnum);
1036 err = ubi_add_to_av(ubi, ai, pnum, ec, vidh, bitflips); 1040 err = ubi_add_to_av(ubi, ai, pnum, ec, vidh, bitflips);
1037 if (err) 1041 if (err)
@@ -1075,7 +1079,7 @@ static int late_analysis(struct ubi_device *ubi, struct ubi_attach_info *ai)
1075 * with the flash HW or driver. 1079 * with the flash HW or driver.
1076 */ 1080 */
1077 if (ai->corr_peb_count) { 1081 if (ai->corr_peb_count) {
1078 ubi_err("%d PEBs are corrupted and preserved", 1082 ubi_err(ubi, "%d PEBs are corrupted and preserved",
1079 ai->corr_peb_count); 1083 ai->corr_peb_count);
1080 pr_err("Corrupted PEBs are:"); 1084 pr_err("Corrupted PEBs are:");
1081 list_for_each_entry(aeb, &ai->corr, u.list) 1085 list_for_each_entry(aeb, &ai->corr, u.list)
@@ -1087,7 +1091,7 @@ static int late_analysis(struct ubi_device *ubi, struct ubi_attach_info *ai)
1087 * otherwise, only print a warning. 1091 * otherwise, only print a warning.
1088 */ 1092 */
1089 if (ai->corr_peb_count >= max_corr) { 1093 if (ai->corr_peb_count >= max_corr) {
1090 ubi_err("too many corrupted PEBs, refusing"); 1094 ubi_err(ubi, "too many corrupted PEBs, refusing");
1091 return -EINVAL; 1095 return -EINVAL;
1092 } 1096 }
1093 } 1097 }
@@ -1110,11 +1114,11 @@ static int late_analysis(struct ubi_device *ubi, struct ubi_attach_info *ai)
1110 */ 1114 */
1111 if (ai->maybe_bad_peb_count <= 2) { 1115 if (ai->maybe_bad_peb_count <= 2) {
1112 ai->is_empty = 1; 1116 ai->is_empty = 1;
1113 ubi_msg("empty MTD device detected"); 1117 ubi_msg(ubi, "empty MTD device detected");
1114 get_random_bytes(&ubi->image_seq, 1118 get_random_bytes(&ubi->image_seq,
1115 sizeof(ubi->image_seq)); 1119 sizeof(ubi->image_seq));
1116 } else { 1120 } else {
1117 ubi_err("MTD device is not UBI-formatted and possibly contains non-UBI data - refusing it"); 1121 ubi_err(ubi, "MTD device is not UBI-formatted and possibly contains non-UBI data - refusing it");
1118 return -EINVAL; 1122 return -EINVAL;
1119 } 1123 }
1120 1124
@@ -1248,7 +1252,7 @@ static int scan_all(struct ubi_device *ubi, struct ubi_attach_info *ai,
1248 goto out_vidh; 1252 goto out_vidh;
1249 } 1253 }
1250 1254
1251 ubi_msg("scanning is finished"); 1255 ubi_msg(ubi, "scanning is finished");
1252 1256
1253 /* Calculate mean erase counter */ 1257 /* Calculate mean erase counter */
1254 if (ai->ec_count) 1258 if (ai->ec_count)
@@ -1515,37 +1519,37 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1515 vols_found += 1; 1519 vols_found += 1;
1516 1520
1517 if (ai->is_empty) { 1521 if (ai->is_empty) {
1518 ubi_err("bad is_empty flag"); 1522 ubi_err(ubi, "bad is_empty flag");
1519 goto bad_av; 1523 goto bad_av;
1520 } 1524 }
1521 1525
1522 if (av->vol_id < 0 || av->highest_lnum < 0 || 1526 if (av->vol_id < 0 || av->highest_lnum < 0 ||
1523 av->leb_count < 0 || av->vol_type < 0 || av->used_ebs < 0 || 1527 av->leb_count < 0 || av->vol_type < 0 || av->used_ebs < 0 ||
1524 av->data_pad < 0 || av->last_data_size < 0) { 1528 av->data_pad < 0 || av->last_data_size < 0) {
1525 ubi_err("negative values"); 1529 ubi_err(ubi, "negative values");
1526 goto bad_av; 1530 goto bad_av;
1527 } 1531 }
1528 1532
1529 if (av->vol_id >= UBI_MAX_VOLUMES && 1533 if (av->vol_id >= UBI_MAX_VOLUMES &&
1530 av->vol_id < UBI_INTERNAL_VOL_START) { 1534 av->vol_id < UBI_INTERNAL_VOL_START) {
1531 ubi_err("bad vol_id"); 1535 ubi_err(ubi, "bad vol_id");
1532 goto bad_av; 1536 goto bad_av;
1533 } 1537 }
1534 1538
1535 if (av->vol_id > ai->highest_vol_id) { 1539 if (av->vol_id > ai->highest_vol_id) {
1536 ubi_err("highest_vol_id is %d, but vol_id %d is there", 1540 ubi_err(ubi, "highest_vol_id is %d, but vol_id %d is there",
1537 ai->highest_vol_id, av->vol_id); 1541 ai->highest_vol_id, av->vol_id);
1538 goto out; 1542 goto out;
1539 } 1543 }
1540 1544
1541 if (av->vol_type != UBI_DYNAMIC_VOLUME && 1545 if (av->vol_type != UBI_DYNAMIC_VOLUME &&
1542 av->vol_type != UBI_STATIC_VOLUME) { 1546 av->vol_type != UBI_STATIC_VOLUME) {
1543 ubi_err("bad vol_type"); 1547 ubi_err(ubi, "bad vol_type");
1544 goto bad_av; 1548 goto bad_av;
1545 } 1549 }
1546 1550
1547 if (av->data_pad > ubi->leb_size / 2) { 1551 if (av->data_pad > ubi->leb_size / 2) {
1548 ubi_err("bad data_pad"); 1552 ubi_err(ubi, "bad data_pad");
1549 goto bad_av; 1553 goto bad_av;
1550 } 1554 }
1551 1555
@@ -1557,48 +1561,48 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1557 leb_count += 1; 1561 leb_count += 1;
1558 1562
1559 if (aeb->pnum < 0 || aeb->ec < 0) { 1563 if (aeb->pnum < 0 || aeb->ec < 0) {
1560 ubi_err("negative values"); 1564 ubi_err(ubi, "negative values");
1561 goto bad_aeb; 1565 goto bad_aeb;
1562 } 1566 }
1563 1567
1564 if (aeb->ec < ai->min_ec) { 1568 if (aeb->ec < ai->min_ec) {
1565 ubi_err("bad ai->min_ec (%d), %d found", 1569 ubi_err(ubi, "bad ai->min_ec (%d), %d found",
1566 ai->min_ec, aeb->ec); 1570 ai->min_ec, aeb->ec);
1567 goto bad_aeb; 1571 goto bad_aeb;
1568 } 1572 }
1569 1573
1570 if (aeb->ec > ai->max_ec) { 1574 if (aeb->ec > ai->max_ec) {
1571 ubi_err("bad ai->max_ec (%d), %d found", 1575 ubi_err(ubi, "bad ai->max_ec (%d), %d found",
1572 ai->max_ec, aeb->ec); 1576 ai->max_ec, aeb->ec);
1573 goto bad_aeb; 1577 goto bad_aeb;
1574 } 1578 }
1575 1579
1576 if (aeb->pnum >= ubi->peb_count) { 1580 if (aeb->pnum >= ubi->peb_count) {
1577 ubi_err("too high PEB number %d, total PEBs %d", 1581 ubi_err(ubi, "too high PEB number %d, total PEBs %d",
1578 aeb->pnum, ubi->peb_count); 1582 aeb->pnum, ubi->peb_count);
1579 goto bad_aeb; 1583 goto bad_aeb;
1580 } 1584 }
1581 1585
1582 if (av->vol_type == UBI_STATIC_VOLUME) { 1586 if (av->vol_type == UBI_STATIC_VOLUME) {
1583 if (aeb->lnum >= av->used_ebs) { 1587 if (aeb->lnum >= av->used_ebs) {
1584 ubi_err("bad lnum or used_ebs"); 1588 ubi_err(ubi, "bad lnum or used_ebs");
1585 goto bad_aeb; 1589 goto bad_aeb;
1586 } 1590 }
1587 } else { 1591 } else {
1588 if (av->used_ebs != 0) { 1592 if (av->used_ebs != 0) {
1589 ubi_err("non-zero used_ebs"); 1593 ubi_err(ubi, "non-zero used_ebs");
1590 goto bad_aeb; 1594 goto bad_aeb;
1591 } 1595 }
1592 } 1596 }
1593 1597
1594 if (aeb->lnum > av->highest_lnum) { 1598 if (aeb->lnum > av->highest_lnum) {
1595 ubi_err("incorrect highest_lnum or lnum"); 1599 ubi_err(ubi, "incorrect highest_lnum or lnum");
1596 goto bad_aeb; 1600 goto bad_aeb;
1597 } 1601 }
1598 } 1602 }
1599 1603
1600 if (av->leb_count != leb_count) { 1604 if (av->leb_count != leb_count) {
1601 ubi_err("bad leb_count, %d objects in the tree", 1605 ubi_err(ubi, "bad leb_count, %d objects in the tree",
1602 leb_count); 1606 leb_count);
1603 goto bad_av; 1607 goto bad_av;
1604 } 1608 }
@@ -1609,13 +1613,13 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1609 aeb = last_aeb; 1613 aeb = last_aeb;
1610 1614
1611 if (aeb->lnum != av->highest_lnum) { 1615 if (aeb->lnum != av->highest_lnum) {
1612 ubi_err("bad highest_lnum"); 1616 ubi_err(ubi, "bad highest_lnum");
1613 goto bad_aeb; 1617 goto bad_aeb;
1614 } 1618 }
1615 } 1619 }
1616 1620
1617 if (vols_found != ai->vols_found) { 1621 if (vols_found != ai->vols_found) {
1618 ubi_err("bad ai->vols_found %d, should be %d", 1622 ubi_err(ubi, "bad ai->vols_found %d, should be %d",
1619 ai->vols_found, vols_found); 1623 ai->vols_found, vols_found);
1620 goto out; 1624 goto out;
1621 } 1625 }
@@ -1632,7 +1636,8 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1632 1636
1633 err = ubi_io_read_vid_hdr(ubi, aeb->pnum, vidh, 1); 1637 err = ubi_io_read_vid_hdr(ubi, aeb->pnum, vidh, 1);
1634 if (err && err != UBI_IO_BITFLIPS) { 1638 if (err && err != UBI_IO_BITFLIPS) {
1635 ubi_err("VID header is not OK (%d)", err); 1639 ubi_err(ubi, "VID header is not OK (%d)",
1640 err);
1636 if (err > 0) 1641 if (err > 0)
1637 err = -EIO; 1642 err = -EIO;
1638 return err; 1643 return err;
@@ -1641,37 +1646,37 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1641 vol_type = vidh->vol_type == UBI_VID_DYNAMIC ? 1646 vol_type = vidh->vol_type == UBI_VID_DYNAMIC ?
1642 UBI_DYNAMIC_VOLUME : UBI_STATIC_VOLUME; 1647 UBI_DYNAMIC_VOLUME : UBI_STATIC_VOLUME;
1643 if (av->vol_type != vol_type) { 1648 if (av->vol_type != vol_type) {
1644 ubi_err("bad vol_type"); 1649 ubi_err(ubi, "bad vol_type");
1645 goto bad_vid_hdr; 1650 goto bad_vid_hdr;
1646 } 1651 }
1647 1652
1648 if (aeb->sqnum != be64_to_cpu(vidh->sqnum)) { 1653 if (aeb->sqnum != be64_to_cpu(vidh->sqnum)) {
1649 ubi_err("bad sqnum %llu", aeb->sqnum); 1654 ubi_err(ubi, "bad sqnum %llu", aeb->sqnum);
1650 goto bad_vid_hdr; 1655 goto bad_vid_hdr;
1651 } 1656 }
1652 1657
1653 if (av->vol_id != be32_to_cpu(vidh->vol_id)) { 1658 if (av->vol_id != be32_to_cpu(vidh->vol_id)) {
1654 ubi_err("bad vol_id %d", av->vol_id); 1659 ubi_err(ubi, "bad vol_id %d", av->vol_id);
1655 goto bad_vid_hdr; 1660 goto bad_vid_hdr;
1656 } 1661 }
1657 1662
1658 if (av->compat != vidh->compat) { 1663 if (av->compat != vidh->compat) {
1659 ubi_err("bad compat %d", vidh->compat); 1664 ubi_err(ubi, "bad compat %d", vidh->compat);
1660 goto bad_vid_hdr; 1665 goto bad_vid_hdr;
1661 } 1666 }
1662 1667
1663 if (aeb->lnum != be32_to_cpu(vidh->lnum)) { 1668 if (aeb->lnum != be32_to_cpu(vidh->lnum)) {
1664 ubi_err("bad lnum %d", aeb->lnum); 1669 ubi_err(ubi, "bad lnum %d", aeb->lnum);
1665 goto bad_vid_hdr; 1670 goto bad_vid_hdr;
1666 } 1671 }
1667 1672
1668 if (av->used_ebs != be32_to_cpu(vidh->used_ebs)) { 1673 if (av->used_ebs != be32_to_cpu(vidh->used_ebs)) {
1669 ubi_err("bad used_ebs %d", av->used_ebs); 1674 ubi_err(ubi, "bad used_ebs %d", av->used_ebs);
1670 goto bad_vid_hdr; 1675 goto bad_vid_hdr;
1671 } 1676 }
1672 1677
1673 if (av->data_pad != be32_to_cpu(vidh->data_pad)) { 1678 if (av->data_pad != be32_to_cpu(vidh->data_pad)) {
1674 ubi_err("bad data_pad %d", av->data_pad); 1679 ubi_err(ubi, "bad data_pad %d", av->data_pad);
1675 goto bad_vid_hdr; 1680 goto bad_vid_hdr;
1676 } 1681 }
1677 } 1682 }
@@ -1680,12 +1685,13 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1680 continue; 1685 continue;
1681 1686
1682 if (av->highest_lnum != be32_to_cpu(vidh->lnum)) { 1687 if (av->highest_lnum != be32_to_cpu(vidh->lnum)) {
1683 ubi_err("bad highest_lnum %d", av->highest_lnum); 1688 ubi_err(ubi, "bad highest_lnum %d", av->highest_lnum);
1684 goto bad_vid_hdr; 1689 goto bad_vid_hdr;
1685 } 1690 }
1686 1691
1687 if (av->last_data_size != be32_to_cpu(vidh->data_size)) { 1692 if (av->last_data_size != be32_to_cpu(vidh->data_size)) {
1688 ubi_err("bad last_data_size %d", av->last_data_size); 1693 ubi_err(ubi, "bad last_data_size %d",
1694 av->last_data_size);
1689 goto bad_vid_hdr; 1695 goto bad_vid_hdr;
1690 } 1696 }
1691 } 1697 }
@@ -1726,7 +1732,7 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1726 err = 0; 1732 err = 0;
1727 for (pnum = 0; pnum < ubi->peb_count; pnum++) 1733 for (pnum = 0; pnum < ubi->peb_count; pnum++)
1728 if (!buf[pnum]) { 1734 if (!buf[pnum]) {
1729 ubi_err("PEB %d is not referred", pnum); 1735 ubi_err(ubi, "PEB %d is not referred", pnum);
1730 err = 1; 1736 err = 1;
1731 } 1737 }
1732 1738
@@ -1736,18 +1742,18 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
1736 return 0; 1742 return 0;
1737 1743
1738bad_aeb: 1744bad_aeb:
1739 ubi_err("bad attaching information about LEB %d", aeb->lnum); 1745 ubi_err(ubi, "bad attaching information about LEB %d", aeb->lnum);
1740 ubi_dump_aeb(aeb, 0); 1746 ubi_dump_aeb(aeb, 0);
1741 ubi_dump_av(av); 1747 ubi_dump_av(av);
1742 goto out; 1748 goto out;
1743 1749
1744bad_av: 1750bad_av:
1745 ubi_err("bad attaching information about volume %d", av->vol_id); 1751 ubi_err(ubi, "bad attaching information about volume %d", av->vol_id);
1746 ubi_dump_av(av); 1752 ubi_dump_av(av);
1747 goto out; 1753 goto out;
1748 1754
1749bad_vid_hdr: 1755bad_vid_hdr:
1750 ubi_err("bad attaching information about volume %d", av->vol_id); 1756 ubi_err(ubi, "bad attaching information about volume %d", av->vol_id);
1751 ubi_dump_av(av); 1757 ubi_dump_av(av);
1752 ubi_dump_vid_hdr(vidh); 1758 ubi_dump_vid_hdr(vidh);
1753 1759