Lines Matching full: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) in check_offs_len() argument
42 if (mtd_mod_by_eb(ofs, mtd)) { in check_offs_len()
48 if (mtd_mod_by_eb(len, mtd)) { in check_offs_len()
56 static int ram_erase(struct mtd_info *mtd, struct erase_info *instr) in ram_erase() argument
58 if (check_offs_len(mtd, instr->addr, instr->len)) in ram_erase()
60 memset((char *)mtd->priv + instr->addr, 0xff, instr->len); in ram_erase()
65 static int ram_point(struct mtd_info *mtd, loff_t from, size_t len, in ram_point() argument
68 *virt = mtd->priv + from; in ram_point()
94 static int ram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) in ram_unpoint() argument
99 static int ram_read(struct mtd_info *mtd, loff_t from, size_t len, in ram_read() argument
102 memcpy(buf, mtd->priv + from, len); in ram_read()
107 static int ram_write(struct mtd_info *mtd, loff_t to, size_t len, in ram_write() argument
110 memcpy((char *)mtd->priv + to, buf, len); in ram_write()
124 int mtdram_init_device(struct mtd_info *mtd, void *mapped_address, in mtdram_init_device() argument
127 memset(mtd, 0, sizeof(*mtd)); in mtdram_init_device()
129 /* Setup the MTD structure */ in mtdram_init_device()
130 mtd->name = name; in mtdram_init_device()
131 mtd->type = MTD_RAM; in mtdram_init_device()
132 mtd->flags = MTD_CAP_RAM; in mtdram_init_device()
133 mtd->size = size; in mtdram_init_device()
134 mtd->writesize = 1; in mtdram_init_device()
135 mtd->writebufsize = writebuf_size; in mtdram_init_device()
136 mtd->erasesize = MTDRAM_ERASE_SIZE; in mtdram_init_device()
137 mtd->priv = mapped_address; in mtdram_init_device()
139 mtd->owner = THIS_MODULE; in mtdram_init_device()
140 mtd->_erase = ram_erase; in mtdram_init_device()
141 mtd->_point = ram_point; in mtdram_init_device()
142 mtd->_unpoint = ram_unpoint; in mtdram_init_device()
143 mtd->_read = ram_read; in mtdram_init_device()
144 mtd->_write = ram_write; in mtdram_init_device()
146 if (mtd_device_register(mtd, NULL, 0)) in mtdram_init_device()
187 MODULE_DESCRIPTION("Simulated MTD driver for testing");