Lines Matching refs:mtd
101 int (*ecc)(struct mtd_info *mtd, int section,
103 int (*free)(struct mtd_info *mtd, int section,
177 int (*get_info)(struct mtd_info *mtd, int wunit,
179 int (*get_wunit)(struct mtd_info *mtd,
276 int (*_erase) (struct mtd_info *mtd, struct erase_info *instr);
277 int (*_point) (struct mtd_info *mtd, loff_t from, size_t len,
279 int (*_unpoint) (struct mtd_info *mtd, loff_t from, size_t len);
280 int (*_read) (struct mtd_info *mtd, loff_t from, size_t len,
282 int (*_write) (struct mtd_info *mtd, loff_t to, size_t len,
284 int (*_panic_write) (struct mtd_info *mtd, loff_t to, size_t len,
286 int (*_read_oob) (struct mtd_info *mtd, loff_t from,
288 int (*_write_oob) (struct mtd_info *mtd, loff_t to,
290 int (*_get_fact_prot_info) (struct mtd_info *mtd, size_t len,
292 int (*_read_fact_prot_reg) (struct mtd_info *mtd, loff_t from,
294 int (*_get_user_prot_info) (struct mtd_info *mtd, size_t len,
296 int (*_read_user_prot_reg) (struct mtd_info *mtd, loff_t from,
298 int (*_write_user_prot_reg) (struct mtd_info *mtd, loff_t to,
300 int (*_lock_user_prot_reg) (struct mtd_info *mtd, loff_t from,
302 int (*_writev) (struct mtd_info *mtd, const struct kvec *vecs,
304 void (*_sync) (struct mtd_info *mtd);
305 int (*_lock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
306 int (*_unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
307 int (*_is_locked) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
308 int (*_block_isreserved) (struct mtd_info *mtd, loff_t ofs);
309 int (*_block_isbad) (struct mtd_info *mtd, loff_t ofs);
310 int (*_block_markbad) (struct mtd_info *mtd, loff_t ofs);
311 int (*_max_bad_blocks) (struct mtd_info *mtd, loff_t ofs, size_t len);
312 int (*_suspend) (struct mtd_info *mtd);
313 void (*_resume) (struct mtd_info *mtd);
314 void (*_reboot) (struct mtd_info *mtd);
319 int (*_get_device) (struct mtd_info *mtd);
320 void (*_put_device) (struct mtd_info *mtd);
344 int mtd_ooblayout_ecc(struct mtd_info *mtd, int section,
346 int mtd_ooblayout_find_eccregion(struct mtd_info *mtd, int eccbyte,
349 int mtd_ooblayout_get_eccbytes(struct mtd_info *mtd, u8 *eccbuf,
351 int mtd_ooblayout_set_eccbytes(struct mtd_info *mtd, const u8 *eccbuf,
353 int mtd_ooblayout_free(struct mtd_info *mtd, int section,
355 int mtd_ooblayout_get_databytes(struct mtd_info *mtd, u8 *databuf,
357 int mtd_ooblayout_set_databytes(struct mtd_info *mtd, const u8 *databuf,
359 int mtd_ooblayout_count_freebytes(struct mtd_info *mtd);
360 int mtd_ooblayout_count_eccbytes(struct mtd_info *mtd);
362 static inline void mtd_set_ooblayout(struct mtd_info *mtd, in mtd_set_ooblayout() argument
365 mtd->ooblayout = ooblayout; in mtd_set_ooblayout()
368 static inline void mtd_set_pairing_scheme(struct mtd_info *mtd, in mtd_set_pairing_scheme() argument
371 mtd->pairing = pairing; in mtd_set_pairing_scheme()
374 static inline void mtd_set_of_node(struct mtd_info *mtd, in mtd_set_of_node() argument
377 mtd->dev.of_node = np; in mtd_set_of_node()
378 if (!mtd->name) in mtd_set_of_node()
379 of_property_read_string(np, "label", &mtd->name); in mtd_set_of_node()
382 static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd) in mtd_get_of_node() argument
384 return dev_of_node(&mtd->dev); in mtd_get_of_node()
387 static inline u32 mtd_oobavail(struct mtd_info *mtd, struct mtd_oob_ops *ops) in mtd_oobavail() argument
389 return ops->mode == MTD_OPS_AUTO_OOB ? mtd->oobavail : mtd->oobsize; in mtd_oobavail()
392 static inline int mtd_max_bad_blocks(struct mtd_info *mtd, in mtd_max_bad_blocks() argument
395 if (!mtd->_max_bad_blocks) in mtd_max_bad_blocks()
398 if (mtd->size < (len + ofs) || ofs < 0) in mtd_max_bad_blocks()
401 return mtd->_max_bad_blocks(mtd, ofs, len); in mtd_max_bad_blocks()
404 int mtd_wunit_to_pairing_info(struct mtd_info *mtd, int wunit,
406 int mtd_pairing_info_to_wunit(struct mtd_info *mtd,
408 int mtd_pairing_groups(struct mtd_info *mtd);
409 int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
410 int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
412 int mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len);
413 unsigned long mtd_get_unmapped_area(struct mtd_info *mtd, unsigned long len,
415 int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
417 int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
419 int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
422 int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops);
423 int mtd_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops);
425 int mtd_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
427 int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
429 int mtd_get_user_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
431 int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
433 int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, size_t len,
435 int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len);
437 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);
453 static inline int mtd_suspend(struct mtd_info *mtd) in mtd_suspend() argument
455 return mtd->_suspend ? mtd->_suspend(mtd) : 0; in mtd_suspend()
458 static inline void mtd_resume(struct mtd_info *mtd) in mtd_resume() argument
460 if (mtd->_resume) in mtd_resume()
461 mtd->_resume(mtd); in mtd_resume()
464 static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd) in mtd_div_by_eb() argument
466 if (mtd->erasesize_shift) in mtd_div_by_eb()
467 return sz >> mtd->erasesize_shift; in mtd_div_by_eb()
468 do_div(sz, mtd->erasesize); in mtd_div_by_eb()
472 static inline uint32_t mtd_mod_by_eb(uint64_t sz, struct mtd_info *mtd) in mtd_mod_by_eb() argument
474 if (mtd->erasesize_shift) in mtd_mod_by_eb()
475 return sz & mtd->erasesize_mask; in mtd_mod_by_eb()
476 return do_div(sz, mtd->erasesize); in mtd_mod_by_eb()
488 static inline void mtd_align_erase_req(struct mtd_info *mtd, in mtd_align_erase_req() argument
493 if (WARN_ON(!mtd->erasesize)) in mtd_align_erase_req()
496 mod = mtd_mod_by_eb(req->addr, mtd); in mtd_align_erase_req()
502 mod = mtd_mod_by_eb(req->addr + req->len, mtd); in mtd_align_erase_req()
504 req->len += mtd->erasesize - mod; in mtd_align_erase_req()
507 static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd) in mtd_div_by_ws() argument
509 if (mtd->writesize_shift) in mtd_div_by_ws()
510 return sz >> mtd->writesize_shift; in mtd_div_by_ws()
511 do_div(sz, mtd->writesize); in mtd_div_by_ws()
515 static inline uint32_t mtd_mod_by_ws(uint64_t sz, struct mtd_info *mtd) in mtd_mod_by_ws() argument
517 if (mtd->writesize_shift) in mtd_mod_by_ws()
518 return sz & mtd->writesize_mask; in mtd_mod_by_ws()
519 return do_div(sz, mtd->writesize); in mtd_mod_by_ws()
522 static inline int mtd_wunit_per_eb(struct mtd_info *mtd) in mtd_wunit_per_eb() argument
524 return mtd->erasesize / mtd->writesize; in mtd_wunit_per_eb()
527 static inline int mtd_offset_to_wunit(struct mtd_info *mtd, loff_t offs) in mtd_offset_to_wunit() argument
529 return mtd_div_by_ws(mtd_mod_by_eb(offs, mtd), mtd); in mtd_offset_to_wunit()
532 static inline loff_t mtd_wunit_to_offset(struct mtd_info *mtd, loff_t base, in mtd_wunit_to_offset() argument
535 return base + (wunit * mtd->writesize); in mtd_wunit_to_offset()
539 static inline int mtd_has_oob(const struct mtd_info *mtd) in mtd_has_oob() argument
541 return mtd->_read_oob && mtd->_write_oob; in mtd_has_oob()
544 static inline int mtd_type_is_nand(const struct mtd_info *mtd) in mtd_type_is_nand() argument
546 return mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH; in mtd_type_is_nand()
549 static inline int mtd_can_have_bb(const struct mtd_info *mtd) in mtd_can_have_bb() argument
551 return !!mtd->_block_isbad; in mtd_can_have_bb()
559 extern int mtd_device_parse_register(struct mtd_info *mtd,
567 extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
568 extern int __get_mtd_device(struct mtd_info *mtd);
569 extern void __put_mtd_device(struct mtd_info *mtd);
571 extern void put_mtd_device(struct mtd_info *mtd);
575 void (*add)(struct mtd_info *mtd);
576 void (*remove)(struct mtd_info *mtd);
583 void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size);
597 unsigned mtd_mmap_capabilities(struct mtd_info *mtd);