Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros
build.c File Reference
#include <linux/err.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/stringify.h>
#include <linux/namei.h>
#include <linux/stat.h>
#include <linux/miscdevice.h>
#include <linux/mtd/partitions.h>
#include <linux/log2.h>
#include <linux/kthread.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include "ubi.h"

Go to the source code of this file.

Data Structures

struct  mtd_dev_param
 

Macros

#define MTD_PARAM_LEN_MAX   64
 
#define MTD_PARAM_MAX_COUNT   3
 
#define MAX_MTD_UBI_BEB_LIMIT   768
 
#define ubi_is_module()   0
 

: MTD character device node path, MTD device name, or MTD device number

struct mtd_dev_param - MTD device parameter description data structure.

   string

: VID header offset : maximum expected number of bad PEBs per 1024 PEBs

struct classubi_class
 
struct kmem_cacheubi_wl_entry_slab
 
 DEFINE_MUTEX (ubi_devices_mutex)
 
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)
 
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)
 
void ubi_free_internal_volumes (struct ubi_device *ubi)
 
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)
 
 late_initcall (ubi_init)
 
 module_exit (ubi_exit)
 
 module_param_call (mtd, ubi_mtd_param_parse, NULL, NULL, 000)
 
 MODULE_PARM_DESC (mtd,"MTD devices to attach. Parameter format: mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024]].\n""Multiple \"mtd\" parameters may be specified.\n""MTD devices may be specified by their number, name, or path to the MTD character device node.\n""Optional \"vid_hdr_offs\" parameter specifies UBI VID header position to be used by UBI. (default value if 0)\n""Optional \"max_beb_per1024\" parameter specifies the maximum expected bad eraseblock per 1024 eraseblocks. (default value ("__stringify(CONFIG_MTD_UBI_BEB_LIMIT)") if 0)\n""\n""Example 1: mtd=/dev/mtd0 - attach MTD device /dev/mtd0.\n""Example 2: mtd=content,1984 mtd=4 - attach MTD device with name \"content\" using VID header offset 1984, and MTD device number 4 with default VID header offset.\n""Example 3: mtd=/dev/mtd1,0,25 - attach MTD device /dev/mtd1 using default VID header offset and reserve 25*nand_size_in_blocks/1024 erase blocks for bad block handling.\n""\t(e.g. if the NAND *chipset* has 4096 PEB, 100 will be reserved for this UBI device).")
 
 MODULE_VERSION (__stringify(UBI_VERSION))
 
 MODULE_DESCRIPTION ("UBI - Unsorted Block Images")
 
 MODULE_AUTHOR ("Artem Bityutskiy")
 
 MODULE_LICENSE ("GPL")
 

Macro Definition Documentation

#define MAX_MTD_UBI_BEB_LIMIT   768

Definition at line 53 of file build.c.

#define MTD_PARAM_LEN_MAX   64

Definition at line 47 of file build.c.

#define MTD_PARAM_MAX_COUNT   3

Definition at line 50 of file build.c.

#define ubi_is_module ( )    0

Definition at line 58 of file build.c.

Function Documentation

DEFINE_MUTEX ( ubi_devices_mutex  )
late_initcall ( ubi_init  )
MODULE_AUTHOR ( "Artem Bityutskiy"  )
MODULE_DESCRIPTION ( "UBI - Unsorted Block Images"  )
module_exit ( ubi_exit  )
MODULE_LICENSE ( "GPL"  )
module_param_call ( mtd  ,
ubi_mtd_param_parse  ,
NULL  ,
NULL  ,
000   
)
MODULE_PARM_DESC ( mtd  ,
"MTD devices to attach. Parameter format:  mtd = <name|num|path>[,
< vid_hdr_offs >].\n""Multiple\"mtd\" parameters may be specified.\n""MTD devices may be specified by their  number[, max_beb_per1024],
name  ,
or path to the MTD character device node.\n""Optional\"vid_hdr_offs\" parameter specifies UBI VID header position to be used by UBI. (default value if 0)\n""Optional \"max_beb_per1024\" parameter specifies the maximum expected bad eraseblock per 1024 eraseblocks. (default value ("__stringify(CONFIG_MTD_UBI_BEB_LIMIT)") if 0)\n""\n""Example 1:  mtd = /dev/mtd0 - attach MTD device /dev/mtd0.\n""Example 2: mtd=content,
1984  mtd = 4 - attach MTD device with name \"content\" using VID header offset 1984, and MTD device number 4 with default VID header offset.\n""Example 3: mtd=/dev/mtd1,0,25 - attach MTD device /dev/mtd1 using default VID header offset and reserve 25*nand_size_in_blocks/1024 erase blocks for bad block handling.\n""\t(e.g. if the NAND *chipset* has 4096 PEB, 100 will be reserved for this UBI device)." 
)
MODULE_VERSION ( __stringify(UBI_VERSION )
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_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.

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.

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.

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_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_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_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.

Variable Documentation

struct class* ubi_class

Definition at line 84 of file build.c.

struct kmem_cache* ubi_wl_entry_slab

Definition at line 87 of file build.c.