diff options
author | Dmitry Lavnikevich <d.lavnikevich@sam-solutions.com> | 2014-03-10 14:39:49 +0300 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-03-12 21:26:37 +0100 |
commit | 1ee640765a71a7b9ee2cf4ebad22ed5961aef8db (patch) | |
tree | b41e5eefa1033297be8f1713fbcdacfa58e3aebc /include | |
parent | cf1b29a8504c83bb1922e249c2293a3ecd2920da (diff) | |
download | barebox-1ee640765a71a7b9ee2cf4ebad22ed5961aef8db.tar.gz barebox-1ee640765a71a7b9ee2cf4ebad22ed5961aef8db.tar.xz |
mtd: Update internal API to support 64-bit device size
MTD internal API presently uses 32-bit values to represent device
size. This patch updates them to 64-bits but leaves the external API
unchanged.
In general, changing from 32-bit to 64-bit values cause little
or no changes to the majority of the code with the following
exceptions:
- printk message formats;
- division and modulus of 64-bit values (mtd_div_by_wb,
mtd_div_by_eb may be used in some of such cases).
Was tested on phyFLEX i.MX6.
Signed-off-by: Dmitry Lavnikevich <d.lavnikevich@sam-solutions.com>
Signed-off-by: Grigory Milev <g.milev@sam-solutions.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/mtd/mtd-abi.h | 12 | ||||
-rw-r--r-- | include/linux/mtd/mtd.h | 11 |
2 files changed, 20 insertions, 3 deletions
diff --git a/include/linux/mtd/mtd-abi.h b/include/linux/mtd/mtd-abi.h index 11d51e2744..c1ba55bd2d 100644 --- a/include/linux/mtd/mtd-abi.h +++ b/include/linux/mtd/mtd-abi.h @@ -9,6 +9,8 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS +#include <asm-generic/div64.h> + struct erase_info_user { uint32_t start; uint32_t length; @@ -73,7 +75,7 @@ enum { struct mtd_info_user { uint8_t type; uint32_t flags; - uint32_t size; // Total size of the MTD + uint64_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) @@ -173,6 +175,14 @@ enum mtd_file_modes { MTD_MODE_RAW, }; + +static inline uint32_t mtd_user_div_by_eb(uint64_t sz, + struct mtd_info_user *mtd_user) +{ + do_div(sz, mtd_user->erasesize); + return sz; +} + #endif /* DOXYGEN_SHOULD_SKIP_THIS */ #endif /* __MTD_ABI_H__ */ diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index e02204a503..970cdb02fa 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -86,7 +86,7 @@ struct mtd_oob_ops { struct mtd_info { u_char type; u_int32_t flags; - u_int32_t size; // Total size of the MTD + u_int64_t size; /* Total size of the MTD */ /* "Major" erase size for the device. Naïve users may take this * to be the only erase size available, or may use the more detailed @@ -219,7 +219,7 @@ struct mtd_info { int p_allow_erasebad; struct mtd_info *master; - uint32_t master_offset; + loff_t master_offset; }; int mtd_erase(struct mtd_info *mtd, struct erase_info *instr); @@ -256,6 +256,13 @@ static inline uint32_t mtd_mod_by_eb(uint64_t sz, struct mtd_info *mtd) { return do_div(sz, mtd->erasesize); } + +static inline uint32_t mtd_div_by_wb(uint64_t sz, struct mtd_info *mtd) +{ + do_div(sz, mtd->writesize); + return sz; +} + /* Kernel-side ioctl definitions */ extern int add_mtd_device(struct mtd_info *mtd, char *devname, int device_id); |