diff mbox series

[v2] scsi: ufs: Use wait-for-reg in HCE init

Message ID 20241016063950.436190-1-avri.altman@wdc.com (mailing list archive)
State Superseded
Headers show
Series [v2] scsi: ufs: Use wait-for-reg in HCE init | expand

Commit Message

Avri Altman Oct. 16, 2024, 6:39 a.m. UTC
The current so called "inner loop" in ufshcd_hba_execute_hce() is open
coding ufshcd_wait_for_register. Replace it by ufshcd_wait_for_register.
This is a code simplification - no functional change.

Signed-off-by: Avri Altman <avri.altman@wdc.com>

---
Changes in v2:
 - Elaborate the commit log (Bart)
 - Change a while-loop into a for-loop (Bart)
---
 drivers/ufs/core/ufshcd.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

Comments

Avri Altman Oct. 16, 2024, 10:05 a.m. UTC | #1
> The current so called "inner loop" in ufshcd_hba_execute_hce() is open
> coding ufshcd_wait_for_register. Replace it by ufshcd_wait_for_register.
> This is a code simplification - no functional change.
> 
> Signed-off-by: Avri Altman <avri.altman@wdc.com>
Please ignore this version - will resend soon.

Thanks,
Avri
diff mbox series

Patch

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 9e6d008f4ea4..7587477d1712 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -4818,8 +4818,7 @@  EXPORT_SYMBOL_GPL(ufshcd_hba_stop);
  */
 static int ufshcd_hba_execute_hce(struct ufs_hba *hba)
 {
-	int retry_outer = 3;
-	int retry_inner;
+	int retry;
 
 start:
 	if (ufshcd_is_hba_active(hba))
@@ -4847,22 +4846,17 @@  static int ufshcd_hba_execute_hce(struct ufs_hba *hba)
 	ufshcd_delay_us(hba->vps->hba_enable_delay_us, 100);
 
 	/* wait for the host controller to complete initialization */
-	retry_inner = 50;
-	while (!ufshcd_is_hba_active(hba)) {
-		if (retry_inner) {
-			retry_inner--;
-		} else {
-			dev_err(hba->dev,
-				"Controller enable failed\n");
-			if (retry_outer) {
-				retry_outer--;
-				goto start;
-			}
-			return -EIO;
-		}
-		usleep_range(1000, 1100);
+	for (retry = 3; retry > 0; retry--) {
+		if (!ufshcd_wait_for_register(hba, REG_CONTROLLER_ENABLE, CONTROLLER_ENABLE,
+					      CONTROLLER_ENABLE, 1000, 50))
+			break;
+		dev_err(hba->dev, "Enabling the controller failed\n");
+		goto start;
 	}
 
+	if (!retry)
+		return -EIO;
+
 	/* enable UIC related interrupts */
 	ufshcd_enable_intr(hba, UFSHCD_UIC_MASK);