Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations
ubi.h File Reference
#include <linux/init.h>
#include <linux/types.h>
#include <linux/list.h>
#include <linux/rbtree.h>
#include <linux/sched.h>
#include <linux/wait.h>
#include <linux/mutex.h>
#include <linux/rwsem.h>
#include <linux/spinlock.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/device.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/vmalloc.h>
#include <linux/notifier.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/ubi.h>
#include <asm/pgtable.h>
#include "ubi-media.h"
#include "debug.h"

Go to the source code of this file.

Data Structures

struct  ubi_wl_entry
 
struct  ubi_ltree_entry
 
struct  ubi_rename_entry
 
struct  ubi_fastmap_layout
 
struct  ubi_fm_pool
 
struct  ubi_volume
 
struct  ubi_volume_desc
 
struct  ubi_device
 
struct  ubi_ainf_peb
 
struct  ubi_ainf_volume
 
struct  ubi_attach_info
 
struct  ubi_work
 

Macros

#define UBI_MAX_DEVICES   32
 
#define UBI_NAME_STR   "ubi"
 
#define ubi_msg(fmt,...)   pr_notice("UBI: " fmt "\n", ##__VA_ARGS__)
 
#define ubi_warn(fmt,...)
 
#define ubi_err(fmt,...)
 
#define UBI_BGT_NAME_PATTERN   "ubi_bgt%dd"
 
#define UBI_LEB_UNMAPPED   -1
 
#define UBI_IO_RETRIES   3
 
#define UBI_PROT_QUEUE_LEN   10
 
#define UBI_UNKNOWN   -1
 

Enumerations

enum  {
  UBI_IO_FF = 1, UBI_IO_FF_BITFLIPS, UBI_IO_BAD_HDR, UBI_IO_BAD_HDR_EBADMSG,
  UBI_IO_BITFLIPS
}
 
enum  {
  MOVE_CANCEL_RACE = 1, MOVE_SOURCE_RD_ERR, MOVE_TARGET_RD_ERR, MOVE_TARGET_WR_ERR,
  MOVE_TARGET_BITFLIPS, MOVE_RETRY
}
 
enum  { UBI_NO_FASTMAP = 1, UBI_BAD_FASTMAP }
 

: volume name

struct ubi_volume - UBI volume description data structure. : device object to make use of the the Linux device model : character device object to create character device : reference to the UBI device description object : volume ID : volume reference count : number of users holding this volume in read-only mode : number of users holding this volume in read-write mode : whether somebody holds this volume in exclusive mode

: how many physical eraseblocks are reserved for this volume : volume type (UBI_DYNAMIC_VOLUME or UBI_STATIC_VOLUME) : logical eraseblock size without padding : how many logical eraseblocks in this volume contain data : how many bytes are stored in the last logical eraseblock : how many bytes of data this volume contains : volume alignment : how many bytes are not used at the end of physical eraseblocks to satisfy the requested alignment : volume name length

: how many eraseblocks are expected to be updated : LEB number which is being changing by the atomic LEB change operation : how many bytes are expected to be received for volume update or atomic LEB change : how many bytes were already received for volume update or atomic LEB change : update buffer which is used to collect update data or data for atomic LEB change

: EBA table of this volume (LEB->PEB mapping) : %1 if this static volume was checked : %1 if the volume is corrupted (static volumes only) : %1 if the update marker is set for this volume : %1 if the volume is being updated : %1 if the atomic LEB change ioctl command is in progress : %1 if direct writes are enabled for this volume

The field indicates that the volume's contents is corrupted. Since UBI protects only static volumes, this field is not relevant to dynamic volumes - it is user's responsibility to assure their data integrity.

The flag indicates that this volume is either being updated at the moment or is damaged because of an unclean reboot.

#define ubi_rb_for_each_entry(rb, pos, root, member)
 
struct kmem_cacheubi_wl_entry_slab
 
struct file_operations ubi_ctrl_cdev_operations
 
struct file_operations ubi_cdev_operations
 
struct file_operations ubi_vol_cdev_operations
 
struct classubi_class
 
struct mutex ubi_devices_mutex
 
struct blocking_notifier_head ubi_notifiers
 
int ubi_add_to_av (struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum, int ec, const struct ubi_vid_hdr *vid_hdr, int bitflips)
 
struct ubi_ainf_volumeubi_find_av (const struct ubi_attach_info *ai, int vol_id)
 
void ubi_remove_av (struct ubi_attach_info *ai, struct ubi_ainf_volume *av)
 
struct ubi_ainf_pebubi_early_get_peb (struct ubi_device *ubi, struct ubi_attach_info *ai)
 
int ubi_attach (struct ubi_device *ubi, int force_scan)
 
void ubi_destroy_ai (struct ubi_attach_info *ai)
 
int ubi_change_vtbl_record (struct ubi_device *ubi, int idx, struct ubi_vtbl_record *vtbl_rec)
 
int ubi_vtbl_rename_volumes (struct ubi_device *ubi, struct list_head *rename_list)
 
int ubi_read_volume_table (struct ubi_device *ubi, struct ubi_attach_info *ai)
 
int ubi_create_volume (struct ubi_device *ubi, struct ubi_mkvol_req *req)
 
int ubi_remove_volume (struct ubi_volume_desc *desc, int no_vtbl)
 
int ubi_resize_volume (struct ubi_volume_desc *desc, int reserved_pebs)
 
int ubi_rename_volumes (struct ubi_device *ubi, struct list_head *rename_list)
 
int ubi_add_volume (struct ubi_device *ubi, struct ubi_volume *vol)
 
void ubi_free_volume (struct ubi_device *ubi, struct ubi_volume *vol)
 
int ubi_start_update (struct ubi_device *ubi, struct ubi_volume *vol, long long bytes)
 
int ubi_more_update_data (struct ubi_device *ubi, struct ubi_volume *vol, const void __user *buf, int count)
 
int ubi_start_leb_change (struct ubi_device *ubi, struct ubi_volume *vol, const struct ubi_leb_change_req *req)
 
int ubi_more_leb_change_data (struct ubi_device *ubi, struct ubi_volume *vol, const void __user *buf, int count)
 
int ubi_calc_data_len (const struct ubi_device *ubi, const void *buf, int length)
 
int ubi_check_volume (struct ubi_device *ubi, int vol_id)
 
void ubi_update_reserved (struct ubi_device *ubi)
 
void ubi_calculate_reserved (struct ubi_device *ubi)
 
int ubi_check_pattern (const void *buf, uint8_t patt, int size)
 
int ubi_eba_unmap_leb (struct ubi_device *ubi, struct ubi_volume *vol, int lnum)
 
int ubi_eba_read_leb (struct ubi_device *ubi, struct ubi_volume *vol, int lnum, void *buf, int offset, int len, int check)
 
int ubi_eba_write_leb (struct ubi_device *ubi, struct ubi_volume *vol, int lnum, const void *buf, int offset, int len)
 
int ubi_eba_write_leb_st (struct ubi_device *ubi, struct ubi_volume *vol, int lnum, const void *buf, int len, int used_ebs)
 
int ubi_eba_atomic_leb_change (struct ubi_device *ubi, struct ubi_volume *vol, int lnum, const void *buf, int len)
 
int ubi_eba_copy_leb (struct ubi_device *ubi, int from, int to, struct ubi_vid_hdr *vid_hdr)
 
int ubi_eba_init (struct ubi_device *ubi, struct ubi_attach_info *ai)
 
unsigned long long ubi_next_sqnum (struct ubi_device *ubi)
 
int self_check_eba (struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap, struct ubi_attach_info *ai_scan)
 
int ubi_wl_get_peb (struct ubi_device *ubi)
 
int ubi_wl_put_peb (struct ubi_device *ubi, int vol_id, int lnum, int pnum, int torture)
 
int ubi_wl_flush (struct ubi_device *ubi, int vol_id, int lnum)
 
int ubi_wl_scrub_peb (struct ubi_device *ubi, int pnum)
 
int ubi_wl_init (struct ubi_device *ubi, struct ubi_attach_info *ai)
 
void ubi_wl_close (struct ubi_device *ubi)
 
int ubi_thread (void *u)
 
struct ubi_wl_entryubi_wl_get_fm_peb (struct ubi_device *ubi, int anchor)
 
int ubi_wl_put_fm_peb (struct ubi_device *ubi, struct ubi_wl_entry *used_e, int lnum, int torture)
 
int ubi_is_erase_work (struct ubi_work *wrk)
 
void ubi_refill_pools (struct ubi_device *ubi)
 
int ubi_ensure_anchor_pebs (struct ubi_device *ubi)
 
int ubi_io_read (const struct ubi_device *ubi, void *buf, int pnum, int offset, int len)
 
int ubi_io_write (struct ubi_device *ubi, const void *buf, int pnum, int offset, int len)
 
int ubi_io_sync_erase (struct ubi_device *ubi, int pnum, int torture)
 
int ubi_io_is_bad (const struct ubi_device *ubi, int pnum)
 
int ubi_io_mark_bad (const struct ubi_device *ubi, int pnum)
 
int ubi_io_read_ec_hdr (struct ubi_device *ubi, int pnum, struct ubi_ec_hdr *ec_hdr, int verbose)
 
int ubi_io_write_ec_hdr (struct ubi_device *ubi, int pnum, struct ubi_ec_hdr *ec_hdr)
 
int ubi_io_read_vid_hdr (struct ubi_device *ubi, int pnum, struct ubi_vid_hdr *vid_hdr, int verbose)
 
int ubi_io_write_vid_hdr (struct ubi_device *ubi, int pnum, struct ubi_vid_hdr *vid_hdr)
 
int ubi_attach_mtd_dev (struct mtd_info *mtd, int ubi_num, int vid_hdr_offset, int max_beb_per1024)
 
int ubi_detach_mtd_dev (int ubi_num, int anyway)
 
struct ubi_deviceubi_get_device (int ubi_num)
 
void ubi_put_device (struct ubi_device *ubi)
 
struct ubi_deviceubi_get_by_major (int major)
 
int ubi_major2num (int major)
 
int ubi_volume_notify (struct ubi_device *ubi, struct ubi_volume *vol, int ntype)
 
int ubi_notify_all (struct ubi_device *ubi, int ntype, struct notifier_block *nb)
 
int ubi_enumerate_volumes (struct notifier_block *nb)
 
void ubi_free_internal_volumes (struct ubi_device *ubi)
 
void ubi_do_get_device_info (struct ubi_device *ubi, struct ubi_device_info *di)
 
