diff options
Diffstat (limited to 'drivers/mtd/ubi/io.c')
| -rw-r--r-- | drivers/mtd/ubi/io.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index 2fb64be44f1b..a74118c05745 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c | |||
| @@ -637,8 +637,6 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, | |||
| 637 | 637 | ||
| 638 | dbg_io("read EC header from PEB %d", pnum); | 638 | dbg_io("read EC header from PEB %d", pnum); |
| 639 | ubi_assert(pnum >= 0 && pnum < ubi->peb_count); | 639 | ubi_assert(pnum >= 0 && pnum < ubi->peb_count); |
| 640 | if (UBI_IO_DEBUG) | ||
| 641 | verbose = 1; | ||
| 642 | 640 | ||
| 643 | err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE); | 641 | err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE); |
| 644 | if (err) { | 642 | if (err) { |
| @@ -685,6 +683,9 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, | |||
| 685 | if (verbose) | 683 | if (verbose) |
| 686 | ubi_warn("no EC header found at PEB %d, " | 684 | ubi_warn("no EC header found at PEB %d, " |
| 687 | "only 0xFF bytes", pnum); | 685 | "only 0xFF bytes", pnum); |
| 686 | else if (UBI_IO_DEBUG) | ||
| 687 | dbg_msg("no EC header found at PEB %d, " | ||
| 688 | "only 0xFF bytes", pnum); | ||
| 688 | return UBI_IO_PEB_EMPTY; | 689 | return UBI_IO_PEB_EMPTY; |
| 689 | } | 690 | } |
| 690 | 691 | ||
| @@ -696,7 +697,9 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, | |||
| 696 | ubi_warn("bad magic number at PEB %d: %08x instead of " | 697 | ubi_warn("bad magic number at PEB %d: %08x instead of " |
| 697 | "%08x", pnum, magic, UBI_EC_HDR_MAGIC); | 698 | "%08x", pnum, magic, UBI_EC_HDR_MAGIC); |
| 698 | ubi_dbg_dump_ec_hdr(ec_hdr); | 699 | ubi_dbg_dump_ec_hdr(ec_hdr); |
| 699 | } | 700 | } else if (UBI_IO_DEBUG) |
| 701 | dbg_msg("bad magic number at PEB %d: %08x instead of " | ||
| 702 | "%08x", pnum, magic, UBI_EC_HDR_MAGIC); | ||
| 700 | return UBI_IO_BAD_EC_HDR; | 703 | return UBI_IO_BAD_EC_HDR; |
| 701 | } | 704 | } |
| 702 | 705 | ||
| @@ -708,7 +711,9 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, | |||
| 708 | ubi_warn("bad EC header CRC at PEB %d, calculated " | 711 | ubi_warn("bad EC header CRC at PEB %d, calculated " |
| 709 | "%#08x, read %#08x", pnum, crc, hdr_crc); | 712 | "%#08x, read %#08x", pnum, crc, hdr_crc); |
| 710 | ubi_dbg_dump_ec_hdr(ec_hdr); | 713 | ubi_dbg_dump_ec_hdr(ec_hdr); |
| 711 | } | 714 | } else if (UBI_IO_DEBUG) |
| 715 | dbg_msg("bad EC header CRC at PEB %d, calculated " | ||
| 716 | "%#08x, read %#08x", pnum, crc, hdr_crc); | ||
| 712 | return UBI_IO_BAD_EC_HDR; | 717 | return UBI_IO_BAD_EC_HDR; |
| 713 | } | 718 | } |
| 714 | 719 | ||
| @@ -912,8 +917,6 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, | |||
| 912 | 917 | ||
| 913 | dbg_io("read VID header from PEB %d", pnum); | 918 | dbg_io("read VID header from PEB %d", pnum); |
| 914 | ubi_assert(pnum >= 0 && pnum < ubi->peb_count); | 919 | ubi_assert(pnum >= 0 && pnum < ubi->peb_count); |
| 915 | if (UBI_IO_DEBUG) | ||
| 916 | verbose = 1; | ||
| 917 | 920 | ||
| 918 | p = (char *)vid_hdr - ubi->vid_hdr_shift; | 921 | p = (char *)vid_hdr - ubi->vid_hdr_shift; |
| 919 | err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset, | 922 | err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset, |
| @@ -960,6 +963,9 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, | |||
| 960 | if (verbose) | 963 | if (verbose) |
| 961 | ubi_warn("no VID header found at PEB %d, " | 964 | ubi_warn("no VID header found at PEB %d, " |
| 962 | "only 0xFF bytes", pnum); | 965 | "only 0xFF bytes", pnum); |
| 966 | else if (UBI_IO_DEBUG) | ||
| 967 | dbg_msg("no VID header found at PEB %d, " | ||
| 968 | "only 0xFF bytes", pnum); | ||
| 963 | return UBI_IO_PEB_FREE; | 969 | return UBI_IO_PEB_FREE; |
| 964 | } | 970 | } |
| 965 | 971 | ||
| @@ -971,7 +977,9 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, | |||
| 971 | ubi_warn("bad magic number at PEB %d: %08x instead of " | 977 | ubi_warn("bad magic number at PEB %d: %08x instead of " |
| 972 | "%08x", pnum, magic, UBI_VID_HDR_MAGIC); | 978 | "%08x", pnum, magic, UBI_VID_HDR_MAGIC); |
| 973 | ubi_dbg_dump_vid_hdr(vid_hdr); | 979 | ubi_dbg_dump_vid_hdr(vid_hdr); |
| 974 | } | 980 | } else if (UBI_IO_DEBUG) |
| 981 | dbg_msg("bad magic number at PEB %d: %08x instead of " | ||
| 982 | "%08x", pnum, magic, UBI_VID_HDR_MAGIC); | ||
| 975 | return UBI_IO_BAD_VID_HDR; | 983 | return UBI_IO_BAD_VID_HDR; |
| 976 | } | 984 | } |
| 977 | 985 | ||
| @@ -983,7 +991,9 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, | |||
| 983 | ubi_warn("bad CRC at PEB %d, calculated %#08x, " | 991 | ubi_warn("bad CRC at PEB %d, calculated %#08x, " |
| 984 | "read %#08x", pnum, crc, hdr_crc); | 992 | "read %#08x", pnum, crc, hdr_crc); |
| 985 | ubi_dbg_dump_vid_hdr(vid_hdr); | 993 | ubi_dbg_dump_vid_hdr(vid_hdr); |
| 986 | } | 994 | } else if (UBI_IO_DEBUG) |
| 995 | dbg_msg("bad CRC at PEB %d, calculated %#08x, " | ||
| 996 | "read %#08x", pnum, crc, hdr_crc); | ||
| 987 | return UBI_IO_BAD_VID_HDR; | 997 | return UBI_IO_BAD_VID_HDR; |
| 988 | } | 998 | } |
| 989 | 999 | ||
| @@ -1024,7 +1034,7 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum, | |||
| 1024 | 1034 | ||
| 1025 | err = paranoid_check_peb_ec_hdr(ubi, pnum); | 1035 | err = paranoid_check_peb_ec_hdr(ubi, pnum); |
| 1026 | if (err) | 1036 | if (err) |
| 1027 | return err > 0 ? -EINVAL: err; | 1037 | return err > 0 ? -EINVAL : err; |
| 1028 | 1038 | ||
| 1029 | vid_hdr->magic = cpu_to_be32(UBI_VID_HDR_MAGIC); | 1039 | vid_hdr->magic = cpu_to_be32(UBI_VID_HDR_MAGIC); |
| 1030 | vid_hdr->version = UBI_VERSION; | 1040 | vid_hdr->version = UBI_VERSION; |
