Lines Matching refs:mtd
35 struct mtd_info *mtd; member
42 return fixed_size_llseek(file, offset, orig, mfi->mtd->size); in mtdchar_lseek()
50 struct mtd_info *mtd; in mtdchar_open() local
59 mtd = get_mtd_device(NULL, devnum); in mtdchar_open()
61 if (IS_ERR(mtd)) in mtdchar_open()
62 return PTR_ERR(mtd); in mtdchar_open()
64 if (mtd->type == MTD_ABSENT) { in mtdchar_open()
70 if ((file->f_mode & FMODE_WRITE) && !(mtd->flags & MTD_WRITEABLE)) { in mtdchar_open()
80 mfi->mtd = mtd; in mtdchar_open()
85 put_mtd_device(mtd); in mtdchar_open()
94 struct mtd_info *mtd = mfi->mtd; in mtdchar_close() local
100 mtd_sync(mtd); in mtdchar_close()
102 put_mtd_device(mtd); in mtdchar_close()
131 struct mtd_info *mtd = mfi->mtd; in mtdchar_read() local
141 if (*ppos + count > mtd->size) { in mtdchar_read()
142 if (*ppos < mtd->size) in mtdchar_read()
143 count = mtd->size - *ppos; in mtdchar_read()
151 kbuf = mtd_kmalloc_up_to(mtd, &size); in mtdchar_read()
160 ret = mtd_read_fact_prot_reg(mtd, *ppos, len, in mtdchar_read()
164 ret = mtd_read_user_prot_reg(mtd, *ppos, len, in mtdchar_read()
176 ret = mtd_read_oob(mtd, *ppos, &ops); in mtdchar_read()
181 ret = mtd_read(mtd, *ppos, len, &retlen, kbuf); in mtdchar_read()
221 struct mtd_info *mtd = mfi->mtd; in mtdchar_write() local
231 if (*ppos >= mtd->size) in mtdchar_write()
234 if (*ppos + count > mtd->size) in mtdchar_write()
235 count = mtd->size - *ppos; in mtdchar_write()
240 kbuf = mtd_kmalloc_up_to(mtd, &size); in mtdchar_write()
257 ret = mtd_write_user_prot_reg(mtd, *ppos, len, in mtdchar_write()
271 ret = mtd_write_oob(mtd, *ppos, &ops); in mtdchar_write()
277 ret = mtd_write(mtd, *ppos, len, &retlen, kbuf); in mtdchar_write()
312 struct mtd_info *mtd = mfi->mtd; in otp_select_filemode() local
317 if (mtd_read_fact_prot_reg(mtd, -1, 0, &retlen, NULL) == in otp_select_filemode()
324 if (mtd_read_user_prot_reg(mtd, -1, 0, &retlen, NULL) == in otp_select_filemode()
340 static int mtdchar_writeoob(struct file *file, struct mtd_info *mtd, in mtdchar_writeoob() argument
344 struct mtd_info *master = mtd_get_master(mtd); in mtdchar_writeoob()
357 ops.ooboffs = start & (mtd->writesize - 1); in mtdchar_writeoob()
362 if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) in mtdchar_writeoob()
369 start &= ~((uint64_t)mtd->writesize - 1); in mtdchar_writeoob()
370 ret = mtd_write_oob(mtd, start, &ops); in mtdchar_writeoob()
382 static int mtdchar_readoob(struct file *file, struct mtd_info *mtd, in mtdchar_readoob() argument
394 ops.ooboffs = start & (mtd->writesize - 1); in mtdchar_readoob()
399 if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) in mtdchar_readoob()
406 start &= ~((uint64_t)mtd->writesize - 1); in mtdchar_readoob()
407 ret = mtd_read_oob(mtd, start, &ops); in mtdchar_readoob()
443 static int shrink_ecclayout(struct mtd_info *mtd, in shrink_ecclayout() argument
449 if (!mtd || !to) in shrink_ecclayout()
458 ret = mtd_ooblayout_ecc(mtd, section++, &oobregion); in shrink_ecclayout()
475 ret = mtd_ooblayout_free(mtd, i, &oobregion); in shrink_ecclayout()
491 static int get_oobinfo(struct mtd_info *mtd, struct nand_oobinfo *to) in get_oobinfo() argument
496 if (!mtd || !to) in get_oobinfo()
505 ret = mtd_ooblayout_ecc(mtd, section++, &oobregion); in get_oobinfo()
524 ret = mtd_ooblayout_free(mtd, i, &oobregion); in get_oobinfo()
541 static int mtdchar_blkpg_ioctl(struct mtd_info *mtd, in mtdchar_blkpg_ioctl() argument
556 if (mtd_is_partition(mtd)) in mtdchar_blkpg_ioctl()
562 return mtd_add_partition(mtd, p.devname, p.start, p.length); in mtdchar_blkpg_ioctl()
569 return mtd_del_partition(mtd, p.pno); in mtdchar_blkpg_ioctl()
576 static int mtdchar_write_ioctl(struct mtd_info *mtd, in mtdchar_write_ioctl() argument
579 struct mtd_info *master = mtd_get_master(mtd); in mtdchar_write_ioctl()
616 ret = mtd_write_oob(mtd, (loff_t)req.start, &ops); in mtdchar_write_ioctl()
627 struct mtd_info *mtd = mfi->mtd; in mtdchar_ioctl() local
628 struct mtd_info *master = mtd_get_master(mtd); in mtdchar_ioctl()
680 if (copy_to_user(argp, &(mtd->numeraseregions), sizeof(int))) in mtdchar_ioctl()
693 if (ur_idx >= mtd->numeraseregions) in mtdchar_ioctl()
696 kr = &(mtd->eraseregions[ur_idx]); in mtdchar_ioctl()
708 info.type = mtd->type; in mtdchar_ioctl()
709 info.flags = mtd->flags; in mtdchar_ioctl()
710 info.size = mtd->size; in mtdchar_ioctl()
711 info.erasesize = mtd->erasesize; in mtdchar_ioctl()
712 info.writesize = mtd->writesize; in mtdchar_ioctl()
713 info.oobsize = mtd->oobsize; in mtdchar_ioctl()
751 ret = mtd_erase(mtd, erase); in mtdchar_ioctl()
766 ret = mtdchar_writeoob(file, mtd, buf.start, buf.length, in mtdchar_ioctl()
780 ret = mtdchar_readoob(file, mtd, buf.start, buf.length, in mtdchar_ioctl()
793 ret = mtdchar_writeoob(file, mtd, buf.start, buf.length, in mtdchar_ioctl()
807 ret = mtdchar_readoob(file, mtd, buf.start, buf.length, in mtdchar_ioctl()
815 ret = mtdchar_write_ioctl(mtd, in mtdchar_ioctl()
827 ret = mtd_lock(mtd, einfo.start, einfo.length); in mtdchar_ioctl()
838 ret = mtd_unlock(mtd, einfo.start, einfo.length); in mtdchar_ioctl()
849 ret = mtd_is_locked(mtd, einfo.start, einfo.length); in mtdchar_ioctl()
861 ret = get_oobinfo(mtd, &oi); in mtdchar_ioctl()
876 return mtd_block_isbad(mtd, offs); in mtdchar_ioctl()
885 return mtd_block_markbad(mtd, offs); in mtdchar_ioctl()
911 ret = mtd_get_fact_prot_info(mtd, 4096, &retlen, buf); in mtdchar_ioctl()
914 ret = mtd_get_user_prot_info(mtd, 4096, &retlen, buf); in mtdchar_ioctl()
943 ret = mtd_lock_user_prot_reg(mtd, oinfo.start, oinfo.length); in mtdchar_ioctl()
945 ret = mtd_erase_user_prot_reg(mtd, oinfo.start, oinfo.length); in mtdchar_ioctl()
961 shrink_ecclayout(mtd, usrlay); in mtdchar_ioctl()
971 if (copy_to_user(argp, &mtd->ecc_stats, in mtdchar_ioctl()
988 if (!mtd_has_oob(mtd)) in mtdchar_ioctl()
1010 ret = mtdchar_blkpg_ioctl(mtd, &a); in mtdchar_ioctl()
1028 struct mtd_info *mtd = mfi->mtd; in mtdchar_unlocked_ioctl() local
1029 struct mtd_info *master = mtd_get_master(mtd); in mtdchar_unlocked_ioctl()
1054 struct mtd_info *mtd = mfi->mtd; in mtdchar_compat_ioctl() local
1055 struct mtd_info *master = mtd_get_master(mtd); in mtdchar_compat_ioctl()
1075 ret = mtdchar_writeoob(file, mtd, buf.start, in mtdchar_compat_ioctl()
1090 ret = mtdchar_readoob(file, mtd, buf.start, in mtdchar_compat_ioctl()
1114 ret = mtdchar_blkpg_ioctl(mtd, &a); in mtdchar_compat_ioctl()
1142 struct mtd_info *mtd = mfi->mtd; in mtdchar_get_unmapped_area() local
1149 if (len > mtd->size || pgoff >= (mtd->size >> PAGE_SHIFT)) in mtdchar_get_unmapped_area()
1153 if (offset > mtd->size - len) in mtdchar_get_unmapped_area()
1156 ret = mtd_get_unmapped_area(mtd, len, offset, flags); in mtdchar_get_unmapped_area()
1164 return mtd_mmap_capabilities(mfi->mtd); in mtdchar_mmap_capabilities()
1175 struct mtd_info *mtd = mfi->mtd; in mtdchar_mmap() local
1176 struct map_info *map = mtd->priv; in mtdchar_mmap()