mtd: ubi: remove redundant check on bytes_left at end of function
authorColin Ian King <colin.i.king@gmail.com>
Thu, 7 Nov 2024 15:23:57 +0000 (15:23 +0000)
committerRichard Weinberger <richard@nod.at>
Thu, 14 Nov 2024 18:54:27 +0000 (19:54 +0100)
In function ubi_nvmem_reg_read the while-loop can only be exiting
of bytes_left is zero or an error has occurred. There is an exit
return path if an error occurs, so the bytes_left can only be
zero after that point. Hence the check for a non-zero bytes_left
at the end of the function is redundant and can be removed. Remove
the check and just return 0.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/ubi/nvmem.c

index a94a1a9..34f8c1d 100644 (file)
@@ -55,7 +55,7 @@ static int ubi_nvmem_reg_read(void *priv, unsigned int from,
        if (err)
                return err;
 
-       return bytes_left == 0 ? 0 : -EIO;
+       return 0;
 }
 
 static int ubi_nvmem_add(struct ubi_volume_info *vi)