void ubi_do_get_volume_info (struct ubi_device *ubi, struct ubi_volume *vol, struct ubi_volume_info *vi)
 
int ubi_compare_lebs (struct ubi_device *ubi, const struct ubi_ainf_peb *aeb, int pnum, const struct ubi_vid_hdr *vid_hdr)
 
size_t ubi_calc_fm_size (struct ubi_device *ubi)
 
int ubi_update_fastmap (struct ubi_device *ubi)
 
int ubi_scan_fastmap (struct ubi_device *ubi, struct ubi_attach_info *ai, int fm_anchor)
 

Macro Definition Documentation

#define UBI_BGT_NAME_PATTERN   "ubi_bgt%dd"

Definition at line 63 of file ubi.h.

#define ubi_err (   fmt,
  ... 
)
Value:
pr_err("UBI error: %s: " fmt "\n", \
__func__, ##__VA_ARGS__)

Definition at line 59 of file ubi.h.

#define UBI_IO_RETRIES   3

Definition at line 75 of file ubi.h.

#define UBI_LEB_UNMAPPED   -1

Definition at line 69 of file ubi.h.

#define UBI_MAX_DEVICES   32

Definition at line 48 of file ubi.h.

#define ubi_msg (   fmt,
  ... 
)    pr_notice("UBI: " fmt "\n", ##__VA_ARGS__)

Definition at line 54 of file ubi.h.

#define UBI_NAME_STR   "ubi"

Definition at line 51 of file ubi.h.

#define UBI_PROT_QUEUE_LEN   10

Definition at line 82 of file ubi.h.

#define ubi_rb_for_each_entry (   rb,
  pos,
  root,
  member 
)
Value:
for (rb = rb_first(root), \
pos = (rb ? container_of(rb, typeof(*pos), member) : NULL); \
rb; \
rb = rb_next(rb), \
pos = (rb ? container_of(rb, typeof(*pos), member) : NULL))

Definition at line 836 of file ubi.h.

#define UBI_UNKNOWN   -1

Definition at line 85 of file ubi.h.

