* [PATCH] mmc: sdhci-of-esdhc: poll ESDHC_CLOCK_STABLE bit with udelay
@ 2017-04-26 2:45 Yangbo Lu
2017-04-26 6:02 ` Adrian Hunter
2017-04-28 12:53 ` Ulf Hansson
0 siblings, 2 replies; 3+ messages in thread
From: Yangbo Lu @ 2017-04-26 2:45 UTC (permalink / raw)
To: linux-mmc, ulf.hansson, Adrian Hunter; +Cc: Xiaobo Xie, Yangbo Lu
The loop to poll ESDHC_CLOCK_STABLE bit with mdelay would waste time
because the time to stabilize is much less than 1 ms. This patch is
to use udelay instead to avoid time wasting.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
drivers/mmc/host/sdhci-of-esdhc.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index 7518360..77dfc59 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -445,7 +445,7 @@ static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)
struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host);
int pre_div = 1;
int div = 1;
- u32 timeout;
+ ktime_t timeout;
u32 temp;
host->mmc->actual_clock = 0;
@@ -489,15 +489,14 @@ static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)
sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
/* Wait max 20 ms */
- timeout = 20;
+ timeout = ktime_add_ms(ktime_get(), 20);
while (!(sdhci_readl(host, ESDHC_PRSSTAT) & ESDHC_CLOCK_STABLE)) {
- if (timeout == 0) {
+ if (ktime_after(ktime_get(), timeout)) {
pr_err("%s: Internal clock never stabilised.\n",
mmc_hostname(host->mmc));
return;
}
- timeout--;
- mdelay(1);
+ udelay(10);
}
temp |= ESDHC_CLOCK_SDCLKEN;
--
2.1.0.27.g96db324
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mmc: sdhci-of-esdhc: poll ESDHC_CLOCK_STABLE bit with udelay
2017-04-26 2:45 [PATCH] mmc: sdhci-of-esdhc: poll ESDHC_CLOCK_STABLE bit with udelay Yangbo Lu
@ 2017-04-26 6:02 ` Adrian Hunter
2017-04-28 12:53 ` Ulf Hansson
1 sibling, 0 replies; 3+ messages in thread
From: Adrian Hunter @ 2017-04-26 6:02 UTC (permalink / raw)
To: Yangbo Lu, linux-mmc, ulf.hansson; +Cc: Xiaobo Xie
On 26/04/17 05:45, Yangbo Lu wrote:
> The loop to poll ESDHC_CLOCK_STABLE bit with mdelay would waste time
> because the time to stabilize is much less than 1 ms. This patch is
> to use udelay instead to avoid time wasting.
>
> Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> drivers/mmc/host/sdhci-of-esdhc.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
> index 7518360..77dfc59 100644
> --- a/drivers/mmc/host/sdhci-of-esdhc.c
> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> @@ -445,7 +445,7 @@ static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)
> struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host);
> int pre_div = 1;
> int div = 1;
> - u32 timeout;
> + ktime_t timeout;
> u32 temp;
>
> host->mmc->actual_clock = 0;
> @@ -489,15 +489,14 @@ static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)
> sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
>
> /* Wait max 20 ms */
> - timeout = 20;
> + timeout = ktime_add_ms(ktime_get(), 20);
> while (!(sdhci_readl(host, ESDHC_PRSSTAT) & ESDHC_CLOCK_STABLE)) {
> - if (timeout == 0) {
> + if (ktime_after(ktime_get(), timeout)) {
> pr_err("%s: Internal clock never stabilised.\n",
> mmc_hostname(host->mmc));
> return;
> }
> - timeout--;
> - mdelay(1);
> + udelay(10);
> }
>
> temp |= ESDHC_CLOCK_SDCLKEN;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mmc: sdhci-of-esdhc: poll ESDHC_CLOCK_STABLE bit with udelay
2017-04-26 2:45 [PATCH] mmc: sdhci-of-esdhc: poll ESDHC_CLOCK_STABLE bit with udelay Yangbo Lu
2017-04-26 6:02 ` Adrian Hunter
@ 2017-04-28 12:53 ` Ulf Hansson
1 sibling, 0 replies; 3+ messages in thread
From: Ulf Hansson @ 2017-04-28 12:53 UTC (permalink / raw)
To: Yangbo Lu; +Cc: linux-mmc, Adrian Hunter, Xiaobo Xie
On 26 April 2017 at 04:45, Yangbo Lu <yangbo.lu@nxp.com> wrote:
> The loop to poll ESDHC_CLOCK_STABLE bit with mdelay would waste time
> because the time to stabilize is much less than 1 ms. This patch is
> to use udelay instead to avoid time wasting.
>
> Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Thanks, applied for next!
Kind regards
Uffe
> ---
> drivers/mmc/host/sdhci-of-esdhc.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
> index 7518360..77dfc59 100644
> --- a/drivers/mmc/host/sdhci-of-esdhc.c
> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> @@ -445,7 +445,7 @@ static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)
> struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host);
> int pre_div = 1;
> int div = 1;
> - u32 timeout;
> + ktime_t timeout;
> u32 temp;
>
> host->mmc->actual_clock = 0;
> @@ -489,15 +489,14 @@ static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)
> sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
>
> /* Wait max 20 ms */
> - timeout = 20;
> + timeout = ktime_add_ms(ktime_get(), 20);
> while (!(sdhci_readl(host, ESDHC_PRSSTAT) & ESDHC_CLOCK_STABLE)) {
> - if (timeout == 0) {
> + if (ktime_after(ktime_get(), timeout)) {
> pr_err("%s: Internal clock never stabilised.\n",
> mmc_hostname(host->mmc));
> return;
> }
> - timeout--;
> - mdelay(1);
> + udelay(10);
> }
>
> temp |= ESDHC_CLOCK_SDCLKEN;
> --
> 2.1.0.27.g96db324
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-04-28 12:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-26 2:45 [PATCH] mmc: sdhci-of-esdhc: poll ESDHC_CLOCK_STABLE bit with udelay Yangbo Lu
2017-04-26 6:02 ` Adrian Hunter
2017-04-28 12:53 ` Ulf Hansson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.