File indexing completed on 2025-05-11 08:24:17
0001 #ifndef __LINUX_MTD_MTD_H__
0002 #define __LINUX_MTD_MTD_H__
0003
0004 #include <linux/slab.h>
0005 #include <errno.h>
0006
0007 #define MTD_FAIL_ADDR_UNKNOWN -1LL
0008
0009 struct mtd_info {
0010 uint32_t oobavail;
0011 uint32_t oobsize;
0012 uint32_t size;
0013 uint32_t erasesize;
0014 uint32_t writesize;
0015 };
0016
0017 static inline int do_mtd_point(size_t *retlen, void **ebuf)
0018 {
0019 *retlen = 0;
0020 *ebuf = NULL;
0021
0022 return -EOPNOTSUPP;
0023 }
0024
0025 #define mtd_point(a, b, c, d, e, f) do_mtd_point(d, e)
0026
0027 #define mtd_unpoint(a, b, c) do { } while (0)
0028
0029 #define mtd_kmalloc_up_to(a, b) kmalloc(*(b), GFP_KERNEL)
0030
0031 struct mtd_oob_ops {
0032 uint32_t mode;
0033 size_t len;
0034 size_t retlen;
0035 size_t ooblen;
0036 size_t oobretlen;
0037 uint32_t ooboffs;
0038 uint8_t *datbuf;
0039 uint8_t *oobbuf;
0040 };
0041
0042 #define EUCLEAN EAGAIN
0043 static inline int mtd_is_bitflip(int err) { return (err == -EUCLEAN); }
0044
0045 #define mtd_block_isbad(mtd_sp, offset) ({ \
0046 bool bad; \
0047 int sc = jffs2_flash_block_is_bad(RTEMS_CONTAINER_OF(&(mtd_sp), struct jffs2_sb_info, mtd), offset, &bad); \
0048 if (sc) { \
0049 return sc; \
0050 } \
0051 bad; \
0052 })
0053 #define mtd_block_markbad(mtd_sp, offset) \
0054 jffs2_flash_block_mark_bad(RTEMS_CONTAINER_OF(&(mtd_sp), struct jffs2_sb_info, mtd), offset)
0055 #define mtd_write(mtd_sp, ofs, len, retlen, buf) \
0056 jffs2_flash_direct_write(RTEMS_CONTAINER_OF(&(mtd_sp), struct jffs2_sb_info, mtd), ofs, len, retlen, buf)
0057 #define mtd_read(mtd_sp, ofs, len, retlen, buf) \
0058 jffs2_flash_direct_read(RTEMS_CONTAINER_OF(&(mtd_sp), struct jffs2_sb_info, mtd), ofs, len, retlen, buf)
0059
0060 #endif