diff options
author | Christoph Hellwig <hch@lst.de> | 2007-05-21 10:41:46 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-07-18 09:53:49 -0400 |
commit | 3261ebd7d4194ff30d0eae7ba8d937dcccf7235d (patch) | |
tree | 75381f6dd24263cdf484ebc9a5c8a93db6d83cb4 /drivers/mtd/ubi/scan.c | |
parent | bf07803a6827ef8d4c9d840a1de800ba36db0213 (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/scan.c')
-rw-r--r-- | drivers/mtd/ubi/scan.c | 56 |
1 files changed, 28 insertions, 28 deletions
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 | } |