summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/ubi.h
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@free-electrons.com>2016-09-16 16:59:22 +0200
committerRichard Weinberger <richard@nod.at>2016-10-02 22:48:14 +0200
commit9a5f09ac0ab83e4a965a24edd6cf7cb0303c6dc9 (patch)
tree585c31efc8dc614a7bc705f73cfb8c69ae728913 /drivers/mtd/ubi/ubi.h
parentUBI: simplify LEB write and atomic LEB change code (diff)
downloadlinux-9a5f09ac0ab83e4a965a24edd6cf7cb0303c6dc9.tar.xz
linux-9a5f09ac0ab83e4a965a24edd6cf7cb0303c6dc9.zip
UBI: add an helper to check lnum validity
ubi_leb_valid() is here to replace the lnum < 0 || lnum >= vol->reserved_pebs checks. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'drivers/mtd/ubi/ubi.h')
-rw-r--r--drivers/mtd/ubi/ubi.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index b51d398f2356..23c902e204aa 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -843,6 +843,11 @@ void ubi_update_reserved(struct ubi_device *ubi);
void ubi_calculate_reserved(struct ubi_device *ubi);
int ubi_check_pattern(const void *buf, uint8_t patt, int size);
+static inline bool ubi_leb_valid(struct ubi_volume *vol, int lnum)
+{
+ return lnum >= 0 && lnum < vol->reserved_pebs;
+}
+
/* eba.c */
int ubi_eba_unmap_leb(struct ubi_device *ubi, struct ubi_volume *vol,
int lnum);