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>
hd_driveid_t iop;
#ifdef CONFIG_ATAPI
bool is_atapi = false;
- int retries = 0;
+ int tries = 1;
#endif
int device;
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) &&
*/
ide_outb(device, ATA_DEV_HD,
ATA_LBA | ATA_DEVICE(device));
- retries++;
+ tries--;
#else
return;
#endif
break;
} /* see above - ugly to read */
- if (retries == 2) /* Not found */
+ if (!tries) /* Not found */
return;
#endif