Lines Matching defs:mtd
15 * size (@mtd->writesize) is equivalent to the UBI minimal I/O unit. The
26 #include <linux/mtd/ubi.h>
27 #include <linux/mtd/mtd.h>
36 * @mtd: emulated MTD device description object
44 struct mtd_info mtd;
78 * @mtd: the MTD device description object
84 static int gluebi_get_device(struct mtd_info *mtd)
89 if (mtd->flags & MTD_WRITEABLE)
92 gluebi = container_of(mtd, struct gluebi_device, mtd);
125 * @mtd: the MTD device description object
130 static void gluebi_put_device(struct mtd_info *mtd)
134 gluebi = container_of(mtd, struct gluebi_device, mtd);
144 * @mtd: MTD device description object
153 static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len,
159 gluebi = container_of(mtd, struct gluebi_device, mtd);
160 lnum = div_u64_rem(from, mtd->erasesize, &offs);
163 size_t to_read = mtd->erasesize - offs;
184 * @mtd: MTD device description object
193 static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len,
199 gluebi = container_of(mtd, struct gluebi_device, mtd);
200 lnum = div_u64_rem(to, mtd->erasesize, &offs);
202 if (len % mtd->writesize || offs % mtd->writesize)
207 size_t to_write = mtd->erasesize - offs;
228 * @mtd: the MTD device description object
234 static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr)
239 if (mtd_mod_by_ws(instr->addr, mtd) || mtd_mod_by_ws(instr->len, mtd))
242 lnum = mtd_div_by_eb(instr->addr, mtd);
243 count = mtd_div_by_eb(instr->len, mtd);
244 gluebi = container_of(mtd, struct gluebi_device, mtd);
265 instr->fail_addr = (long long)lnum * mtd->erasesize;
282 struct mtd_info *mtd;
288 mtd = &gluebi->mtd;
289 mtd->name = kmemdup(vi->name, vi->name_len + 1, GFP_KERNEL);
290 if (!mtd->name) {
297 mtd->type = MTD_UBIVOLUME;
299 mtd->flags = MTD_WRITEABLE;
300 mtd->owner = THIS_MODULE;
301 mtd->writesize = di->min_io_size;
302 mtd->erasesize = vi->usable_leb_size;
303 mtd->_read = gluebi_read;
304 mtd->_write = gluebi_write;
305 mtd->_erase = gluebi_erase;
306 mtd->_get_device = gluebi_get_device;
307 mtd->_put_device = gluebi_put_device;
315 mtd->size = (unsigned long long)vi->usable_leb_size * vi->size;
317 mtd->size = vi->used_bytes;
324 g->mtd.index, vi->ubi_num, vi->vol_id);
327 if (mtd_device_register(mtd, NULL, 0)) {
329 kfree(mtd->name);
351 struct mtd_info *mtd;
368 mtd = &gluebi->mtd;
369 err = mtd_device_unregister(mtd);
372 mtd->index, gluebi->ubi_num, gluebi->vol_id, err);
379 kfree(mtd->name);
408 gluebi->mtd.size = vi->used_bytes;
433 gluebi->mtd.size = vi->used_bytes;
483 struct mtd_info *mtd = &gluebi->mtd;
485 err = mtd_device_unregister(mtd);
488 err, mtd->index, gluebi->ubi_num,
490 kfree(mtd->name);