Lines Matching refs:mtd
47 struct mtd_info *mtd; member
135 int (*ecc)(struct mtd_info *mtd, int section,
137 int (*rfree)(struct mtd_info *mtd, int section,
238 int (*_erase) (struct mtd_info *mtd, struct erase_info *instr);
240 int (*_point) (struct mtd_info *mtd, loff_t from, size_t len,
242 int (*_unpoint) (struct mtd_info *mtd, loff_t from, size_t len);
244 unsigned long (*_get_unmapped_area) (struct mtd_info *mtd,
248 int (*_read) (struct mtd_info *mtd, loff_t from, size_t len,
250 int (*_write) (struct mtd_info *mtd, loff_t to, size_t len,
252 int (*_panic_write) (struct mtd_info *mtd, loff_t to, size_t len,
254 int (*_read_oob) (struct mtd_info *mtd, loff_t from,
256 int (*_write_oob) (struct mtd_info *mtd, loff_t to,
258 int (*_get_fact_prot_info) (struct mtd_info *mtd, size_t len,
260 int (*_read_fact_prot_reg) (struct mtd_info *mtd, loff_t from,
262 int (*_get_user_prot_info) (struct mtd_info *mtd, size_t len,
264 int (*_read_user_prot_reg) (struct mtd_info *mtd, loff_t from,
266 int (*_write_user_prot_reg) (struct mtd_info *mtd, loff_t to,
268 int (*_lock_user_prot_reg) (struct mtd_info *mtd, loff_t from,
271 int (*_writev) (struct mtd_info *mtd, const struct kvec *vecs,
274 void (*_sync) (struct mtd_info *mtd);
275 int (*_lock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
276 int (*_unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
277 int (*_is_locked) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
278 int (*_block_isreserved) (struct mtd_info *mtd, loff_t ofs);
279 int (*_block_isbad) (struct mtd_info *mtd, loff_t ofs);
280 int (*_block_markbad) (struct mtd_info *mtd, loff_t ofs);
282 int (*_suspend) (struct mtd_info *mtd);
283 void (*_resume) (struct mtd_info *mtd);
284 void (*_reboot) (struct mtd_info *mtd);
290 int (*_get_device) (struct mtd_info *mtd);
291 void (*_put_device) (struct mtd_info *mtd);
340 static inline void mtd_set_of_node(struct mtd_info *mtd, in mtd_set_of_node() argument
343 mtd->dev->node.np = np; in mtd_set_of_node()
346 static inline const struct device_node *mtd_get_of_node(struct mtd_info *mtd) in mtd_get_of_node() argument
348 return mtd->dev->node.np; in mtd_get_of_node()
353 static inline void mtd_set_of_node(struct mtd_info *mtd, in mtd_set_of_node() argument
358 static inline const struct device_node *mtd_get_of_node(struct mtd_info *mtd) in mtd_get_of_node() argument
364 static inline bool mtd_is_partition(const struct mtd_info *mtd) in mtd_is_partition() argument
366 return mtd->parent; in mtd_is_partition()
369 static inline bool mtd_has_partitions(const struct mtd_info *mtd) in mtd_has_partitions() argument
371 return !list_empty(&mtd->partitions); in mtd_has_partitions()
376 int mtd_ooblayout_ecc(struct mtd_info *mtd, int section,
378 int mtd_ooblayout_find_eccregion(struct mtd_info *mtd, int eccbyte,
381 int mtd_ooblayout_get_eccbytes(struct mtd_info *mtd, u8 *eccbuf,
383 int mtd_ooblayout_set_eccbytes(struct mtd_info *mtd, const u8 *eccbuf,
385 int mtd_ooblayout_free(struct mtd_info *mtd, int section,
387 int mtd_ooblayout_get_databytes(struct mtd_info *mtd, u8 *databuf,
389 int mtd_ooblayout_set_databytes(struct mtd_info *mtd, const u8 *databuf,
391 int mtd_ooblayout_count_freebytes(struct mtd_info *mtd);
392 int mtd_ooblayout_count_eccbytes(struct mtd_info *mtd);
394 static inline void mtd_set_ooblayout(struct mtd_info *mtd, in mtd_set_ooblayout() argument
397 mtd->ooblayout = ooblayout; in mtd_set_ooblayout()
400 static inline int mtd_oobavail(struct mtd_info *mtd, struct mtd_oob_ops *ops) in mtd_oobavail() argument
402 return ops->mode == MTD_OPS_AUTO_OOB ? mtd->oobavail : mtd->oobsize; in mtd_oobavail()
405 int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
407 int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
409 int mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len);
411 unsigned long mtd_get_unmapped_area(struct mtd_info *mtd, unsigned long len,
413 int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
415 int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
417 int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
420 int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops);
421 int mtd_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops);
423 int mtd_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
425 int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
427 int mtd_get_user_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
429 int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
431 int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, size_t len,
433 int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len);
436 int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
440 static inline void mtd_sync(struct mtd_info *mtd) in mtd_sync() argument
442 if (mtd->_sync) in mtd_sync()
443 mtd->_sync(mtd); in mtd_sync()
446 int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
447 int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
448 int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len);
449 int mtd_block_isreserved(struct mtd_info *mtd, loff_t ofs);
450 int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs);
451 int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs);
454 static inline int mtd_suspend(struct mtd_info *mtd) in mtd_suspend() argument
456 return mtd->_suspend ? mtd->_suspend(mtd) : 0; in mtd_suspend()
459 static inline void mtd_resume(struct mtd_info *mtd) in mtd_resume() argument
461 if (mtd->_resume) in mtd_resume()
462 mtd->_resume(mtd); in mtd_resume()
466 static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd) in mtd_div_by_eb() argument
468 if (mtd->erasesize_shift) in mtd_div_by_eb()
469 return sz >> mtd->erasesize_shift; in mtd_div_by_eb()
470 do_div(sz, mtd->erasesize); in mtd_div_by_eb()
474 static inline uint32_t mtd_mod_by_eb(uint64_t sz, struct mtd_info *mtd) in mtd_mod_by_eb() argument
476 if (mtd->erasesize_shift) in mtd_mod_by_eb()
477 return sz & mtd->erasesize_mask; in mtd_mod_by_eb()
478 return do_div(sz, mtd->erasesize); in mtd_mod_by_eb()
481 static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd) in mtd_div_by_ws() argument
483 if (mtd->writesize_shift) in mtd_div_by_ws()
484 return sz >> mtd->writesize_shift; in mtd_div_by_ws()
485 do_div(sz, mtd->writesize); in mtd_div_by_ws()
489 static inline uint32_t mtd_mod_by_ws(uint64_t sz, struct mtd_info *mtd) in mtd_mod_by_ws() argument
491 if (mtd->writesize_shift) in mtd_mod_by_ws()
492 return sz & mtd->writesize_mask; in mtd_mod_by_ws()
493 return do_div(sz, mtd->writesize); in mtd_mod_by_ws()
496 static inline int mtd_has_oob(const struct mtd_info *mtd) in mtd_has_oob() argument
498 return mtd->_read_oob && mtd->_write_oob; in mtd_has_oob()
501 static inline int mtd_type_is_nand(const struct mtd_info *mtd) in mtd_type_is_nand() argument
503 return mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH; in mtd_type_is_nand()
506 static inline int mtd_can_have_bb(const struct mtd_info *mtd) in mtd_can_have_bb() argument
508 return !!mtd->_block_isbad; in mtd_can_have_bb()
516 extern int mtd_device_parse_register(struct mtd_info *mtd,
524 extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
525 extern int __get_mtd_device(struct mtd_info *mtd);
526 extern void __put_mtd_device(struct mtd_info *mtd);
528 extern void put_mtd_device(struct mtd_info *mtd);
533 void (*add)(struct mtd_info *mtd);
534 void (*remove)(struct mtd_info *mtd);
542 void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size);
566 unsigned mtd_mmap_capabilities(struct mtd_info *mtd);
570 int add_mtd_device(struct mtd_info *mtd);
571 int del_mtd_device(struct mtd_info *mtd);
577 static inline int add_mtd_partitions(struct mtd_info *mtd, in add_mtd_partitions() argument
584 static inline int del_mtd_partitions(struct mtd_info *mtd) in del_mtd_partitions() argument
591 #define mtd_for_each_device(mtd) \ argument
592 for ((mtd) = __mtd_next_device(0); \
593 (mtd) != NULL; \
594 (mtd) = __mtd_next_device(mtd->index + 1))
603 void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,