diff mbox series

mtd: chips: Remove for loop which never execute more than once

Message ID 20241114142728.2270-1-rex.nie@jaguarmicro.com
State New
Headers show
Series mtd: chips: Remove for loop which never execute more than once | expand

Commit Message

Rex Nie Nov. 14, 2024, 2:27 p.m. UTC
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@jaguarmicro.com>
---
 drivers/mtd/chips/cfi_cmdset_0002.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)
diff mbox series

Patch

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: