mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mtd: ubi: remove redundant check on bytes_left at end of function
@ 2024-11-07 15:23 Colin Ian King
  2024-11-08  1:41 ` Zhihao Cheng
  0 siblings, 1 reply; 2+ messages in thread
From: Colin Ian King @ 2024-11-07 15:23 UTC (permalink / raw)
  To: Richard Weinberger, Zhihao Cheng, Miquel Raynal,
	Vignesh Raghavendra, linux-mtd
  Cc: kernel-janitors, linux-kernel

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>
---
 drivers/mtd/ubi/nvmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/nvmem.c b/drivers/mtd/ubi/nvmem.c
index a94a1a9aaec1..34f8c1d3cdee 100644
--- a/drivers/mtd/ubi/nvmem.c
+++ b/drivers/mtd/ubi/nvmem.c
@@ -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)
-- 
2.39.5


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mtd: ubi: remove redundant check on bytes_left at end of function
  2024-11-07 15:23 [PATCH] mtd: ubi: remove redundant check on bytes_left at end of function Colin Ian King
@ 2024-11-08  1:41 ` Zhihao Cheng
  0 siblings, 0 replies; 2+ messages in thread
From: Zhihao Cheng @ 2024-11-08  1:41 UTC (permalink / raw)
  To: Colin Ian King, Richard Weinberger, Miquel Raynal,
	Vignesh Raghavendra, linux-mtd
  Cc: kernel-janitors, linux-kernel

在 2024/11/7 23:23, Colin Ian King 写道:
> 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>
> ---
>   drivers/mtd/ubi/nvmem.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
Make sense.
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> diff --git a/drivers/mtd/ubi/nvmem.c b/drivers/mtd/ubi/nvmem.c
> index a94a1a9aaec1..34f8c1d3cdee 100644
> --- a/drivers/mtd/ubi/nvmem.c
> +++ b/drivers/mtd/ubi/nvmem.c
> @@ -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)
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-08  1:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-07 15:23 [PATCH] mtd: ubi: remove redundant check on bytes_left at end of function Colin Ian King
2024-11-08  1:41 ` Zhihao Cheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®