[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20241114142728.2270-1-rex.nie@jaguarmicro.com>
Date: Thu, 14 Nov 2024 22:27:28 +0800
From: Rex Nie <rex.nie@...uarmicro.com>
To: miquel.raynal@...tlin.com,
richard@....at,
vigneshr@...com
Cc: colin.i.king@...il.com,
rex.nie@...uarmicro.com,
linux-mtd@...ts.infradead.org,
linux-kernel@...r.kernel.org,
angus.chen@...uarmicro.com
Subject: [PATCH] mtd: chips: Remove for loop which never execute more than once
Since the loop increment is unreachable, the loop body will never
execute more than once. Remove it to simplify the code. Note that
this does not change the semantics of get_chip().
Signed-off-by: Rex Nie <rex.nie@...uarmicro.com>
---
drivers/mtd/chips/cfi_cmdset_0002.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index 9f2223d3e8e1..da221253d688 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -884,21 +884,18 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
switch (chip->state) {
case FL_STATUS:
- for (;;) {
- if (chip_ready(map, chip, adr, NULL))
- break;
+ if (chip_ready(map, chip, adr, NULL))
+ return 0;
- if (time_after(jiffies, timeo)) {
- printk(KERN_ERR "Waiting for chip to be ready timed out.\n");
- return -EIO;
- }
- mutex_unlock(&chip->mutex);
- cfi_udelay(1);
- mutex_lock(&chip->mutex);
- /* Someone else might have been playing with it. */
- goto retry;
+ if (time_after(jiffies, timeo)) {
+ printk(KERN_ERR "Waiting for chip to be ready timed out.\n");
+ return -EIO;
}
- return 0;
+ mutex_unlock(&chip->mutex);
+ cfi_udelay(1);
+ mutex_lock(&chip->mutex);
+ /* Someone else might have been playing with it. */
+ goto retry;
case FL_READY:
case FL_CFI_QUERY:
--
2.17.1
Powered by blists - more mailing lists