diff options
Diffstat (limited to 'drivers/mtd/ubi/eba.c')
-rw-r--r-- | drivers/mtd/ubi/eba.c | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index 5fdb31bc5636..b2b0f29bdc53 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c | |||
@@ -289,17 +289,17 @@ static void leb_write_unlock(struct ubi_device *ubi, int vol_id, int lnum) | |||
289 | /** | 289 | /** |
290 | * ubi_eba_unmap_leb - un-map logical eraseblock. | 290 | * ubi_eba_unmap_leb - un-map logical eraseblock. |
291 | * @ubi: UBI device description object | 291 | * @ubi: UBI device description object |
292 | * @vol_id: volume ID | 292 | * @vol: volume description object |
293 | * @lnum: logical eraseblock number | 293 | * @lnum: logical eraseblock number |
294 | * | 294 | * |
295 | * This function un-maps logical eraseblock @lnum and schedules corresponding | 295 | * This function un-maps logical eraseblock @lnum and schedules corresponding |
296 | * physical eraseblock for erasure. Returns zero in case of success and a | 296 | * physical eraseblock for erasure. Returns zero in case of success and a |
297 | * negative error code in case of failure. | 297 | * negative error code in case of failure. |
298 | */ | 298 | */ |
299 | int ubi_eba_unmap_leb(struct ubi_device *ubi, int vol_id, int lnum) | 299 | int ubi_eba_unmap_leb(struct ubi_device *ubi, struct ubi_volume *vol, |
300 | int lnum) | ||
300 | { | 301 | { |
301 | int idx = vol_id2idx(ubi, vol_id), err, pnum; | 302 | int err, pnum, vol_id = vol->vol_id; |
302 | struct ubi_volume *vol = ubi->volumes[idx]; | ||
303 | 303 | ||
304 | if (ubi->ro_mode) | 304 | if (ubi->ro_mode) |
305 | return -EROFS; | 305 | return -EROFS; |
@@ -326,7 +326,7 @@ out_unlock: | |||
326 | /** | 326 | /** |
327 | * ubi_eba_read_leb - read data. | 327 | * ubi_eba_read_leb - read data. |
328 | * @ubi: UBI device description object | 328 | * @ubi: UBI device description object |
329 | * @vol_id: volume ID | 329 | * @vol: volume description object |
330 | * @lnum: logical eraseblock number | 330 | * @lnum: logical eraseblock number |
331 | * @buf: buffer to store the read data | 331 | * @buf: buffer to store the read data |
332 | * @offset: offset from where to read | 332 | * @offset: offset from where to read |
@@ -342,12 +342,11 @@ out_unlock: | |||
342 | * returned for any volume type if an ECC error was detected by the MTD device | 342 | * returned for any volume type if an ECC error was detected by the MTD device |
343 | * driver. Other negative error cored may be returned in case of other errors. | 343 | * driver. Other negative error cored may be returned in case of other errors. |
344 | */ | 344 | */ |
345 | int ubi_eba_read_leb(struct ubi_device *ubi, int vol_id, int lnum, void *buf, | 345 | int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, |
346 | int offset, int len, int check) | 346 | void *buf, int offset, int len, int check) |
347 | { | 347 | { |
348 | int err, pnum, scrub = 0, idx = vol_id2idx(ubi, vol_id); | 348 | int err, pnum, scrub = 0, vol_id = vol->vol_id; |
349 | struct ubi_vid_hdr *vid_hdr; | 349 | struct ubi_vid_hdr *vid_hdr; |
350 | struct ubi_volume *vol = ubi->volumes[idx]; | ||
351 | uint32_t uninitialized_var(crc); | 350 | uint32_t uninitialized_var(crc); |
352 | 351 | ||
353 | err = leb_read_lock(ubi, vol_id, lnum); | 352 | err = leb_read_lock(ubi, vol_id, lnum); |
@@ -555,7 +554,7 @@ write_error: | |||
555 | /** | 554 | /** |
556 | * ubi_eba_write_leb - write data to dynamic volume. | 555 | * ubi_eba_write_leb - write data to dynamic volume. |
557 | * @ubi: UBI device description object | 556 | * @ubi: UBI device description object |
558 | * @vol_id: volume ID | 557 | * @vol: volume description object |
559 | * @lnum: logical eraseblock number | 558 | * @lnum: logical eraseblock number |
560 | * @buf: the data to write | 559 | * @buf: the data to write |
561 | * @offset: offset within the logical eraseblock where to write | 560 | * @offset: offset within the logical eraseblock where to write |
@@ -563,15 +562,14 @@ write_error: | |||
563 | * @dtype: data type | 562 | * @dtype: data type |
564 | * | 563 | * |
565 | * This function writes data to logical eraseblock @lnum of a dynamic volume | 564 | * This function writes data to logical eraseblock @lnum of a dynamic volume |
566 | * @vol_id. Returns zero in case of success and a negative error code in case | 565 | * @vol. Returns zero in case of success and a negative error code in case |
567 | * of failure. In case of error, it is possible that something was still | 566 | * of failure. In case of error, it is possible that something was still |
568 | * written to the flash media, but may be some garbage. | 567 | * written to the flash media, but may be some garbage. |
569 | */ | 568 | */ |
570 | int ubi_eba_write_leb(struct ubi_device *ubi, int vol_id, int lnum, | 569 | int ubi_eba_write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, |
571 | const void *buf, int offset, int len, int dtype) | 570 | const void *buf, int offset, int len, int dtype) |
572 | { | 571 | { |
573 | int idx = vol_id2idx(ubi, vol_id), err, pnum, tries = 0; | 572 | int err, pnum, tries = 0, vol_id = vol->vol_id; |
574 | struct ubi_volume *vol = ubi->volumes[idx]; | ||
575 | struct ubi_vid_hdr *vid_hdr; | 573 | struct ubi_vid_hdr *vid_hdr; |
576 | 574 | ||
577 | if (ubi->ro_mode) | 575 | if (ubi->ro_mode) |
@@ -590,7 +588,8 @@ int ubi_eba_write_leb(struct ubi_device *ubi, int vol_id, int lnum, | |||
590 | if (err) { | 588 | if (err) { |
591 | ubi_warn("failed to write data to PEB %d", pnum); | 589 | ubi_warn("failed to write data to PEB %d", pnum); |
592 | if (err == -EIO && ubi->bad_allowed) | 590 | if (err == -EIO && ubi->bad_allowed) |
593 | err = recover_peb(ubi, pnum, vol_id, lnum, buf, offset, len); | 591 | err = recover_peb(ubi, pnum, vol_id, lnum, buf, |
592 | offset, len); | ||
594 | if (err) | 593 | if (err) |
595 | ubi_ro_mode(ubi); | 594 | ubi_ro_mode(ubi); |
596 | } | 595 | } |
@@ -678,7 +677,7 @@ write_error: | |||
678 | /** | 677 | /** |
679 | * ubi_eba_write_leb_st - write data to static volume. | 678 | * ubi_eba_write_leb_st - write data to static volume. |
680 | * @ubi: UBI device description object | 679 | * @ubi: UBI device description object |
681 | * @vol_id: volume ID | 680 | * @vol: volume description object |
682 | * @lnum: logical eraseblock number | 681 | * @lnum: logical eraseblock number |
683 | * @buf: data to write | 682 | * @buf: data to write |
684 | * @len: how many bytes to write | 683 | * @len: how many bytes to write |
@@ -686,7 +685,7 @@ write_error: | |||
686 | * @used_ebs: how many logical eraseblocks will this volume contain | 685 | * @used_ebs: how many logical eraseblocks will this volume contain |
687 | * | 686 | * |
688 | * This function writes data to logical eraseblock @lnum of static volume | 687 | * This function writes data to logical eraseblock @lnum of static volume |
689 | * @vol_id. The @used_ebs argument should contain total number of logical | 688 | * @vol. The @used_ebs argument should contain total number of logical |
690 | * eraseblock in this static volume. | 689 | * eraseblock in this static volume. |
691 | * | 690 | * |
692 | * When writing to the last logical eraseblock, the @len argument doesn't have | 691 | * When writing to the last logical eraseblock, the @len argument doesn't have |
@@ -698,12 +697,11 @@ write_error: | |||
698 | * volumes. This function returns zero in case of success and a negative error | 697 | * volumes. This function returns zero in case of success and a negative error |
699 | * code in case of failure. | 698 | * code in case of failure. |
700 | */ | 699 | */ |
701 | int ubi_eba_write_leb_st(struct ubi_device *ubi, int vol_id, int lnum, | 700 | int ubi_eba_write_leb_st(struct ubi_device *ubi, struct ubi_volume *vol, |
702 | const void *buf, int len, int dtype, int used_ebs) | 701 | int lnum, const void *buf, int len, int dtype, |
702 | int used_ebs) | ||
703 | { | 703 | { |
704 | int err, pnum, tries = 0, data_size = len; | 704 | int err, pnum, tries = 0, data_size = len, vol_id = vol->vol_id; |
705 | int idx = vol_id2idx(ubi, vol_id); | ||
706 | struct ubi_volume *vol = ubi->volumes[idx]; | ||
707 | struct ubi_vid_hdr *vid_hdr; | 705 | struct ubi_vid_hdr *vid_hdr; |
708 | uint32_t crc; | 706 | uint32_t crc; |
709 | 707 | ||
@@ -799,7 +797,7 @@ write_error: | |||
799 | /* | 797 | /* |
800 | * ubi_eba_atomic_leb_change - change logical eraseblock atomically. | 798 | * ubi_eba_atomic_leb_change - change logical eraseblock atomically. |
801 | * @ubi: UBI device description object | 799 | * @ubi: UBI device description object |
802 | * @vol_id: volume ID | 800 | * @vol: volume escription object |
803 | * @lnum: logical eraseblock number | 801 | * @lnum: logical eraseblock number |
804 | * @buf: data to write | 802 | * @buf: data to write |
805 | * @len: how many bytes to write | 803 | * @len: how many bytes to write |
@@ -814,11 +812,10 @@ write_error: | |||
814 | * UBI reserves one LEB for the "atomic LEB change" operation, so only one | 812 | * UBI reserves one LEB for the "atomic LEB change" operation, so only one |
815 | * LEB change may be done at a time. This is ensured by @ubi->alc_mutex. | 813 | * LEB change may be done at a time. This is ensured by @ubi->alc_mutex. |
816 | */ | 814 | */ |
817 | int ubi_eba_atomic_leb_change(struct ubi_device *ubi, int vol_id, int lnum, | 815 | int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol, |
818 | const void *buf, int len, int dtype) | 816 | int lnum, const void *buf, int len, int dtype) |
819 | { | 817 | { |
820 | int err, pnum, tries = 0, idx = vol_id2idx(ubi, vol_id); | 818 | int err, pnum, tries = 0, vol_id = vol->vol_id; |
821 | struct ubi_volume *vol = ubi->volumes[idx]; | ||
822 | struct ubi_vid_hdr *vid_hdr; | 819 | struct ubi_vid_hdr *vid_hdr; |
823 | uint32_t crc; | 820 | uint32_t crc; |
824 | 821 | ||