diff options
Diffstat (limited to 'include/linux/mtd/ubi.h')
| -rw-r--r-- | include/linux/mtd/ubi.h | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/include/linux/mtd/ubi.h b/include/linux/mtd/ubi.h index c3918a0684fe..1e271cb559cd 100644 --- a/include/linux/mtd/ubi.h +++ b/include/linux/mtd/ubi.h | |||
| @@ -23,22 +23,32 @@ | |||
| 23 | 23 | ||
| 24 | #include <linux/ioctl.h> | 24 | #include <linux/ioctl.h> |
| 25 | #include <linux/types.h> | 25 | #include <linux/types.h> |
| 26 | #include <linux/scatterlist.h> | ||
| 26 | #include <mtd/ubi-user.h> | 27 | #include <mtd/ubi-user.h> |
| 27 | 28 | ||
| 28 | /* All voumes/LEBs */ | 29 | /* All voumes/LEBs */ |
| 29 | #define UBI_ALL -1 | 30 | #define UBI_ALL -1 |
| 30 | 31 | ||
| 31 | /* | 32 | /* |
| 33 | * Maximum number of scatter gather list entries, | ||
| 34 | * we use only 64 to have a lower memory foot print. | ||
| 35 | */ | ||
| 36 | #define UBI_MAX_SG_COUNT 64 | ||
| 37 | |||
| 38 | /* | ||
| 32 | * enum ubi_open_mode - UBI volume open mode constants. | 39 | * enum ubi_open_mode - UBI volume open mode constants. |
| 33 | * | 40 | * |
| 34 | * UBI_READONLY: read-only mode | 41 | * UBI_READONLY: read-only mode |
| 35 | * UBI_READWRITE: read-write mode | 42 | * UBI_READWRITE: read-write mode |
| 36 | * UBI_EXCLUSIVE: exclusive mode | 43 | * UBI_EXCLUSIVE: exclusive mode |
| 44 | * UBI_METAONLY: modify only the volume meta-data, | ||
| 45 | * i.e. the data stored in the volume table, but not in any of volume LEBs. | ||
| 37 | */ | 46 | */ |
| 38 | enum { | 47 | enum { |
| 39 | UBI_READONLY = 1, | 48 | UBI_READONLY = 1, |
| 40 | UBI_READWRITE, | 49 | UBI_READWRITE, |
| 41 | UBI_EXCLUSIVE | 50 | UBI_EXCLUSIVE, |
| 51 | UBI_METAONLY | ||
| 42 | }; | 52 | }; |
| 43 | 53 | ||
| 44 | /** | 54 | /** |
| @@ -116,6 +126,35 @@ struct ubi_volume_info { | |||
| 116 | }; | 126 | }; |
| 117 | 127 | ||
| 118 | /** | 128 | /** |
| 129 | * struct ubi_sgl - UBI scatter gather list data structure. | ||
| 130 | * @list_pos: current position in @sg[] | ||
| 131 | * @page_pos: current position in @sg[@list_pos] | ||
| 132 | * @sg: the scatter gather list itself | ||
| 133 | * | ||
| 134 | * ubi_sgl is a wrapper around a scatter list which keeps track of the | ||
| 135 | * current position in the list and the current list item such that | ||
| 136 | * it can be used across multiple ubi_leb_read_sg() calls. | ||
| 137 | */ | ||
| 138 | struct ubi_sgl { | ||
| 139 | int list_pos; | ||
| 140 | int page_pos; | ||
| 141 | struct scatterlist sg[UBI_MAX_SG_COUNT]; | ||
| 142 | }; | ||
| 143 | |||
| 144 | /** | ||
| 145 | * ubi_sgl_init - initialize an UBI scatter gather list data structure. | ||
| 146 | * @usgl: the UBI scatter gather struct itself | ||
| 147 | * | ||
| 148 | * Please note that you still have to use sg_init_table() or any adequate | ||
| 149 | * function to initialize the unterlaying struct scatterlist. | ||
| 150 | */ | ||
| 151 | static inline void ubi_sgl_init(struct ubi_sgl *usgl) | ||
| 152 | { | ||
| 153 | usgl->list_pos = 0; | ||
| 154 | usgl->page_pos = 0; | ||
| 155 | } | ||
| 156 | |||
| 157 | /** | ||
| 119 | * struct ubi_device_info - UBI device description data structure. | 158 | * struct ubi_device_info - UBI device description data structure. |
| 120 | * @ubi_num: ubi device number | 159 | * @ubi_num: ubi device number |
| 121 | * @leb_size: logical eraseblock size on this UBI device | 160 | * @leb_size: logical eraseblock size on this UBI device |
| @@ -210,6 +249,8 @@ int ubi_unregister_volume_notifier(struct notifier_block *nb); | |||
| 210 | void ubi_close_volume(struct ubi_volume_desc *desc); | 249 | void ubi_close_volume(struct ubi_volume_desc *desc); |
| 211 | int ubi_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset, | 250 | int ubi_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset, |
| 212 | int len, int check); | 251 | int len, int check); |
| 252 | int ubi_leb_read_sg(struct ubi_volume_desc *desc, int lnum, struct ubi_sgl *sgl, | ||
| 253 | int offset, int len, int check); | ||
| 213 | int ubi_leb_write(struct ubi_volume_desc *desc, int lnum, const void *buf, | 254 | int ubi_leb_write(struct ubi_volume_desc *desc, int lnum, const void *buf, |
| 214 | int offset, int len); | 255 | int offset, int len); |
| 215 | int ubi_leb_change(struct ubi_volume_desc *desc, int lnum, const void *buf, | 256 | int ubi_leb_change(struct ubi_volume_desc *desc, int lnum, const void *buf, |
| @@ -230,4 +271,14 @@ static inline int ubi_read(struct ubi_volume_desc *desc, int lnum, char *buf, | |||
| 230 | { | 271 | { |
| 231 | return ubi_leb_read(desc, lnum, buf, offset, len, 0); | 272 | return ubi_leb_read(desc, lnum, buf, offset, len, 0); |
| 232 | } | 273 | } |
| 274 | |||
| 275 | /* | ||
| 276 | * This function is the same as the 'ubi_leb_read_sg()' function, but it does | ||
| 277 | * not provide the checking capability. | ||
| 278 | */ | ||
| 279 | static inline int ubi_read_sg(struct ubi_volume_desc *desc, int lnum, | ||
| 280 | struct ubi_sgl *sgl, int offset, int len) | ||
| 281 | { | ||
| 282 | return ubi_leb_read_sg(desc, lnum, sgl, offset, len, 0); | ||
| 283 | } | ||
| 233 | #endif /* !__LINUX_UBI_H__ */ | 284 | #endif /* !__LINUX_UBI_H__ */ |
