diff options
Diffstat (limited to 'drivers/mtd/ubi/eba.c')
-rw-r--r-- | drivers/mtd/ubi/eba.c | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index 2402d3b50171..a40020cf0923 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c | |||
@@ -422,7 +422,7 @@ retry: | |||
422 | */ | 422 | */ |
423 | if (err == UBI_IO_BAD_HDR_EBADMSG || | 423 | if (err == UBI_IO_BAD_HDR_EBADMSG || |
424 | err == UBI_IO_BAD_HDR) { | 424 | err == UBI_IO_BAD_HDR) { |
425 | ubi_warn("corrupted VID header at PEB %d, LEB %d:%d", | 425 | ubi_warn(ubi, "corrupted VID header at PEB %d, LEB %d:%d", |
426 | pnum, vol_id, lnum); | 426 | pnum, vol_id, lnum); |
427 | err = -EBADMSG; | 427 | err = -EBADMSG; |
428 | } else | 428 | } else |
@@ -448,7 +448,7 @@ retry: | |||
448 | goto out_unlock; | 448 | goto out_unlock; |
449 | scrub = 1; | 449 | scrub = 1; |
450 | if (!check) { | 450 | if (!check) { |
451 | ubi_msg("force data checking"); | 451 | ubi_msg(ubi, "force data checking"); |
452 | check = 1; | 452 | check = 1; |
453 | goto retry; | 453 | goto retry; |
454 | } | 454 | } |
@@ -459,7 +459,7 @@ retry: | |||
459 | if (check) { | 459 | if (check) { |
460 | uint32_t crc1 = crc32(UBI_CRC32_INIT, buf, len); | 460 | uint32_t crc1 = crc32(UBI_CRC32_INIT, buf, len); |
461 | if (crc1 != crc) { | 461 | if (crc1 != crc) { |
462 | ubi_warn("CRC error: calculated %#08x, must be %#08x", | 462 | ubi_warn(ubi, "CRC error: calculated %#08x, must be %#08x", |
463 | crc1, crc); | 463 | crc1, crc); |
464 | err = -EBADMSG; | 464 | err = -EBADMSG; |
465 | goto out_unlock; | 465 | goto out_unlock; |
@@ -513,7 +513,8 @@ retry: | |||
513 | return new_pnum; | 513 | return new_pnum; |
514 | } | 514 | } |
515 | 515 | ||
516 | ubi_msg("recover PEB %d, move data to PEB %d", pnum, new_pnum); | 516 | ubi_msg(ubi, "recover PEB %d, move data to PEB %d", |
517 | pnum, new_pnum); | ||
517 | 518 | ||
518 | err = ubi_io_read_vid_hdr(ubi, pnum, vid_hdr, 1); | 519 | err = ubi_io_read_vid_hdr(ubi, pnum, vid_hdr, 1); |
519 | if (err && err != UBI_IO_BITFLIPS) { | 520 | if (err && err != UBI_IO_BITFLIPS) { |
@@ -554,7 +555,7 @@ retry: | |||
554 | up_read(&ubi->fm_sem); | 555 | up_read(&ubi->fm_sem); |
555 | ubi_wl_put_peb(ubi, vol_id, lnum, pnum, 1); | 556 | ubi_wl_put_peb(ubi, vol_id, lnum, pnum, 1); |
556 | 557 | ||
557 | ubi_msg("data was successfully recovered"); | 558 | ubi_msg(ubi, "data was successfully recovered"); |
558 | return 0; | 559 | return 0; |
559 | 560 | ||
560 | out_unlock: | 561 | out_unlock: |
@@ -569,13 +570,13 @@ write_error: | |||
569 | * Bad luck? This physical eraseblock is bad too? Crud. Let's try to | 570 | * Bad luck? This physical eraseblock is bad too? Crud. Let's try to |
570 | * get another one. | 571 | * get another one. |
571 | */ | 572 | */ |
572 | ubi_warn("failed to write to PEB %d", new_pnum); | 573 | ubi_warn(ubi, "failed to write to PEB %d", new_pnum); |
573 | ubi_wl_put_peb(ubi, vol_id, lnum, new_pnum, 1); | 574 | ubi_wl_put_peb(ubi, vol_id, lnum, new_pnum, 1); |
574 | if (++tries > UBI_IO_RETRIES) { | 575 | if (++tries > UBI_IO_RETRIES) { |
575 | ubi_free_vid_hdr(ubi, vid_hdr); | 576 | ubi_free_vid_hdr(ubi, vid_hdr); |
576 | return err; | 577 | return err; |
577 | } | 578 | } |
578 | ubi_msg("try again"); | 579 | ubi_msg(ubi, "try again"); |
579 | goto retry; | 580 | goto retry; |
580 | } | 581 | } |
581 | 582 | ||
@@ -613,7 +614,7 @@ int ubi_eba_write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, | |||
613 | 614 | ||
614 | err = ubi_io_write_data(ubi, buf, pnum, offset, len); | 615 | err = ubi_io_write_data(ubi, buf, pnum, offset, len); |
615 | if (err) { | 616 | if (err) { |
616 | ubi_warn("failed to write data to PEB %d", pnum); | 617 | ubi_warn(ubi, "failed to write data to PEB %d", pnum); |
617 | if (err == -EIO && ubi->bad_allowed) | 618 | if (err == -EIO && ubi->bad_allowed) |
618 | err = recover_peb(ubi, pnum, vol_id, lnum, buf, | 619 | err = recover_peb(ubi, pnum, vol_id, lnum, buf, |
619 | offset, len); | 620 | offset, len); |
@@ -654,7 +655,7 @@ retry: | |||
654 | 655 | ||
655 | err = ubi_io_write_vid_hdr(ubi, pnum, vid_hdr); | 656 | err = ubi_io_write_vid_hdr(ubi, pnum, vid_hdr); |
656 | if (err) { | 657 | if (err) { |
657 | ubi_warn("failed to write VID header to LEB %d:%d, PEB %d", | 658 | ubi_warn(ubi, "failed to write VID header to LEB %d:%d, PEB %d", |
658 | vol_id, lnum, pnum); | 659 | vol_id, lnum, pnum); |
659 | goto write_error; | 660 | goto write_error; |
660 | } | 661 | } |
@@ -662,7 +663,7 @@ retry: | |||
662 | if (len) { | 663 | if (len) { |
663 | err = ubi_io_write_data(ubi, buf, pnum, offset, len); | 664 | err = ubi_io_write_data(ubi, buf, pnum, offset, len); |
664 | if (err) { | 665 | if (err) { |
665 | ubi_warn("failed to write %d bytes at offset %d of LEB %d:%d, PEB %d", | 666 | ubi_warn(ubi, "failed to write %d bytes at offset %d of LEB %d:%d, PEB %d", |
666 | len, offset, vol_id, lnum, pnum); | 667 | len, offset, vol_id, lnum, pnum); |
667 | goto write_error; | 668 | goto write_error; |
668 | } | 669 | } |
@@ -698,7 +699,7 @@ write_error: | |||
698 | } | 699 | } |
699 | 700 | ||
700 | vid_hdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi)); | 701 | vid_hdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi)); |
701 | ubi_msg("try another PEB"); | 702 | ubi_msg(ubi, "try another PEB"); |
702 | goto retry; | 703 | goto retry; |
703 | } | 704 | } |
704 | 705 | ||
@@ -775,14 +776,14 @@ retry: | |||
775 | 776 | ||
776 | err = ubi_io_write_vid_hdr(ubi, pnum, vid_hdr); | 777 | err = ubi_io_write_vid_hdr(ubi, pnum, vid_hdr); |
777 | if (err) { | 778 | if (err) { |
778 | ubi_warn("failed to write VID header to LEB %d:%d, PEB %d", | 779 | ubi_warn(ubi, "failed to write VID header to LEB %d:%d, PEB %d", |
779 | vol_id, lnum, pnum); | 780 | vol_id, lnum, pnum); |
780 | goto write_error; | 781 | goto write_error; |
781 | } | 782 | } |
782 | 783 | ||
783 | err = ubi_io_write_data(ubi, buf, pnum, 0, len); | 784 | err = ubi_io_write_data(ubi, buf, pnum, 0, len); |
784 | if (err) { | 785 | if (err) { |
785 | ubi_warn("failed to write %d bytes of data to PEB %d", | 786 | ubi_warn(ubi, "failed to write %d bytes of data to PEB %d", |
786 | len, pnum); | 787 | len, pnum); |
787 | goto write_error; | 788 | goto write_error; |
788 | } | 789 | } |
@@ -818,7 +819,7 @@ write_error: | |||
818 | } | 819 | } |
819 | 820 | ||
820 | vid_hdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi)); | 821 | vid_hdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi)); |
821 | ubi_msg("try another PEB"); | 822 | ubi_msg(ubi, "try another PEB"); |
822 | goto retry; | 823 | goto retry; |
823 | } | 824 | } |
824 | 825 | ||
@@ -893,14 +894,14 @@ retry: | |||
893 | 894 | ||
894 | err = ubi_io_write_vid_hdr(ubi, pnum, vid_hdr); | 895 | err = ubi_io_write_vid_hdr(ubi, pnum, vid_hdr); |
895 | if (err) { | 896 | if (err) { |
896 | ubi_warn("failed to write VID header to LEB %d:%d, PEB %d", | 897 | ubi_warn(ubi, "failed to write VID header to LEB %d:%d, PEB %d", |
897 | vol_id, lnum, pnum); | 898 | vol_id, lnum, pnum); |
898 | goto write_error; | 899 | goto write_error; |
899 | } | 900 | } |
900 | 901 | ||
901 | err = ubi_io_write_data(ubi, buf, pnum, 0, len); | 902 | err = ubi_io_write_data(ubi, buf, pnum, 0, len); |
902 | if (err) { | 903 | if (err) { |
903 | ubi_warn("failed to write %d bytes of data to PEB %d", | 904 | ubi_warn(ubi, "failed to write %d bytes of data to PEB %d", |
904 | len, pnum); | 905 | len, pnum); |
905 | goto write_error; | 906 | goto write_error; |
906 | } | 907 | } |
@@ -940,7 +941,7 @@ write_error: | |||
940 | } | 941 | } |
941 | 942 | ||
942 | vid_hdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi)); | 943 | vid_hdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi)); |
943 | ubi_msg("try another PEB"); | 944 | ubi_msg(ubi, "try another PEB"); |
944 | goto retry; | 945 | goto retry; |
945 | } | 946 | } |
946 | 947 | ||
@@ -1063,7 +1064,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, | |||
1063 | dbg_wl("read %d bytes of data", aldata_size); | 1064 | dbg_wl("read %d bytes of data", aldata_size); |
1064 | err = ubi_io_read_data(ubi, ubi->peb_buf, from, 0, aldata_size); | 1065 | err = ubi_io_read_data(ubi, ubi->peb_buf, from, 0, aldata_size); |
1065 | if (err && err != UBI_IO_BITFLIPS) { | 1066 | if (err && err != UBI_IO_BITFLIPS) { |
1066 | ubi_warn("error %d while reading data from PEB %d", | 1067 | ubi_warn(ubi, "error %d while reading data from PEB %d", |
1067 | err, from); | 1068 | err, from); |
1068 | err = MOVE_SOURCE_RD_ERR; | 1069 | err = MOVE_SOURCE_RD_ERR; |
1069 | goto out_unlock_buf; | 1070 | goto out_unlock_buf; |
@@ -1113,7 +1114,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, | |||
1113 | err = ubi_io_read_vid_hdr(ubi, to, vid_hdr, 1); | 1114 | err = ubi_io_read_vid_hdr(ubi, to, vid_hdr, 1); |
1114 | if (err) { | 1115 | if (err) { |
1115 | if (err != UBI_IO_BITFLIPS) { | 1116 | if (err != UBI_IO_BITFLIPS) { |
1116 | ubi_warn("error %d while reading VID header back from PEB %d", | 1117 | ubi_warn(ubi, "error %d while reading VID header back from PEB %d", |
1117 | err, to); | 1118 | err, to); |
1118 | if (is_error_sane(err)) | 1119 | if (is_error_sane(err)) |
1119 | err = MOVE_TARGET_RD_ERR; | 1120 | err = MOVE_TARGET_RD_ERR; |
@@ -1140,7 +1141,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, | |||
1140 | err = ubi_io_read_data(ubi, ubi->peb_buf, to, 0, aldata_size); | 1141 | err = ubi_io_read_data(ubi, ubi->peb_buf, to, 0, aldata_size); |
1141 | if (err) { | 1142 | if (err) { |
1142 | if (err != UBI_IO_BITFLIPS) { | 1143 | if (err != UBI_IO_BITFLIPS) { |
1143 | ubi_warn("error %d while reading data back from PEB %d", | 1144 | ubi_warn(ubi, "error %d while reading data back from PEB %d", |
1144 | err, to); | 1145 | err, to); |
1145 | if (is_error_sane(err)) | 1146 | if (is_error_sane(err)) |
1146 | err = MOVE_TARGET_RD_ERR; | 1147 | err = MOVE_TARGET_RD_ERR; |
@@ -1152,7 +1153,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, | |||
1152 | cond_resched(); | 1153 | cond_resched(); |
1153 | 1154 | ||
1154 | if (crc != crc32(UBI_CRC32_INIT, ubi->peb_buf, data_size)) { | 1155 | if (crc != crc32(UBI_CRC32_INIT, ubi->peb_buf, data_size)) { |
1155 | ubi_warn("read data back from PEB %d and it is different", | 1156 | ubi_warn(ubi, "read data back from PEB %d and it is different", |
1156 | to); | 1157 | to); |
1157 | err = -EINVAL; | 1158 | err = -EINVAL; |
1158 | goto out_unlock_buf; | 1159 | goto out_unlock_buf; |
@@ -1205,10 +1206,10 @@ static void print_rsvd_warning(struct ubi_device *ubi, | |||
1205 | return; | 1206 | return; |
1206 | } | 1207 | } |
1207 | 1208 | ||
1208 | ubi_warn("cannot reserve enough PEBs for bad PEB handling, reserved %d, need %d", | 1209 | ubi_warn(ubi, "cannot reserve enough PEBs for bad PEB handling, reserved %d, need %d", |
1209 | ubi->beb_rsvd_pebs, ubi->beb_rsvd_level); | 1210 | ubi->beb_rsvd_pebs, ubi->beb_rsvd_level); |
1210 | if (ubi->corr_peb_count) | 1211 | if (ubi->corr_peb_count) |
1211 | ubi_warn("%d PEBs are corrupted and not used", | 1212 | ubi_warn(ubi, "%d PEBs are corrupted and not used", |
1212 | ubi->corr_peb_count); | 1213 | ubi->corr_peb_count); |
1213 | } | 1214 | } |
1214 | 1215 | ||
@@ -1286,7 +1287,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap, | |||
1286 | fm_eba[i][j] == UBI_LEB_UNMAPPED) | 1287 | fm_eba[i][j] == UBI_LEB_UNMAPPED) |
1287 | continue; | 1288 | continue; |
1288 | 1289 | ||
1289 | ubi_err("LEB:%i:%i is PEB:%i instead of %i!", | 1290 | ubi_err(ubi, "LEB:%i:%i is PEB:%i instead of %i!", |
1290 | vol->vol_id, i, fm_eba[i][j], | 1291 | vol->vol_id, i, fm_eba[i][j], |
1291 | scan_eba[i][j]); | 1292 | scan_eba[i][j]); |
1292 | ubi_assert(0); | 1293 | ubi_assert(0); |
@@ -1366,10 +1367,10 @@ int ubi_eba_init(struct ubi_device *ubi, struct ubi_attach_info *ai) | |||
1366 | } | 1367 | } |
1367 | 1368 | ||
1368 | if (ubi->avail_pebs < EBA_RESERVED_PEBS) { | 1369 | if (ubi->avail_pebs < EBA_RESERVED_PEBS) { |
1369 | ubi_err("no enough physical eraseblocks (%d, need %d)", | 1370 | ubi_err(ubi, "no enough physical eraseblocks (%d, need %d)", |
1370 | ubi->avail_pebs, EBA_RESERVED_PEBS); | 1371 | ubi->avail_pebs, EBA_RESERVED_PEBS); |
1371 | if (ubi->corr_peb_count) | 1372 | if (ubi->corr_peb_count) |
1372 | ubi_err("%d PEBs are corrupted and not used", | 1373 | ubi_err(ubi, "%d PEBs are corrupted and not used", |
1373 | ubi->corr_peb_count); | 1374 | ubi->corr_peb_count); |
1374 | err = -ENOSPC; | 1375 | err = -ENOSPC; |
1375 | goto out_free; | 1376 | goto out_free; |