Lines Matching defs:mtd
2 * mtdram - a test mtd device
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/mtdram.h>
34 // We could store these in the mtd structure, but we only support 1 device..
37 static int check_offs_len(struct mtd_info *mtd, loff_t ofs, uint64_t len)
42 if (mtd_mod_by_eb(ofs, mtd)) {
48 if (mtd_mod_by_eb(len, mtd)) {
56 static int ram_erase(struct mtd_info *mtd, struct erase_info *instr)
58 if (check_offs_len(mtd, instr->addr, instr->len))
60 memset((char *)mtd->priv + instr->addr, 0xff, instr->len);
65 static int ram_point(struct mtd_info *mtd, loff_t from, size_t len,
68 *virt = mtd->priv + from;
94 static int ram_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
99 static int ram_read(struct mtd_info *mtd, loff_t from, size_t len,
102 memcpy(buf, mtd->priv + from, len);
107 static int ram_write(struct mtd_info *mtd, loff_t to, size_t len,
110 memcpy((char *)mtd->priv + to, buf, len);
124 int mtdram_init_device(struct mtd_info *mtd, void *mapped_address,
127 memset(mtd, 0, sizeof(*mtd));
130 mtd->name = name;
131 mtd->type = MTD_RAM;
132 mtd->flags = MTD_CAP_RAM;
133 mtd->size = size;
134 mtd->writesize = 1;
135 mtd->writebufsize = writebuf_size;
136 mtd->erasesize = MTDRAM_ERASE_SIZE;
137 mtd->priv = mapped_address;
139 mtd->owner = THIS_MODULE;
140 mtd->_erase = ram_erase;
141 mtd->_point = ram_point;
142 mtd->_unpoint = ram_unpoint;
143 mtd->_read = ram_read;
144 mtd->_write = ram_write;
146 if (mtd_device_register(mtd, NULL, 0))