aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/host
diff options
context:
space:
mode:
authorLudovic Desroches <ludovic.desroches@atmel.com>2015-05-06 09:16:46 -0400
committerUlf Hansson <ulf.hansson@linaro.org>2015-05-18 03:04:42 -0400
commit60c8f783a18feb95ad967c87e9660caf09fb4700 (patch)
tree11da018d6c00c891e59a37cb6f83867fad098642 /drivers/mmc/host
parent030bbdbf4c833bc69f502eae58498bc5572db736 (diff)
mmc: atmel-mci: fix bad variable type for clkdiv
clkdiv is declared as an u32 but it can be set to a negative value causing a huge divisor value. Change its type to int to avoid this case. Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> Cc: <stable@vger.kernel.org> # 3.4 and later Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc/host')
-rw-r--r--drivers/mmc/host/atmel-mci.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 03d7c7521d97..9a39e0b7e583 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -1304,7 +1304,7 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1304 1304
1305 if (ios->clock) { 1305 if (ios->clock) {
1306 unsigned int clock_min = ~0U; 1306 unsigned int clock_min = ~0U;
1307 u32 clkdiv; 1307 int clkdiv;
1308 1308
1309 spin_lock_bh(&host->lock); 1309 spin_lock_bh(&host->lock);
1310 if (!host->mode_reg) { 1310 if (!host->mode_reg) {
@@ -1328,7 +1328,12 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1328 /* Calculate clock divider */ 1328 /* Calculate clock divider */
1329 if (host->caps.has_odd_clk_div) { 1329 if (host->caps.has_odd_clk_div) {
1330 clkdiv = DIV_ROUND_UP(host->bus_hz, clock_min) - 2; 1330 clkdiv = DIV_ROUND_UP(host->bus_hz, clock_min) - 2;
1331 if (clkdiv > 511) { 1331 if (clkdiv < 0) {
1332 dev_warn(&mmc->class_dev,
1333 "clock %u too fast; using %lu\n",
1334 clock_min, host->bus_hz / 2);
1335 clkdiv = 0;
1336 } else if (clkdiv > 511) {
1332 dev_warn(&mmc->class_dev, 1337 dev_warn(&mmc->class_dev,
1333 "clock %u too slow; using %lu\n", 1338 "clock %u too slow; using %lu\n",
1334 clock_min, host->bus_hz / (511 + 2)); 1339 clock_min, host->bus_hz / (511 + 2));