diff options
Diffstat (limited to 'drivers/mtd/ubi/ubi.h')
-rw-r--r-- | drivers/mtd/ubi/ubi.h | 171 |
1 files changed, 124 insertions, 47 deletions
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index 5e941a633030..457710615261 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h | |||
@@ -94,8 +94,43 @@ enum { | |||
94 | UBI_IO_BITFLIPS | 94 | UBI_IO_BITFLIPS |
95 | }; | 95 | }; |
96 | 96 | ||
97 | extern int ubi_devices_cnt; | 97 | /** |
98 | extern struct ubi_device *ubi_devices[]; | 98 | * struct ubi_wl_entry - wear-leveling entry. |
99 | * @rb: link in the corresponding RB-tree | ||
100 | * @ec: erase counter | ||
101 | * @pnum: physical eraseblock number | ||
102 | * | ||
103 | * This data structure is used in the WL unit. Each physical eraseblock has a | ||
104 | * corresponding &struct wl_entry object which may be kept in different | ||
105 | * RB-trees. See WL unit for details. | ||
106 | */ | ||
107 | struct ubi_wl_entry { | ||
108 | struct rb_node rb; | ||
109 | int ec; | ||
110 | int pnum; | ||
111 | }; | ||
112 | |||
113 | /** | ||
114 | * struct ubi_ltree_entry - an entry in the lock tree. | ||
115 | * @rb: links RB-tree nodes | ||
116 | * @vol_id: volume ID of the locked logical eraseblock | ||
117 | * @lnum: locked logical eraseblock number | ||
118 | * @users: how many tasks are using this logical eraseblock or wait for it | ||
119 | * @mutex: read/write mutex to implement read/write access serialization to | ||
120 | * the (@vol_id, @lnum) logical eraseblock | ||
121 | * | ||
122 | * This data structure is used in the EBA unit to implement per-LEB locking. | ||
123 | * When a logical eraseblock is being locked - corresponding | ||
124 | * &struct ubi_ltree_entry object is inserted to the lock tree (@ubi->ltree). | ||
125 | * See EBA unit for details. | ||
126 | */ | ||
127 | struct ubi_ltree_entry { | ||
128 | struct rb_node rb; | ||
129 | int vol_id; | ||
130 | int lnum; | ||
131 | int users; | ||
132 | struct rw_semaphore mutex; | ||
133 | }; | ||
99 | 134 | ||
100 | struct ubi_volume_desc; | 135 | struct ubi_volume_desc; |
101 | 136 | ||
@@ -105,11 +140,10 @@ struct ubi_volume_desc; | |||
105 | * @cdev: character device object to create character device | 140 | * @cdev: character device object to create character device |
106 | * @ubi: reference to the UBI device description object | 141 | * @ubi: reference to the UBI device description object |
107 | * @vol_id: volume ID | 142 | * @vol_id: volume ID |
143 | * @ref_count: volume reference count | ||
108 | * @readers: number of users holding this volume in read-only mode | 144 | * @readers: number of users holding this volume in read-only mode |
109 | * @writers: number of users holding this volume in read-write mode | 145 | * @writers: number of users holding this volume in read-write mode |
110 | * @exclusive: whether somebody holds this volume in exclusive mode | 146 | * @exclusive: whether somebody holds this volume in exclusive mode |
111 | * @removed: if the volume was removed | ||
112 | * @checked: if this static volume was checked | ||
113 | * | 147 | * |
114 | * @reserved_pebs: how many physical eraseblocks are reserved for this volume | 148 | * @reserved_pebs: how many physical eraseblocks are reserved for this volume |
115 | * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME) | 149 | * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME) |
@@ -117,21 +151,30 @@ struct ubi_volume_desc; | |||
117 | * @used_ebs: how many logical eraseblocks in this volume contain data | 151 | * @used_ebs: how many logical eraseblocks in this volume contain data |
118 | * @last_eb_bytes: how many bytes are stored in the last logical eraseblock | 152 | * @last_eb_bytes: how many bytes are stored in the last logical eraseblock |
119 | * @used_bytes: how many bytes of data this volume contains | 153 | * @used_bytes: how many bytes of data this volume contains |
120 | * @upd_marker: non-zero if the update marker is set for this volume | ||
121 | * @corrupted: non-zero if the volume is corrupted (static volumes only) | ||
122 | * @alignment: volume alignment | 154 | * @alignment: volume alignment |
123 | * @data_pad: how many bytes are not used at the end of physical eraseblocks to | 155 | * @data_pad: how many bytes are not used at the end of physical eraseblocks to |
124 | * satisfy the requested alignment | 156 | * satisfy the requested alignment |
125 | * @name_len: volume name length | 157 | * @name_len: volume name length |
126 | * @name: volume name | 158 | * @name: volume name |
127 | * | 159 | * |
128 | * @updating: whether the volume is being updated | ||
129 | * @upd_ebs: how many eraseblocks are expected to be updated | 160 | * @upd_ebs: how many eraseblocks are expected to be updated |
130 | * @upd_bytes: how many bytes are expected to be received | 161 | * @ch_lnum: LEB number which is being changing by the atomic LEB change |
131 | * @upd_received: how many update bytes were already received | 162 | * operation |
132 | * @upd_buf: update buffer which is used to collect update data | 163 | * @ch_dtype: data persistency type which is being changing by the atomic LEB |
164 | * change operation | ||
165 | * @upd_bytes: how many bytes are expected to be received for volume update or | ||
166 | * atomic LEB change | ||
167 | * @upd_received: how many bytes were already received for volume update or | ||
168 | * atomic LEB change | ||
169 | * @upd_buf: update buffer which is used to collect update data or data for | ||
170 | * atomic LEB change | ||
133 | * | 171 | * |
134 | * @eba_tbl: EBA table of this volume (LEB->PEB mapping) | 172 | * @eba_tbl: EBA table of this volume (LEB->PEB mapping) |
173 | * @checked: %1 if this static volume was checked | ||
174 | * @corrupted: %1 if the volume is corrupted (static volumes only) | ||
175 | * @upd_marker: %1 if the update marker is set for this volume | ||
176 | * @updating: %1 if the volume is being updated | ||
177 | * @changing_leb: %1 if the atomic LEB change ioctl command is in progress | ||
135 | * | 178 | * |
136 | * @gluebi_desc: gluebi UBI volume descriptor | 179 | * @gluebi_desc: gluebi UBI volume descriptor |
137 | * @gluebi_refcount: reference count of the gluebi MTD device | 180 | * @gluebi_refcount: reference count of the gluebi MTD device |
@@ -150,11 +193,10 @@ struct ubi_volume { | |||
150 | struct cdev cdev; | 193 | struct cdev cdev; |
151 | struct ubi_device *ubi; | 194 | struct ubi_device *ubi; |
152 | int vol_id; | 195 | int vol_id; |
196 | int ref_count; | ||
153 | int readers; | 197 | int readers; |
154 | int writers; | 198 | int writers; |
155 | int exclusive; | 199 | int exclusive; |
156 | int removed; | ||
157 | int checked; | ||
158 | 200 | ||
159 | int reserved_pebs; | 201 | int reserved_pebs; |
160 | int vol_type; | 202 | int vol_type; |
@@ -162,23 +204,31 @@ struct ubi_volume { | |||
162 | int used_ebs; | 204 | int used_ebs; |
163 | int last_eb_bytes; | 205 | int last_eb_bytes; |
164 | long long used_bytes; | 206 | long long used_bytes; |
165 | int upd_marker; | ||
166 | int corrupted; | ||
167 | int alignment; | 207 | int alignment; |
168 | int data_pad; | 208 | int data_pad; |
169 | int name_len; | 209 | int name_len; |
170 | char name[UBI_VOL_NAME_MAX+1]; | 210 | char name[UBI_VOL_NAME_MAX+1]; |
171 | 211 | ||
172 | int updating; | ||
173 | int upd_ebs; | 212 | int upd_ebs; |
213 | int ch_lnum; | ||
214 | int ch_dtype; | ||
174 | long long upd_bytes; | 215 | long long upd_bytes; |
175 | long long upd_received; | 216 | long long upd_received; |
176 | void *upd_buf; | 217 | void *upd_buf; |
177 | 218 | ||
178 | int *eba_tbl; | 219 | int *eba_tbl; |
220 | int checked:1; | ||
221 | int corrupted:1; | ||
222 | int upd_marker:1; | ||
223 | int updating:1; | ||
224 | int changing_leb:1; | ||
179 | 225 | ||
180 | #ifdef CONFIG_MTD_UBI_GLUEBI | 226 | #ifdef CONFIG_MTD_UBI_GLUEBI |
181 | /* Gluebi-related stuff may be compiled out */ | 227 | /* |
228 | * Gluebi-related stuff may be compiled out. | ||
229 | * TODO: this should not be built into UBI but should be a separate | ||
230 | * ubimtd driver which works on top of UBI and emulates MTD devices. | ||
231 | */ | ||
182 | struct ubi_volume_desc *gluebi_desc; | 232 | struct ubi_volume_desc *gluebi_desc; |
183 | int gluebi_refcount; | 233 | int gluebi_refcount; |
184 | struct mtd_info gluebi_mtd; | 234 | struct mtd_info gluebi_mtd; |
@@ -200,28 +250,31 @@ struct ubi_wl_entry; | |||
200 | 250 | ||
201 | /** | 251 | /** |
202 | * struct ubi_device - UBI device description structure | 252 | * struct ubi_device - UBI device description structure |
203 | * @dev: class device object to use the the Linux device model | 253 | * @dev: UBI device object to use the the Linux device model |
204 | * @cdev: character device object to create character device | 254 | * @cdev: character device object to create character device |
205 | * @ubi_num: UBI device number | 255 | * @ubi_num: UBI device number |
206 | * @ubi_name: UBI device name | 256 | * @ubi_name: UBI device name |
207 | * @major: character device major number | ||
208 | * @vol_count: number of volumes in this UBI device | 257 | * @vol_count: number of volumes in this UBI device |
209 | * @volumes: volumes of this UBI device | 258 | * @volumes: volumes of this UBI device |
210 | * @volumes_lock: protects @volumes, @rsvd_pebs, @avail_pebs, beb_rsvd_pebs, | 259 | * @volumes_lock: protects @volumes, @rsvd_pebs, @avail_pebs, beb_rsvd_pebs, |
211 | * @beb_rsvd_level, @bad_peb_count, @good_peb_count, @vol_count, @vol->readers, | 260 | * @beb_rsvd_level, @bad_peb_count, @good_peb_count, @vol_count, |
212 | * @vol->writers, @vol->exclusive, @vol->removed, @vol->mapping and | 261 | * @vol->readers, @vol->writers, @vol->exclusive, |
213 | * @vol->eba_tbl. | 262 | * @vol->ref_count, @vol->mapping and @vol->eba_tbl. |
263 | * @ref_count: count of references on the UBI device | ||
214 | * | 264 | * |
215 | * @rsvd_pebs: count of reserved physical eraseblocks | 265 | * @rsvd_pebs: count of reserved physical eraseblocks |
216 | * @avail_pebs: count of available physical eraseblocks | 266 | * @avail_pebs: count of available physical eraseblocks |
217 | * @beb_rsvd_pebs: how many physical eraseblocks are reserved for bad PEB | 267 | * @beb_rsvd_pebs: how many physical eraseblocks are reserved for bad PEB |
218 | * handling | 268 | * handling |
219 | * @beb_rsvd_level: normal level of PEBs reserved for bad PEB handling | 269 | * @beb_rsvd_level: normal level of PEBs reserved for bad PEB handling |
220 | * | 270 | * |
271 | * @autoresize_vol_id: ID of the volume which has to be auto-resized at the end | ||
272 | * of UBI ititializetion | ||
221 | * @vtbl_slots: how many slots are available in the volume table | 273 | * @vtbl_slots: how many slots are available in the volume table |
222 | * @vtbl_size: size of the volume table in bytes | 274 | * @vtbl_size: size of the volume table in bytes |
223 | * @vtbl: in-RAM volume table copy | 275 | * @vtbl: in-RAM volume table copy |
224 | * @vtbl_mutex: protects on-flash volume table | 276 | * @volumes_mutex: protects on-flash volume table and serializes volume |
277 | * changes, like creation, deletion, update, resize | ||
225 | * | 278 | * |
226 | * @max_ec: current highest erase counter value | 279 | * @max_ec: current highest erase counter value |
227 | * @mean_ec: current mean erase counter value | 280 | * @mean_ec: current mean erase counter value |
@@ -238,15 +291,15 @@ struct ubi_wl_entry; | |||
238 | * @prot.pnum: protection tree indexed by physical eraseblock numbers | 291 | * @prot.pnum: protection tree indexed by physical eraseblock numbers |
239 | * @prot.aec: protection tree indexed by absolute erase counter value | 292 | * @prot.aec: protection tree indexed by absolute erase counter value |
240 | * @wl_lock: protects the @used, @free, @prot, @lookuptbl, @abs_ec, @move_from, | 293 | * @wl_lock: protects the @used, @free, @prot, @lookuptbl, @abs_ec, @move_from, |
241 | * @move_to, @move_to_put @erase_pending, @wl_scheduled, and @works | 294 | * @move_to, @move_to_put @erase_pending, @wl_scheduled, and @works |
242 | * fields | 295 | * fields |
296 | * @move_mutex: serializes eraseblock moves | ||
243 | * @wl_scheduled: non-zero if the wear-leveling was scheduled | 297 | * @wl_scheduled: non-zero if the wear-leveling was scheduled |
244 | * @lookuptbl: a table to quickly find a &struct ubi_wl_entry object for any | 298 | * @lookuptbl: a table to quickly find a &struct ubi_wl_entry object for any |
245 | * physical eraseblock | 299 | * physical eraseblock |
246 | * @abs_ec: absolute erase counter | 300 | * @abs_ec: absolute erase counter |
247 | * @move_from: physical eraseblock from where the data is being moved | 301 | * @move_from: physical eraseblock from where the data is being moved |
248 | * @move_to: physical eraseblock where the data is being moved to | 302 | * @move_to: physical eraseblock where the data is being moved to |
249 | * @move_from_put: if the "from" PEB was put | ||
250 | * @move_to_put: if the "to" PEB was put | 303 | * @move_to_put: if the "to" PEB was put |
251 | * @works: list of pending works | 304 | * @works: list of pending works |
252 | * @works_count: count of pending works | 305 | * @works_count: count of pending works |
@@ -273,13 +326,13 @@ struct ubi_wl_entry; | |||
273 | * @hdrs_min_io_size | 326 | * @hdrs_min_io_size |
274 | * @vid_hdr_shift: contains @vid_hdr_offset - @vid_hdr_aloffset | 327 | * @vid_hdr_shift: contains @vid_hdr_offset - @vid_hdr_aloffset |
275 | * @bad_allowed: whether the MTD device admits of bad physical eraseblocks or | 328 | * @bad_allowed: whether the MTD device admits of bad physical eraseblocks or |
276 | * not | 329 | * not |
277 | * @mtd: MTD device descriptor | 330 | * @mtd: MTD device descriptor |
278 | * | 331 | * |
279 | * @peb_buf1: a buffer of PEB size used for different purposes | 332 | * @peb_buf1: a buffer of PEB size used for different purposes |
280 | * @peb_buf2: another buffer of PEB size used for different purposes | 333 | * @peb_buf2: another buffer of PEB size used for different purposes |
281 | * @buf_mutex: proptects @peb_buf1 and @peb_buf2 | 334 | * @buf_mutex: proptects @peb_buf1 and @peb_buf2 |
282 | * @dbg_peb_buf: buffer of PEB size used for debugging | 335 | * @dbg_peb_buf: buffer of PEB size used for debugging |
283 | * @dbg_buf_mutex: proptects @dbg_peb_buf | 336 | * @dbg_buf_mutex: proptects @dbg_peb_buf |
284 | */ | 337 | */ |
285 | struct ubi_device { | 338 | struct ubi_device { |
@@ -287,22 +340,24 @@ struct ubi_device { | |||
287 | struct device dev; | 340 | struct device dev; |
288 | int ubi_num; | 341 | int ubi_num; |
289 | char ubi_name[sizeof(UBI_NAME_STR)+5]; | 342 | char ubi_name[sizeof(UBI_NAME_STR)+5]; |
290 | int major; | ||
291 | int vol_count; | 343 | int vol_count; |
292 | struct ubi_volume *volumes[UBI_MAX_VOLUMES+UBI_INT_VOL_COUNT]; | 344 | struct ubi_volume *volumes[UBI_MAX_VOLUMES+UBI_INT_VOL_COUNT]; |
293 | spinlock_t volumes_lock; | 345 | spinlock_t volumes_lock; |
346 | int ref_count; | ||
294 | 347 | ||
295 | int rsvd_pebs; | 348 | int rsvd_pebs; |
296 | int avail_pebs; | 349 | int avail_pebs; |
297 | int beb_rsvd_pebs; | 350 | int beb_rsvd_pebs; |
298 | int beb_rsvd_level; | 351 | int beb_rsvd_level; |
299 | 352 | ||
353 | int autoresize_vol_id; | ||
300 | int vtbl_slots; | 354 | int vtbl_slots; |
301 | int vtbl_size; | 355 | int vtbl_size; |
302 | struct ubi_vtbl_record *vtbl; | 356 | struct ubi_vtbl_record *vtbl; |
303 | struct mutex vtbl_mutex; | 357 | struct mutex volumes_mutex; |
304 | 358 | ||
305 | int max_ec; | 359 | int max_ec; |
360 | /* TODO: mean_ec is not updated run-time, fix */ | ||
306 | int mean_ec; | 361 | int mean_ec; |
307 | 362 | ||
308 | /* EBA unit's stuff */ | 363 | /* EBA unit's stuff */ |
@@ -320,12 +375,13 @@ struct ubi_device { | |||
320 | struct rb_root aec; | 375 | struct rb_root aec; |
321 | } prot; | 376 | } prot; |
322 | spinlock_t wl_lock; | 377 | spinlock_t wl_lock; |
378 | struct mutex move_mutex; | ||
379 | struct rw_semaphore work_sem; | ||
323 | int wl_scheduled; | 380 | int wl_scheduled; |
324 | struct ubi_wl_entry **lookuptbl; | 381 | struct ubi_wl_entry **lookuptbl; |
325 | unsigned long long abs_ec; | 382 | unsigned long long abs_ec; |
326 | struct ubi_wl_entry *move_from; | 383 | struct ubi_wl_entry *move_from; |
327 | struct ubi_wl_entry *move_to; | 384 | struct ubi_wl_entry *move_to; |
328 | int move_from_put; | ||
329 | int move_to_put; | 385 | int move_to_put; |
330 | struct list_head works; | 386 | struct list_head works; |
331 | int works_count; | 387 | int works_count; |
@@ -355,15 +411,19 @@ struct ubi_device { | |||
355 | void *peb_buf1; | 411 | void *peb_buf1; |
356 | void *peb_buf2; | 412 | void *peb_buf2; |
357 | struct mutex buf_mutex; | 413 | struct mutex buf_mutex; |
414 | struct mutex ckvol_mutex; | ||
358 | #ifdef CONFIG_MTD_UBI_DEBUG | 415 | #ifdef CONFIG_MTD_UBI_DEBUG |
359 | void *dbg_peb_buf; | 416 | void *dbg_peb_buf; |
360 | struct mutex dbg_buf_mutex; | 417 | struct mutex dbg_buf_mutex; |
361 | #endif | 418 | #endif |
362 | }; | 419 | }; |
363 | 420 | ||
421 | extern struct kmem_cache *ubi_wl_entry_slab; | ||
422 | extern struct file_operations ubi_ctrl_cdev_operations; | ||
364 | extern struct file_operations ubi_cdev_operations; | 423 | extern struct file_operations ubi_cdev_operations; |
365 | extern struct file_operations ubi_vol_cdev_operations; | 424 | extern struct file_operations ubi_vol_cdev_operations; |
366 | extern struct class *ubi_class; | 425 | extern struct class *ubi_class; |
426 | extern struct mutex ubi_devices_mutex; | ||
367 | 427 | ||
368 | /* vtbl.c */ | 428 | /* vtbl.c */ |
369 | int ubi_change_vtbl_record(struct ubi_device *ubi, int idx, | 429 | int ubi_change_vtbl_record(struct ubi_device *ubi, int idx, |
@@ -374,13 +434,18 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_scan_info *si); | |||
374 | int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req); | 434 | int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req); |
375 | int ubi_remove_volume(struct ubi_volume_desc *desc); | 435 | int ubi_remove_volume(struct ubi_volume_desc *desc); |
376 | int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs); | 436 | int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs); |
377 | int ubi_add_volume(struct ubi_device *ubi, int vol_id); | 437 | int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol); |
378 | void ubi_free_volume(struct ubi_device *ubi, int vol_id); | 438 | void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol); |
379 | 439 | ||
380 | /* upd.c */ | 440 | /* upd.c */ |
381 | int ubi_start_update(struct ubi_device *ubi, int vol_id, long long bytes); | 441 | int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol, |
382 | int ubi_more_update_data(struct ubi_device *ubi, int vol_id, | 442 | long long bytes); |
443 | int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol, | ||
383 | const void __user *buf, int count); | 444 | const void __user *buf, int count); |
445 | int ubi_start_leb_change(struct ubi_device *ubi, struct ubi_volume *vol, | ||
446 | const struct ubi_leb_change_req *req); | ||
447 | int ubi_more_leb_change_data(struct ubi_device *ubi, struct ubi_volume *vol, | ||
448 | const void __user *buf, int count); | ||
384 | 449 | ||
385 | /* misc.c */ | 450 | /* misc.c */ |
386 | int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf, int length); | 451 | int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf, int length); |
@@ -399,16 +464,17 @@ void ubi_gluebi_updated(struct ubi_volume *vol); | |||
399 | #endif | 464 | #endif |
400 | 465 | ||
401 | /* eba.c */ | 466 | /* eba.c */ |
402 | int ubi_eba_unmap_leb(struct ubi_device *ubi, int vol_id, int lnum); | 467 | int ubi_eba_unmap_leb(struct ubi_device *ubi, struct ubi_volume *vol, |
403 | int ubi_eba_read_leb(struct ubi_device *ubi, int vol_id, int lnum, void *buf, | 468 | int lnum); |
404 | int offset, int len, int check); | 469 | int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, |
405 | int ubi_eba_write_leb(struct ubi_device *ubi, int vol_id, int lnum, | 470 | void *buf, int offset, int len, int check); |
471 | int ubi_eba_write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, | ||
406 | const void *buf, int offset, int len, int dtype); | 472 | const void *buf, int offset, int len, int dtype); |
407 | int ubi_eba_write_leb_st(struct ubi_device *ubi, int vol_id, int lnum, | 473 | int ubi_eba_write_leb_st(struct ubi_device *ubi, struct ubi_volume *vol, |
408 | const void *buf, int len, int dtype, | 474 | int lnum, const void *buf, int len, int dtype, |
409 | int used_ebs); | 475 | int used_ebs); |
410 | int ubi_eba_atomic_leb_change(struct ubi_device *ubi, int vol_id, int lnum, | 476 | int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol, |
411 | const void *buf, int len, int dtype); | 477 | int lnum, const void *buf, int len, int dtype); |
412 | int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, | 478 | int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, |
413 | struct ubi_vid_hdr *vid_hdr); | 479 | struct ubi_vid_hdr *vid_hdr); |
414 | int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si); | 480 | int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si); |
@@ -421,6 +487,7 @@ int ubi_wl_flush(struct ubi_device *ubi); | |||
421 | int ubi_wl_scrub_peb(struct ubi_device *ubi, int pnum); | 487 | int ubi_wl_scrub_peb(struct ubi_device *ubi, int pnum); |
422 | int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si); | 488 | int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si); |
423 | void ubi_wl_close(struct ubi_device *ubi); | 489 | void ubi_wl_close(struct ubi_device *ubi); |
490 | int ubi_thread(void *u); | ||
424 | 491 | ||
425 | /* io.c */ | 492 | /* io.c */ |
426 | int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset, | 493 | int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset, |
@@ -439,6 +506,14 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, | |||
439 | int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum, | 506 | int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum, |
440 | struct ubi_vid_hdr *vid_hdr); | 507 | struct ubi_vid_hdr *vid_hdr); |
441 | 508 | ||
509 | /* build.c */ | ||
510 | int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset); | ||
511 | int ubi_detach_mtd_dev(int ubi_num, int anyway); | ||
512 | struct ubi_device *ubi_get_device(int ubi_num); | ||
513 | void ubi_put_device(struct ubi_device *ubi); | ||
514 | struct ubi_device *ubi_get_by_major(int major); | ||
515 | int ubi_major2num(int major); | ||
516 | |||
442 | /* | 517 | /* |
443 | * ubi_rb_for_each_entry - walk an RB-tree. | 518 | * ubi_rb_for_each_entry - walk an RB-tree. |
444 | * @rb: a pointer to type 'struct rb_node' to to use as a loop counter | 519 | * @rb: a pointer to type 'struct rb_node' to to use as a loop counter |
@@ -523,8 +598,10 @@ static inline int ubi_io_write_data(struct ubi_device *ubi, const void *buf, | |||
523 | */ | 598 | */ |
524 | static inline void ubi_ro_mode(struct ubi_device *ubi) | 599 | static inline void ubi_ro_mode(struct ubi_device *ubi) |
525 | { | 600 | { |
526 | ubi->ro_mode = 1; | 601 | if (!ubi->ro_mode) { |
527 | ubi_warn("switch to read-only mode"); | 602 | ubi->ro_mode = 1; |
603 | ubi_warn("switch to read-only mode"); | ||
604 | } | ||
528 | } | 605 | } |
529 | 606 | ||
530 | /** | 607 | /** |