From: Nicolas Ferre <nicolas.ferre@atmel.com>
To: ludovic.desroches@atmel.com
Cc: linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 1/3] mmc: atmel-mci: correct data timeout computation
Date: Wed, 28 Mar 2012 13:44:37 +0200 [thread overview]
Message-ID: <4F72F9A5.60900@atmel.com> (raw)
In-Reply-To: <1332930513-14893-1-git-send-email-ludovic.desroches@atmel.com>
On 03/28/2012 12:28 PM, ludovic.desroches@atmel.com :
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
>
> The HSMCI operates at a rate of up to Master Clock divided by two.
> Moreover previous calculation can cause overflows and so wrong
> timeouts.
>
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> Cc: stable <stable@vger.kernel.org>
> ---
> drivers/mmc/host/atmel-mci.c | 9 ++++++++-
> 1 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index e4449a5..3a57964 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -480,7 +480,14 @@ err:
> static inline unsigned int atmci_ns_to_clocks(struct atmel_mci *host,
> unsigned int ns)
> {
> - return (ns * (host->bus_hz / 1000000) + 999) / 1000;
> + /*
> + * It is easier here to use us instead of ns for the timeout,
> + * it prevents from overflows during calculation.
> + */
> + unsigned int us = DIV_ROUND_UP(ns, 1000);
> +
> + /* Maximum clock frequency is host->bus_hz/2 */
> + return us * (DIV_ROUND_UP(host->bus_hz, 2000000));
> }
>
> static void atmci_set_timeout(struct atmel_mci *host,
--
Nicolas Ferre
next prev parent reply other threads:[~2012-03-28 11:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-21 15:41 [PATCH 0/3] atmel-mci fixes ludovic.desroches
2012-03-21 15:41 ` [PATCH 1/3] mmc: atmel-mci: correct data timeout computation ludovic.desroches
2012-03-21 16:26 ` Sergei Shtylyov
2012-03-22 8:57 ` Ludovic Desroches
2012-03-28 10:28 ` [PATCH v2 " ludovic.desroches
2012-03-28 11:44 ` Nicolas Ferre [this message]
2012-04-01 3:43 ` Chris Ball
2012-03-21 15:41 ` [PATCH 2/3] mmc: atmel-mci: r/w proof capability only available since v2xx ludovic.desroches
2012-03-22 14:44 ` Nicolas Ferre
2012-04-01 3:43 ` Chris Ball
2012-03-21 15:41 ` [PATCH 3/3] mmc: atmel-mci: add support for odd clock dividers ludovic.desroches
2012-03-22 14:48 ` Nicolas Ferre
2012-04-01 3:44 ` Chris Ball
2012-04-02 6:52 ` Ludovic Desroches
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=4F72F9A5.60900@atmel.com \
--to=nicolas.ferre@atmel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ludovic.desroches@atmel.com \
/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