[PATCH 12/30] ide: Change the retries variable

Simon Glass sjg at chromium.org
Mon Mar 27 21:06:59 CEST 2023


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 at chromium.org>
---

 drivers/block/ide.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/block/ide.c b/drivers/block/ide.c
index 1d5e54d6eb98..782780fd302b 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
 
-- 
2.40.0.348.gf938b09366-goog



More information about the U-Boot mailing list