Skip to content

Commit ccef7ab

Browse files
arndbIngo Molnar
authored andcommitted
make MTD headers use strict integer types
The MTD headers traditionally use stdint types rather than the kernel integer types. This converts them to do the same as all the others. Cc: David Woodhouse <dwmw2@infradead.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 9adfbfb commit ccef7ab

6 files changed

Lines changed: 123 additions & 115 deletions

File tree

‎include/linux/jffs2.h‎

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#ifndef __LINUX_JFFS2_H__
1313
#define __LINUX_JFFS2_H__
1414

15+
#include <linux/types.h>
1516
#include <linux/magic.h>
1617

1718
/* You must include something which defines the C99 uintXX_t types.
@@ -91,15 +92,15 @@
9192
byteswapping */
9293

9394
typedef struct {
94-
uint32_t v32;
95+
__u32 v32;
9596
} __attribute__((packed)) jint32_t;
9697

9798
typedef struct {
98-
uint32_t m;
99+
__u32 m;
99100
} __attribute__((packed)) jmode_t;
100101

101102
typedef struct {
102-
uint16_t v16;
103+
__u16 v16;
103104
} __attribute__((packed)) jint16_t;
104105

105106
struct jffs2_unknown_node
@@ -121,12 +122,12 @@ struct jffs2_raw_dirent
121122
jint32_t version;
122123
jint32_t ino; /* == zero for unlink */
123124
jint32_t mctime;
124-
uint8_t nsize;
125-
uint8_t type;
126-
uint8_t unused[2];
125+
__u8 nsize;
126+
__u8 type;
127+
__u8 unused[2];
127128
jint32_t node_crc;
128129
jint32_t name_crc;
129-
uint8_t name[0];
130+
__u8 name[0];
130131
};
131132

132133
/* The JFFS2 raw inode structure: Used for storage on physical media. */
@@ -153,12 +154,12 @@ struct jffs2_raw_inode
153154
jint32_t offset; /* Where to begin to write. */
154155
jint32_t csize; /* (Compressed) data size */
155156
jint32_t dsize; /* Size of the node's data. (after decompression) */
156-
uint8_t compr; /* Compression algorithm used */
157-
uint8_t usercompr; /* Compression algorithm requested by the user */
157+
__u8 compr; /* Compression algorithm used */
158+
__u8 usercompr; /* Compression algorithm requested by the user */
158159
jint16_t flags; /* See JFFS2_INO_FLAG_* */
159160
jint32_t data_crc; /* CRC for the (compressed) data. */
160161
jint32_t node_crc; /* CRC for the raw inode (excluding data) */
161-
uint8_t data[0];
162+
__u8 data[0];
162163
};
163164

164165
struct jffs2_raw_xattr {
@@ -168,12 +169,12 @@ struct jffs2_raw_xattr {
168169
jint32_t hdr_crc;
169170
jint32_t xid; /* XATTR identifier number */
170171
jint32_t version;
171-
uint8_t xprefix;
172-
uint8_t name_len;
172+
__u8 xprefix;
173+
__u8 name_len;
173174
jint16_t value_len;
174175
jint32_t data_crc;
175176
jint32_t node_crc;
176-
uint8_t data[0];
177+
__u8 data[0];
177178
} __attribute__((packed));
178179

179180
struct jffs2_raw_xref

‎include/mtd/inftl-user.h‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,33 @@
1616
/* Block Control Information */
1717

1818
struct inftl_bci {
19-
uint8_t ECCsig[6];
20-
uint8_t Status;
21-
uint8_t Status1;
19+
__u8 ECCsig[6];
20+
__u8 Status;
21+
__u8 Status1;
2222
} __attribute__((packed));
2323

2424
struct inftl_unithead1 {
25-
uint16_t virtualUnitNo;
26-
uint16_t prevUnitNo;
27-
uint8_t ANAC;
28-
uint8_t NACs;
29-
uint8_t parityPerField;
30-
uint8_t discarded;
25+
__u16 virtualUnitNo;
26+
__u16 prevUnitNo;
27+
__u8 ANAC;
28+
__u8 NACs;
29+
__u8 parityPerField;
30+
__u8 discarded;
3131
} __attribute__((packed));
3232

3333
struct inftl_unithead2 {
34-
uint8_t parityPerField;
35-
uint8_t ANAC;
36-
uint16_t prevUnitNo;
37-
uint16_t virtualUnitNo;
38-
uint8_t NACs;
39-
uint8_t discarded;
34+
__u8 parityPerField;
35+
__u8 ANAC;
36+
__u16 prevUnitNo;
37+
__u16 virtualUnitNo;
38+
__u8 NACs;
39+
__u8 discarded;
4040
} __attribute__((packed));
4141

4242
struct inftl_unittail {
43-
uint8_t Reserved[4];
44-
uint16_t EraseMark;
45-
uint16_t EraseMark1;
43+
__u8 Reserved[4];
44+
__u16 EraseMark;
45+
__u16 EraseMark1;
4646
} __attribute__((packed));
4747

4848
union inftl_uci {

‎include/mtd/jffs2-user.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
/* This file is blessed for inclusion by userspace */
99
#include <linux/jffs2.h>
10+
#include <linux/types.h>
1011
#include <endian.h>
1112
#include <byteswap.h>
1213

@@ -19,8 +20,8 @@
1920

2021
extern int target_endian;
2122

22-
#define t16(x) ({ uint16_t __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_16(__b); })
23-
#define t32(x) ({ uint32_t __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_32(__b); })
23+
#define t16(x) ({ __u16 __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_16(__b); })
24+
#define t32(x) ({ __u32 __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_32(__b); })
2425

2526
#define cpu_to_je16(x) ((jint16_t){t16(x)})
2627
#define cpu_to_je32(x) ((jint32_t){t32(x)})

‎include/mtd/mtd-abi.h‎

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
#ifndef __MTD_ABI_H__
66
#define __MTD_ABI_H__
77

8+
#include <linux/types.h>
9+
810
struct erase_info_user {
9-
uint32_t start;
10-
uint32_t length;
11+
__u32 start;
12+
__u32 length;
1113
};
1214

1315
struct mtd_oob_buf {
14-
uint32_t start;
15-
uint32_t length;
16+
__u32 start;
17+
__u32 length;
1618
unsigned char __user *ptr;
1719
};
1820

@@ -48,30 +50,30 @@ struct mtd_oob_buf {
4850
#define MTD_OTP_USER 2
4951

5052
struct mtd_info_user {
51-
uint8_t type;
52-
uint32_t flags;
53-
uint32_t size; // Total size of the MTD
54-
uint32_t erasesize;
55-
uint32_t writesize;
56-
uint32_t oobsize; // Amount of OOB data per block (e.g. 16)
53+
__u8 type;
54+
__u32 flags;
55+
__u32 size; // Total size of the MTD
56+
__u32 erasesize;
57+
__u32 writesize;
58+
__u32 oobsize; // Amount of OOB data per block (e.g. 16)
5759
/* The below two fields are obsolete and broken, do not use them
5860
* (TODO: remove at some point) */
59-
uint32_t ecctype;
60-
uint32_t eccsize;
61+
__u32 ecctype;
62+
__u32 eccsize;
6163
};
6264

6365
struct region_info_user {
64-
uint32_t offset; /* At which this region starts,
66+
__u32 offset; /* At which this region starts,
6567
* from the beginning of the MTD */
66-
uint32_t erasesize; /* For this region */
67-
uint32_t numblocks; /* Number of blocks in this region */
68-
uint32_t regionindex;
68+
__u32 erasesize; /* For this region */
69+
__u32 numblocks; /* Number of blocks in this region */
70+
__u32 regionindex;
6971
};
7072

7173
struct otp_info {
72-
uint32_t start;
73-
uint32_t length;
74-
uint32_t locked;
74+
__u32 start;
75+
__u32 length;
76+
__u32 locked;
7577
};
7678

7779
#define MEMGETINFO _IOR('M', 1, struct mtd_info_user)
@@ -99,15 +101,15 @@ struct otp_info {
99101
* interfaces
100102
*/
101103
struct nand_oobinfo {
102-
uint32_t useecc;
103-
uint32_t eccbytes;
104-
uint32_t oobfree[8][2];
105-
uint32_t eccpos[32];
104+
__u32 useecc;
105+
__u32 eccbytes;
106+
__u32 oobfree[8][2];
107+
__u32 eccpos[32];
106108
};
107109

108110
struct nand_oobfree {
109-
uint32_t offset;
110-
uint32_t length;
111+
__u32 offset;
112+
__u32 length;
111113
};
112114

113115
#define MTD_MAX_OOBFREE_ENTRIES 8
@@ -116,9 +118,9 @@ struct nand_oobfree {
116118
* diagnosis and to allow creation of raw images
117119
*/
118120
struct nand_ecclayout {
119-
uint32_t eccbytes;
120-
uint32_t eccpos[64];
121-
uint32_t oobavail;
121+
__u32 eccbytes;
122+
__u32 eccpos[64];
123+
__u32 oobavail;
122124
struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES];
123125
};
124126

@@ -131,10 +133,10 @@ struct nand_ecclayout {
131133
* @bbtblocks: number of blocks reserved for bad block tables
132134
*/
133135
struct mtd_ecc_stats {
134-
uint32_t corrected;
135-
uint32_t failed;
136-
uint32_t badblocks;
137-
uint32_t bbtblocks;
136+
__u32 corrected;
137+
__u32 failed;
138+
__u32 badblocks;
139+
__u32 bbtblocks;
138140
};
139141

140142
/*

‎include/mtd/nftl-user.h‎

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,35 @@
66
#ifndef __MTD_NFTL_USER_H__
77
#define __MTD_NFTL_USER_H__
88

9+
#include <linux/types.h>
10+
911
/* Block Control Information */
1012

1113
struct nftl_bci {
1214
unsigned char ECCSig[6];
13-
uint8_t Status;
14-
uint8_t Status1;
15+
__u8 Status;
16+
__u8 Status1;
1517
}__attribute__((packed));
1618

1719
/* Unit Control Information */
1820

1921
struct nftl_uci0 {
20-
uint16_t VirtUnitNum;
21-
uint16_t ReplUnitNum;
22-
uint16_t SpareVirtUnitNum;
23-
uint16_t SpareReplUnitNum;
22+
__u16 VirtUnitNum;
23+
__u16 ReplUnitNum;
24+
__u16 SpareVirtUnitNum;
25+
__u16 SpareReplUnitNum;
2426
} __attribute__((packed));
2527

2628
struct nftl_uci1 {
27-
uint32_t WearInfo;
28-
uint16_t EraseMark;
29-
uint16_t EraseMark1;
29+
__u32 WearInfo;
30+
__u16 EraseMark;
31+
__u16 EraseMark1;
3032
} __attribute__((packed));
3133

3234
struct nftl_uci2 {
33-
uint16_t FoldMark;
34-
uint16_t FoldMark1;
35-
uint32_t unused;
35+
__u16 FoldMark;
36+
__u16 FoldMark1;
37+
__u32 unused;
3638
} __attribute__((packed));
3739

3840
union nftl_uci {
@@ -50,9 +52,9 @@ struct nftl_oob {
5052

5153
struct NFTLMediaHeader {
5254
char DataOrgID[6];
53-
uint16_t NumEraseUnits;
54-
uint16_t FirstPhysicalEUN;
55-
uint32_t FormattedSize;
55+
__u16 NumEraseUnits;
56+
__u16 FirstPhysicalEUN;
57+
__u32 FormattedSize;
5658
unsigned char UnitSizeFactor;
5759
} __attribute__((packed));
5860

0 commit comments

Comments
 (0)