summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-04-25 10:54:39 -0600
committerTom Rini <trini@konsulko.com>2023-04-27 13:51:06 -0400
commit9367e6174aba22cd376e9d2c8fc1260115f44f97 (patch)
treea87330b224c8242e70d5ebf6a1112bc00ffaaaed
parent6579bb00cf4f072084a02e806b214eed95a9e5bc (diff)
ide: Simplify success condition
Change the if() to remove extra brackets and check for the positive case first, i.e. when a device is found. Exit the loop in that case, with the retry logic in the 'else' part. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--drivers/block/ide.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/drivers/block/ide.c b/drivers/block/ide.c
index 2f45bb6bffb..a51a0008cae 100644
--- a/drivers/block/ide.c
+++ b/drivers/block/ide.c
@@ -599,27 +599,25 @@ static void ide_ident(struct blk_desc *dev_desc)
c = ide_wait(device, IDE_TIME_OUT);
}
- if (((c & ATA_STAT_DRQ) == 0) ||
- ((c & (ATA_STAT_FAULT | ATA_STAT_ERR)) != 0)) {
- if (IS_ENABLED(CONFIG_ATAPI)) {
- /*
- * Need to soft reset the device
- * in case it's an ATAPI...
- */
- debug("Retrying...\n");
- ide_outb(device, ATA_DEV_HD,
- ATA_LBA | ATA_DEVICE(device));
- mdelay(100);
- ide_outb(device, ATA_COMMAND, 0x08);
- mdelay(500);
- /* Select device */
- ide_outb(device, ATA_DEV_HD,
- ATA_LBA | ATA_DEVICE(device));
- }
- tries--;
- } else {
+ if ((c & ATA_STAT_DRQ) &&
+ !(c & (ATA_STAT_FAULT | ATA_STAT_ERR))) {
break;
+ } else if (IS_ENABLED(CONFIG_ATAPI)) {
+ /*
+ * Need to soft reset the device
+ * in case it's an ATAPI...
+ */
+ debug("Retrying...\n");
+ ide_outb(device, ATA_DEV_HD,
+ ATA_LBA | ATA_DEVICE(device));
+ mdelay(100);
+ ide_outb(device, ATA_COMMAND, 0x08);
+ mdelay(500);
+ /* Select device */
+ ide_outb(device, ATA_DEV_HD,
+ ATA_LBA | ATA_DEVICE(device));
}
+ tries--;
}
if (!tries) /* Not found */