diff options
-rw-r--r-- | drivers/mtd/ubi/eba.c | 12 | ||||
-rw-r--r-- | drivers/mtd/ubi/kapi.c | 4 | ||||
-rw-r--r-- | drivers/mtd/ubi/ubi.h | 1 |
3 files changed, 15 insertions, 2 deletions
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index 180eb006e966..32045dd3d1db 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c | |||
@@ -312,6 +312,18 @@ static void leb_write_unlock(struct ubi_device *ubi, int vol_id, int lnum) | |||
312 | } | 312 | } |
313 | 313 | ||
314 | /** | 314 | /** |
315 | * ubi_eba_is_mapped - check if a LEB is mapped. | ||
316 | * @vol: volume description object | ||
317 | * @lnum: logical eraseblock number | ||
318 | * | ||
319 | * This function returns true if the LEB is mapped, false otherwise. | ||
320 | */ | ||
321 | bool ubi_eba_is_mapped(struct ubi_volume *vol, int lnum) | ||
322 | { | ||
323 | return vol->eba_tbl[lnum] >= 0; | ||
324 | } | ||
325 | |||
326 | /** | ||
315 | * ubi_eba_unmap_leb - un-map logical eraseblock. | 327 | * ubi_eba_unmap_leb - un-map logical eraseblock. |
316 | * @ubi: UBI device description object | 328 | * @ubi: UBI device description object |
317 | * @vol: volume description object | 329 | * @vol: volume description object |
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c index cec7f65beb9e..88b1897aeb40 100644 --- a/drivers/mtd/ubi/kapi.c +++ b/drivers/mtd/ubi/kapi.c | |||
@@ -722,7 +722,7 @@ int ubi_leb_map(struct ubi_volume_desc *desc, int lnum) | |||
722 | if (vol->upd_marker) | 722 | if (vol->upd_marker) |
723 | return -EBADF; | 723 | return -EBADF; |
724 | 724 | ||
725 | if (vol->eba_tbl[lnum] >= 0) | 725 | if (ubi_eba_is_mapped(vol, lnum)) |
726 | return -EBADMSG; | 726 | return -EBADMSG; |
727 | 727 | ||
728 | return ubi_eba_write_leb(ubi, vol, lnum, NULL, 0, 0); | 728 | return ubi_eba_write_leb(ubi, vol, lnum, NULL, 0, 0); |
@@ -757,7 +757,7 @@ int ubi_is_mapped(struct ubi_volume_desc *desc, int lnum) | |||
757 | if (vol->upd_marker) | 757 | if (vol->upd_marker) |
758 | return -EBADF; | 758 | return -EBADF; |
759 | 759 | ||
760 | return vol->eba_tbl[lnum] >= 0; | 760 | return ubi_eba_is_mapped(vol, lnum); |
761 | } | 761 | } |
762 | EXPORT_SYMBOL_GPL(ubi_is_mapped); | 762 | EXPORT_SYMBOL_GPL(ubi_is_mapped); |
763 | 763 | ||
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index 23c902e204aa..37469805591d 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h | |||
@@ -849,6 +849,7 @@ static inline bool ubi_leb_valid(struct ubi_volume *vol, int lnum) | |||
849 | } | 849 | } |
850 | 850 | ||
851 | /* eba.c */ | 851 | /* eba.c */ |
852 | bool ubi_eba_is_mapped(struct ubi_volume *vol, int lnum); | ||
852 | int ubi_eba_unmap_leb(struct ubi_device *ubi, struct ubi_volume *vol, | 853 | int ubi_eba_unmap_leb(struct ubi_device *ubi, struct ubi_volume *vol, |
853 | int lnum); | 854 | int lnum); |
854 | int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, | 855 | int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, |