Lines Matching refs:mtd
57 struct mtd_info mtd; member
97 static int gluebi_get_device(struct mtd_info *mtd) in gluebi_get_device() argument
102 if (mtd->flags & MTD_WRITEABLE) in gluebi_get_device()
105 gluebi = container_of(mtd, struct gluebi_device, mtd); in gluebi_get_device()
143 static void gluebi_put_device(struct mtd_info *mtd) in gluebi_put_device() argument
147 gluebi = container_of(mtd, struct gluebi_device, mtd); in gluebi_put_device()
166 static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len, in gluebi_read() argument
172 gluebi = container_of(mtd, struct gluebi_device, mtd); in gluebi_read()
173 lnum = div_u64_rem(from, mtd->erasesize, &offs); in gluebi_read()
176 size_t to_read = mtd->erasesize - offs; in gluebi_read()
206 static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len, in gluebi_write() argument
212 gluebi = container_of(mtd, struct gluebi_device, mtd); in gluebi_write()
213 lnum = div_u64_rem(to, mtd->erasesize, &offs); in gluebi_write()
215 if (len % mtd->writesize || offs % mtd->writesize) in gluebi_write()
220 size_t to_write = mtd->erasesize - offs; in gluebi_write()
247 static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr) in gluebi_erase() argument
252 if (mtd_mod_by_ws(instr->addr, mtd) || mtd_mod_by_ws(instr->len, mtd)) in gluebi_erase()
255 lnum = mtd_div_by_eb(instr->addr, mtd); in gluebi_erase()
256 count = mtd_div_by_eb(instr->len, mtd); in gluebi_erase()
257 gluebi = container_of(mtd, struct gluebi_device, mtd); in gluebi_erase()
281 instr->fail_addr = (long long)lnum * mtd->erasesize; in gluebi_erase()
298 struct mtd_info *mtd; in gluebi_create() local
304 mtd = &gluebi->mtd; in gluebi_create()
305 mtd->name = kmemdup(vi->name, vi->name_len + 1, GFP_KERNEL); in gluebi_create()
306 if (!mtd->name) { in gluebi_create()
313 mtd->type = MTD_UBIVOLUME; in gluebi_create()
315 mtd->flags = MTD_WRITEABLE; in gluebi_create()
316 mtd->owner = THIS_MODULE; in gluebi_create()
317 mtd->writesize = di->min_io_size; in gluebi_create()
318 mtd->erasesize = vi->usable_leb_size; in gluebi_create()
319 mtd->_read = gluebi_read; in gluebi_create()
320 mtd->_write = gluebi_write; in gluebi_create()
321 mtd->_erase = gluebi_erase; in gluebi_create()
322 mtd->_get_device = gluebi_get_device; in gluebi_create()
323 mtd->_put_device = gluebi_put_device; in gluebi_create()
331 mtd->size = (unsigned long long)vi->usable_leb_size * vi->size; in gluebi_create()
333 mtd->size = vi->used_bytes; in gluebi_create()
340 g->mtd.index, vi->ubi_num, vi->vol_id); in gluebi_create()
343 if (mtd_device_register(mtd, NULL, 0)) { in gluebi_create()
345 kfree(mtd->name); in gluebi_create()
367 struct mtd_info *mtd; in gluebi_remove() local
384 mtd = &gluebi->mtd; in gluebi_remove()
385 err = mtd_device_unregister(mtd); in gluebi_remove()
388 mtd->index, gluebi->ubi_num, gluebi->vol_id, err); in gluebi_remove()
395 kfree(mtd->name); in gluebi_remove()
424 gluebi->mtd.size = vi->used_bytes; in gluebi_updated()
449 gluebi->mtd.size = vi->used_bytes; in gluebi_resized()
499 struct mtd_info *mtd = &gluebi->mtd; in ubi_gluebi_exit() local
501 err = mtd_device_unregister(mtd); in ubi_gluebi_exit()
504 err, mtd->index, gluebi->ubi_num, in ubi_gluebi_exit()
506 kfree(mtd->name); in ubi_gluebi_exit()