aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@free-electrons.com>2016-02-04 03:52:30 -0500
committerBoris Brezillon <boris.brezillon@free-electrons.com>2016-04-19 16:05:47 -0400
commit75eb2cec251fda33c9bb716ecc372819abb9278a (patch)
tree6adaf011cf01e43273cf1b70f82ed12812182fc5 /include/linux
parentc4f3ef2c6c219c3e58e0f5a9589a67685a75d787 (diff)
mtd: add mtd_ooblayout_xxx() helper functions
In order to make the ecclayout definition completely dynamic we need to rework the way the OOB layout are defined and iterated. Create a few mtd_ooblayout_xxx() helpers to ease OOB bytes manipulation and hide ecclayout internals to their users. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/mtd/mtd.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index ef9fea4fc400..117ca1ff581d 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -108,6 +108,21 @@ struct nand_ecclayout {
108 struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES_LARGE]; 108 struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES_LARGE];
109}; 109};
110 110
111/**
112 * struct mtd_oob_region - oob region definition
113 * @offset: region offset
114 * @length: region length
115 *
116 * This structure describes a region of the OOB area, and is used
117 * to retrieve ECC or free bytes sections.
118 * Each section is defined by an offset within the OOB area and a
119 * length.
120 */
121struct mtd_oob_region {
122 u32 offset;
123 u32 length;
124};
125
111struct module; /* only needed for owner field in mtd_info */ 126struct module; /* only needed for owner field in mtd_info */
112 127
113struct mtd_info { 128struct mtd_info {
@@ -253,6 +268,24 @@ struct mtd_info {
253 int usecount; 268 int usecount;
254}; 269};
255 270
271int mtd_ooblayout_ecc(struct mtd_info *mtd, int section,
272 struct mtd_oob_region *oobecc);
273int mtd_ooblayout_find_eccregion(struct mtd_info *mtd, int eccbyte,
274 int *section,
275 struct mtd_oob_region *oobregion);
276int mtd_ooblayout_get_eccbytes(struct mtd_info *mtd, u8 *eccbuf,
277 const u8 *oobbuf, int start, int nbytes);
278int mtd_ooblayout_set_eccbytes(struct mtd_info *mtd, const u8 *eccbuf,
279 u8 *oobbuf, int start, int nbytes);
280int mtd_ooblayout_free(struct mtd_info *mtd, int section,
281 struct mtd_oob_region *oobfree);
282int mtd_ooblayout_get_databytes(struct mtd_info *mtd, u8 *databuf,
283 const u8 *oobbuf, int start, int nbytes);
284int mtd_ooblayout_set_databytes(struct mtd_info *mtd, const u8 *databuf,
285 u8 *oobbuf, int start, int nbytes);
286int mtd_ooblayout_count_freebytes(struct mtd_info *mtd);
287int mtd_ooblayout_count_eccbytes(struct mtd_info *mtd);
288
256static inline void mtd_set_of_node(struct mtd_info *mtd, 289static inline void mtd_set_of_node(struct mtd_info *mtd,
257 struct device_node *np) 290 struct device_node *np)
258{ 291{