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 /include | |
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 'include')
-rw-r--r-- | include/mtd/ubi-header.h | 101 |
1 files changed, 36 insertions, 65 deletions
diff --git a/include/mtd/ubi-header.h b/include/mtd/ubi-header.h index fa479c71aa34..74efa7763479 100644 --- a/include/mtd/ubi-header.h +++ b/include/mtd/ubi-header.h | |||
@@ -74,42 +74,13 @@ enum { | |||
74 | UBI_COMPAT_REJECT = 5 | 74 | UBI_COMPAT_REJECT = 5 |
75 | }; | 75 | }; |
76 | 76 | ||
77 | /* | ||
78 | * ubi16_t/ubi32_t/ubi64_t - 16, 32, and 64-bit integers used in UBI on-flash | ||
79 | * data structures. | ||
80 | */ | ||
81 | typedef struct { | ||
82 | uint16_t int16; | ||
83 | } __attribute__ ((packed)) ubi16_t; | ||
84 | |||
85 | typedef struct { | ||
86 | uint32_t int32; | ||
87 | } __attribute__ ((packed)) ubi32_t; | ||
88 | |||
89 | typedef struct { | ||
90 | uint64_t int64; | ||
91 | } __attribute__ ((packed)) ubi64_t; | ||
92 | |||
93 | /* | ||
94 | * In this implementation of UBI uses the big-endian format for on-flash | ||
95 | * integers. The below are the corresponding conversion macros. | ||
96 | */ | ||
97 | #define cpu_to_ubi16(x) ((ubi16_t){__cpu_to_be16(x)}) | ||
98 | #define ubi16_to_cpu(x) ((uint16_t)__be16_to_cpu((x).int16)) | ||
99 | |||
100 | #define cpu_to_ubi32(x) ((ubi32_t){__cpu_to_be32(x)}) | ||
101 | #define ubi32_to_cpu(x) ((uint32_t)__be32_to_cpu((x).int32)) | ||
102 | |||
103 | #define cpu_to_ubi64(x) ((ubi64_t){__cpu_to_be64(x)}) | ||
104 | #define ubi64_to_cpu(x) ((uint64_t)__be64_to_cpu((x).int64)) | ||
105 | |||
106 | /* Sizes of UBI headers */ | 77 | /* Sizes of UBI headers */ |
107 | #define UBI_EC_HDR_SIZE sizeof(struct ubi_ec_hdr) | 78 | #define UBI_EC_HDR_SIZE sizeof(struct ubi_ec_hdr) |
108 | #define UBI_VID_HDR_SIZE sizeof(struct ubi_vid_hdr) | 79 | #define UBI_VID_HDR_SIZE sizeof(struct ubi_vid_hdr) |
109 | 80 | ||
110 | /* Sizes of UBI headers without the ending CRC */ | 81 | /* Sizes of UBI headers without the ending CRC */ |
111 | #define UBI_EC_HDR_SIZE_CRC (UBI_EC_HDR_SIZE - sizeof(ubi32_t)) | 82 | #define UBI_EC_HDR_SIZE_CRC (UBI_EC_HDR_SIZE - sizeof(__be32)) |
112 | #define UBI_VID_HDR_SIZE_CRC (UBI_VID_HDR_SIZE - sizeof(ubi32_t)) | 83 | #define UBI_VID_HDR_SIZE_CRC (UBI_VID_HDR_SIZE - sizeof(__be32)) |
113 | 84 | ||
114 | /** | 85 | /** |
115 | * struct ubi_ec_hdr - UBI erase counter header. | 86 | * struct ubi_ec_hdr - UBI erase counter header. |
@@ -137,14 +108,14 @@ typedef struct { | |||
137 | * eraseblocks. | 108 | * eraseblocks. |
138 | */ | 109 | */ |
139 | struct ubi_ec_hdr { | 110 | struct ubi_ec_hdr { |
140 | ubi32_t magic; | 111 | __be32 magic; |
141 | uint8_t version; | 112 | __u8 version; |
142 | uint8_t padding1[3]; | 113 | __u8 padding1[3]; |
143 | ubi64_t ec; /* Warning: the current limit is 31-bit anyway! */ | 114 | __be64 ec; /* Warning: the current limit is 31-bit anyway! */ |
144 | ubi32_t vid_hdr_offset; | 115 | __be32 vid_hdr_offset; |
145 | ubi32_t data_offset; | 116 | __be32 data_offset; |
146 | uint8_t padding2[36]; | 117 | __u8 padding2[36]; |
147 | ubi32_t hdr_crc; | 118 | __be32 hdr_crc; |
148 | } __attribute__ ((packed)); | 119 | } __attribute__ ((packed)); |
149 | 120 | ||
150 | /** | 121 | /** |
@@ -262,22 +233,22 @@ struct ubi_ec_hdr { | |||
262 | * software (say, cramfs) on top of the UBI volume. | 233 | * software (say, cramfs) on top of the UBI volume. |
263 | */ | 234 | */ |
264 | struct ubi_vid_hdr { | 235 | struct ubi_vid_hdr { |
265 | ubi32_t magic; | 236 | __be32 magic; |
266 | uint8_t version; | 237 | __u8 version; |
267 | uint8_t vol_type; | 238 | __u8 vol_type; |
268 | uint8_t copy_flag; | 239 | __u8 copy_flag; |
269 | uint8_t compat; | 240 | __u8 compat; |
270 | ubi32_t vol_id; | 241 | __be32 vol_id; |
271 | ubi32_t lnum; | 242 | __be32 lnum; |
272 | ubi32_t leb_ver; /* obsolete, to be removed, don't use */ | 243 | __be32 leb_ver; /* obsolete, to be removed, don't use */ |
273 | ubi32_t data_size; | 244 | __be32 data_size; |
274 | ubi32_t used_ebs; | 245 | __be32 used_ebs; |
275 | ubi32_t data_pad; | 246 | __be32 data_pad; |
276 | ubi32_t data_crc; | 247 | __be32 data_crc; |
277 | uint8_t padding1[4]; | 248 | __u8 padding1[4]; |
278 | ubi64_t sqnum; | 249 | __be64 sqnum; |
279 | uint8_t padding2[12]; | 250 | __u8 padding2[12]; |
280 | ubi32_t hdr_crc; | 251 | __be32 hdr_crc; |
281 | } __attribute__ ((packed)); | 252 | } __attribute__ ((packed)); |
282 | 253 | ||
283 | /* Internal UBI volumes count */ | 254 | /* Internal UBI volumes count */ |
@@ -306,7 +277,7 @@ struct ubi_vid_hdr { | |||
306 | #define UBI_VTBL_RECORD_SIZE sizeof(struct ubi_vtbl_record) | 277 | #define UBI_VTBL_RECORD_SIZE sizeof(struct ubi_vtbl_record) |
307 | 278 | ||
308 | /* Size of the volume table record without the ending CRC */ | 279 | /* Size of the volume table record without the ending CRC */ |
309 | #define UBI_VTBL_RECORD_SIZE_CRC (UBI_VTBL_RECORD_SIZE - sizeof(ubi32_t)) | 280 | #define UBI_VTBL_RECORD_SIZE_CRC (UBI_VTBL_RECORD_SIZE - sizeof(__be32)) |
310 | 281 | ||
311 | /** | 282 | /** |
312 | * struct ubi_vtbl_record - a record in the volume table. | 283 | * struct ubi_vtbl_record - a record in the volume table. |
@@ -346,15 +317,15 @@ struct ubi_vid_hdr { | |||
346 | * Empty records contain all zeroes and the CRC checksum of those zeroes. | 317 | * Empty records contain all zeroes and the CRC checksum of those zeroes. |
347 | */ | 318 | */ |
348 | struct ubi_vtbl_record { | 319 | struct ubi_vtbl_record { |
349 | ubi32_t reserved_pebs; | 320 | __be32 reserved_pebs; |
350 | ubi32_t alignment; | 321 | __be32 alignment; |
351 | ubi32_t data_pad; | 322 | __be32 data_pad; |
352 | uint8_t vol_type; | 323 | __u8 vol_type; |
353 | uint8_t upd_marker; | 324 | __u8 upd_marker; |
354 | ubi16_t name_len; | 325 | __be16 name_len; |
355 | uint8_t name[UBI_VOL_NAME_MAX+1]; | 326 | __u8 name[UBI_VOL_NAME_MAX+1]; |
356 | uint8_t padding2[24]; | 327 | __u8 padding2[24]; |
357 | ubi32_t crc; | 328 | __be32 crc; |
358 | } __attribute__ ((packed)); | 329 | } __attribute__ ((packed)); |
359 | 330 | ||
360 | #endif /* !__UBI_HEADER_H__ */ | 331 | #endif /* !__UBI_HEADER_H__ */ |