Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
mtd.h File Reference
#include <linux/types.h>
#include <linux/uio.h>
#include <linux/notifier.h>
#include <linux/device.h>
#include <mtd/mtd-abi.h>
#include <asm/div64.h>

Go to the source code of this file.

Data Structures

struct  erase_info
 
struct  mtd_erase_region_info
 
struct  mtd_oob_ops
 
struct  nand_ecclayout
 
struct  mtd_info
 
struct  mtd_notifier
 

Macros

#define MTD_CHAR_MAJOR   90
 
#define MTD_BLOCK_MAJOR   31
 
#define MTD_ERASE_PENDING   0x01
 
#define MTD_ERASING   0x02
 
#define MTD_ERASE_SUSPEND   0x04
 
#define MTD_ERASE_DONE   0x08
 
#define MTD_ERASE_FAILED   0x10
 
#define MTD_FAIL_ADDR_UNKNOWN   -1LL
 
#define MTD_MAX_OOBFREE_ENTRIES_LARGE   32
 
#define MTD_MAX_ECCPOS_ENTRIES_LARGE   448
 
#define mtd_device_register(master, parts, nr_parts)   mtd_device_parse_register(master, NULL, NULL, parts, nr_parts)
 

Functions

int mtd_erase (struct mtd_info *mtd, struct erase_info *instr)
 
int mtd_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, void **virt, resource_size_t *phys)
 
int mtd_unpoint (struct mtd_info *mtd, loff_t from, size_t len)
 
unsigned long mtd_get_unmapped_area (struct mtd_info *mtd, unsigned long len, unsigned long offset, unsigned long flags)
 
int mtd_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
 
int mtd_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
 
int mtd_panic_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
 
int mtd_read_oob (struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
 
int mtd_get_fact_prot_info (struct mtd_info *mtd, struct otp_info *buf, size_t len)
 
int mtd_read_fact_prot_reg (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
 
int mtd_get_user_prot_info (struct mtd_info *mtd, struct otp_info *buf, size_t len)
 
int mtd_read_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
 
int mtd_write_user_prot_reg (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, u_char *buf)
 
int mtd_lock_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t len)
 
int mtd_writev (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen)
 
int mtd_lock (struct mtd_info *mtd, loff_t ofs, uint64_t len)
 
int mtd_unlock (struct mtd_info *mtd, loff_t ofs, uint64_t len)
 
int mtd_is_locked (struct mtd_info *mtd, loff_t ofs, uint64_t len)
 
int mtd_block_isbad (struct mtd_info *mtd, loff_t ofs)
 
int mtd_block_markbad (struct mtd_info *mtd, loff_t ofs)
 
int mtd_device_parse_register (struct mtd_info *mtd, const char **part_probe_types, struct mtd_part_parser_data *parser_data, const struct mtd_partition *defparts, int defnr_parts)
 
int mtd_device_unregister (struct mtd_info *master)
 
struct mtd_infoget_mtd_device (struct mtd_info *mtd, int num)
 
int __get_mtd_device (struct mtd_info *mtd)
 
void __put_mtd_device (struct mtd_info *mtd)
 
struct mtd_infoget_mtd_device_nm (const char *name)
 
void put_mtd_device (struct mtd_info *mtd)
 
void register_mtd_user (struct mtd_notifier *new)
 
int unregister_mtd_user (struct mtd_notifier *old)
 
voidmtd_kmalloc_up_to (const struct mtd_info *mtd, size_t *size)
 
void mtd_erase_callback (struct erase_info *instr)
 

Macro Definition Documentation

#define MTD_BLOCK_MAJOR   31

Definition at line 33 of file mtd.h.

#define MTD_CHAR_MAJOR   90

Definition at line 32 of file mtd.h.

#define mtd_device_register (   master,
  parts,
  nr_parts 
)    mtd_device_parse_register(master, NULL, NULL, parts, nr_parts)

Definition at line 369 of file mtd.h.

#define MTD_ERASE_DONE   0x08

Definition at line 38 of file mtd.h.

#define MTD_ERASE_FAILED   0x10

Definition at line 39 of file mtd.h.

