Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: sdhci-of-at91: replace while loop with read_poll_timeout

Replace while loop with read_poll_timeout().

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20210924082851.2132068-3-claudiu.beznea@microchip.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Claudiu Beznea and committed by
Ulf Hansson
30d4b990 af467fad

+5 -11
+5 -11
drivers/mmc/host/sdhci-of-at91.c
··· 62 62 static void sdhci_at91_set_clock(struct sdhci_host *host, unsigned int clock) 63 63 { 64 64 u16 clk; 65 - unsigned long timeout; 66 65 67 66 host->mmc->actual_clock = 0; 68 67 ··· 86 87 sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); 87 88 88 89 /* Wait max 20 ms */ 89 - timeout = 20; 90 - while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL)) 91 - & SDHCI_CLOCK_INT_STABLE)) { 92 - if (timeout == 0) { 93 - pr_err("%s: Internal clock never stabilised.\n", 94 - mmc_hostname(host->mmc)); 95 - return; 96 - } 97 - timeout--; 98 - mdelay(1); 90 + if (read_poll_timeout(sdhci_readw, clk, (clk & SDHCI_CLOCK_INT_STABLE), 91 + 1000, 20000, false, host, SDHCI_CLOCK_CONTROL)) { 92 + pr_err("%s: Internal clock never stabilised.\n", 93 + mmc_hostname(host->mmc)); 94 + return; 99 95 } 100 96 101 97 clk |= SDHCI_CLOCK_CARD_EN;