[3/3] mmc: sdhci-xenon: Fix timeout checks
diff mbox series

Message ID 20181210085626.19764-4-adrian.hunter@intel.com
State New
Headers show
Series
  • mmc: sdhci: Fix timeout checks
Related show

Commit Message

Adrian Hunter Dec. 10, 2018, 8:56 a.m. UTC
Always check the wait condition before returning timeout.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci-xenon-phy.c | 10 +++++++---
 drivers/mmc/host/sdhci-xenon.c     | 10 +++++++---
 2 files changed, 14 insertions(+), 6 deletions(-)

Comments

Zhoujie Wu Dec. 11, 2018, 12:59 a.m. UTC | #1
Reviewed-by: Zhoujie Wu <zjwu@marvell.com>

On 12/10/2018 12:56 AM, Adrian Hunter wrote:
> External Email
>
> ----------------------------------------------------------------------
> Always check the wait condition before returning timeout.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>   drivers/mmc/host/sdhci-xenon-phy.c | 10 +++++++---
>   drivers/mmc/host/sdhci-xenon.c     | 10 +++++++---
>   2 files changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-xenon-phy.c b/drivers/mmc/host/sdhci-xenon-phy.c
> index 5956e90380e8..5b5eb53a63d2 100644
> --- a/drivers/mmc/host/sdhci-xenon-phy.c
> +++ b/drivers/mmc/host/sdhci-xenon-phy.c
> @@ -357,9 +357,13 @@ static int xenon_emmc_phy_enable_dll(struct sdhci_host *host)
>   
>   	/* Wait max 32 ms */
>   	timeout = ktime_add_ms(ktime_get(), 32);
> -	while (!(sdhci_readw(host, XENON_SLOT_EXT_PRESENT_STATE) &
> -		XENON_DLL_LOCK_STATE)) {
> -		if (ktime_after(ktime_get(), timeout)) {
> +	while (1) {
> +		bool timedout = ktime_after(ktime_get(), timeout);
> +
> +		if (sdhci_readw(host, XENON_SLOT_EXT_PRESENT_STATE) &
> +		    XENON_DLL_LOCK_STATE)
> +			break;
> +		if (timedout) {
>   			dev_err(mmc_dev(host->mmc), "Wait for DLL Lock time-out\n");
>   			return -ETIMEDOUT;
>   		}
> diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c
> index 4d0791f6ec23..a0b5089b3274 100644
> --- a/drivers/mmc/host/sdhci-xenon.c
> +++ b/drivers/mmc/host/sdhci-xenon.c
> @@ -34,9 +34,13 @@ static int xenon_enable_internal_clk(struct sdhci_host *host)
>   	sdhci_writel(host, reg, SDHCI_CLOCK_CONTROL);
>   	/* Wait max 20 ms */
>   	timeout = ktime_add_ms(ktime_get(), 20);
> -	while (!((reg = sdhci_readw(host, SDHCI_CLOCK_CONTROL))
> -			& SDHCI_CLOCK_INT_STABLE)) {
> -		if (ktime_after(ktime_get(), timeout)) {
> +	while (1) {
> +		bool timedout = ktime_after(ktime_get(), timeout);
> +
> +		reg = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
> +		if (reg & SDHCI_CLOCK_INT_STABLE)
> +			break;
> +		if (timedout) {
>   			dev_err(mmc_dev(host->mmc), "Internal clock never stabilised.\n");
>   			return -ETIMEDOUT;
>   		}

Patch
diff mbox series

diff --git a/drivers/mmc/host/sdhci-xenon-phy.c b/drivers/mmc/host/sdhci-xenon-phy.c
index 5956e90380e8..5b5eb53a63d2 100644
--- a/drivers/mmc/host/sdhci-xenon-phy.c
+++ b/drivers/mmc/host/sdhci-xenon-phy.c
@@ -357,9 +357,13 @@  static int xenon_emmc_phy_enable_dll(struct sdhci_host *host)
 
 	/* Wait max 32 ms */
 	timeout = ktime_add_ms(ktime_get(), 32);
-	while (!(sdhci_readw(host, XENON_SLOT_EXT_PRESENT_STATE) &
-		XENON_DLL_LOCK_STATE)) {
-		if (ktime_after(ktime_get(), timeout)) {
+	while (1) {
+		bool timedout = ktime_after(ktime_get(), timeout);
+
+		if (sdhci_readw(host, XENON_SLOT_EXT_PRESENT_STATE) &
+		    XENON_DLL_LOCK_STATE)
+			break;
+		if (timedout) {
 			dev_err(mmc_dev(host->mmc), "Wait for DLL Lock time-out\n");
 			return -ETIMEDOUT;
 		}
diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c
index 4d0791f6ec23..a0b5089b3274 100644
--- a/drivers/mmc/host/sdhci-xenon.c
+++ b/drivers/mmc/host/sdhci-xenon.c
@@ -34,9 +34,13 @@  static int xenon_enable_internal_clk(struct sdhci_host *host)
 	sdhci_writel(host, reg, SDHCI_CLOCK_CONTROL);
 	/* Wait max 20 ms */
 	timeout = ktime_add_ms(ktime_get(), 20);
-	while (!((reg = sdhci_readw(host, SDHCI_CLOCK_CONTROL))
-			& SDHCI_CLOCK_INT_STABLE)) {
-		if (ktime_after(ktime_get(), timeout)) {
+	while (1) {
+		bool timedout = ktime_after(ktime_get(), timeout);
+
+		reg = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
+		if (reg & SDHCI_CLOCK_INT_STABLE)
+			break;
+		if (timedout) {
 			dev_err(mmc_dev(host->mmc), "Internal clock never stabilised.\n");
 			return -ETIMEDOUT;
 		}