#define MTD_ERASE_PENDING   0x01

Definition at line 35 of file mtd.h.

#define MTD_ERASE_SUSPEND   0x04

Definition at line 37 of file mtd.h.

#define MTD_ERASING   0x02

Definition at line 36 of file mtd.h.

#define MTD_FAIL_ADDR_UNKNOWN   -1LL

Definition at line 41 of file mtd.h.

#define MTD_MAX_ECCPOS_ENTRIES_LARGE   448

Definition at line 101 of file mtd.h.

#define MTD_MAX_OOBFREE_ENTRIES_LARGE   32

Definition at line 100 of file mtd.h.

Function Documentation

int __get_mtd_device ( struct mtd_info mtd)

Definition at line 649 of file mtdcore.c.

void __put_mtd_device ( struct mtd_info mtd)

Definition at line 716 of file mtdcore.c.

struct mtd_info* get_mtd_device ( struct mtd_info mtd,
int  num 
)
read

get_mtd_device - obtain a validated handle for an MTD device : last known address of the required MTD device : internal device number of the required MTD device

Given a number and NULL address, return the num'th entry in the device table, if any. Given an address and num == -1, search the device table for a device with that address and return if it's still present. Given both, return the num'th driver only if its address matches. Return error code if not.

Definition at line 614 of file mtdcore.c.

struct mtd_info* get_mtd_device_nm ( const char name)
read

Definition at line 677 of file mtdcore.c.

int mtd_block_isbad ( struct mtd_info mtd,
loff_t  ofs 
)

Definition at line 992 of file mtdcore.c.

int mtd_block_markbad ( struct mtd_info mtd,
loff_t  ofs 
)

Definition at line 1002 of file mtdcore.c.

int mtd_device_parse_register ( struct mtd_info mtd,
const char **  types,
struct mtd_part_parser_data parser_data,
const struct mtd_partition parts,
int  nr_parts 
)

mtd_device_parse_register - parse partitions and register an MTD device.

: the MTD device to register : the list of MTD partition probes to try, see 'parse_mtd_partitions()' for more information : MTD partition parser-specific data : fallback partition information to register, if parsing fails; only valid if nr_parts > %0 : the number of partitions in parts, if zero then the full MTD device is registered if no partition info is found

This function aggregates MTD partitions parsing (done by 'parse_mtd_partitions()') and MTD device and partitions registering. It basically follows the most common pattern found in many MTD drivers:

  • It first tries to probe partitions on MTD device using parsers specified in (if is NULL, then the default list of parsers is used, see 'parse_mtd_partitions()' for more information). If none are found this functions tries to fallback to information specified in /.
  • If any partitioning info was found, this function registers the found partitions.
  • If no partitions were found this function just registers the MTD device and exits.

Returns zero in case of success and a negative error code in case of failure.

Definition at line 500 of file mtdcore.c.

int mtd_device_unregister ( struct mtd_info master)

mtd_device_unregister - unregister an existing MTD device.

: the MTD device to unregister. This will unregister both the master and any partitions if registered.

Definition at line 537 of file mtdcore.c.

int mtd_erase ( struct mtd_info mtd,
struct erase_info instr 
)

Definition at line 735 of file mtdcore.c.

void mtd_erase_callback ( struct erase_info instr)

Definition at line 241 of file mtdpart.c.

int mtd_get_fact_prot_info ( struct mtd_info mtd,
struct otp_info buf,
size_t  len 
)

Definition at line 887 of file mtdcore.c.

unsigned long mtd_get_unmapped_area ( struct mtd_info mtd,
unsigned long  len,
unsigned long  offset,
unsigned long  flags 
)

Definition at line 789 of file mtdcore.c.

int mtd_get_user_prot_info ( struct mtd_info mtd,
struct otp_info buf,
size_t  len 
)

Definition at line 910 of file mtdcore.c.

int mtd_is_locked ( struct mtd_info mtd,
loff_t  ofs,
uint64_t  len 
)

Definition at line 980 of file mtdcore.c.

void* mtd_kmalloc_up_to ( const struct mtd_info mtd,
size_t size 
)

