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

Message ID 20181210085626.19764-3-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-omap.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

Comments

Kishon Vijay Abraham I Dec. 11, 2018, 5:10 a.m. UTC | #1
On 10/12/18 2:26 PM, Adrian Hunter wrote:
> Always check the wait condition before returning timeout.
> 
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>  drivers/mmc/host/sdhci-omap.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
> index 88347ce78f23..4b562a8c38a6 100644
> --- a/drivers/mmc/host/sdhci-omap.c
> +++ b/drivers/mmc/host/sdhci-omap.c
> @@ -220,8 +220,12 @@ static void sdhci_omap_conf_bus_power(struct sdhci_omap_host *omap_host,
>  
>  	/* wait 1ms */
>  	timeout = ktime_add_ms(ktime_get(), SDHCI_OMAP_TIMEOUT);
> -	while (!(sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL) & HCTL_SDBP)) {
> -		if (WARN_ON(ktime_after(ktime_get(), timeout)))
> +	while (1) {
> +		bool timedout = ktime_after(ktime_get(), timeout);
> +
> +		if (sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL) & HCTL_SDBP)
> +			break;
> +		if (WARN_ON(timedout))
>  			return;
>  		usleep_range(5, 10);
>  	}
> @@ -649,8 +653,12 @@ static void sdhci_omap_init_74_clocks(struct sdhci_host *host, u8 power_mode)
>  
>  	/* wait 1ms */
>  	timeout = ktime_add_ms(ktime_get(), SDHCI_OMAP_TIMEOUT);
> -	while (!(sdhci_omap_readl(omap_host, SDHCI_OMAP_STAT) & INT_CC_EN)) {
> -		if (WARN_ON(ktime_after(ktime_get(), timeout)))
> +	while (1) {
> +		bool timedout = ktime_after(ktime_get(), timeout);
> +
> +		if (sdhci_omap_readl(omap_host, SDHCI_OMAP_STAT) & INT_CC_EN)
> +			break;
> +		if (WARN_ON(timedout))
>  			return;
>  		usleep_range(5, 10);
>  	}
>

Patch
diff mbox series

diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
index 88347ce78f23..4b562a8c38a6 100644
--- a/drivers/mmc/host/sdhci-omap.c
+++ b/drivers/mmc/host/sdhci-omap.c
@@ -220,8 +220,12 @@  static void sdhci_omap_conf_bus_power(struct sdhci_omap_host *omap_host,
 
 	/* wait 1ms */
 	timeout = ktime_add_ms(ktime_get(), SDHCI_OMAP_TIMEOUT);
-	while (!(sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL) & HCTL_SDBP)) {
-		if (WARN_ON(ktime_after(ktime_get(), timeout)))
+	while (1) {
+		bool timedout = ktime_after(ktime_get(), timeout);
+
+		if (sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL) & HCTL_SDBP)
+			break;
+		if (WARN_ON(timedout))
 			return;
 		usleep_range(5, 10);
 	}
@@ -649,8 +653,12 @@  static void sdhci_omap_init_74_clocks(struct sdhci_host *host, u8 power_mode)
 
 	/* wait 1ms */
 	timeout = ktime_add_ms(ktime_get(), SDHCI_OMAP_TIMEOUT);
-	while (!(sdhci_omap_readl(omap_host, SDHCI_OMAP_STAT) & INT_CC_EN)) {
-		if (WARN_ON(ktime_after(ktime_get(), timeout)))
+	while (1) {
+		bool timedout = ktime_after(ktime_get(), timeout);
+
+		if (sdhci_omap_readl(omap_host, SDHCI_OMAP_STAT) & INT_CC_EN)
+			break;
+		if (WARN_ON(timedout))
 			return;
 		usleep_range(5, 10);
 	}