aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/ubi/debug.c38
-rw-r--r--drivers/mtd/ubi/eba.c62
-rw-r--r--drivers/mtd/ubi/io.c46
-rw-r--r--drivers/mtd/ubi/scan.c56
-rw-r--r--drivers/mtd/ubi/vmt.c18
-rw-r--r--drivers/mtd/ubi/vtbl.c40
-rw-r--r--drivers/mtd/ubi/wl.c4
7 files changed, 132 insertions, 132 deletions
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index 86364221fafe..9a996c5280f9 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -35,12 +35,12 @@
35void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr) 35void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr)
36{ 36{
37 dbg_msg("erase counter header dump:"); 37 dbg_msg("erase counter header dump:");
38 dbg_msg("magic %#08x", ubi32_to_cpu(ec_hdr->magic)); 38 dbg_msg("magic %#08x", be32_to_cpu(ec_hdr->magic));
39 dbg_msg("version %d", (int)ec_hdr->version); 39 dbg_msg("version %d", (int)ec_hdr->version);
40 dbg_msg("ec %llu", (long long)ubi64_to_cpu(ec_hdr->ec)); 40 dbg_msg("ec %llu", (long long)be64_to_cpu(ec_hdr->ec));
41 dbg_msg("vid_hdr_offset %d", ubi32_to_cpu(ec_hdr->vid_hdr_offset)); 41 dbg_msg("vid_hdr_offset %d", be32_to_cpu(ec_hdr->vid_hdr_offset));
42 dbg_msg("data_offset %d", ubi32_to_cpu(ec_hdr->data_offset)); 42 dbg_msg("data_offset %d", be32_to_cpu(ec_hdr->data_offset));
43 dbg_msg("hdr_crc %#08x", ubi32_to_cpu(ec_hdr->hdr_crc)); 43 dbg_msg("hdr_crc %#08x", be32_to_cpu(ec_hdr->hdr_crc));
44 dbg_msg("erase counter header hexdump:"); 44 dbg_msg("erase counter header hexdump:");
45 ubi_dbg_hexdump(ec_hdr, UBI_EC_HDR_SIZE); 45 ubi_dbg_hexdump(ec_hdr, UBI_EC_HDR_SIZE);
46} 46}
@@ -52,20 +52,20 @@ void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr)
52void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr) 52void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr)
53{ 53{
54 dbg_msg("volume identifier header dump:"); 54 dbg_msg("volume identifier header dump:");
55 dbg_msg("magic %08x", ubi32_to_cpu(vid_hdr->magic)); 55 dbg_msg("magic %08x", be32_to_cpu(vid_hdr->magic));
56 dbg_msg("version %d", (int)vid_hdr->version); 56 dbg_msg("version %d", (int)vid_hdr->version);
57 dbg_msg("vol_type %d", (int)vid_hdr->vol_type); 57 dbg_msg("vol_type %d", (int)vid_hdr->vol_type);
58 dbg_msg("copy_flag %d", (int)vid_hdr->copy_flag); 58 dbg_msg("copy_flag %d", (int)vid_hdr->copy_flag);
59 dbg_msg("compat %d", (int)vid_hdr->compat); 59 dbg_msg("compat %d", (int)vid_hdr->compat);
60 dbg_msg("vol_id %d", ubi32_to_cpu(vid_hdr->vol_id)); 60 dbg_msg("vol_id %d", be32_to_cpu(vid_hdr->vol_id));
61 dbg_msg("lnum %d", ubi32_to_cpu(vid_hdr->lnum)); 61 dbg_msg("lnum %d", be32_to_cpu(vid_hdr->lnum));
62 dbg_msg("leb_ver %u", ubi32_to_cpu(vid_hdr->leb_ver)); 62 dbg_msg("leb_ver %u", be32_to_cpu(vid_hdr->leb_ver));
63 dbg_msg("data_size %d", ubi32_to_cpu(vid_hdr->data_size)); 63 dbg_msg("data_size %d", be32_to_cpu(vid_hdr->data_size));
64 dbg_msg("used_ebs %d", ubi32_to_cpu(vid_hdr->used_ebs)); 64 dbg_msg("used_ebs %d", be32_to_cpu(vid_hdr->used_ebs));
65 dbg_msg("data_pad %d", ubi32_to_cpu(vid_hdr->data_pad)); 65 dbg_msg("data_pad %d", be32_to_cpu(vid_hdr->data_pad));
66 dbg_msg("sqnum %llu", 66 dbg_msg("sqnum %llu",
67 (unsigned long long)ubi64_to_cpu(vid_hdr->sqnum)); 67 (unsigned long long)be64_to_cpu(vid_hdr->sqnum));
68 dbg_msg("hdr_crc %08x", ubi32_to_cpu(vid_hdr->hdr_crc)); 68 dbg_msg("hdr_crc %08x", be32_to_cpu(vid_hdr->hdr_crc));
69 dbg_msg("volume identifier header hexdump:"); 69 dbg_msg("volume identifier header hexdump:");
70} 70}
71 71
@@ -106,12 +106,12 @@ void ubi_dbg_dump_vol_info(const struct ubi_volume *vol)
106 */ 106 */
107void ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) 107void ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx)
108{ 108{
109 int name_len = ubi16_to_cpu(r->name_len); 109 int name_len = be16_to_cpu(r->name_len);
110 110
111 dbg_msg("volume table record %d dump:", idx); 111 dbg_msg("volume table record %d dump:", idx);
112 dbg_msg("reserved_pebs %d", ubi32_to_cpu(r->reserved_pebs)); 112 dbg_msg("reserved_pebs %d", be32_to_cpu(r->reserved_pebs));
113 dbg_msg("alignment %d", ubi32_to_cpu(r->alignment)); 113 dbg_msg("alignment %d", be32_to_cpu(r->alignment));
114 dbg_msg("data_pad %d", ubi32_to_cpu(r->data_pad)); 114 dbg_msg("data_pad %d", be32_to_cpu(r->data_pad));
115 dbg_msg("vol_type %d", (int)r->vol_type); 115 dbg_msg("vol_type %d", (int)r->vol_type);
116 dbg_msg("upd_marker %d", (int)r->upd_marker); 116 dbg_msg("upd_marker %d", (int)r->upd_marker);
117 dbg_msg("name_len %d", name_len); 117 dbg_msg("name_len %d", name_len);
@@ -129,7 +129,7 @@ void ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx)
129 r->name[0], r->name[1], r->name[2], r->name[3], 129 r->name[0], r->name[1], r->name[2], r->name[3],
130 r->name[4]); 130 r->name[4]);
131 } 131 }
132 dbg_msg("crc %#08x", ubi32_to_cpu(r->crc)); 132 dbg_msg("crc %#08x", be32_to_cpu(r->crc));
133} 133}
134 134
135/** 135/**
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index 6964fe4ab41a..a1820151e9f9 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -425,10 +425,10 @@ retry:
425 } else if (err == UBI_IO_BITFLIPS) 425 } else if (err == UBI_IO_BITFLIPS)
426 scrub = 1; 426 scrub = 1;
427 427
428 ubi_assert(lnum < ubi32_to_cpu(vid_hdr->used_ebs)); 428 ubi_assert(lnum < be32_to_cpu(vid_hdr->used_ebs));
429 ubi_assert(len == ubi32_to_cpu(vid_hdr->data_size)); 429 ubi_assert(len == be32_to_cpu(vid_hdr->data_size));
430 430
431 crc = ubi32_to_cpu(vid_hdr->data_crc); 431 crc = be32_to_cpu(vid_hdr->data_crc);
432 ubi_free_vid_hdr(ubi, vid_hdr); 432 ubi_free_vid_hdr(ubi, vid_hdr);
433 } 433 }
434 434
@@ -518,7 +518,7 @@ retry:
518 goto out_put; 518 goto out_put;
519 } 519 }
520 520
521 vid_hdr->sqnum = cpu_to_ubi64(next_sqnum(ubi)); 521 vid_hdr->sqnum = cpu_to_be64(next_sqnum(ubi));
522 err = ubi_io_write_vid_hdr(ubi, new_pnum, vid_hdr); 522 err = ubi_io_write_vid_hdr(ubi, new_pnum, vid_hdr);
523 if (err) 523 if (err)
524 goto write_error; 524 goto write_error;
@@ -634,11 +634,11 @@ int ubi_eba_write_leb(struct ubi_device *ubi, int vol_id, int lnum,
634 } 634 }
635 635
636 vid_hdr->vol_type = UBI_VID_DYNAMIC; 636 vid_hdr->vol_type = UBI_VID_DYNAMIC;
637 vid_hdr->sqnum = cpu_to_ubi64(next_sqnum(ubi)); 637 vid_hdr->sqnum = cpu_to_be64(next_sqnum(ubi));
638 vid_hdr->vol_id = cpu_to_ubi32(vol_id); 638 vid_hdr->vol_id = cpu_to_be32(vol_id);
639 vid_hdr->lnum = cpu_to_ubi32(lnum); 639 vid_hdr->lnum = cpu_to_be32(lnum);
640 vid_hdr->compat = ubi_get_compat(ubi, vol_id); 640 vid_hdr->compat = ubi_get_compat(ubi, vol_id);
641 vid_hdr->data_pad = cpu_to_ubi32(vol->data_pad); 641 vid_hdr->data_pad = cpu_to_be32(vol->data_pad);
642 642
643retry: 643retry:
644 pnum = ubi_wl_get_peb(ubi, dtype); 644 pnum = ubi_wl_get_peb(ubi, dtype);
@@ -692,7 +692,7 @@ write_error:
692 return err; 692 return err;
693 } 693 }
694 694
695 vid_hdr->sqnum = cpu_to_ubi64(next_sqnum(ubi)); 695 vid_hdr->sqnum = cpu_to_be64(next_sqnum(ubi));
696 ubi_msg("try another PEB"); 696 ubi_msg("try another PEB");
697 goto retry; 697 goto retry;
698} 698}
@@ -748,17 +748,17 @@ int ubi_eba_write_leb_st(struct ubi_device *ubi, int vol_id, int lnum,
748 return err; 748 return err;
749 } 749 }
750 750
751 vid_hdr->sqnum = cpu_to_ubi64(next_sqnum(ubi)); 751 vid_hdr->sqnum = cpu_to_be64(next_sqnum(ubi));
752 vid_hdr->vol_id = cpu_to_ubi32(vol_id); 752 vid_hdr->vol_id = cpu_to_be32(vol_id);
753 vid_hdr->lnum = cpu_to_ubi32(lnum); 753 vid_hdr->lnum = cpu_to_be32(lnum);
754 vid_hdr->compat = ubi_get_compat(ubi, vol_id); 754 vid_hdr->compat = ubi_get_compat(ubi, vol_id);
755 vid_hdr->data_pad = cpu_to_ubi32(vol->data_pad); 755 vid_hdr->data_pad = cpu_to_be32(vol->data_pad);
756 756
757 crc = crc32(UBI_CRC32_INIT, buf, data_size); 757 crc = crc32(UBI_CRC32_INIT, buf, data_size);
758 vid_hdr->vol_type = UBI_VID_STATIC; 758 vid_hdr->vol_type = UBI_VID_STATIC;
759 vid_hdr->data_size = cpu_to_ubi32(data_size); 759 vid_hdr->data_size = cpu_to_be32(data_size);
760 vid_hdr->used_ebs = cpu_to_ubi32(used_ebs); 760 vid_hdr->used_ebs = cpu_to_be32(used_ebs);
761 vid_hdr->data_crc = cpu_to_ubi32(crc); 761 vid_hdr->data_crc = cpu_to_be32(crc);
762 762
763retry: 763retry:
764 pnum = ubi_wl_get_peb(ubi, dtype); 764 pnum = ubi_wl_get_peb(ubi, dtype);
@@ -813,7 +813,7 @@ write_error:
813 return err; 813 return err;
814 } 814 }
815 815
816 vid_hdr->sqnum = cpu_to_ubi64(next_sqnum(ubi)); 816 vid_hdr->sqnum = cpu_to_be64(next_sqnum(ubi));
817 ubi_msg("try another PEB"); 817 ubi_msg("try another PEB");
818 goto retry; 818 goto retry;
819} 819}
@@ -854,17 +854,17 @@ int ubi_eba_atomic_leb_change(struct ubi_device *ubi, int vol_id, int lnum,
854 return err; 854 return err;
855 } 855 }
856 856
857 vid_hdr->sqnum = cpu_to_ubi64(next_sqnum(ubi)); 857 vid_hdr->sqnum = cpu_to_be64(next_sqnum(ubi));
858 vid_hdr->vol_id = cpu_to_ubi32(vol_id); 858 vid_hdr->vol_id = cpu_to_be32(vol_id);
859 vid_hdr->lnum = cpu_to_ubi32(lnum); 859 vid_hdr->lnum = cpu_to_be32(lnum);
860 vid_hdr->compat = ubi_get_compat(ubi, vol_id); 860 vid_hdr->compat = ubi_get_compat(ubi, vol_id);
861 vid_hdr->data_pad = cpu_to_ubi32(vol->data_pad); 861 vid_hdr->data_pad = cpu_to_be32(vol->data_pad);
862 862
863 crc = crc32(UBI_CRC32_INIT, buf, len); 863 crc = crc32(UBI_CRC32_INIT, buf, len);
864 vid_hdr->vol_type = UBI_VID_STATIC; 864 vid_hdr->vol_type = UBI_VID_STATIC;
865 vid_hdr->data_size = cpu_to_ubi32(len); 865 vid_hdr->data_size = cpu_to_be32(len);
866 vid_hdr->copy_flag = 1; 866 vid_hdr->copy_flag = 1;
867 vid_hdr->data_crc = cpu_to_ubi32(crc); 867 vid_hdr->data_crc = cpu_to_be32(crc);
868 868
869retry: 869retry:
870 pnum = ubi_wl_get_peb(ubi, dtype); 870 pnum = ubi_wl_get_peb(ubi, dtype);
@@ -924,7 +924,7 @@ write_error:
924 return err; 924 return err;
925 } 925 }
926 926
927 vid_hdr->sqnum = cpu_to_ubi64(next_sqnum(ubi)); 927 vid_hdr->sqnum = cpu_to_be64(next_sqnum(ubi));
928 ubi_msg("try another PEB"); 928 ubi_msg("try another PEB");
929 goto retry; 929 goto retry;
930} 930}
@@ -965,17 +965,17 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
965 uint32_t crc; 965 uint32_t crc;
966 void *buf, *buf1 = NULL; 966 void *buf, *buf1 = NULL;
967 967
968 vol_id = ubi32_to_cpu(vid_hdr->vol_id); 968 vol_id = be32_to_cpu(vid_hdr->vol_id);
969 lnum = ubi32_to_cpu(vid_hdr->lnum); 969 lnum = be32_to_cpu(vid_hdr->lnum);
970 970
971 dbg_eba("copy LEB %d:%d, PEB %d to PEB %d", vol_id, lnum, from, to); 971 dbg_eba("copy LEB %d:%d, PEB %d to PEB %d", vol_id, lnum, from, to);
972 972
973 if (vid_hdr->vol_type == UBI_VID_STATIC) { 973 if (vid_hdr->vol_type == UBI_VID_STATIC) {
974 data_size = ubi32_to_cpu(vid_hdr->data_size); 974 data_size = be32_to_cpu(vid_hdr->data_size);
975 aldata_size = ALIGN(data_size, ubi->min_io_size); 975 aldata_size = ALIGN(data_size, ubi->min_io_size);
976 } else 976 } else
977 data_size = aldata_size = 977 data_size = aldata_size =
978 ubi->leb_size - ubi32_to_cpu(vid_hdr->data_pad); 978 ubi->leb_size - be32_to_cpu(vid_hdr->data_pad);
979 979
980 buf = vmalloc(aldata_size); 980 buf = vmalloc(aldata_size);
981 if (!buf) 981 if (!buf)
@@ -1054,10 +1054,10 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
1054 */ 1054 */
1055 if (data_size > 0) { 1055 if (data_size > 0) {
1056 vid_hdr->copy_flag = 1; 1056 vid_hdr->copy_flag = 1;
1057 vid_hdr->data_size = cpu_to_ubi32(data_size); 1057 vid_hdr->data_size = cpu_to_be32(data_size);
1058 vid_hdr->data_crc = cpu_to_ubi32(crc); 1058 vid_hdr->data_crc = cpu_to_be32(crc);
1059 } 1059 }
1060 vid_hdr->sqnum = cpu_to_ubi64(next_sqnum(ubi)); 1060 vid_hdr->sqnum = cpu_to_be64(next_sqnum(ubi));
1061 1061
1062 err = ubi_io_write_vid_hdr(ubi, to, vid_hdr); 1062 err = ubi_io_write_vid_hdr(ubi, to, vid_hdr);
1063 if (err) 1063 if (err)
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 7bb473e646e3..20e297ad7f6b 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -557,9 +557,9 @@ static int validate_ec_hdr(const struct ubi_device *ubi,
557 long long ec; 557 long long ec;
558 int vid_hdr_offset, leb_start; 558 int vid_hdr_offset, leb_start;
559 559
560 ec = ubi64_to_cpu(ec_hdr->ec); 560 ec = be64_to_cpu(ec_hdr->ec);
561 vid_hdr_offset = ubi32_to_cpu(ec_hdr->vid_hdr_offset); 561 vid_hdr_offset = be32_to_cpu(ec_hdr->vid_hdr_offset);
562 leb_start = ubi32_to_cpu(ec_hdr->data_offset); 562 leb_start = be32_to_cpu(ec_hdr->data_offset);
563 563
564 if (ec_hdr->version != UBI_VERSION) { 564 if (ec_hdr->version != UBI_VERSION) {
565 ubi_err("node with incompatible UBI version found: " 565 ubi_err("node with incompatible UBI version found: "
@@ -640,7 +640,7 @@ int ubi_io_read_ec_hdr(const struct ubi_device *ubi, int pnum,
640 read_err = err; 640 read_err = err;
641 } 641 }
642 642
643 magic = ubi32_to_cpu(ec_hdr->magic); 643 magic = be32_to_cpu(ec_hdr->magic);
644 if (magic != UBI_EC_HDR_MAGIC) { 644 if (magic != UBI_EC_HDR_MAGIC) {
645 /* 645 /*
646 * The magic field is wrong. Let's check if we have read all 646 * The magic field is wrong. Let's check if we have read all
@@ -684,7 +684,7 @@ int ubi_io_read_ec_hdr(const struct ubi_device *ubi, int pnum,
684 } 684 }
685 685
686 crc = crc32(UBI_CRC32_INIT, ec_hdr, UBI_EC_HDR_SIZE_CRC); 686 crc = crc32(UBI_CRC32_INIT, ec_hdr, UBI_EC_HDR_SIZE_CRC);
687 hdr_crc = ubi32_to_cpu(ec_hdr->hdr_crc); 687 hdr_crc = be32_to_cpu(ec_hdr->hdr_crc);
688 688
689 if (hdr_crc != crc) { 689 if (hdr_crc != crc) {
690 if (verbose) { 690 if (verbose) {
@@ -729,12 +729,12 @@ int ubi_io_write_ec_hdr(const struct ubi_device *ubi, int pnum,
729 dbg_io("write EC header to PEB %d", pnum); 729 dbg_io("write EC header to PEB %d", pnum);
730 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); 730 ubi_assert(pnum >= 0 && pnum < ubi->peb_count);
731 731
732 ec_hdr->magic = cpu_to_ubi32(UBI_EC_HDR_MAGIC); 732 ec_hdr->magic = cpu_to_be32(UBI_EC_HDR_MAGIC);
733 ec_hdr->version = UBI_VERSION; 733 ec_hdr->version = UBI_VERSION;
734 ec_hdr->vid_hdr_offset = cpu_to_ubi32(ubi->vid_hdr_offset); 734 ec_hdr->vid_hdr_offset = cpu_to_be32(ubi->vid_hdr_offset);
735 ec_hdr->data_offset = cpu_to_ubi32(ubi->leb_start); 735 ec_hdr->data_offset = cpu_to_be32(ubi->leb_start);
736 crc = crc32(UBI_CRC32_INIT, ec_hdr, UBI_EC_HDR_SIZE_CRC); 736 crc = crc32(UBI_CRC32_INIT, ec_hdr, UBI_EC_HDR_SIZE_CRC);
737 ec_hdr->hdr_crc = cpu_to_ubi32(crc); 737 ec_hdr->hdr_crc = cpu_to_be32(crc);
738 738
739 err = paranoid_check_ec_hdr(ubi, pnum, ec_hdr); 739 err = paranoid_check_ec_hdr(ubi, pnum, ec_hdr);
740 if (err) 740 if (err)
@@ -757,13 +757,13 @@ static int validate_vid_hdr(const struct ubi_device *ubi,
757{ 757{
758 int vol_type = vid_hdr->vol_type; 758 int vol_type = vid_hdr->vol_type;
759 int copy_flag = vid_hdr->copy_flag; 759 int copy_flag = vid_hdr->copy_flag;
760 int vol_id = ubi32_to_cpu(vid_hdr->vol_id); 760 int vol_id = be32_to_cpu(vid_hdr->vol_id);
761 int lnum = ubi32_to_cpu(vid_hdr->lnum); 761 int lnum = be32_to_cpu(vid_hdr->lnum);
762 int compat = vid_hdr->compat; 762 int compat = vid_hdr->compat;
763 int data_size = ubi32_to_cpu(vid_hdr->data_size); 763 int data_size = be32_to_cpu(vid_hdr->data_size);
764 int used_ebs = ubi32_to_cpu(vid_hdr->used_ebs); 764 int used_ebs = be32_to_cpu(vid_hdr->used_ebs);
765 int data_pad = ubi32_to_cpu(vid_hdr->data_pad); 765 int data_pad = be32_to_cpu(vid_hdr->data_pad);
766 int data_crc = ubi32_to_cpu(vid_hdr->data_crc); 766 int data_crc = be32_to_cpu(vid_hdr->data_crc);
767 int usable_leb_size = ubi->leb_size - data_pad; 767 int usable_leb_size = ubi->leb_size - data_pad;
768 768
769 if (copy_flag != 0 && copy_flag != 1) { 769 if (copy_flag != 0 && copy_flag != 1) {
@@ -914,7 +914,7 @@ int ubi_io_read_vid_hdr(const struct ubi_device *ubi, int pnum,
914 read_err = err; 914 read_err = err;
915 } 915 }
916 916
917 magic = ubi32_to_cpu(vid_hdr->magic); 917 magic = be32_to_cpu(vid_hdr->magic);
918 if (magic != UBI_VID_HDR_MAGIC) { 918 if (magic != UBI_VID_HDR_MAGIC) {
919 /* 919 /*
920 * If we have read all 0xFF bytes, the VID header probably does 920 * If we have read all 0xFF bytes, the VID header probably does
@@ -957,7 +957,7 @@ int ubi_io_read_vid_hdr(const struct ubi_device *ubi, int pnum,
957 } 957 }
958 958
959 crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_VID_HDR_SIZE_CRC); 959 crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_VID_HDR_SIZE_CRC);
960 hdr_crc = ubi32_to_cpu(vid_hdr->hdr_crc); 960 hdr_crc = be32_to_cpu(vid_hdr->hdr_crc);
961 961
962 if (hdr_crc != crc) { 962 if (hdr_crc != crc) {
963 if (verbose) { 963 if (verbose) {
@@ -1007,10 +1007,10 @@ int ubi_io_write_vid_hdr(const struct ubi_device *ubi, int pnum,
1007 if (err) 1007 if (err)
1008 return err > 0 ? -EINVAL: err; 1008 return err > 0 ? -EINVAL: err;
1009 1009
1010 vid_hdr->magic = cpu_to_ubi32(UBI_VID_HDR_MAGIC); 1010 vid_hdr->magic = cpu_to_be32(UBI_VID_HDR_MAGIC);
1011 vid_hdr->version = UBI_VERSION; 1011 vid_hdr->version = UBI_VERSION;
1012 crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_VID_HDR_SIZE_CRC); 1012 crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_VID_HDR_SIZE_CRC);
1013 vid_hdr->hdr_crc = cpu_to_ubi32(crc); 1013 vid_hdr->hdr_crc = cpu_to_be32(crc);
1014 1014
1015 err = paranoid_check_vid_hdr(ubi, pnum, vid_hdr); 1015 err = paranoid_check_vid_hdr(ubi, pnum, vid_hdr);
1016 if (err) 1016 if (err)
@@ -1060,7 +1060,7 @@ static int paranoid_check_ec_hdr(const struct ubi_device *ubi, int pnum,
1060 int err; 1060 int err;
1061 uint32_t magic; 1061 uint32_t magic;
1062 1062
1063 magic = ubi32_to_cpu(ec_hdr->magic); 1063 magic = be32_to_cpu(ec_hdr->magic);
1064 if (magic != UBI_EC_HDR_MAGIC) { 1064 if (magic != UBI_EC_HDR_MAGIC) {
1065 ubi_err("bad magic %#08x, must be %#08x", 1065 ubi_err("bad magic %#08x, must be %#08x",
1066 magic, UBI_EC_HDR_MAGIC); 1066 magic, UBI_EC_HDR_MAGIC);
@@ -1105,7 +1105,7 @@ static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum)
1105 goto exit; 1105 goto exit;
1106 1106
1107 crc = crc32(UBI_CRC32_INIT, ec_hdr, UBI_EC_HDR_SIZE_CRC); 1107 crc = crc32(UBI_CRC32_INIT, ec_hdr, UBI_EC_HDR_SIZE_CRC);
1108 hdr_crc = ubi32_to_cpu(ec_hdr->hdr_crc); 1108 hdr_crc = be32_to_cpu(ec_hdr->hdr_crc);
1109 if (hdr_crc != crc) { 1109 if (hdr_crc != crc) {
1110 ubi_err("bad CRC, calculated %#08x, read %#08x", crc, hdr_crc); 1110 ubi_err("bad CRC, calculated %#08x, read %#08x", crc, hdr_crc);
1111 ubi_err("paranoid check failed for PEB %d", pnum); 1111 ubi_err("paranoid check failed for PEB %d", pnum);
@@ -1137,7 +1137,7 @@ static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum,
1137 int err; 1137 int err;
1138 uint32_t magic; 1138 uint32_t magic;
1139 1139
1140 magic = ubi32_to_cpu(vid_hdr->magic); 1140 magic = be32_to_cpu(vid_hdr->magic);
1141 if (magic != UBI_VID_HDR_MAGIC) { 1141 if (magic != UBI_VID_HDR_MAGIC) {
1142 ubi_err("bad VID header magic %#08x at PEB %d, must be %#08x", 1142 ubi_err("bad VID header magic %#08x at PEB %d, must be %#08x",
1143 magic, pnum, UBI_VID_HDR_MAGIC); 1143 magic, pnum, UBI_VID_HDR_MAGIC);
@@ -1187,7 +1187,7 @@ static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum)
1187 goto exit; 1187 goto exit;
1188 1188
1189 crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_EC_HDR_SIZE_CRC); 1189 crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_EC_HDR_SIZE_CRC);
1190 hdr_crc = ubi32_to_cpu(vid_hdr->hdr_crc); 1190 hdr_crc = be32_to_cpu(vid_hdr->hdr_crc);
1191 if (hdr_crc != crc) { 1191 if (hdr_crc != crc) {
1192 ubi_err("bad VID header CRC at PEB %d, calculated %#08x, " 1192 ubi_err("bad VID header CRC at PEB %d, calculated %#08x, "
1193 "read %#08x", pnum, crc, hdr_crc); 1193 "read %#08x", pnum, crc, hdr_crc);
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index cbd588d60168..23e30ac089ce 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -132,9 +132,9 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr,
132 const struct ubi_scan_volume *sv, int pnum) 132 const struct ubi_scan_volume *sv, int pnum)
133{ 133{
134 int vol_type = vid_hdr->vol_type; 134 int vol_type = vid_hdr->vol_type;
135 int vol_id = ubi32_to_cpu(vid_hdr->vol_id); 135 int vol_id = be32_to_cpu(vid_hdr->vol_id);
136 int used_ebs = ubi32_to_cpu(vid_hdr->used_ebs); 136 int used_ebs = be32_to_cpu(vid_hdr->used_ebs);
137 int data_pad = ubi32_to_cpu(vid_hdr->data_pad); 137 int data_pad = be32_to_cpu(vid_hdr->data_pad);
138 138
139 if (sv->leb_count != 0) { 139 if (sv->leb_count != 0) {
140 int sv_vol_type; 140 int sv_vol_type;
@@ -200,7 +200,7 @@ static struct ubi_scan_volume *add_volume(struct ubi_scan_info *si, int vol_id,
200 struct ubi_scan_volume *sv; 200 struct ubi_scan_volume *sv;
201 struct rb_node **p = &si->volumes.rb_node, *parent = NULL; 201 struct rb_node **p = &si->volumes.rb_node, *parent = NULL;
202 202
203 ubi_assert(vol_id == ubi32_to_cpu(vid_hdr->vol_id)); 203 ubi_assert(vol_id == be32_to_cpu(vid_hdr->vol_id));
204 204
205 /* Walk the volume RB-tree to look if this volume is already present */ 205 /* Walk the volume RB-tree to look if this volume is already present */
206 while (*p) { 206 while (*p) {
@@ -225,8 +225,8 @@ static struct ubi_scan_volume *add_volume(struct ubi_scan_info *si, int vol_id,
225 si->max_sqnum = 0; 225 si->max_sqnum = 0;
226 sv->vol_id = vol_id; 226 sv->vol_id = vol_id;
227 sv->root = RB_ROOT; 227 sv->root = RB_ROOT;
228 sv->used_ebs = ubi32_to_cpu(vid_hdr->used_ebs); 228 sv->used_ebs = be32_to_cpu(vid_hdr->used_ebs);
229 sv->data_pad = ubi32_to_cpu(vid_hdr->data_pad); 229 sv->data_pad = be32_to_cpu(vid_hdr->data_pad);
230 sv->compat = vid_hdr->compat; 230 sv->compat = vid_hdr->compat;
231 sv->vol_type = vid_hdr->vol_type == UBI_VID_DYNAMIC ? UBI_DYNAMIC_VOLUME 231 sv->vol_type = vid_hdr->vol_type == UBI_VID_DYNAMIC ? UBI_DYNAMIC_VOLUME
232 : UBI_STATIC_VOLUME; 232 : UBI_STATIC_VOLUME;
@@ -268,10 +268,10 @@ static int compare_lebs(const struct ubi_device *ubi,
268 int len, err, second_is_newer, bitflips = 0, corrupted = 0; 268 int len, err, second_is_newer, bitflips = 0, corrupted = 0;
269 uint32_t data_crc, crc; 269 uint32_t data_crc, crc;
270 struct ubi_vid_hdr *vidh = NULL; 270 struct ubi_vid_hdr *vidh = NULL;
271 unsigned long long sqnum2 = ubi64_to_cpu(vid_hdr->sqnum); 271 unsigned long long sqnum2 = be64_to_cpu(vid_hdr->sqnum);
272 272
273 if (seb->sqnum == 0 && sqnum2 == 0) { 273 if (seb->sqnum == 0 && sqnum2 == 0) {
274 long long abs, v1 = seb->leb_ver, v2 = ubi32_to_cpu(vid_hdr->leb_ver); 274 long long abs, v1 = seb->leb_ver, v2 = be32_to_cpu(vid_hdr->leb_ver);
275 275
276 /* 276 /*
277 * UBI constantly increases the logical eraseblock version 277 * UBI constantly increases the logical eraseblock version
@@ -355,7 +355,7 @@ static int compare_lebs(const struct ubi_device *ubi,
355 355
356 /* Read the data of the copy and check the CRC */ 356 /* Read the data of the copy and check the CRC */
357 357
358 len = ubi32_to_cpu(vid_hdr->data_size); 358 len = be32_to_cpu(vid_hdr->data_size);
359 buf = vmalloc(len); 359 buf = vmalloc(len);
360 if (!buf) { 360 if (!buf) {
361 err = -ENOMEM; 361 err = -ENOMEM;
@@ -366,7 +366,7 @@ static int compare_lebs(const struct ubi_device *ubi,
366 if (err && err != UBI_IO_BITFLIPS) 366 if (err && err != UBI_IO_BITFLIPS)
367 goto out_free_buf; 367 goto out_free_buf;
368 368
369 data_crc = ubi32_to_cpu(vid_hdr->data_crc); 369 data_crc = be32_to_cpu(vid_hdr->data_crc);
370 crc = crc32(UBI_CRC32_INIT, buf, len); 370 crc = crc32(UBI_CRC32_INIT, buf, len);
371 if (crc != data_crc) { 371 if (crc != data_crc) {
372 dbg_bld("PEB %d CRC error: calculated %#08x, must be %#08x", 372 dbg_bld("PEB %d CRC error: calculated %#08x, must be %#08x",
@@ -425,10 +425,10 @@ int ubi_scan_add_used(const struct ubi_device *ubi, struct ubi_scan_info *si,
425 struct ubi_scan_leb *seb; 425 struct ubi_scan_leb *seb;
426 struct rb_node **p, *parent = NULL; 426 struct rb_node **p, *parent = NULL;
427 427
428 vol_id = ubi32_to_cpu(vid_hdr->vol_id); 428 vol_id = be32_to_cpu(vid_hdr->vol_id);
429 lnum = ubi32_to_cpu(vid_hdr->lnum); 429 lnum = be32_to_cpu(vid_hdr->lnum);
430 sqnum = ubi64_to_cpu(vid_hdr->sqnum); 430 sqnum = be64_to_cpu(vid_hdr->sqnum);
431 leb_ver = ubi32_to_cpu(vid_hdr->leb_ver); 431 leb_ver = be32_to_cpu(vid_hdr->leb_ver);
432 432
433 dbg_bld("PEB %d, LEB %d:%d, EC %d, sqnum %llu, ver %u, bitflips %d", 433 dbg_bld("PEB %d, LEB %d:%d, EC %d, sqnum %llu, ver %u, bitflips %d",
434 pnum, vol_id, lnum, ec, sqnum, leb_ver, bitflips); 434 pnum, vol_id, lnum, ec, sqnum, leb_ver, bitflips);
@@ -523,7 +523,7 @@ int ubi_scan_add_used(const struct ubi_device *ubi, struct ubi_scan_info *si,
523 523
524 if (sv->highest_lnum == lnum) 524 if (sv->highest_lnum == lnum)
525 sv->last_data_size = 525 sv->last_data_size =
526 ubi32_to_cpu(vid_hdr->data_size); 526 be32_to_cpu(vid_hdr->data_size);
527 527
528 return 0; 528 return 0;
529 } else { 529 } else {
@@ -560,7 +560,7 @@ int ubi_scan_add_used(const struct ubi_device *ubi, struct ubi_scan_info *si,
560 560
561 if (sv->highest_lnum <= lnum) { 561 if (sv->highest_lnum <= lnum) {
562 sv->highest_lnum = lnum; 562 sv->highest_lnum = lnum;
563 sv->last_data_size = ubi32_to_cpu(vid_hdr->data_size); 563 sv->last_data_size = be32_to_cpu(vid_hdr->data_size);
564 } 564 }
565 565
566 if (si->max_sqnum < sqnum) 566 if (si->max_sqnum < sqnum)
@@ -687,7 +687,7 @@ int ubi_scan_erase_peb(const struct ubi_device *ubi,
687 return -EINVAL; 687 return -EINVAL;
688 } 688 }
689 689
690 ec_hdr->ec = cpu_to_ubi64(ec); 690 ec_hdr->ec = cpu_to_be64(ec);
691 691
692 err = ubi_io_sync_erase(ubi, pnum, 0); 692 err = ubi_io_sync_erase(ubi, pnum, 0);
693 if (err < 0) 693 if (err < 0)
@@ -818,7 +818,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si, int pnum
818 return -EINVAL; 818 return -EINVAL;
819 } 819 }
820 820
821 ec = ubi64_to_cpu(ech->ec); 821 ec = be64_to_cpu(ech->ec);
822 if (ec > UBI_MAX_ERASECOUNTER) { 822 if (ec > UBI_MAX_ERASECOUNTER) {
823 /* 823 /*
824 * Erase counter overflow. The EC headers have 64 bits 824 * Erase counter overflow. The EC headers have 64 bits
@@ -856,9 +856,9 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si, int pnum
856 goto adjust_mean_ec; 856 goto adjust_mean_ec;
857 } 857 }
858 858
859 vol_id = ubi32_to_cpu(vidh->vol_id); 859 vol_id = be32_to_cpu(vidh->vol_id);
860 if (vol_id > UBI_MAX_VOLUMES && vol_id != UBI_LAYOUT_VOL_ID) { 860 if (vol_id > UBI_MAX_VOLUMES && vol_id != UBI_LAYOUT_VOL_ID) {
861 int lnum = ubi32_to_cpu(vidh->lnum); 861 int lnum = be32_to_cpu(vidh->lnum);
862 862
863 /* Unsupported internal volume */ 863 /* Unsupported internal volume */
864 switch (vidh->compat) { 864 switch (vidh->compat) {
@@ -1261,12 +1261,12 @@ static int paranoid_check_si(const struct ubi_device *ubi,
1261 goto bad_vid_hdr; 1261 goto bad_vid_hdr;
1262 } 1262 }
1263 1263
1264 if (seb->sqnum != ubi64_to_cpu(vidh->sqnum)) { 1264 if (seb->sqnum != be64_to_cpu(vidh->sqnum)) {
1265 ubi_err("bad sqnum %llu", seb->sqnum); 1265 ubi_err("bad sqnum %llu", seb->sqnum);
1266 goto bad_vid_hdr; 1266 goto bad_vid_hdr;
1267 } 1267 }
1268 1268
1269 if (sv->vol_id != ubi32_to_cpu(vidh->vol_id)) { 1269 if (sv->vol_id != be32_to_cpu(vidh->vol_id)) {
1270 ubi_err("bad vol_id %d", sv->vol_id); 1270 ubi_err("bad vol_id %d", sv->vol_id);
1271 goto bad_vid_hdr; 1271 goto bad_vid_hdr;
1272 } 1272 }
@@ -1276,22 +1276,22 @@ static int paranoid_check_si(const struct ubi_device *ubi,
1276 goto bad_vid_hdr; 1276 goto bad_vid_hdr;
1277 } 1277 }
1278 1278
1279 if (seb->lnum != ubi32_to_cpu(vidh->lnum)) { 1279 if (seb->lnum != be32_to_cpu(vidh->lnum)) {
1280 ubi_err("bad lnum %d", seb->lnum); 1280 ubi_err("bad lnum %d", seb->lnum);
1281 goto bad_vid_hdr; 1281 goto bad_vid_hdr;
1282 } 1282 }
1283 1283
1284 if (sv->used_ebs != ubi32_to_cpu(vidh->used_ebs)) { 1284 if (sv->used_ebs != be32_to_cpu(vidh->used_ebs)) {
1285 ubi_err("bad used_ebs %d", sv->used_ebs); 1285 ubi_err("bad used_ebs %d", sv->used_ebs);
1286 goto bad_vid_hdr; 1286 goto bad_vid_hdr;
1287 } 1287 }
1288 1288
1289 if (sv->data_pad != ubi32_to_cpu(vidh->data_pad)) { 1289 if (sv->data_pad != be32_to_cpu(vidh->data_pad)) {
1290 ubi_err("bad data_pad %d", sv->data_pad); 1290 ubi_err("bad data_pad %d", sv->data_pad);
1291 goto bad_vid_hdr; 1291 goto bad_vid_hdr;
1292 } 1292 }
1293 1293
1294 if (seb->leb_ver != ubi32_to_cpu(vidh->leb_ver)) { 1294 if (seb->leb_ver != be32_to_cpu(vidh->leb_ver)) {
1295 ubi_err("bad leb_ver %u", seb->leb_ver); 1295 ubi_err("bad leb_ver %u", seb->leb_ver);
1296 goto bad_vid_hdr; 1296 goto bad_vid_hdr;
1297 } 1297 }
@@ -1300,12 +1300,12 @@ static int paranoid_check_si(const struct ubi_device *ubi,
1300 if (!last_seb) 1300 if (!last_seb)
1301 continue; 1301 continue;
1302 1302
1303 if (sv->highest_lnum != ubi32_to_cpu(vidh->lnum)) { 1303 if (sv->highest_lnum != be32_to_cpu(vidh->lnum)) {
1304 ubi_err("bad highest_lnum %d", sv->highest_lnum); 1304 ubi_err("bad highest_lnum %d", sv->highest_lnum);
1305 goto bad_vid_hdr; 1305 goto bad_vid_hdr;
1306 } 1306 }
1307 1307
1308 if (sv->last_data_size != ubi32_to_cpu(vidh->data_size)) { 1308 if (sv->last_data_size != be32_to_cpu(vidh->data_size)) {
1309 ubi_err("bad last_data_size %d", sv->last_data_size); 1309 ubi_err("bad last_data_size %d", sv->last_data_size);
1310 goto bad_vid_hdr; 1310 goto bad_vid_hdr;
1311 } 1311 }
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index 4add5c816b14..6e135996e42d 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -319,10 +319,10 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
319 319
320 /* Fill volume table record */ 320 /* Fill volume table record */
321 memset(&vtbl_rec, 0, sizeof(struct ubi_vtbl_record)); 321 memset(&vtbl_rec, 0, sizeof(struct ubi_vtbl_record));
322 vtbl_rec.reserved_pebs = cpu_to_ubi32(vol->reserved_pebs); 322 vtbl_rec.reserved_pebs = cpu_to_be32(vol->reserved_pebs);
323 vtbl_rec.alignment = cpu_to_ubi32(vol->alignment); 323 vtbl_rec.alignment = cpu_to_be32(vol->alignment);
324 vtbl_rec.data_pad = cpu_to_ubi32(vol->data_pad); 324 vtbl_rec.data_pad = cpu_to_be32(vol->data_pad);
325 vtbl_rec.name_len = cpu_to_ubi16(vol->name_len); 325 vtbl_rec.name_len = cpu_to_be16(vol->name_len);
326 if (vol->vol_type == UBI_DYNAMIC_VOLUME) 326 if (vol->vol_type == UBI_DYNAMIC_VOLUME)
327 vtbl_rec.vol_type = UBI_VID_DYNAMIC; 327 vtbl_rec.vol_type = UBI_VID_DYNAMIC;
328 else 328 else
@@ -502,7 +502,7 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs)
502 502
503 /* Change volume table record */ 503 /* Change volume table record */
504 memcpy(&vtbl_rec, &ubi->vtbl[vol_id], sizeof(struct ubi_vtbl_record)); 504 memcpy(&vtbl_rec, &ubi->vtbl[vol_id], sizeof(struct ubi_vtbl_record));
505 vtbl_rec.reserved_pebs = cpu_to_ubi32(reserved_pebs); 505 vtbl_rec.reserved_pebs = cpu_to_be32(reserved_pebs);
506 err = ubi_change_vtbl_record(ubi, vol_id, &vtbl_rec); 506 err = ubi_change_vtbl_record(ubi, vol_id, &vtbl_rec);
507 if (err) 507 if (err)
508 goto out_acc; 508 goto out_acc;
@@ -650,7 +650,7 @@ static void paranoid_check_volume(const struct ubi_device *ubi, int vol_id)
650 long long n; 650 long long n;
651 const char *name; 651 const char *name;
652 652
653 reserved_pebs = ubi32_to_cpu(ubi->vtbl[vol_id].reserved_pebs); 653 reserved_pebs = be32_to_cpu(ubi->vtbl[vol_id].reserved_pebs);
654 654
655 if (!vol) { 655 if (!vol) {
656 if (reserved_pebs) { 656 if (reserved_pebs) {
@@ -764,9 +764,9 @@ static void paranoid_check_volume(const struct ubi_device *ubi, int vol_id)
764 } 764 }
765 } 765 }
766 766
767 alignment = ubi32_to_cpu(ubi->vtbl[vol_id].alignment); 767 alignment = be32_to_cpu(ubi->vtbl[vol_id].alignment);
768 data_pad = ubi32_to_cpu(ubi->vtbl[vol_id].data_pad); 768 data_pad = be32_to_cpu(ubi->vtbl[vol_id].data_pad);
769 name_len = ubi16_to_cpu(ubi->vtbl[vol_id].name_len); 769 name_len = be16_to_cpu(ubi->vtbl[vol_id].name_len);
770 upd_marker = ubi->vtbl[vol_id].upd_marker; 770 upd_marker = ubi->vtbl[vol_id].upd_marker;
771 name = &ubi->vtbl[vol_id].name[0]; 771 name = &ubi->vtbl[vol_id].name[0];
772 if (ubi->vtbl[vol_id].vol_type == UBI_VID_DYNAMIC) 772 if (ubi->vtbl[vol_id].vol_type == UBI_VID_DYNAMIC)
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index e3557b987efd..800ce940a820 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -93,7 +93,7 @@ int ubi_change_vtbl_record(struct ubi_device *ubi, int idx,
93 vtbl_rec = &empty_vtbl_record; 93 vtbl_rec = &empty_vtbl_record;
94 else { 94 else {
95 crc = crc32(UBI_CRC32_INIT, vtbl_rec, UBI_VTBL_RECORD_SIZE_CRC); 95 crc = crc32(UBI_CRC32_INIT, vtbl_rec, UBI_VTBL_RECORD_SIZE_CRC);
96 vtbl_rec->crc = cpu_to_ubi32(crc); 96 vtbl_rec->crc = cpu_to_be32(crc);
97 } 97 }
98 98
99 dbg_msg("change record %d", idx); 99 dbg_msg("change record %d", idx);
@@ -141,18 +141,18 @@ static int vtbl_check(const struct ubi_device *ubi,
141 for (i = 0; i < ubi->vtbl_slots; i++) { 141 for (i = 0; i < ubi->vtbl_slots; i++) {
142 cond_resched(); 142 cond_resched();
143 143
144 reserved_pebs = ubi32_to_cpu(vtbl[i].reserved_pebs); 144 reserved_pebs = be32_to_cpu(vtbl[i].reserved_pebs);
145 alignment = ubi32_to_cpu(vtbl[i].alignment); 145 alignment = be32_to_cpu(vtbl[i].alignment);
146 data_pad = ubi32_to_cpu(vtbl[i].data_pad); 146 data_pad = be32_to_cpu(vtbl[i].data_pad);
147 upd_marker = vtbl[i].upd_marker; 147 upd_marker = vtbl[i].upd_marker;
148 vol_type = vtbl[i].vol_type; 148 vol_type = vtbl[i].vol_type;
149 name_len = ubi16_to_cpu(vtbl[i].name_len); 149 name_len = be16_to_cpu(vtbl[i].name_len);
150 name = &vtbl[i].name[0]; 150 name = &vtbl[i].name[0];
151 151
152 crc = crc32(UBI_CRC32_INIT, &vtbl[i], UBI_VTBL_RECORD_SIZE_CRC); 152 crc = crc32(UBI_CRC32_INIT, &vtbl[i], UBI_VTBL_RECORD_SIZE_CRC);
153 if (ubi32_to_cpu(vtbl[i].crc) != crc) { 153 if (be32_to_cpu(vtbl[i].crc) != crc) {
154 ubi_err("bad CRC at record %u: %#08x, not %#08x", 154 ubi_err("bad CRC at record %u: %#08x, not %#08x",
155 i, crc, ubi32_to_cpu(vtbl[i].crc)); 155 i, crc, be32_to_cpu(vtbl[i].crc));
156 ubi_dbg_dump_vtbl_record(&vtbl[i], i); 156 ubi_dbg_dump_vtbl_record(&vtbl[i], i);
157 return 1; 157 return 1;
158 } 158 }
@@ -225,8 +225,8 @@ static int vtbl_check(const struct ubi_device *ubi,
225 /* Checks that all names are unique */ 225 /* Checks that all names are unique */
226 for (i = 0; i < ubi->vtbl_slots - 1; i++) { 226 for (i = 0; i < ubi->vtbl_slots - 1; i++) {
227 for (n = i + 1; n < ubi->vtbl_slots; n++) { 227 for (n = i + 1; n < ubi->vtbl_slots; n++) {
228 int len1 = ubi16_to_cpu(vtbl[i].name_len); 228 int len1 = be16_to_cpu(vtbl[i].name_len);
229 int len2 = ubi16_to_cpu(vtbl[n].name_len); 229 int len2 = be16_to_cpu(vtbl[n].name_len);
230 230
231 if (len1 > 0 && len1 == len2 && 231 if (len1 > 0 && len1 == len2 &&
232 !strncmp(vtbl[i].name, vtbl[n].name, len1)) { 232 !strncmp(vtbl[i].name, vtbl[n].name, len1)) {
@@ -288,13 +288,13 @@ retry:
288 } 288 }
289 289
290 vid_hdr->vol_type = UBI_VID_DYNAMIC; 290 vid_hdr->vol_type = UBI_VID_DYNAMIC;
291 vid_hdr->vol_id = cpu_to_ubi32(UBI_LAYOUT_VOL_ID); 291 vid_hdr->vol_id = cpu_to_be32(UBI_LAYOUT_VOL_ID);
292 vid_hdr->compat = UBI_LAYOUT_VOLUME_COMPAT; 292 vid_hdr->compat = UBI_LAYOUT_VOLUME_COMPAT;
293 vid_hdr->data_size = vid_hdr->used_ebs = 293 vid_hdr->data_size = vid_hdr->used_ebs =
294 vid_hdr->data_pad = cpu_to_ubi32(0); 294 vid_hdr->data_pad = cpu_to_be32(0);
295 vid_hdr->lnum = cpu_to_ubi32(copy); 295 vid_hdr->lnum = cpu_to_be32(copy);
296 vid_hdr->sqnum = cpu_to_ubi64(++si->max_sqnum); 296 vid_hdr->sqnum = cpu_to_be64(++si->max_sqnum);
297 vid_hdr->leb_ver = cpu_to_ubi32(old_seb ? old_seb->leb_ver + 1: 0); 297 vid_hdr->leb_ver = cpu_to_be32(old_seb ? old_seb->leb_ver + 1: 0);
298 298
299 /* The EC header is already there, write the VID header */ 299 /* The EC header is already there, write the VID header */
300 err = ubi_io_write_vid_hdr(ubi, new_seb->pnum, vid_hdr); 300 err = ubi_io_write_vid_hdr(ubi, new_seb->pnum, vid_hdr);
@@ -503,19 +503,19 @@ static int init_volumes(struct ubi_device *ubi, const struct ubi_scan_info *si,
503 for (i = 0; i < ubi->vtbl_slots; i++) { 503 for (i = 0; i < ubi->vtbl_slots; i++) {
504 cond_resched(); 504 cond_resched();
505 505
506 if (ubi32_to_cpu(vtbl[i].reserved_pebs) == 0) 506 if (be32_to_cpu(vtbl[i].reserved_pebs) == 0)
507 continue; /* Empty record */ 507 continue; /* Empty record */
508 508
509 vol = kzalloc(sizeof(struct ubi_volume), GFP_KERNEL); 509 vol = kzalloc(sizeof(struct ubi_volume), GFP_KERNEL);
510 if (!vol) 510 if (!vol)
511 return -ENOMEM; 511 return -ENOMEM;
512 512
513 vol->reserved_pebs = ubi32_to_cpu(vtbl[i].reserved_pebs); 513 vol->reserved_pebs = be32_to_cpu(vtbl[i].reserved_pebs);
514 vol->alignment = ubi32_to_cpu(vtbl[i].alignment); 514 vol->alignment = be32_to_cpu(vtbl[i].alignment);
515 vol->data_pad = ubi32_to_cpu(vtbl[i].data_pad); 515 vol->data_pad = be32_to_cpu(vtbl[i].data_pad);
516 vol->vol_type = vtbl[i].vol_type == UBI_VID_DYNAMIC ? 516 vol->vol_type = vtbl[i].vol_type == UBI_VID_DYNAMIC ?
517 UBI_DYNAMIC_VOLUME : UBI_STATIC_VOLUME; 517 UBI_DYNAMIC_VOLUME : UBI_STATIC_VOLUME;
518 vol->name_len = ubi16_to_cpu(vtbl[i].name_len); 518 vol->name_len = be16_to_cpu(vtbl[i].name_len);
519 vol->usable_leb_size = ubi->leb_size - vol->data_pad; 519 vol->usable_leb_size = ubi->leb_size - vol->data_pad;
520 memcpy(vol->name, vtbl[i].name, vol->name_len); 520 memcpy(vol->name, vtbl[i].name, vol->name_len);
521 vol->name[vol->name_len] = '\0'; 521 vol->name[vol->name_len] = '\0';
@@ -721,7 +721,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_scan_info *si)
721 int i, err; 721 int i, err;
722 struct ubi_scan_volume *sv; 722 struct ubi_scan_volume *sv;
723 723
724 empty_vtbl_record.crc = cpu_to_ubi32(0xf116c36b); 724 empty_vtbl_record.crc = cpu_to_be32(0xf116c36b);
725 725
726 /* 726 /*
727 * The number of supported volumes is limited by the eraseblock size 727 * The number of supported volumes is limited by the eraseblock size
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index ab2174a56bc2..d512cf16350d 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -667,7 +667,7 @@ static int sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e, int tortur
667 667
668 dbg_wl("erased PEB %d, new EC %llu", e->pnum, ec); 668 dbg_wl("erased PEB %d, new EC %llu", e->pnum, ec);
669 669
670 ec_hdr->ec = cpu_to_ubi64(ec); 670 ec_hdr->ec = cpu_to_be64(ec);
671 671
672 err = ubi_io_write_ec_hdr(ubi, e->pnum, ec_hdr); 672 err = ubi_io_write_ec_hdr(ubi, e->pnum, ec_hdr);
673 if (err) 673 if (err)
@@ -1634,7 +1634,7 @@ static int paranoid_check_ec(const struct ubi_device *ubi, int pnum, int ec)
1634 goto out_free; 1634 goto out_free;
1635 } 1635 }
1636 1636
1637 read_ec = ubi64_to_cpu(ec_hdr->ec); 1637 read_ec = be64_to_cpu(ec_hdr->ec);
1638 if (ec != read_ec) { 1638 if (ec != read_ec) {
1639 ubi_err("paranoid check failed for PEB %d", pnum); 1639 ubi_err("paranoid check failed for PEB %d", pnum);
1640 ubi_err("read EC is %lld, should be %d", read_ec, ec); 1640 ubi_err("read EC is %lld, should be %d", read_ec, ec);