mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 1/3] mci: sdhci: atmel: don't print errors on command timeouts
Date: Tue, 23 Jun 2020 12:16:23 +0200	[thread overview]
Message-ID: <20200623101623.GC11869@pengutronix.de> (raw)
In-Reply-To: <20200623100846.21965-1-a.fatoum@pengutronix.de>

On Tue, Jun 23, 2020 at 12:08:44PM +0200, Ahmad Fatoum wrote:
> Time outs can be expected, e.g. when probing whether a card is a MMC
> one. The core handles it, so don't have the driver print an error.
> 
> While at it, simplify the error handling. We don't need to read the
> status more than once and returning -EPERM on non-timeout is what the
> other drivers are doing.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---

Applied, thanks

Sascha

> v1 -> v2:
>   no change
> ---
>  drivers/mci/atmel-sdhci-common.c | 40 ++++++++++++++++++--------------
>  1 file changed, 22 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/mci/atmel-sdhci-common.c b/drivers/mci/atmel-sdhci-common.c
> index b9524622620f..fff4468d71e8 100644
> --- a/drivers/mci/atmel-sdhci-common.c
> +++ b/drivers/mci/atmel-sdhci-common.c
> @@ -83,10 +83,10 @@ exit:
>  static int at91_sdhci_wait_for_done(struct at91_sdhci *host, u32 mask)
>  {
>  	struct sdhci *sdhci = &host->sdhci;
> -	u16 status;
> +	u32 status;
>  	int ret;
>  
> -	ret = sdhci_read16_poll_timeout(sdhci, SDHCI_INT_NORMAL_STATUS, status,
> +	ret = sdhci_read32_poll_timeout(sdhci, SDHCI_INT_STATUS, status,
>  					(status & mask) == mask || (status & SDHCI_INT_ERROR),
>  					USEC_PER_SEC);
>  
> @@ -95,13 +95,15 @@ static int at91_sdhci_wait_for_done(struct at91_sdhci *host, u32 mask)
>  		return ret;
>  	}
>  
> +	if (status & SDHCI_INT_TIMEOUT)
> +		return -ETIMEDOUT;
> +
>  	if (status & SDHCI_INT_ERROR) {
> -		pr_err("SDHCI_INT_ERROR: 0x%08x\n",
> -			sdhci_read16(sdhci, SDHCI_INT_ERROR_STATUS));
> +		pr_err("SDHCI_INT_STATUS: 0x%08x\n", status);
>  		return -EPERM;
>  	}
>  
> -	return status;
> +	return status & 0xFFFF;
>  }
>  
>  int at91_sdhci_send_command(struct at91_sdhci *host, struct mci_cmd *cmd,
> @@ -109,7 +111,8 @@ int at91_sdhci_send_command(struct at91_sdhci *host, struct mci_cmd *cmd,
>  {
>  	unsigned command, xfer;
>  	struct sdhci *sdhci = &host->sdhci;
> -	u32 mask, status, state;
> +	u32 mask, state;
> +	int status;
>  	int ret;
>  
>  	/* Wait for idle before next command */
> @@ -147,28 +150,29 @@ int at91_sdhci_send_command(struct at91_sdhci *host, struct mci_cmd *cmd,
>  	sdhci_write16(sdhci, SDHCI_COMMAND, command);
>  
>  	status = at91_sdhci_wait_for_done(host, mask);
> -	if (status >= 0 && (status & (SDHCI_INT_ERROR | mask)) == mask) {
> -		sdhci_read_response(sdhci, cmd);
> -		sdhci_write32(sdhci, SDHCI_INT_STATUS, mask);
> -
> -		if (data)
> -			sdhci_transfer_data(sdhci, data);
> +	if (status < 0)
> +		goto error;
>  
> -		udelay(1000);
> +	sdhci_read_response(sdhci, cmd);
> +	sdhci_write32(sdhci, SDHCI_INT_STATUS, mask);
>  
> -		status = sdhci_read32(sdhci, SDHCI_INT_STATUS);
> -		sdhci_write32(sdhci, SDHCI_INT_STATUS, ~0U);
> +	if (data)
> +		sdhci_transfer_data(sdhci, data);
>  
> -		return 0;
> -	}
> +	udelay(1000);
>  
>  	status = sdhci_read32(sdhci, SDHCI_INT_STATUS);
>  	sdhci_write32(sdhci, SDHCI_INT_STATUS, ~0U);
>  
> +	return 0;
> +
> +error:
> +	sdhci_write32(sdhci, SDHCI_INT_STATUS, ~0U);
> +
>  	sdhci_reset(sdhci, SDHCI_RESET_CMD);
>  	sdhci_reset(sdhci, SDHCI_RESET_DATA);
>  
> -	return status & SDHCI_INT_TIMEOUT ? -ETIMEDOUT : -ECOMM;
> +	return status;
>  }
>  
>  static void at91_sdhci_set_power(struct at91_sdhci *host, unsigned vdd)
> -- 
> 2.27.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2020-06-23 10:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23 10:08 Ahmad Fatoum
2020-06-23 10:08 ` [PATCH v2 2/3] mci: sdhci: atmel: use dev_printf instead of pr_print in common code Ahmad Fatoum
2020-06-23 10:08 ` [PATCH v2 3/3] mci: sdhci: atmel: avoid buggy SDHCI_RESET_ALL Ahmad Fatoum
2020-06-23 10:16 ` Sascha Hauer [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=20200623101623.GC11869@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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