#define ubi_warn (   fmt,
  ... 
)
Value:
pr_warn("UBI warning: %s: " fmt "\n", \
__func__, ##__VA_ARGS__)

Definition at line 56 of file ubi.h.

Enumeration Type Documentation

anonymous enum
Enumerator:
UBI_IO_FF 
UBI_IO_FF_BITFLIPS 
UBI_IO_BAD_HDR 
UBI_IO_BAD_HDR_EBADMSG 
UBI_IO_BITFLIPS 

Definition at line 104 of file ubi.h.

anonymous enum
Enumerator:
MOVE_CANCEL_RACE 
MOVE_SOURCE_RD_ERR 
MOVE_TARGET_RD_ERR 
MOVE_TARGET_WR_ERR 
MOVE_TARGET_BITFLIPS 
MOVE_RETRY 

Definition at line 127 of file ubi.h.

anonymous enum
Enumerator:
UBI_NO_FASTMAP 
UBI_BAD_FASTMAP 

Definition at line 142 of file ubi.h.

Function Documentation

int self_check_eba ( struct ubi_device ubi,
struct ubi_attach_info ai_fastmap,
struct ubi_attach_info ai_scan 
)

self_check_eba - run a self check on the EBA table constructed by fastmap. : UBI device description object : UBI attach info object created by fastmap : UBI attach info object created by scanning

Returns < 0 in case of an internal error, 0 otherwise. If a bad EBA table entry was found it will be printed out and ubi_assert() triggers.

Definition at line 1226 of file eba.c.

int ubi_add_to_av ( struct ubi_device ubi,
struct ubi_attach_info ai,
int  pnum,
int  ec,
const struct ubi_vid_hdr vid_hdr,
int  bitflips 
)

ubi_add_to_av - add used physical eraseblock to the attaching information. : UBI device description object : attaching information : the physical eraseblock number : erase counter : the volume identifier header : if bit-flips were detected when this physical eraseblock was read

This function adds information about a used physical eraseblock to the 'used' tree of the corresponding volume. The function is rather complex because it has to handle cases when this is not the first physical eraseblock belonging to the same logical eraseblock, and the newer one has to be picked, while the older one has to be dropped. This function returns zero in case of success and a negative error code in case of failure.

Definition at line 452 of file attach.c.

int ubi_add_volume ( struct ubi_device ubi,
struct ubi_volume vol 
)

ubi_add_volume - add volume. : UBI device description object : volume description object

This function adds an existing volume and initializes all its data structures. Returns zero in case of success and a negative error code in case of failure.

Definition at line 633 of file vmt.c.

int ubi_attach ( struct ubi_device ubi,
int  force_scan 
)

ubi_attach - attach an MTD device. : UBI device descriptor : if set to non-zero attach by scanning

This function returns zero in case of success and a negative error code in case of failure.

Definition at line 1399 of file attach.c.

int ubi_attach_mtd_dev ( struct mtd_info mtd,
int  ubi_num,
int  vid_hdr_offset,
int  max_beb_per1024 
)

ubi_attach_mtd_dev - attach an MTD device. : MTD device description object : number to assign to the new UBI device : VID header offset : maximum expected number of bad PEB per 1024 PEBs

This function attaches MTD device to UBI and assign number to the newly created UBI device, unless is UBI_DEV_NUM_AUTO, in which case this function finds a vacant device number and assigns it automatically. Returns the new UBI device number in case of success and a negative error code in case of failure.

Note, the invocations of this function has to be serialized by the .

Definition at line 866 of file build.c.

int ubi_calc_data_len ( const struct ubi_device ubi,
const void buf,
int  length 
)

calc_data_len - calculate how much real data is stored in a buffer. : UBI device description object : a buffer with the contents of the physical eraseblock : the buffer length

This function calculates how much "real data" is stored in and returnes the length. Continuous 0xFF bytes at the end of the buffer are not considered as "real data".

Definition at line 35 of file misc.c.

size_t ubi_calc_fm_size ( struct ubi_device ubi)

ubi_calc_fm_size - calculates the fastmap size in bytes for an UBI device. : UBI device description object

Definition at line 23 of file fastmap.c.

void ubi_calculate_reserved ( struct ubi_device ubi)

ubi_calculate_reserved - calculate how many PEBs must be reserved for bad eraseblock handling. : UBI device description object

Definition at line 122 of file misc.c.

int ubi_change_vtbl_record ( struct ubi_device ubi,
int  idx,
struct ubi_vtbl_record vtbl_rec 
)

ubi_change_vtbl_record - change volume table record. : UBI device description object : table index to change : new volume table record

This function changes volume table record . If is NULL, empty volume table record is written. The caller does not have to calculate CRC of the record as it is done by this function. Returns zero in case of success and a negative error code in case of failure.

Definition at line 80 of file vtbl.c.

int ubi_check_pattern ( const void buf,
uint8_t  patt,
int  size 
)

ubi_check_pattern - check if buffer contains only a certain byte pattern. : buffer to check : the pattern to check : buffer size in bytes

This function returns %1 in there are only bytes in , and %0 if something else was also found.

Definition at line 145 of file misc.c.

int ubi_check_volume ( struct ubi_device ubi,
int  vol_id 
)

ubi_check_volume - check the contents of a static volume. : UBI device description object : ID of the volume to check

This function checks if static volume is corrupted by fully reading it and checking data CRC. This function returns %0 if the volume is not corrupted, %1 if it is corrupted and a negative error code in case of failure. Dynamic volumes are not checked and zero is returned immediately.

Definition at line 61 of file misc.c.

int ubi_compare_lebs ( struct ubi_device ubi,
const struct ubi_ainf_peb aeb,
int  pnum,
const struct ubi_vid_hdr vid_hdr 
)

ubi_compare_lebs - find out which logical eraseblock is newer. : UBI device description object : first logical eraseblock to compare : physical eraseblock number of the second logical eraseblock to compare : volume identifier header of the second logical eraseblock

This function compares 2 copies of a LEB and informs which one is newer. In case of success this function returns a positive value, in case of failure, a negative error code is returned. The success return codes use the following bits: o bit 0 is cleared: the first PEB (described by ) is newer than the second PEB (described by and ); o bit 0 is set: the second PEB is newer; o bit 1 is cleared: no bit-flips were detected in the newer LEB; o bit 1 is set: bit-flips were detected in the newer LEB; o bit 2 is cleared: the older LEB is not corrupted; o bit 2 is set: the older LEB is corrupted.

Definition at line 322 of file attach.c.

int ubi_create_volume ( struct ubi_device ubi,
struct ubi_mkvol_req req 
)

ubi_create_volume - create volume. : UBI device description object : volume creation request

This function creates volume described by . If ->vol_id id UBI_VOL_NUM_AUTO, this function automatically assign ID to the new volume and saves it in ->vol_id. Returns zero in case of success and a negative error code in case of failure. Note, the caller has to have the ->device_mutex locked.

Definition at line 201 of file vmt.c.

void ubi_destroy_ai ( struct ubi_attach_info ai)
int ubi_detach_mtd_dev ( int  ubi_num,
int  anyway 
)

ubi_detach_mtd_dev - detach an MTD device. : UBI device number to detach from : detach MTD even if device reference count is not zero

This function destroys an UBI device number and detaches the underlying MTD device. Returns zero in case of success and %-EBUSY if the UBI device is busy and cannot be destroyed, and %-EINVAL if it does not exist.

Note, the invocations of this function has to be serialized by the .

Definition at line 1088 of file build.c.

void ubi_do_get_device_info ( struct ubi_device ubi,
struct ubi_device_info di 
)

ubi_do_get_device_info - get information about UBI device. : UBI device description object : the information is stored here

This function is the same as 'ubi_get_device_info()', but it assumes the UBI device is locked and cannot disappear.

Definition at line 39 of file kapi.c.

void ubi_do_get_volume_info ( struct ubi_device ubi,
struct ubi_volume vol,
struct ubi_volume_info vi 
)

ubi_do_get_volume_info - get information about UBI volume. : UBI device description object : volume description object : the information is stored here

Definition at line 80 of file kapi.c.

struct ubi_ainf_peb* ubi_early_get_peb ( struct ubi_device ubi,
struct ubi_attach_info ai 
)
read

ubi_early_get_peb - get a free physical eraseblock. : UBI device description object : attaching information

This function returns a free physical eraseblock. It is supposed to be called on the UBI initialization stages when the wear-leveling sub-system is not initialized yet. This function picks a physical eraseblocks from one of the lists, writes the EC header if it is needed, and removes it from the list.

This function returns a pointer to the "aeb" of the found free PEB in case of success and an error code in case of failure.

Definition at line 711 of file attach.c.

int ubi_eba_atomic_leb_change ( struct ubi_device ubi,
struct ubi_volume vol,
int  lnum,
const void buf,
int  len 
)

Definition at line 843 of file eba.c.

int ubi_eba_copy_leb ( struct ubi_device ubi,
int  from,
int  to,
struct ubi_vid_hdr vid_hdr 
)

ubi_eba_copy_leb - copy logical eraseblock. : UBI device description object : physical eraseblock number from where to copy : physical eraseblock number where to copy : VID header of the physical eraseblock

This function copies logical eraseblock from physical eraseblock to physical eraseblock . The buffer may be changed by this function. Returns: o %0 in case of success; o MOVE_CANCEL_RACE, MOVE_TARGET_WR_ERR, MOVE_TARGET_BITFLIPS, etc; o a negative error code in case of failure.

Definition at line 989 of file eba.c.

int ubi_eba_init ( struct ubi_device ubi,
struct ubi_attach_info ai 
)

ubi_eba_init - initialize the EBA sub-system using attaching information. : UBI device description object : attaching information

This function returns zero in case of success and a negative error code in case of failure.

Definition at line 1320 of file eba.c.

int ubi_eba_read_leb ( struct ubi_device ubi,
struct ubi_volume vol,
int  lnum,
void buf,
int  offset,
int  len,
int  check 
)

ubi_eba_read_leb - read data. : UBI device description object : volume description object : logical eraseblock number : buffer to store the read data : offset from where to read : how many bytes to read : data CRC check flag

If the logical eraseblock is unmapped, is filled with 0xFF bytes. The flag only makes sense for static volumes and forces eraseblock data CRC checking.

In case of success this function returns zero. In case of a static volume, if data CRC mismatches - %-EBADMSG is returned. %-EBADMSG may also be returned for any volume type if an ECC error was detected by the MTD device driver. Other negative error cored may be returned in case of other errors.

Definition at line 372 of file eba.c.

int ubi_eba_unmap_leb ( struct ubi_device ubi,
struct ubi_volume vol,
int  lnum 
)

ubi_eba_unmap_leb - un-map logical eraseblock. : UBI device description object : volume description object : logical eraseblock number

This function un-maps logical eraseblock and schedules corresponding physical eraseblock for erasure. Returns zero in case of success and a negative error code in case of failure.

Definition at line 324 of file eba.c.

int ubi_eba_write_leb ( struct ubi_device ubi,
struct ubi_volume vol,
int  lnum,
const void buf,
int  offset,
int  len 
)

ubi_eba_write_leb - write data to dynamic volume. : UBI device description object : volume description object : logical eraseblock number : the data to write : offset within the logical eraseblock where to write : how many bytes to write

This function writes data to logical eraseblock of a dynamic volume . Returns zero in case of success and a negative error code in case of failure. In case of error, it is possible that something was still written to the flash media, but may be some garbage.

Definition at line 597 of file eba.c.

int ubi_eba_write_leb_st ( struct ubi_device ubi,
struct ubi_volume vol,
int  lnum,
const void buf,
int  len,
int  used_ebs 
)

ubi_eba_write_leb_st - write data to static volume. : UBI device description object : volume description object : logical eraseblock number : data to write : how many bytes to write : how many logical eraseblocks will this volume contain

This function writes data to logical eraseblock of static volume . The argument should contain total number of logical eraseblock in this static volume.

When writing to the last logical eraseblock, the argument doesn't have to be aligned to the minimal I/O unit size. Instead, it has to be equivalent to the real data size, although the buffer has to contain the alignment. In all other cases, has to be aligned.

It is prohibited to write more than once to logical eraseblocks of static volumes. This function returns zero in case of success and a negative error code in case of failure.

Definition at line 728 of file eba.c.

int ubi_ensure_anchor_pebs ( struct ubi_device ubi)
int ubi_enumerate_volumes ( struct notifier_block nb)

ubi_enumerate_volumes - send "add" notification for all existing volumes. : the notifier to call

This function walks all UBI devices and volumes and sends the UBI_VOLUME_ADDED notification for each volume. If is NULL, then all registered notifiers are called, otherwise only the notifier is called. Returns the number of sent notifications.

Definition at line 225 of file build.c.

struct ubi_ainf_volume* ubi_find_av ( const struct ubi_attach_info ai,
int  vol_id 
)
read

ubi_find_av - find volume in the attaching information. : attaching information : the requested volume ID

This function returns a pointer to the volume description or NULL if there are no data about this volume in the attaching information.

Definition at line 608 of file attach.c.

void ubi_free_internal_volumes ( struct ubi_device ubi)

ubi_free_internal_volumes - free internal volumes. : UBI device description object

Definition at line 581 of file build.c.

void ubi_free_volume ( struct ubi_device ubi,
struct ubi_volume vol 
)

ubi_free_volume - free volume. : UBI device description object : volume description object

This function frees all resources for volume but does not remove it. Used only when the UBI device is detached.

Definition at line 683 of file vmt.c.

struct ubi_device* ubi_get_by_major ( int  major)
read

ubi_get_by_major - get UBI device by character device major number. : major number

This function is similar to 'ubi_get_device()', but it searches the device by its major number.

Definition at line 288 of file build.c.

struct ubi_device* ubi_get_device ( int  ubi_num)
read

ubi_get_device - get UBI device. : UBI device number

This function returns UBI device description object for UBI device number , or NULL if the device does not exist. This function increases the device reference count to prevent removal of the device. In other words, the device cannot be removed if its reference count is not zero.

Definition at line 253 of file build.c.

int ubi_io_is_bad ( const struct ubi_device ubi,
int  pnum 
)

ubi_io_is_bad - check if a physical eraseblock is bad. : UBI device description object : the physical eraseblock number to check

This function returns a positive number if the physical eraseblock is bad, zero if not, and a negative error code if an error occurred.

Definition at line 618 of file io.c.

int ubi_io_mark_bad ( const struct ubi_device ubi,
int  pnum 
)

ubi_io_mark_bad - mark a physical eraseblock as bad. : UBI device description object : the physical eraseblock number to mark

This function returns zero in case of success and a negative error code in case of failure.

Definition at line 647 of file io.c.

int ubi_io_read ( const struct ubi_device ubi,
void buf,
int  pnum,
int  offset,
int  len 
)

ubi_io_read - read data from a physical eraseblock. : UBI device description object : buffer where to store the read data : physical eraseblock number to read from : offset within the physical eraseblock from where to read : how many bytes to read

This function reads data from offset of physical eraseblock and stores the read data in the buffer. The following return codes are possible:

o %0 if all the requested data were successfully read; o UBI_IO_BITFLIPS if all the requested data were successfully read, but correctable bit-flips were detected; this is harmless but may indicate that this eraseblock may become bad soon (but do not have to); o %-EBADMSG if the MTD subsystem reported about data integrity problems, for example it can be an ECC error in case of NAND; this most probably means that the data is corrupted; o %-EIO if some I/O error occurred; o other negative error codes in case of other errors.

Definition at line 126 of file io.c.

int ubi_io_read_ec_hdr ( struct ubi_device ubi,
int  pnum,
struct ubi_ec_hdr ec_hdr,
int  verbose 
)

ubi_io_read_ec_hdr - read and check an erase counter header. : UBI device description object : physical eraseblock to read from : a &struct ubi_ec_hdr object where to store the read erase counter header : be verbose if the header is corrupted or was not found

This function reads erase counter header from physical eraseblock and stores it in . This function also checks CRC checksum of the read erase counter header. The following codes may be returned:

o %0 if the CRC checksum is correct and the header was successfully read; o UBI_IO_BITFLIPS if the CRC is correct, but bit-flips were detected and corrected by the flash driver; this is harmless but may indicate that this eraseblock may become bad soon (but may be not); o UBI_IO_BAD_HDR if the erase counter header is corrupted (a CRC error); o UBI_IO_BAD_HDR_EBADMSG is the same as UBI_IO_BAD_HDR, but there also was a data integrity error (uncorrectable ECC error in case of NAND); o UBI_IO_FF if only 0xFF bytes were read (the PEB is supposedly empty) o a negative error code in case of failure.

Definition at line 740 of file io.c.

int ubi_io_read_vid_hdr ( struct ubi_device ubi,
int  pnum,
struct ubi_vid_hdr vid_hdr,
int  verbose 
)

ubi_io_read_vid_hdr - read and check a volume identifier header. : UBI device description object : physical eraseblock number to read from : &struct ubi_vid_hdr object where to store the read volume identifier header : be verbose if the header is corrupted or wasn't found

This function reads the volume identifier header from physical eraseblock and stores it in . It also checks CRC checksum of the read volume identifier header. The error codes are the same as in 'ubi_io_read_ec_hdr()'.

Note, the implementation of this function is also very similar to 'ubi_io_read_ec_hdr()', so refer commentaries in 'ubi_io_read_ec_hdr()'.

Definition at line 1010 of file io.c.

int ubi_io_sync_erase ( struct ubi_device ubi,
int  pnum,
int  torture 
)

ubi_io_sync_erase - synchronously erase a physical eraseblock. : UBI device description object : physical eraseblock number to erase : if this physical eraseblock has to be tortured

This function synchronously erases physical eraseblock . If flag is not zero, the physical eraseblock is checked by means of writing different patterns to it and reading them back. If the torturing is enabled, the physical eraseblock is erased more than once.

This function returns the number of erasures made in case of success, %-EIO if the erasure failed or the torturing test failed, and other negative error codes in case of other errors. Note, %-EIO means that the physical eraseblock is bad.

Definition at line 576 of file io.c.

int ubi_io_write ( struct ubi_device ubi,
const void buf,
int  pnum,
int  offset,
int  len 
)

ubi_io_write - write data to a physical eraseblock. : UBI device description object : buffer with the data to write : physical eraseblock number to write to : offset within the physical eraseblock where to write : how many bytes to write

This function writes bytes of data from buffer to offset of physical eraseblock . If all the data were successfully written, zero is returned. If an error occurred, this function returns a negative error code. If %-EIO is returned, the physical eraseblock most probably went bad.

Note, in case of an error, it is possible that something was still written to the flash media, but may be some garbage.

Definition at line 234 of file io.c.

int ubi_io_write_ec_hdr ( struct ubi_device ubi,
int  pnum,
struct ubi_ec_hdr ec_hdr 
)

ubi_io_write_ec_hdr - write an erase counter header. : UBI device description object : physical eraseblock to write to : the erase counter header to write

This function writes erase counter header described by to physical eraseblock . It also fills most fields of before writing, so the caller do not have to fill them. Callers must only fill the ->ec field.

This function returns zero in case of success and a negative error code in case of failure. If %-EIO is returned, the physical eraseblock most probably went bad.

Definition at line 849 of file io.c.

int ubi_io_write_vid_hdr ( struct ubi_device ubi,
int  pnum,
struct ubi_vid_hdr vid_hdr 
)

ubi_io_write_vid_hdr - write a volume identifier header. : UBI device description object : the physical eraseblock number to write to : the volume identifier header to write

This function writes the volume identifier header described by to physical eraseblock . This function automatically fills the ->magic and the ->version fields, as well as calculates header CRC checksum and stores it at vid_hdr->hdr_crc.

This function returns zero in case of success and a negative error code in case of failure. If %-EIO is returned, the physical eraseblock probably went bad.

Definition at line 1094 of file io.c.

int ubi_is_erase_work ( struct ubi_work wrk)
int ubi_major2num ( int  major)

ubi_major2num - get UBI device number by character device major number. : major number

This function searches UBI device number object by its major number. If UBI device was not found, this function returns -ENODEV, otherwise the UBI device number is returned.

Definition at line 317 of file build.c.

int ubi_more_leb_change_data ( struct ubi_device ubi,
struct ubi_volume vol,
const void __user buf,
int  count 
)

ubi_more_leb_change_data - accept more data for atomic LEB change. : UBI device description object : volume description object : write data (user-space memory buffer) : how much bytes to write

This function accepts more data to the volume which is being under the "atomic LEB change" operation. It may be called arbitrary number of times until all data arrives. This function returns %0 in case of success, number of bytes written during the last call if the whole "atomic LEB change" operation has been successfully finished, and a negative error code in case of failure.

Definition at line 393 of file upd.c.

int ubi_more_update_data ( struct ubi_device ubi,
struct ubi_volume vol,
const void __user buf,
int  count 
)

ubi_more_update_data - write more update data. : UBI device description object : volume description object : write data (user-space memory buffer) : how much bytes to write

This function writes more data to the volume which is being updated. It may be called arbitrary number of times until all the update data arriveis. This function returns %0 in case of success, number of bytes written during the last call if the whole volume update has been successfully finished, and a negative error code in case of failure.

Definition at line 278 of file upd.c.

unsigned long long ubi_next_sqnum ( struct ubi_device ubi)

next_sqnum - get next sequence number. : UBI device description object

This function returns next sequence number to use, which is just the current global sequence counter value. It also increases the global sequence counter.

Definition at line 60 of file eba.c.

int ubi_notify_all ( struct ubi_device ubi,
int  ntype,
struct notifier_block nb 
)

ubi_notify_all - send a notification to all volumes. : UBI device description object : notification type to send (UBI_VOLUME_ADDED, etc) : the notifier to call

This function walks all volumes of UBI device and sends the notification for each volume. If is NULL, then all registered notifiers are called, otherwise only the notifier is called. Returns the number of sent notifications.

Definition at line 186 of file build.c.

void ubi_put_device ( struct ubi_device ubi)

ubi_put_device - drop an UBI device reference. : UBI device description object

Definition at line 273 of file build.c.

int ubi_read_volume_table ( struct ubi_device ubi,
struct ubi_attach_info ai 
)

ubi_read_volume_table - read the volume table. : UBI device description object : attaching information

This function reads volume table, checks it, recover from errors if needed, or creates it if needed. Returns zero in case of success and a negative error code in case of failure.

Definition at line 777 of file vtbl.c.

void ubi_refill_pools ( struct ubi_device ubi)
void ubi_remove_av ( struct ubi_attach_info ai,
struct ubi_ainf_volume av 
)

ubi_remove_av - delete attaching information about a volume. : attaching information : the volume attaching information to delete

Definition at line 634 of file attach.c.

int ubi_remove_volume ( struct ubi_volume_desc desc,
int  no_vtbl 
)

ubi_remove_volume - remove volume. : volume descriptor : do not change volume table if not zero

This function removes volume described by . The volume has to be opened in "exclusive" mode. Returns zero in case of success and a negative error code in case of failure. The caller has to have the ->device_mutex locked.

Definition at line 403 of file vmt.c.

int ubi_rename_volumes ( struct ubi_device ubi,
struct list_head rename_list 
)

ubi_rename_volumes - re-name UBI volumes. : UBI device description object : list of &struct ubi_rename_entry objects

This function re-names or removes volumes specified in the re-name list. Returns zero in case of success and a negative error code in case of failure.

Definition at line 594 of file vmt.c.

int ubi_resize_volume ( struct ubi_volume_desc desc,
int  reserved_pebs 
)

ubi_resize_volume - re-size volume. : volume descriptor : new size in physical eraseblocks

This function re-sizes the volume and returns zero in case of success, and a negative error code in case of failure. The caller has to have the ->device_mutex locked.

Definition at line 474 of file vmt.c.

int ubi_scan_fastmap ( struct ubi_device ubi,
struct ubi_attach_info ai,
int  fm_anchor 
)

ubi_scan_fastmap - scan the fastmap. : UBI device object : UBI attach info to be filled : The fastmap starts at this PEB

Returns 0 on success, UBI_NO_FASTMAP if no fastmap was found, UBI_BAD_FASTMAP if one was found but is not usable. < 0 indicates an internal error.

Definition at line 850 of file fastmap.c.

int ubi_start_leb_change ( struct ubi_device ubi,
struct ubi_volume vol,
const struct ubi_leb_change_req req 
)

ubi_start_leb_change - start atomic LEB change. : UBI device description object : volume description object : operation request

This function starts atomic LEB change operation. Returns zero in case of success and a negative error code in case of failure.

Definition at line 181 of file upd.c.

int ubi_start_update ( struct ubi_device ubi,
struct ubi_volume vol,
long long  bytes 
)

ubi_start_update - start volume update. : UBI device description object : volume description object : update bytes

This function starts volume update operation. If is zero, the volume is just wiped out. Returns zero in case of success and a negative error code in case of failure.

Definition at line 129 of file upd.c.

int ubi_thread ( void u)

ubi_thread - UBI background thread. : the UBI device description object pointer

Definition at line 1790 of file wl.c.

int ubi_update_fastmap ( struct ubi_device ubi)

ubi_update_fastmap - will be called by UBI if a volume changes or a fastmap pool becomes full. : UBI device object

Returns 0 on success, < 0 indicates an internal error.

Definition at line 1376 of file fastmap.c.

void ubi_update_reserved ( struct ubi_device ubi)

ubi_update_reserved - update bad eraseblock handling accounting data. : UBI device description object

This function calculates the gap between current number of PEBs reserved for bad eraseblock handling and the required level of PEBs that must be reserved, and if necessary, reserves more PEBs to fill that gap, according to availability. Should be called with ubi->volumes_lock held.

Definition at line 103 of file misc.c.

int ubi_volume_notify ( struct ubi_device ubi,
struct ubi_volume vol,
int  ntype 
)

ubi_volume_notify - send a volume change notification. : UBI device description object : volume description object of the changed volume : notification type to send (UBI_VOLUME_ADDED, etc)

This is a helper function which notifies all subscribers about a volume change event (creation, removal, re-sizing, re-naming, updating). Returns zero in case of success and a negative error code in case of failure.

Definition at line 153 of file build.c.

int ubi_vtbl_rename_volumes ( struct ubi_device ubi,
struct list_head rename_list 
)

ubi_vtbl_rename_volumes - rename UBI volumes in the volume table. : UBI device description object : list of &struct ubi_rename_entry objects

This function re-names multiple volumes specified in in the volume table. Returns zero in case of success and a negative error code in case of failure.

Definition at line 122 of file vtbl.c.

void ubi_wl_close ( struct ubi_device ubi)

ubi_wl_close - close the wear-leveling sub-system. : UBI device description object

Definition at line 2025 of file wl.c.

int ubi_wl_flush ( struct ubi_device ubi,
int  vol_id,
int  lnum 
)

ubi_wl_flush - flush all pending works. : UBI device description object : the volume id to flush for : the logical eraseblock number to flush for

This function executes all pending works for a particular volume id / logical eraseblock number pair. If either value is set to UBI_ALL, then it acts as a wildcard for all of the corresponding volume numbers or logical eraseblock numbers. It returns zero in case of success and a negative error code in case of failure.

Definition at line 1704 of file wl.c.

struct ubi_wl_entry* ubi_wl_get_fm_peb ( struct ubi_device ubi,
int  anchor 
)
read
int ubi_wl_get_peb ( struct ubi_device ubi)

Definition at line 684 of file wl.c.

int ubi_wl_init ( struct ubi_device ubi,
struct ubi_attach_info ai 
)

ubi_wl_init - initialize the WL sub-system using attaching information. : UBI device description object : attaching information

This function returns zero in case of success, and a negative error code in case of failure.

Definition at line 1868 of file wl.c.

int ubi_wl_put_fm_peb ( struct ubi_device ubi,
struct ubi_wl_entry used_e,
int  lnum,
int  torture 
)
int ubi_wl_put_peb ( struct ubi_device ubi,
int  vol_id,
int  lnum,
int  pnum,
int  torture 
)

ubi_wl_put_peb - return a PEB to the wear-leveling sub-system. : UBI device description object : the volume ID that last used this PEB : the last used logical eraseblock number for the PEB : physical eraseblock to return : if this physical eraseblock has to be tortured

This function is called to return physical eraseblock to the pool of free physical eraseblocks. The flag has to be set if an I/O error occurred to this and it has to be tested. This function returns zero in case of success, and a negative error code in case of failure.

Definition at line 1552 of file wl.c.

int ubi_wl_scrub_peb ( struct ubi_device ubi,
int  pnum 
)

ubi_wl_scrub_peb - schedule a physical eraseblock for scrubbing. : UBI device description object : the physical eraseblock to schedule

If a bit-flip in a physical eraseblock is detected, this physical eraseblock needs scrubbing. This function schedules a physical eraseblock for scrubbing which is done in background. This function returns zero in case of success and a negative error code in case of failure.

Definition at line 1639 of file wl.c.

Variable Documentation

struct file_operations ubi_cdev_operations

Definition at line 1096 of file cdev.c.

struct class* ubi_class

Definition at line 84 of file build.c.

struct file_operations ubi_ctrl_cdev_operations

Definition at line 1104 of file cdev.c.

struct mutex ubi_devices_mutex
struct file_operations ubi_vol_cdev_operations

Definition at line 1083 of file cdev.c.

struct kmem_cache* ubi_wl_entry_slab

Definition at line 87 of file build.c.