Lines Matching refs:mtd
107 int (*ecc)(struct mtd_info *mtd, int section,
109 int (*free)(struct mtd_info *mtd, int section,
183 int (*get_info)(struct mtd_info *mtd, int wunit,
185 int (*get_wunit)(struct mtd_info *mtd,
316 int (*_erase) (struct mtd_info *mtd, struct erase_info *instr);
317 int (*_point) (struct mtd_info *mtd, loff_t from, size_t len,
319 int (*_unpoint) (struct mtd_info *mtd, loff_t from, size_t len);
320 int (*_read) (struct mtd_info *mtd, loff_t from, size_t len,
322 int (*_write) (struct mtd_info *mtd, loff_t to, size_t len,
324 int (*_panic_write) (struct mtd_info *mtd, loff_t to, size_t len,
326 int (*_read_oob) (struct mtd_info *mtd, loff_t from,
328 int (*_write_oob) (struct mtd_info *mtd, loff_t to,
330 int (*_get_fact_prot_info) (struct mtd_info *mtd, size_t len,
332 int (*_read_fact_prot_reg) (struct mtd_info *mtd, loff_t from,
334 int (*_get_user_prot_info) (struct mtd_info *mtd, size_t len,
336 int (*_read_user_prot_reg) (struct mtd_info *mtd, loff_t from,
338 int (*_write_user_prot_reg) (struct mtd_info *mtd, loff_t to,
341 int (*_lock_user_prot_reg) (struct mtd_info *mtd, loff_t from,
343 int (*_erase_user_prot_reg) (struct mtd_info *mtd, loff_t from,
345 int (*_writev) (struct mtd_info *mtd, const struct kvec *vecs,
347 void (*_sync) (struct mtd_info *mtd);
348 int (*_lock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
349 int (*_unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
350 int (*_is_locked) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
351 int (*_block_isreserved) (struct mtd_info *mtd, loff_t ofs);
352 int (*_block_isbad) (struct mtd_info *mtd, loff_t ofs);
353 int (*_block_markbad) (struct mtd_info *mtd, loff_t ofs);
354 int (*_max_bad_blocks) (struct mtd_info *mtd, loff_t ofs, size_t len);
355 int (*_suspend) (struct mtd_info *mtd);
356 void (*_resume) (struct mtd_info *mtd);
357 void (*_reboot) (struct mtd_info *mtd);
362 int (*_get_device) (struct mtd_info *mtd);
363 void (*_put_device) (struct mtd_info *mtd);
403 static inline struct mtd_info *mtd_get_master(struct mtd_info *mtd) in mtd_get_master() argument
405 while (mtd->parent) in mtd_get_master()
406 mtd = mtd->parent; in mtd_get_master()
408 return mtd; in mtd_get_master()
411 static inline u64 mtd_get_master_ofs(struct mtd_info *mtd, u64 ofs) in mtd_get_master_ofs() argument
413 while (mtd->parent) { in mtd_get_master_ofs()
414 ofs += mtd->part.offset; in mtd_get_master_ofs()
415 mtd = mtd->parent; in mtd_get_master_ofs()
421 static inline bool mtd_is_partition(const struct mtd_info *mtd) in mtd_is_partition() argument
423 return mtd->parent; in mtd_is_partition()
426 static inline bool mtd_has_partitions(const struct mtd_info *mtd) in mtd_has_partitions() argument
428 return !list_empty(&mtd->partitions); in mtd_has_partitions()
431 int mtd_ooblayout_ecc(struct mtd_info *mtd, int section,
433 int mtd_ooblayout_find_eccregion(struct mtd_info *mtd, int eccbyte,
436 int mtd_ooblayout_get_eccbytes(struct mtd_info *mtd, u8 *eccbuf,
438 int mtd_ooblayout_set_eccbytes(struct mtd_info *mtd, const u8 *eccbuf,
440 int mtd_ooblayout_free(struct mtd_info *mtd, int section,
442 int mtd_ooblayout_get_databytes(struct mtd_info *mtd, u8 *databuf,
444 int mtd_ooblayout_set_databytes(struct mtd_info *mtd, const u8 *databuf,
446 int mtd_ooblayout_count_freebytes(struct mtd_info *mtd);
447 int mtd_ooblayout_count_eccbytes(struct mtd_info *mtd);
449 static inline void mtd_set_ooblayout(struct mtd_info *mtd, in mtd_set_ooblayout() argument
452 mtd->ooblayout = ooblayout; in mtd_set_ooblayout()
455 static inline void mtd_set_pairing_scheme(struct mtd_info *mtd, in mtd_set_pairing_scheme() argument
458 mtd->pairing = pairing; in mtd_set_pairing_scheme()
461 static inline void mtd_set_of_node(struct mtd_info *mtd, in mtd_set_of_node() argument
464 mtd->dev.of_node = np; in mtd_set_of_node()
465 if (!mtd->name) in mtd_set_of_node()
466 of_property_read_string(np, "label", &mtd->name); in mtd_set_of_node()
469 static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd) in mtd_get_of_node() argument
471 return dev_of_node(&mtd->dev); in mtd_get_of_node()
474 static inline u32 mtd_oobavail(struct mtd_info *mtd, struct mtd_oob_ops *ops) in mtd_oobavail() argument
476 return ops->mode == MTD_OPS_AUTO_OOB ? mtd->oobavail : mtd->oobsize; in mtd_oobavail()
479 static inline int mtd_max_bad_blocks(struct mtd_info *mtd, in mtd_max_bad_blocks() argument
482 struct mtd_info *master = mtd_get_master(mtd); in mtd_max_bad_blocks()
487 if (mtd->size < (len + ofs) || ofs < 0) in mtd_max_bad_blocks()
490 return master->_max_bad_blocks(master, mtd_get_master_ofs(mtd, ofs), in mtd_max_bad_blocks()
494 int mtd_wunit_to_pairing_info(struct mtd_info *mtd, int wunit,
496 int mtd_pairing_info_to_wunit(struct mtd_info *mtd,
498 int mtd_pairing_groups(struct mtd_info *mtd);
499 int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
500 int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
502 int mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len);
503 unsigned long mtd_get_unmapped_area(struct mtd_info *mtd, unsigned long len,
505 int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
507 int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
509 int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
512 int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops);
513 int mtd_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops);
515 int mtd_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
517 int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
519 int mtd_get_user_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
521 int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
523 int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, size_t len,
525 int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len);
526 int mtd_erase_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len);
528 int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
531 static inline void mtd_sync(struct mtd_info *mtd) in mtd_sync() argument
533 struct mtd_info *master = mtd_get_master(mtd); in mtd_sync()
539 int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
540 int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
541 int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len);
542 int mtd_block_isreserved(struct mtd_info *mtd, loff_t ofs);
543 int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs);
544 int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs);
546 static inline int mtd_suspend(struct mtd_info *mtd) in mtd_suspend() argument
548 struct mtd_info *master = mtd_get_master(mtd); in mtd_suspend()
562 static inline void mtd_resume(struct mtd_info *mtd) in mtd_resume() argument
564 struct mtd_info *master = mtd_get_master(mtd); in mtd_resume()
575 static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd) in mtd_div_by_eb() argument
577 if (mtd->erasesize_shift) in mtd_div_by_eb()
578 return sz >> mtd->erasesize_shift; in mtd_div_by_eb()
579 do_div(sz, mtd->erasesize); in mtd_div_by_eb()
583 static inline uint32_t mtd_mod_by_eb(uint64_t sz, struct mtd_info *mtd) in mtd_mod_by_eb() argument
585 if (mtd->erasesize_shift) in mtd_mod_by_eb()
586 return sz & mtd->erasesize_mask; in mtd_mod_by_eb()
587 return do_div(sz, mtd->erasesize); in mtd_mod_by_eb()
599 static inline void mtd_align_erase_req(struct mtd_info *mtd, in mtd_align_erase_req() argument
604 if (WARN_ON(!mtd->erasesize)) in mtd_align_erase_req()
607 mod = mtd_mod_by_eb(req->addr, mtd); in mtd_align_erase_req()
613 mod = mtd_mod_by_eb(req->addr + req->len, mtd); in mtd_align_erase_req()
615 req->len += mtd->erasesize - mod; in mtd_align_erase_req()
618 static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd) in mtd_div_by_ws() argument
620 if (mtd->writesize_shift) in mtd_div_by_ws()
621 return sz >> mtd->writesize_shift; in mtd_div_by_ws()
622 do_div(sz, mtd->writesize); in mtd_div_by_ws()
626 static inline uint32_t mtd_mod_by_ws(uint64_t sz, struct mtd_info *mtd) in mtd_mod_by_ws() argument
628 if (mtd->writesize_shift) in mtd_mod_by_ws()
629 return sz & mtd->writesize_mask; in mtd_mod_by_ws()
630 return do_div(sz, mtd->writesize); in mtd_mod_by_ws()
633 static inline int mtd_wunit_per_eb(struct mtd_info *mtd) in mtd_wunit_per_eb() argument
635 struct mtd_info *master = mtd_get_master(mtd); in mtd_wunit_per_eb()
637 return master->erasesize / mtd->writesize; in mtd_wunit_per_eb()
640 static inline int mtd_offset_to_wunit(struct mtd_info *mtd, loff_t offs) in mtd_offset_to_wunit() argument
642 return mtd_div_by_ws(mtd_mod_by_eb(offs, mtd), mtd); in mtd_offset_to_wunit()
645 static inline loff_t mtd_wunit_to_offset(struct mtd_info *mtd, loff_t base, in mtd_wunit_to_offset() argument
648 return base + (wunit * mtd->writesize); in mtd_wunit_to_offset()
652 static inline int mtd_has_oob(const struct mtd_info *mtd) in mtd_has_oob() argument
654 struct mtd_info *master = mtd_get_master((struct mtd_info *)mtd); in mtd_has_oob()
659 static inline int mtd_type_is_nand(const struct mtd_info *mtd) in mtd_type_is_nand() argument
661 return mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH; in mtd_type_is_nand()
664 static inline int mtd_can_have_bb(const struct mtd_info *mtd) in mtd_can_have_bb() argument
666 struct mtd_info *master = mtd_get_master((struct mtd_info *)mtd); in mtd_can_have_bb()
676 extern int mtd_device_parse_register(struct mtd_info *mtd,
684 extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
685 extern int __get_mtd_device(struct mtd_info *mtd);
686 extern void __put_mtd_device(struct mtd_info *mtd);
689 extern void put_mtd_device(struct mtd_info *mtd);
693 void (*add)(struct mtd_info *mtd);
694 void (*remove)(struct mtd_info *mtd);
701 void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size);
715 unsigned mtd_mmap_capabilities(struct mtd_info *mtd);