public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jaehoon Chung <jh80.chung@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mmc: sdhci: clean up time out detection
Date: Fri, 08 Jul 2016 20:10:29 +0900	[thread overview]
Message-ID: <577F8A25.8030508@samsung.com> (raw)
In-Reply-To: <1467975504-15761-1-git-send-email-yamada.masahiro@socionext.com>

Hi Masahiro,

On 07/08/2016 07:58 PM, Masahiro Yamada wrote:
> The current timeout detection logic is not very nice; it calls
> get_timer(start) in the while() loop, and then calls it again after
> the loop to check if a timeout error happened.
> 
> Because of the time difference between the two calls of get_time(),
> the reason detected after the loop may not be really true.

It makes sense. Looks good to me.
Tested with Exynos boards

Acked-by: Jaehoon Chung <jh80.chung@samsung.com>

Best Regards,
Jaehoon Chung

> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
> 
>  drivers/mmc/sdhci.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
> index 604f18d..0a1882d 100644
> --- a/drivers/mmc/sdhci.c
> +++ b/drivers/mmc/sdhci.c
> @@ -243,17 +243,17 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
>  		stat = sdhci_readl(host, SDHCI_INT_STATUS);
>  		if (stat & SDHCI_INT_ERROR)
>  			break;
> -	} while (((stat & mask) != mask) &&
> -		 (get_timer(start) < SDHCI_READ_STATUS_TIMEOUT));
>  
> -	if (get_timer(start) >= SDHCI_READ_STATUS_TIMEOUT) {
> -		if (host->quirks & SDHCI_QUIRK_BROKEN_R1B)
> -			return 0;
> -		else {
> -			printf("%s: Timeout for status update!\n", __func__);
> -			return TIMEOUT;
> +		if (get_timer(start) >= SDHCI_READ_STATUS_TIMEOUT) {
> +			if (host->quirks & SDHCI_QUIRK_BROKEN_R1B) {
> +				return 0;
> +			} else {
> +				printf("%s: Timeout for status update!\n",
> +				       __func__);
> +				return TIMEOUT;
> +			}
>  		}
> -	}
> +	} while ((stat & mask) != mask);
>  
>  	if ((stat & (SDHCI_INT_ERROR | mask)) == mask) {
>  		sdhci_cmd_done(host, cmd);
> 

      reply	other threads:[~2016-07-08 11:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20160708105736epcas1p12541f7c8db3d4804a0bd27b631ca3968@epcas1p1.samsung.com>
2016-07-08 10:58 ` [U-Boot] [PATCH] mmc: sdhci: clean up time out detection Masahiro Yamada
2016-07-08 11:10   ` Jaehoon Chung [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=577F8A25.8030508@samsung.com \
    --to=jh80.chung@samsung.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox