diff options
author | Richard Weinberger <richard@nod.at> | 2015-01-10 16:52:13 -0500 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2015-01-28 10:04:26 -0500 |
commit | 9ff08979e17423f0f691c1d76f35dfec72a5e459 (patch) | |
tree | bba6c2556e642bfae792983766d3f07652f9714c /include/linux/mtd | |
parent | 892abde56c1c5a62d49d8b70c73e5d388e74345d (diff) |
UBI: Add initial support for scatter gather
Adds a new set of functions to deal with scatter gather.
ubi_eba_read_leb_sg() will read from a LEB into a scatter gather list.
The new data structure struct ubi_sgl will be used within UBI to
hold the scatter gather list itself and metadata to have a cursor
within the list.
Signed-off-by: Richard Weinberger <richard@nod.at>
Tested-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Diffstat (limited to 'include/linux/mtd')
-rw-r--r-- | include/linux/mtd/ubi.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/include/linux/mtd/ubi.h b/include/linux/mtd/ubi.h index 8fa2753316e8..1e271cb559cd 100644 --- a/include/linux/mtd/ubi.h +++ b/include/linux/mtd/ubi.h | |||
@@ -23,12 +23,19 @@ | |||
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 |
@@ -119,6 +126,35 @@ struct ubi_volume_info { | |||
119 | }; | 126 | }; |
120 | 127 | ||
121 | /** | 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 | /** | ||
122 | * struct ubi_device_info - UBI device description data structure. | 158 | * struct ubi_device_info - UBI device description data structure. |
123 | * @ubi_num: ubi device number | 159 | * @ubi_num: ubi device number |
124 | * @leb_size: logical eraseblock size on this UBI device | 160 | * @leb_size: logical eraseblock size on this UBI device |
@@ -213,6 +249,8 @@ int ubi_unregister_volume_notifier(struct notifier_block *nb); | |||
213 | void ubi_close_volume(struct ubi_volume_desc *desc); | 249 | void ubi_close_volume(struct ubi_volume_desc *desc); |
214 | 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, |
215 | 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); | ||
216 | 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, |
217 | int offset, int len); | 255 | int offset, int len); |
218 | 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, |
@@ -233,4 +271,14 @@ static inline int ubi_read(struct ubi_volume_desc *desc, int lnum, char *buf, | |||
233 | { | 271 | { |
234 | return ubi_leb_read(desc, lnum, buf, offset, len, 0); | 272 | return ubi_leb_read(desc, lnum, buf, offset, len, 0); |
235 | } | 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 | } | ||
236 | #endif /* !__LINUX_UBI_H__ */ | 284 | #endif /* !__LINUX_UBI_H__ */ |