Skip to content

Commit 30d4b99

Browse files
claudiubezneastorulf
authored andcommitted
mmc: sdhci-of-at91: replace while loop with read_poll_timeout
Replace while loop with read_poll_timeout(). Signed-off-by: Claudiu Beznea <[email protected]> Acked-by: Adrian Hunter <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent af467fa commit 30d4b99

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

drivers/mmc/host/sdhci-of-at91.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ static void sdhci_at91_set_force_card_detect(struct sdhci_host *host)
6262
static void sdhci_at91_set_clock(struct sdhci_host *host, unsigned int clock)
6363
{
6464
u16 clk;
65-
unsigned long timeout;
6665

6766
host->mmc->actual_clock = 0;
6867

@@ -87,16 +86,11 @@ static void sdhci_at91_set_clock(struct sdhci_host *host, unsigned int clock)
8786
sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
8887

8988
/* Wait max 20 ms */
90-
timeout = 20;
91-
while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL))
92-
& SDHCI_CLOCK_INT_STABLE)) {
93-
if (timeout == 0) {
94-
pr_err("%s: Internal clock never stabilised.\n",
95-
mmc_hostname(host->mmc));
96-
return;
97-
}
98-
timeout--;
99-
mdelay(1);
89+
if (read_poll_timeout(sdhci_readw, clk, (clk & SDHCI_CLOCK_INT_STABLE),
90+
1000, 20000, false, host, SDHCI_CLOCK_CONTROL)) {
91+
pr_err("%s: Internal clock never stabilised.\n",
92+
mmc_hostname(host->mmc));
93+
return;
10094
}
10195

10296
clk |= SDHCI_CLOCK_CARD_EN;

0 commit comments

Comments
 (0)