Lines Matching refs:mtd

51 	struct mtd_info *mtd;  member
58 return fixed_size_llseek(file, offset, orig, mfi->mtd->size); in mtdchar_lseek()
66 struct mtd_info *mtd; in mtdchar_open() local
76 mtd = get_mtd_device(NULL, devnum); in mtdchar_open()
78 if (IS_ERR(mtd)) { in mtdchar_open()
79 ret = PTR_ERR(mtd); in mtdchar_open()
83 if (mtd->type == MTD_ABSENT) { in mtdchar_open()
89 if ((file->f_mode & FMODE_WRITE) && !(mtd->flags & MTD_WRITEABLE)) { in mtdchar_open()
99 mfi->mtd = mtd; in mtdchar_open()
105 put_mtd_device(mtd); in mtdchar_open()
116 struct mtd_info *mtd = mfi->mtd; in mtdchar_close() local
122 mtd_sync(mtd); in mtdchar_close()
124 put_mtd_device(mtd); in mtdchar_close()
153 struct mtd_info *mtd = mfi->mtd; in mtdchar_read() local
163 if (*ppos + count > mtd->size) in mtdchar_read()
164 count = mtd->size - *ppos; in mtdchar_read()
169 kbuf = mtd_kmalloc_up_to(mtd, &size); in mtdchar_read()
178 ret = mtd_read_fact_prot_reg(mtd, *ppos, len, in mtdchar_read()
182 ret = mtd_read_user_prot_reg(mtd, *ppos, len, in mtdchar_read()
194 ret = mtd_read_oob(mtd, *ppos, &ops); in mtdchar_read()
199 ret = mtd_read(mtd, *ppos, len, &retlen, kbuf); in mtdchar_read()
239 struct mtd_info *mtd = mfi->mtd; in mtdchar_write() local
249 if (*ppos == mtd->size) in mtdchar_write()
252 if (*ppos + count > mtd->size) in mtdchar_write()
253 count = mtd->size - *ppos; in mtdchar_write()
258 kbuf = mtd_kmalloc_up_to(mtd, &size); in mtdchar_write()
275 ret = mtd_write_user_prot_reg(mtd, *ppos, len, in mtdchar_write()
289 ret = mtd_write_oob(mtd, *ppos, &ops); in mtdchar_write()
295 ret = mtd_write(mtd, *ppos, len, &retlen, kbuf); in mtdchar_write()
334 struct mtd_info *mtd = mfi->mtd; in otp_select_filemode() local
339 if (mtd_read_fact_prot_reg(mtd, -1, 0, &retlen, NULL) == in otp_select_filemode()
346 if (mtd_read_user_prot_reg(mtd, -1, 0, &retlen, NULL) == in otp_select_filemode()
362 static int mtdchar_writeoob(struct file *file, struct mtd_info *mtd, in mtdchar_writeoob() argument
377 if (!mtd->_write_oob) in mtdchar_writeoob()
386 ops.ooboffs = start & (mtd->writesize - 1); in mtdchar_writeoob()
391 if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) in mtdchar_writeoob()
398 start &= ~((uint64_t)mtd->writesize - 1); in mtdchar_writeoob()
399 ret = mtd_write_oob(mtd, start, &ops); in mtdchar_writeoob()
411 static int mtdchar_readoob(struct file *file, struct mtd_info *mtd, in mtdchar_readoob() argument
426 ops.ooboffs = start & (mtd->writesize - 1); in mtdchar_readoob()
431 if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) in mtdchar_readoob()
438 start &= ~((uint64_t)mtd->writesize - 1); in mtdchar_readoob()
439 ret = mtd_read_oob(mtd, start, &ops); in mtdchar_readoob()
500 static int mtdchar_blkpg_ioctl(struct mtd_info *mtd, in mtdchar_blkpg_ioctl() argument
515 if (mtd_is_partition(mtd)) in mtdchar_blkpg_ioctl()
521 return mtd_add_partition(mtd, p.devname, p.start, p.length); in mtdchar_blkpg_ioctl()
528 return mtd_del_partition(mtd, p.pno); in mtdchar_blkpg_ioctl()
535 static int mtdchar_write_ioctl(struct mtd_info *mtd, in mtdchar_write_ioctl() argument
552 if (!mtd->_write_oob) in mtdchar_write_ioctl()
578 ret = mtd_write_oob(mtd, (loff_t)req.start, &ops); in mtdchar_write_ioctl()
589 struct mtd_info *mtd = mfi->mtd; in mtdchar_ioctl() local
609 if (copy_to_user(argp, &(mtd->numeraseregions), sizeof(int))) in mtdchar_ioctl()
622 if (ur_idx >= mtd->numeraseregions) in mtdchar_ioctl()
625 kr = &(mtd->eraseregions[ur_idx]); in mtdchar_ioctl()
637 info.type = mtd->type; in mtdchar_ioctl()
638 info.flags = mtd->flags; in mtdchar_ioctl()
639 info.size = mtd->size; in mtdchar_ioctl()
640 info.erasesize = mtd->erasesize; in mtdchar_ioctl()
641 info.writesize = mtd->writesize; in mtdchar_ioctl()
642 info.oobsize = mtd->oobsize; in mtdchar_ioctl()
687 erase->mtd = mtd; in mtdchar_ioctl()
700 ret = mtd_erase(mtd, erase); in mtdchar_ioctl()
726 ret = mtdchar_writeoob(file, mtd, buf.start, buf.length, in mtdchar_ioctl()
740 ret = mtdchar_readoob(file, mtd, buf.start, buf.length, in mtdchar_ioctl()
753 ret = mtdchar_writeoob(file, mtd, buf.start, buf.length, in mtdchar_ioctl()
767 ret = mtdchar_readoob(file, mtd, buf.start, buf.length, in mtdchar_ioctl()
775 ret = mtdchar_write_ioctl(mtd, in mtdchar_ioctl()
787 ret = mtd_lock(mtd, einfo.start, einfo.length); in mtdchar_ioctl()
798 ret = mtd_unlock(mtd, einfo.start, einfo.length); in mtdchar_ioctl()
809 ret = mtd_is_locked(mtd, einfo.start, einfo.length); in mtdchar_ioctl()
818 if (!mtd->ecclayout) in mtdchar_ioctl()
820 if (mtd->ecclayout->eccbytes > ARRAY_SIZE(oi.eccpos)) in mtdchar_ioctl()
824 memcpy(&oi.eccpos, mtd->ecclayout->eccpos, sizeof(oi.eccpos)); in mtdchar_ioctl()
825 memcpy(&oi.oobfree, mtd->ecclayout->oobfree, in mtdchar_ioctl()
827 oi.eccbytes = mtd->ecclayout->eccbytes; in mtdchar_ioctl()
840 return mtd_block_isbad(mtd, offs); in mtdchar_ioctl()
850 return mtd_block_markbad(mtd, offs); in mtdchar_ioctl()
877 ret = mtd_get_fact_prot_info(mtd, 4096, &retlen, buf); in mtdchar_ioctl()
880 ret = mtd_get_user_prot_info(mtd, 4096, &retlen, buf); in mtdchar_ioctl()
907 ret = mtd_lock_user_prot_reg(mtd, oinfo.start, oinfo.length); in mtdchar_ioctl()
916 if (!mtd->ecclayout) in mtdchar_ioctl()
923 shrink_ecclayout(mtd->ecclayout, usrlay); in mtdchar_ioctl()
933 if (copy_to_user(argp, &mtd->ecc_stats, in mtdchar_ioctl()
950 if (!mtd_has_oob(mtd)) in mtdchar_ioctl()
971 ret = mtdchar_blkpg_ioctl(mtd, &a); in mtdchar_ioctl()
1015 struct mtd_info *mtd = mfi->mtd; in mtdchar_compat_ioctl() local
1030 ret = mtdchar_writeoob(file, mtd, buf.start, in mtdchar_compat_ioctl()
1045 ret = mtdchar_readoob(file, mtd, buf.start, in mtdchar_compat_ioctl()
1069 ret = mtdchar_blkpg_ioctl(mtd, &a); in mtdchar_compat_ioctl()
1097 struct mtd_info *mtd = mfi->mtd; in mtdchar_get_unmapped_area() local
1104 if (len > mtd->size || pgoff >= (mtd->size >> PAGE_SHIFT)) in mtdchar_get_unmapped_area()
1108 if (offset > mtd->size - len) in mtdchar_get_unmapped_area()
1111 ret = mtd_get_unmapped_area(mtd, len, offset, flags); in mtdchar_get_unmapped_area()
1119 return mtd_mmap_capabilities(mfi->mtd); in mtdchar_mmap_capabilities()
1130 struct mtd_info *mtd = mfi->mtd; in mtdchar_mmap() local
1131 struct map_info *map = mtd->priv; in mtdchar_mmap()