From: Simon Glass <sjg@chromium.org>
Date: Tue, 25 Apr 2023 16:54:37 +0000 (-0600)
Subject: ide: Change the retries variable
X-Git-Tag: v2025.01-rc5-pxa1908~1026^2~18
X-Git-Url: http://git.dujemihanovic.xyz/img/html/index.html?a=commitdiff_plain;h=2a165956ac804ebd825ba9eaf4fe26c9bbfb8925;p=u-boot.git

ide: Change the retries variable

Use a 'tries' variable which starts at the number of tries we want to do,
rather than a 'retries' one that stops at either 1 or 2. This will make it
easier to refactor the code to avoid the horrible #ifdefs

Signed-off-by: Simon Glass <sjg@chromium.org>
---

diff --git a/drivers/block/ide.c b/drivers/block/ide.c
index 1d5e54d6eb..782780fd30 100644
--- a/drivers/block/ide.c
+++ b/drivers/block/ide.c
@@ -557,7 +557,7 @@ static void ide_ident(struct blk_desc *dev_desc)
 	hd_driveid_t iop;
 #ifdef CONFIG_ATAPI
 	bool is_atapi = false;
-	int retries = 0;
+	int tries = 1;
 #endif
 	int device;
 
@@ -570,10 +570,10 @@ static void ide_ident(struct blk_desc *dev_desc)
 	dev_desc->uclass_id = UCLASS_IDE;
 #ifdef CONFIG_ATAPI
 
-	retries = 0;
+	tries = 2;
 
 	/* Warning: This will be tricky to read */
-	while (retries <= 1) {
+	while (tries) {
 		/* check signature */
 		if ((ide_inb(device, ATA_SECT_CNT) == 0x01) &&
 		    (ide_inb(device, ATA_SECT_NUM) == 0x01) &&
@@ -624,7 +624,7 @@ static void ide_ident(struct blk_desc *dev_desc)
 			 */
 			ide_outb(device, ATA_DEV_HD,
 				 ATA_LBA | ATA_DEVICE(device));
-			retries++;
+			tries--;
 #else
 			return;
 #endif
@@ -634,7 +634,7 @@ static void ide_ident(struct blk_desc *dev_desc)
 			break;
 	}			/* see above - ugly to read */
 
-	if (retries == 2)	/* Not found */
+	if (!tries)	/* Not found */
 		return;
 #endif