Skip to content

Commit

Permalink
make MTD headers use strict integer types
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arnd Bergmann authored and Ingo Molnar committed Mar 26, 2009
1 parent 9adfbfb commit ccef7ab
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 115 deletions.
27 changes: 14 additions & 13 deletions include/linux/jffs2.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#ifndef __LINUX_JFFS2_H__
#define __LINUX_JFFS2_H__

#include <linux/types.h>
#include <linux/magic.h>

/* You must include something which defines the C99 uintXX_t types.
Expand Down Expand Up @@ -91,15 +92,15 @@
byteswapping */

typedef struct {
uint32_t v32;
__u32 v32;
} __attribute__((packed)) jint32_t;

typedef struct {
uint32_t m;
__u32 m;
} __attribute__((packed)) jmode_t;

typedef struct {
uint16_t v16;
__u16 v16;
} __attribute__((packed)) jint16_t;

struct jffs2_unknown_node
Expand All @@ -121,12 +122,12 @@ struct jffs2_raw_dirent
jint32_t version;
jint32_t ino; /* == zero for unlink */
jint32_t mctime;
uint8_t nsize;
uint8_t type;
uint8_t unused[2];
__u8 nsize;
__u8 type;
__u8 unused[2];
jint32_t node_crc;
jint32_t name_crc;
uint8_t name[0];
__u8 name[0];
};

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

