diff mbox series

[1/3] mmc: sdhci-of-esdhc: Fix timeout checks

Message ID 20181210085626.19764-2-adrian.hunter@intel.com (mailing list archive)
State New, archived
Headers show
Series mmc: sdhci: Fix timeout checks | expand

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-of-esdhc.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

Comments

Yangbo Lu Dec. 11, 2018, 8:52 a.m. UTC | #1
Reviewed-by: Yangbo Lu <yangbo.lu@nxp.com>

> -----Original Message-----
> From: Adrian Hunter <adrian.hunter@intel.com>
> Sent: Monday, December 10, 2018 4:56 PM
> To: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: linux-mmc <linux-mmc@vger.kernel.org>; Yinbo Zhu
> <yinbo.zhu@nxp.com>; Laurentiu Tudor <laurentiu.tudor@nxp.com>; Y.B. LU
> <yangbo.lu@nxp.com>; Kishon Vijay Abraham I <kishon@ti.com>; Hu Ziji
> <huziji@marvell.com>; Zhoujie Wu <zjwu@marvell.com>
> Subject: [PATCH 1/3] mmc: sdhci-of-esdhc: Fix timeout checks
> 
> Always check the wait condition before returning timeout.
> 
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>  drivers/mmc/host/sdhci-of-esdhc.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c
> b/drivers/mmc/host/sdhci-of-esdhc.c
> index 86fc9f022002..d111bf62acd9 100644
> --- a/drivers/mmc/host/sdhci-of-esdhc.c
> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> @@ -528,8 +528,12 @@ static void esdhc_clock_enable(struct sdhci_host
> *host, bool enable)
>  	/* Wait max 20 ms */
>  	timeout = ktime_add_ms(ktime_get(), 20);
>  	val = ESDHC_CLOCK_STABLE;
> -	while (!(sdhci_readl(host, ESDHC_PRSSTAT) & val)) {
> -		if (ktime_after(ktime_get(), timeout)) {
> +	while  (1) {
> +		bool timedout = ktime_after(ktime_get(), timeout);
> +
> +		if (sdhci_readl(host, ESDHC_PRSSTAT) & val)
> +			break;
> +		if (timedout) {
>  			pr_err("%s: Internal clock never stabilised.\n",
>  				mmc_hostname(host->mmc));
>  			break;
> @@ -594,8 +598,12 @@ static void esdhc_of_set_clock(struct sdhci_host
> *host, unsigned int clock)
> 
>  	/* Wait max 20 ms */
>  	timeout = ktime_add_ms(ktime_get(), 20);
> -	while (!(sdhci_readl(host, ESDHC_PRSSTAT) & ESDHC_CLOCK_STABLE)) {
> -		if (ktime_after(ktime_get(), timeout)) {
> +	while (1) {
> +		bool timedout = ktime_after(ktime_get(), timeout);
> +
> +		if (sdhci_readl(host, ESDHC_PRSSTAT) & ESDHC_CLOCK_STABLE)
> +			break;
> +		if (timedout) {
>  			pr_err("%s: Internal clock never stabilised.\n",
>  				mmc_hostname(host->mmc));
>  			return;
> --
> 2.17.1
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index 86fc9f022002..d111bf62acd9 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -528,8 +528,12 @@  static void esdhc_clock_enable(struct sdhci_host *host, bool enable)
 	/* Wait max 20 ms */
 	timeout = ktime_add_ms(ktime_get(), 20);
 	val = ESDHC_CLOCK_STABLE;
-	while (!(sdhci_readl(host, ESDHC_PRSSTAT) & val)) {
-		if (ktime_after(ktime_get(), timeout)) {
+	while  (1) {
+		bool timedout = ktime_after(ktime_get(), timeout);
+
+		if (sdhci_readl(host, ESDHC_PRSSTAT) & val)
+			break;
+		if (timedout) {
 			pr_err("%s: Internal clock never stabilised.\n",
 				mmc_hostname(host->mmc));
 			break;
@@ -594,8 +598,12 @@  static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)
 
 	/* Wait max 20 ms */
 	timeout = ktime_add_ms(ktime_get(), 20);
-	while (!(sdhci_readl(host, ESDHC_PRSSTAT) & ESDHC_CLOCK_STABLE)) {
-		if (ktime_after(ktime_get(), timeout)) {
+	while (1) {
+		bool timedout = ktime_after(ktime_get(), timeout);
+
+		if (sdhci_readl(host, ESDHC_PRSSTAT) & ESDHC_CLOCK_STABLE)
+			break;
+		if (timedout) {
 			pr_err("%s: Internal clock never stabilised.\n",
 				mmc_hostname(host->mmc));
 			return;