Lines Matching refs:nand
24 bool nanddev_isbad(struct nand_device *nand, const struct nand_pos *pos) in nanddev_isbad() argument
26 if (nanddev_bbt_is_initialized(nand)) { in nanddev_isbad()
30 entry = nanddev_bbt_pos_to_entry(nand, pos); in nanddev_isbad()
31 status = nanddev_bbt_get_block_status(nand, entry); in nanddev_isbad()
34 if (nand->ops->isbad(nand, pos)) in nanddev_isbad()
39 nanddev_bbt_set_block_status(nand, entry, status); in nanddev_isbad()
49 return nand->ops->isbad(nand, pos); in nanddev_isbad()
63 int nanddev_markbad(struct nand_device *nand, const struct nand_pos *pos) in nanddev_markbad() argument
65 struct mtd_info *mtd = nanddev_to_mtd(nand); in nanddev_markbad()
69 if (nanddev_isbad(nand, pos)) in nanddev_markbad()
72 ret = nand->ops->markbad(nand, pos); in nanddev_markbad()
75 nanddev_pos_to_offs(nand, pos), ret); in nanddev_markbad()
77 if (!nanddev_bbt_is_initialized(nand)) in nanddev_markbad()
80 entry = nanddev_bbt_pos_to_entry(nand, pos); in nanddev_markbad()
81 ret = nanddev_bbt_set_block_status(nand, entry, NAND_BBT_BLOCK_WORN); in nanddev_markbad()
85 ret = nanddev_bbt_update(nand); in nanddev_markbad()
104 bool nanddev_isreserved(struct nand_device *nand, const struct nand_pos *pos) in nanddev_isreserved() argument
109 if (!nanddev_bbt_is_initialized(nand)) in nanddev_isreserved()
113 entry = nanddev_bbt_pos_to_entry(nand, pos); in nanddev_isreserved()
114 status = nanddev_bbt_get_block_status(nand, entry); in nanddev_isreserved()
128 int nanddev_erase(struct nand_device *nand, const struct nand_pos *pos) in nanddev_erase() argument
130 if (nanddev_isbad(nand, pos) || nanddev_isreserved(nand, pos)) { in nanddev_erase()
132 nanddev_pos_to_offs(nand, pos)); in nanddev_erase()
136 return nand->ops->erase(nand, pos); in nanddev_erase()
157 struct nand_device *nand = mtd_to_nanddev(mtd); in nanddev_mtd_erase() local
161 nanddev_offs_to_pos(nand, einfo->addr, &pos); in nanddev_mtd_erase()
162 nanddev_offs_to_pos(nand, einfo->addr + einfo->len - 1, &last); in nanddev_mtd_erase()
164 ret = nanddev_erase(nand, &pos); in nanddev_mtd_erase()
166 einfo->fail_addr = nanddev_pos_to_offs(nand, &pos); in nanddev_mtd_erase()
171 nanddev_pos_next_eraseblock(nand, &pos); in nanddev_mtd_erase()
189 int nanddev_init(struct nand_device *nand, const struct nand_ops *ops, in nanddev_init() argument
192 struct mtd_info *mtd = nanddev_to_mtd(nand); in nanddev_init()
193 struct nand_memory_organization *memorg = nanddev_get_memorg(nand); in nanddev_init()
195 if (!nand || !ops) in nanddev_init()
207 nand->rowconv.eraseblock_addr_shift = in nanddev_init()
209 nand->rowconv.lun_addr_shift = fls(memorg->eraseblocks_per_lun - 1) + in nanddev_init()
210 nand->rowconv.eraseblock_addr_shift; in nanddev_init()
212 nand->ops = ops; in nanddev_init()
221 mtd->size = nanddev_size(nand); in nanddev_init()
224 return nanddev_bbt_init(nand); in nanddev_init()
234 void nanddev_cleanup(struct nand_device *nand) in nanddev_cleanup() argument
236 if (nanddev_bbt_is_initialized(nand)) in nanddev_cleanup()
237 nanddev_bbt_cleanup(nand); in nanddev_cleanup()