struct jffs2_raw_xattr {
Expand All @@ -168,12 +169,12 @@ struct jffs2_raw_xattr {
jint32_t hdr_crc;
jint32_t xid; /* XATTR identifier number */
jint32_t version;
uint8_t xprefix;
uint8_t name_len;
__u8 xprefix;
__u8 name_len;
jint16_t value_len;
jint32_t data_crc;
jint32_t node_crc;
uint8_t data[0];
__u8 data[0];
} __attribute__((packed));

struct jffs2_raw_xref
Expand Down
36 changes: 18 additions & 18 deletions include/mtd/inftl-user.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@
/* Block Control Information */

struct inftl_bci {
uint8_t ECCsig[6];
uint8_t Status;
uint8_t Status1;
__u8 ECCsig[6];
__u8 Status;
__u8 Status1;
} __attribute__((packed));

struct inftl_unithead1 {
uint16_t virtualUnitNo;
uint16_t prevUnitNo;
uint8_t ANAC;
uint8_t NACs;
uint8_t parityPerField;
uint8_t discarded;
__u16 virtualUnitNo;
__u16 prevUnitNo;
__u8 ANAC;
__u8 NACs;
__u8 parityPerField;
__u8 discarded;
} __attribute__((packed));

struct inftl_unithead2 {
uint8_t parityPerField;
uint8_t ANAC;
uint16_t prevUnitNo;
uint16_t virtualUnitNo;
uint8_t NACs;
uint8_t discarded;
__u8 parityPerField;
__u8 ANAC;
__u16 prevUnitNo;
__u16 virtualUnitNo;
__u8 NACs;
__u8 discarded;
} __attribute__((packed));

struct inftl_unittail {
uint8_t Reserved[4];
uint16_t EraseMark;
uint16_t EraseMark1;
__u8 Reserved[4];
__u16 EraseMark;
__u16 EraseMark1;
} __attribute__((packed));

union inftl_uci {
Expand Down
5 changes: 3 additions & 2 deletions include/mtd/jffs2-user.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/* This file is blessed for inclusion by userspace */
#include <linux/jffs2.h>
#include <linux/types.h>
#include <endian.h>
#include <byteswap.h>

Expand All @@ -19,8 +20,8 @@

extern int target_endian;

#define t16(x) ({ uint16_t __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_16(__b); })
#define t32(x) ({ uint32_t __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_32(__b); })
#define t16(x) ({ __u16 __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_16(__b); })
#define t32(x) ({ __u32 __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_32(__b); })

#define cpu_to_je16(x) ((jint16_t){t16(x)})
#define cpu_to_je32(x) ((jint32_t){t32(x)})
Expand Down
66 changes: 34 additions & 32 deletions include/mtd/mtd-abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
#ifndef __MTD_ABI_H__
#define __MTD_ABI_H__

#include <linux/types.h>

struct erase_info_user {
uint32_t start;
uint32_t length;
__u32 start;
__u32 length;
};

struct mtd_oob_buf {
uint32_t start;
uint32_t length;
__u32 start;
__u32 length;
unsigned char __user *ptr;
};

Expand Down Expand Up @@ -48,30 +50,30 @@ struct mtd_oob_buf {
#define MTD_OTP_USER 2

struct mtd_info_user {
uint8_t type;
uint32_t flags;
uint32_t size; // Total size of the MTD
uint32_t erasesize;
uint32_t writesize;
uint32_t oobsize; // Amount of OOB data per block (e.g. 16)
__u8 type;
__u32 flags;
__u32 size; // Total size of the MTD
__u32 erasesize;
__u32 writesize;
__u32 oobsize; // Amount of OOB data per block (e.g. 16)
/* The below two fields are obsolete and broken, do not use them
* (TODO: remove at some point) */
uint32_t ecctype;
uint32_t eccsize;
__u32 ecctype;
__u32 eccsize;
};

struct region_info_user {
uint32_t offset; /* At which this region starts,
__u32 offset; /* At which this region starts,
* from the beginning of the MTD */
uint32_t erasesize; /* For this region */
uint32_t numblocks; /* Number of blocks in this region */
uint32_t regionindex;
__u32 erasesize; /* For this region */
__u32 numblocks; /* Number of blocks in this region */
__u32 regionindex;
};

struct otp_info {
uint32_t start;
uint32_t length;
uint32_t locked;
__u32 start;
__u32 length;
__u32 locked;
};

#define MEMGETINFO _IOR('M', 1, struct mtd_info_user)
Expand Down Expand Up @@ -99,15 +101,15 @@ struct otp_info {
* interfaces
*/
struct nand_oobinfo {
uint32_t useecc;
uint32_t eccbytes;
uint32_t oobfree[8][2];
uint32_t eccpos[32];
__u32 useecc;
__u32 eccbytes;
__u32 oobfree[8][2];
__u32 eccpos[32];
};

struct nand_oobfree {
uint32_t offset;
uint32_t length;
__u32 offset;
__u32 length;
};

#define MTD_MAX_OOBFREE_ENTRIES 8
Expand All @@ -116,9 +118,9 @@ struct nand_oobfree {
* diagnosis and to allow creation of raw images
*/
struct nand_ecclayout {
uint32_t eccbytes;
uint32_t eccpos[64];
uint32_t oobavail;
__u32 eccbytes;
__u32 eccpos[64];
__u32 oobavail;
struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES];
};

Expand All @@ -131,10 +133,10 @@ struct nand_ecclayout {
* @bbtblocks: number of blocks reserved for bad block tables
*/
struct mtd_ecc_stats {
uint32_t corrected;
uint32_t failed;
uint32_t badblocks;
uint32_t bbtblocks;
__u32 corrected;
__u32 failed;
__u32 badblocks;
__u32 bbtblocks;
};

/*
Expand Down
32 changes: 17 additions & 15 deletions include/mtd/nftl-user.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,35 @@
#ifndef __MTD_NFTL_USER_H__
#define __MTD_NFTL_USER_H__

#include <linux/types.h>

/* Block Control Information */

struct nftl_bci {
unsigned char ECCSig[6];
uint8_t Status;
uint8_t Status1;
__u8 Status;
__u8 Status1;
}__attribute__((packed));

/* Unit Control Information */

struct nftl_uci0 {
uint16_t VirtUnitNum;
uint16_t ReplUnitNum;
uint16_t SpareVirtUnitNum;
uint16_t SpareReplUnitNum;
__u16 VirtUnitNum;
__u16 ReplUnitNum;
__u16 SpareVirtUnitNum;
__u16 SpareReplUnitNum;
} __attribute__((packed));

struct nftl_uci1 {
uint32_t WearInfo;
uint16_t EraseMark;
uint16_t EraseMark1;
__u32 WearInfo;
__u16 EraseMark;
__u16 EraseMark1;
} __attribute__((packed));

struct nftl_uci2 {
uint16_t FoldMark;
uint16_t FoldMark1;
uint32_t unused;
__u16 FoldMark;
__u16 FoldMark1;
__u32 unused;
} __attribute__((packed));

union nftl_uci {
Expand All @@ -50,9 +52,9 @@ struct nftl_oob {

struct NFTLMediaHeader {
char DataOrgID[6];
uint16_t NumEraseUnits;
uint16_t FirstPhysicalEUN;
uint32_t FormattedSize;
__u16 NumEraseUnits;
__u16 FirstPhysicalEUN;
__u32 FormattedSize;
unsigned char UnitSizeFactor;
} __attribute__((packed));

Expand Down
Loading

0 comments on commit ccef7ab

Please sign in to comment.