mtd_kmalloc_up_to - allocate a contiguous buffer up to the specified size : mtd device description object pointer : a pointer to the ideal or maximum size of the allocation, points to the actual allocation size on success.

This routine attempts to allocate a contiguous kernel buffer up to the specified size, backing off the size of the request exponentially until the request succeeds or until the allocation size falls below the system page size. This attempts to make sure it does not adversely impact system performance, so when allocating more than one page, we ask the memory allocator to avoid re-trying, swapping, writing back or performing I/O.

Note, this function also makes sure that the allocated buffer is aligned to the MTD device's min. I/O unit, i.e. the "mtd->writesize" value.

This is called, for example by mtd_{read,write} and jffs2_scan_medium, to handle smaller (i.e. degraded) buffer allocations under low- or fragmented-memory situations where such reduced allocations, from a requested ideal, are allowed.

Returns a pointer to the allocated buffer on success; otherwise, NULL.

Definition at line 1093 of file mtdcore.c.

int mtd_lock ( struct mtd_info mtd,
loff_t  ofs,
uint64_t  len 
)

Definition at line 956 of file mtdcore.c.

int mtd_lock_user_prot_reg ( struct mtd_info mtd,
loff_t  from,
size_t  len 
)

Definition at line 945 of file mtdcore.c.

int mtd_panic_write ( struct mtd_info mtd,
loff_t  to,
size_t  len,
size_t retlen,
const u_char buf 
)

Definition at line 845 of file mtdcore.c.

int mtd_point ( struct mtd_info mtd,
loff_t  from,
size_t  len,
size_t retlen,
void **  virt,
resource_size_t phys 
)

Definition at line 754 of file mtdcore.c.

int mtd_read ( struct mtd_info mtd,
loff_t  from,
size_t  len,
size_t retlen,
u_char buf 
)

Definition at line 800 of file mtdcore.c.

int mtd_read_fact_prot_reg ( struct mtd_info mtd,
loff_t  from,
size_t  len,
size_t retlen,
u_char buf 
)

Definition at line 898 of file mtdcore.c.

int mtd_read_oob ( struct mtd_info mtd,
loff_t  from,
struct mtd_oob_ops ops 
)

Definition at line 861 of file mtdcore.c.

int mtd_read_user_prot_reg ( struct mtd_info mtd,
loff_t  from,
size_t  len,
size_t retlen,
u_char buf 
)

Definition at line 921 of file mtdcore.c.

int mtd_unlock ( struct mtd_info mtd,
loff_t  ofs,
uint64_t  len 
)

Definition at line 968 of file mtdcore.c.

int mtd_unpoint ( struct mtd_info mtd,
loff_t  from,
size_t  len 
)

Definition at line 772 of file mtdcore.c.

int mtd_write ( struct mtd_info mtd,
loff_t  to,
size_t  len,
size_t retlen,
const u_char buf 
)

Definition at line 824 of file mtdcore.c.

int mtd_write_user_prot_reg ( struct mtd_info mtd,
loff_t  to,
size_t  len,
size_t retlen,
u_char buf 
)

Definition at line 933 of file mtdcore.c.

int mtd_writev ( struct mtd_info mtd,
const struct kvec vecs,
unsigned long  count,
loff_t  to,
size_t retlen 
)

Definition at line 1057 of file mtdcore.c.

void put_mtd_device ( struct mtd_info mtd)

Definition at line 707 of file mtdcore.c.

void register_mtd_user ( struct mtd_notifier new)

register_mtd_user - register a 'user' of MTD devices. : pointer to notifier info structure

Registers a pair of callbacks function to be called upon addition or removal of MTD devices. Causes the 'add' callback to be immediately invoked for each MTD device currently present in the system.

Definition at line 560 of file mtdcore.c.

int unregister_mtd_user ( struct mtd_notifier old)

unregister_mtd_user - unregister a 'user' of MTD devices. : pointer to notifier info structure

Removes a callback function pair from the list of 'users' to be notified upon addition or removal of MTD devices. Causes the 'remove' callback to be immediately invoked for each MTD device currently present in the system.

Definition at line 586 of file mtdcore.c.