From 9a5f09ac0ab83e4a965a24edd6cf7cb0303c6dc9 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Fri, 16 Sep 2016 16:59:22 +0200 Subject: 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 Signed-off-by: Richard Weinberger --- drivers/mtd/ubi/ubi.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/mtd/ubi/ubi.h') 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); -- cgit v1.2.3