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 if (*ppos < mtd->size) in mtdchar_read()
165 count = mtd->size - *ppos; in mtdchar_read()
173 kbuf = mtd_kmalloc_up_to(mtd, &size); in mtdchar_read()
182 ret = mtd_read_fact_prot_reg(mtd, *ppos, len, in mtdchar_read()
186 ret = mtd_read_user_prot_reg(mtd, *ppos, len, in mtdchar_read()
198 ret = mtd_read_oob(mtd, *ppos, &ops); in mtdchar_read()
203 ret = mtd_read(mtd, *ppos, len, &retlen, kbuf); in mtdchar_read()
243 struct mtd_info *mtd = mfi->mtd; in mtdchar_write() local
253 if (*ppos >= mtd->size) in mtdchar_write()
256 if (*ppos + count > mtd->size) in mtdchar_write()
257 count = mtd->size - *ppos; in mtdchar_write()
262 kbuf = mtd_kmalloc_up_to(mtd, &size); in mtdchar_write()
279 ret = mtd_write_user_prot_reg(mtd, *ppos, len, in mtdchar_write()
293 ret = mtd_write_oob(mtd, *ppos, &ops); in mtdchar_write()
299 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()
381 ops.ooboffs = start & (mtd->writesize - 1); in mtdchar_writeoob()
386 if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) in mtdchar_writeoob()
393 start &= ~((uint64_t)mtd->writesize - 1); in mtdchar_writeoob()
394 ret = mtd_write_oob(mtd, start, &ops); in mtdchar_writeoob()
406 static int mtdchar_readoob(struct file *file, struct mtd_info *mtd, in mtdchar_readoob() argument
418 ops.ooboffs = start & (mtd->writesize - 1); in mtdchar_readoob()
423 if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) in mtdchar_readoob()
430 start &= ~((uint64_t)mtd->writesize - 1); in mtdchar_readoob()
431 ret = mtd_read_oob(mtd, start, &ops); in mtdchar_readoob()
467 static int shrink_ecclayout(struct mtd_info *mtd, in shrink_ecclayout() argument
473 if (!mtd || !to) in shrink_ecclayout()
482 ret = mtd_ooblayout_ecc(mtd, section++, &oobregion); in shrink_ecclayout()
499 ret = mtd_ooblayout_free(mtd, i, &oobregion); in shrink_ecclayout()
515 static int get_oobinfo(struct mtd_info *mtd, struct nand_oobinfo *to) in get_oobinfo() argument
520 if (!mtd || !to) in get_oobinfo()
529 ret = mtd_ooblayout_ecc(mtd, section++, &oobregion); in get_oobinfo()
548 ret = mtd_ooblayout_free(mtd, i, &oobregion); in get_oobinfo()
565 static int mtdchar_blkpg_ioctl(struct mtd_info *mtd, in mtdchar_blkpg_ioctl() argument
580 if (mtd_is_partition(mtd)) in mtdchar_blkpg_ioctl()
586 return mtd_add_partition(mtd, p.devname, p.start, p.length); in mtdchar_blkpg_ioctl()
593 return mtd_del_partition(mtd, p.pno); in mtdchar_blkpg_ioctl()
600 static int mtdchar_write_ioctl(struct mtd_info *mtd, in mtdchar_write_ioctl() argument
614 if (!mtd->_write_oob) in mtdchar_write_ioctl()
640 ret = mtd_write_oob(mtd, (loff_t)req.start, &ops); in mtdchar_write_ioctl()
651 struct mtd_info *mtd = mfi->mtd; in mtdchar_ioctl() local
660 if (copy_to_user(argp, &(mtd->numeraseregions), sizeof(int))) in mtdchar_ioctl()
673 if (ur_idx >= mtd->numeraseregions) in mtdchar_ioctl()
676 kr = &(mtd->eraseregions[ur_idx]); in mtdchar_ioctl()
688 info.type = mtd->type; in mtdchar_ioctl()
689 info.flags = mtd->flags; in mtdchar_ioctl()
690 info.size = mtd->size; in mtdchar_ioctl()
691 info.erasesize = mtd->erasesize; in mtdchar_ioctl()
692 info.writesize = mtd->writesize; in mtdchar_ioctl()
693 info.oobsize = mtd->oobsize; in mtdchar_ioctl()
734 ret = mtd_erase(mtd, erase); in mtdchar_ioctl()
749 ret = mtdchar_writeoob(file, mtd, buf.start, buf.length, in mtdchar_ioctl()
763 ret = mtdchar_readoob(file, mtd, buf.start, buf.length, in mtdchar_ioctl()
776 ret = mtdchar_writeoob(file, mtd, buf.start, buf.length, in mtdchar_ioctl()
790 ret = mtdchar_readoob(file, mtd, buf.start, buf.length, in mtdchar_ioctl()
798 ret = mtdchar_write_ioctl(mtd, in mtdchar_ioctl()
810 ret = mtd_lock(mtd, einfo.start, einfo.length); in mtdchar_ioctl()
821 ret = mtd_unlock(mtd, einfo.start, einfo.length); in mtdchar_ioctl()
832 ret = mtd_is_locked(mtd, einfo.start, einfo.length); in mtdchar_ioctl()
841 if (!mtd->ooblayout) in mtdchar_ioctl()
844 ret = get_oobinfo(mtd, &oi); in mtdchar_ioctl()
859 return mtd_block_isbad(mtd, offs); in mtdchar_ioctl()
869 return mtd_block_markbad(mtd, offs); in mtdchar_ioctl()
896 ret = mtd_get_fact_prot_info(mtd, 4096, &retlen, buf); in mtdchar_ioctl()
899 ret = mtd_get_user_prot_info(mtd, 4096, &retlen, buf); in mtdchar_ioctl()
926 ret = mtd_lock_user_prot_reg(mtd, oinfo.start, oinfo.length); in mtdchar_ioctl()
935 if (!mtd->ooblayout) in mtdchar_ioctl()
942 shrink_ecclayout(mtd, usrlay); in mtdchar_ioctl()
952 if (copy_to_user(argp, &mtd->ecc_stats, in mtdchar_ioctl()
969 if (!mtd_has_oob(mtd)) in mtdchar_ioctl()
990 ret = mtdchar_blkpg_ioctl(mtd, &a); in mtdchar_ioctl()
1034 struct mtd_info *mtd = mfi->mtd; in mtdchar_compat_ioctl() local
1049 ret = mtdchar_writeoob(file, mtd, buf.start, in mtdchar_compat_ioctl()
1064 ret = mtdchar_readoob(file, mtd, buf.start, in mtdchar_compat_ioctl()
1088 ret = mtdchar_blkpg_ioctl(mtd, &a); in mtdchar_compat_ioctl()
1116 struct mtd_info *mtd = mfi->mtd; in mtdchar_get_unmapped_area() local
1123 if (len > mtd->size || pgoff >= (mtd->size >> PAGE_SHIFT)) in mtdchar_get_unmapped_area()
1127 if (offset > mtd->size - len) in mtdchar_get_unmapped_area()
1130 ret = mtd_get_unmapped_area(mtd, len, offset, flags); in mtdchar_get_unmapped_area()
1138 return mtd_mmap_capabilities(mfi->mtd); in mtdchar_mmap_capabilities()
1149 struct mtd_info *mtd = mfi->mtd; in mtdchar_mmap() local
1150 struct map_info *map = mtd->priv; in mtdchar_mmap()