ide: Change the retries variable
authorSimon Glass <sjg@chromium.org>
Tue, 25 Apr 2023 16:54:37 +0000 (10:54 -0600)
committerTom Rini <trini@konsulko.com>
Thu, 27 Apr 2023 17:51:06 +0000 (13:51 -0400)
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>
drivers/block/ide.c

index 1d5e54d..782780f 100644 (file)
@@ -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