1 From 60c8f783a18feb95ad967c87e9660caf09fb4700 Mon Sep 17 00:00:00 2001
2 From: Ludovic Desroches <ludovic.desroches@atmel.com>
3 Date: Wed, 6 May 2015 15:16:46 +0200
4 Subject: mmc: atmel-mci: fix bad variable type for clkdiv
6 From: Ludovic Desroches <ludovic.desroches@atmel.com>
8 commit 60c8f783a18feb95ad967c87e9660caf09fb4700 upstream.
10 clkdiv is declared as an u32 but it can be set to a negative value
11 causing a huge divisor value. Change its type to int to avoid this case.
13 Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
14 Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18 drivers/mmc/host/atmel-mci.c | 9 +++++++--
19 1 file changed, 7 insertions(+), 2 deletions(-)
21 --- a/drivers/mmc/host/atmel-mci.c
22 +++ b/drivers/mmc/host/atmel-mci.c
23 @@ -1300,7 +1300,7 @@ static void atmci_set_ios(struct mmc_hos
26 unsigned int clock_min = ~0U;
30 clk_prepare(host->mck);
32 @@ -1329,7 +1329,12 @@ static void atmci_set_ios(struct mmc_hos
33 /* Calculate clock divider */
34 if (host->caps.has_odd_clk_div) {
35 clkdiv = DIV_ROUND_UP(host->bus_hz, clock_min) - 2;
38 + dev_warn(&mmc->class_dev,
39 + "clock %u too fast; using %lu\n",
40 + clock_min, host->bus_hz / 2);
42 + } else if (clkdiv > 511) {
43 dev_warn(&mmc->class_dev,
44 "clock %u too slow; using %lu\n",
45 clock_min, host->bus_hz / (511 + 2));