]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
mmc: sdhci-of-aspeed: Fix clock divider calculation
authorEddie James <eajames@linux.ibm.com>
Thu, 9 Jul 2020 19:57:06 +0000 (14:57 -0500)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 13 Jul 2020 10:17:34 +0000 (12:17 +0200)
When calculating the clock divider, start dividing at 2 instead of 1.
The divider is divided by two at the end of the calculation, so starting
at 1 may result in a divider of 0, which shouldn't happen.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
Acked-by: Joel Stanley <joel@jms.id.au>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Link: https://lore.kernel.org/r/20200709195706.12741-3-eajames@linux.ibm.com
Cc: stable@vger.kernel.org # v5.4+
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/sdhci-of-aspeed.c

index 56912e30c47ec64c7ce2050c42cfb91241497827..a1bcc0f4ba9e4e19e79c050a627c12a11493810d 100644 (file)
@@ -68,7 +68,7 @@ static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
        if (WARN_ON(clock > host->max_clk))
                clock = host->max_clk;
 
-       for (div = 1; div < 256; div *= 2) {
+       for (div = 2; div < 256; div *= 2) {
                if ((parent / div) <= clock)
                        break;
        }