aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/io.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2007-05-21 10:41:46 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2007-07-18 09:53:49 -0400
commit3261ebd7d4194ff30d0eae7ba8d937dcccf7235d (patch)
tree75381f6dd24263cdf484ebc9a5c8a93db6d83cb4 /drivers/mtd/ubi/io.c
parentbf07803a6827ef8d4c9d840a1de800ba36db0213 (diff)
UBI: kill homegrown endian macros
Kill UBI's homegrown endianess handling and replace it with the standard kernel endianess handling. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/io.c')
-rw-r--r--drivers/mtd/ubi/io.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 7bb473e646e..20e297ad7f6 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);