aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/ubi.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/ubi/ubi.h')
-rw-r--r--drivers/mtd/ubi/ubi.h42
1 files changed, 30 insertions, 12 deletions
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 5959f91be240..5e941a633030 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -221,14 +221,15 @@ struct ubi_wl_entry;
221 * @vtbl_slots: how many slots are available in the volume table 221 * @vtbl_slots: how many slots are available in the volume table
222 * @vtbl_size: size of the volume table in bytes 222 * @vtbl_size: size of the volume table in bytes
223 * @vtbl: in-RAM volume table copy 223 * @vtbl: in-RAM volume table copy
224 * @vtbl_mutex: protects on-flash volume table
224 * 225 *
225 * @max_ec: current highest erase counter value 226 * @max_ec: current highest erase counter value
226 * @mean_ec: current mean erase counter value 227 * @mean_ec: current mean erase counter value
227 * 228 *
228 * global_sqnum: global sequence number 229 * @global_sqnum: global sequence number
229 * @ltree_lock: protects the lock tree and @global_sqnum 230 * @ltree_lock: protects the lock tree and @global_sqnum
230 * @ltree: the lock tree 231 * @ltree: the lock tree
231 * @vtbl_mutex: protects on-flash volume table 232 * @alc_mutex: serializes "atomic LEB change" operations
232 * 233 *
233 * @used: RB-tree of used physical eraseblocks 234 * @used: RB-tree of used physical eraseblocks
234 * @free: RB-tree of free physical eraseblocks 235 * @free: RB-tree of free physical eraseblocks
@@ -274,6 +275,12 @@ struct ubi_wl_entry;
274 * @bad_allowed: whether the MTD device admits of bad physical eraseblocks or 275 * @bad_allowed: whether the MTD device admits of bad physical eraseblocks or
275 * not 276 * not
276 * @mtd: MTD device descriptor 277 * @mtd: MTD device descriptor
278 *
279 * @peb_buf1: a buffer of PEB size used for different purposes
280 * @peb_buf2: another buffer of PEB size used for different purposes
281 * @buf_mutex: proptects @peb_buf1 and @peb_buf2
282 * @dbg_peb_buf: buffer of PEB size used for debugging
283 * @dbg_buf_mutex: proptects @dbg_peb_buf
277 */ 284 */
278struct ubi_device { 285struct ubi_device {
279 struct cdev cdev; 286 struct cdev cdev;
@@ -302,6 +309,7 @@ struct ubi_device {
302 unsigned long long global_sqnum; 309 unsigned long long global_sqnum;
303 spinlock_t ltree_lock; 310 spinlock_t ltree_lock;
304 struct rb_root ltree; 311 struct rb_root ltree;
312 struct mutex alc_mutex;
305 313
306 /* Wear-leveling unit's stuff */ 314 /* Wear-leveling unit's stuff */
307 struct rb_root used; 315 struct rb_root used;
@@ -343,6 +351,14 @@ struct ubi_device {
343 int vid_hdr_shift; 351 int vid_hdr_shift;
344 int bad_allowed; 352 int bad_allowed;
345 struct mtd_info *mtd; 353 struct mtd_info *mtd;
354
355 void *peb_buf1;
356 void *peb_buf2;
357 struct mutex buf_mutex;
358#ifdef CONFIG_MTD_UBI_DEBUG
359 void *dbg_peb_buf;
360 struct mutex dbg_buf_mutex;
361#endif
346}; 362};
347 363
348extern struct file_operations ubi_cdev_operations; 364extern struct file_operations ubi_cdev_operations;
@@ -409,18 +425,18 @@ void ubi_wl_close(struct ubi_device *ubi);
409/* io.c */ 425/* io.c */
410int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset, 426int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset,
411 int len); 427 int len);
412int ubi_io_write(const struct ubi_device *ubi, const void *buf, int pnum, 428int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
413 int offset, int len); 429 int len);
414int ubi_io_sync_erase(const struct ubi_device *ubi, int pnum, int torture); 430int ubi_io_sync_erase(struct ubi_device *ubi, int pnum, int torture);
415int ubi_io_is_bad(const struct ubi_device *ubi, int pnum); 431int ubi_io_is_bad(const struct ubi_device *ubi, int pnum);
416int ubi_io_mark_bad(const struct ubi_device *ubi, int pnum); 432int ubi_io_mark_bad(const struct ubi_device *ubi, int pnum);
417int ubi_io_read_ec_hdr(const struct ubi_device *ubi, int pnum, 433int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
418 struct ubi_ec_hdr *ec_hdr, int verbose); 434 struct ubi_ec_hdr *ec_hdr, int verbose);
419int ubi_io_write_ec_hdr(const struct ubi_device *ubi, int pnum, 435int ubi_io_write_ec_hdr(struct ubi_device *ubi, int pnum,
420 struct ubi_ec_hdr *ec_hdr); 436 struct ubi_ec_hdr *ec_hdr);
421int ubi_io_read_vid_hdr(const struct ubi_device *ubi, int pnum, 437int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
422 struct ubi_vid_hdr *vid_hdr, int verbose); 438 struct ubi_vid_hdr *vid_hdr, int verbose);
423int ubi_io_write_vid_hdr(const struct ubi_device *ubi, int pnum, 439int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
424 struct ubi_vid_hdr *vid_hdr); 440 struct ubi_vid_hdr *vid_hdr);
425 441
426/* 442/*
@@ -439,16 +455,18 @@ int ubi_io_write_vid_hdr(const struct ubi_device *ubi, int pnum,
439/** 455/**
440 * ubi_zalloc_vid_hdr - allocate a volume identifier header object. 456 * ubi_zalloc_vid_hdr - allocate a volume identifier header object.
441 * @ubi: UBI device description object 457 * @ubi: UBI device description object
458 * @gfp_flags: GFP flags to allocate with
442 * 459 *
443 * This function returns a pointer to the newly allocated and zero-filled 460 * This function returns a pointer to the newly allocated and zero-filled
444 * volume identifier header object in case of success and %NULL in case of 461 * volume identifier header object in case of success and %NULL in case of
445 * failure. 462 * failure.
446 */ 463 */
447static inline struct ubi_vid_hdr *ubi_zalloc_vid_hdr(const struct ubi_device *ubi) 464static inline struct ubi_vid_hdr *
465ubi_zalloc_vid_hdr(const struct ubi_device *ubi, gfp_t gfp_flags)
448{ 466{
449 void *vid_hdr; 467 void *vid_hdr;
450 468
451 vid_hdr = kzalloc(ubi->vid_hdr_alsize, GFP_KERNEL); 469 vid_hdr = kzalloc(ubi->vid_hdr_alsize, gfp_flags);
452 if (!vid_hdr) 470 if (!vid_hdr)
453 return NULL; 471 return NULL;
454 472
@@ -492,7 +510,7 @@ static inline int ubi_io_read_data(const struct ubi_device *ubi, void *buf,
492 * the beginning of the logical eraseblock, not to the beginning of the 510 * the beginning of the logical eraseblock, not to the beginning of the
493 * physical eraseblock. 511 * physical eraseblock.
494 */ 512 */
495static inline int ubi_io_write_data(const struct ubi_device *ubi, const void *buf, 513static inline int ubi_io_write_data(struct ubi_device *ubi, const void *buf,
496 int pnum, int offset, int len) 514 int pnum, int offset, int len)
497{ 515{
498 ubi_assert(offset >= 0); 516 ubi_assert(offset >= 0);