From a1a8fe69668f5bf537941dd04647206a3f0af266 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lothar=20Wa=C3=9Fmann?= Date: Mon, 13 Mar 2017 11:19:51 +0100 Subject: [PATCH] mmc: fix data type of timer variables get_timer() returns an unsigned long value. This may be 64bit wide on 64bit archs. Storing this value in an unsigned int will cut off the upper half of the value leading to miscalculation of the elapsed time, if the upper 32bits of the current timestamp are non-zero. --- drivers/mmc/mmc.c | 4 ++-- drivers/mmc/sdhci.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index a7a5134529..c8fd3346d3 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -435,7 +435,7 @@ static int mmc_complete_op_cond(struct mmc *mmc) { struct mmc_cmd cmd; int timeout = 10 * CONFIG_SYS_HZ; - uint start; + unsigned long start; int err; mmc->op_cond_pending = 0; @@ -1684,7 +1684,7 @@ static int mmc_complete_init(struct mmc *mmc) int mmc_init(struct mmc *mmc) { int err = 0; - unsigned start; + unsigned long start; #ifdef CONFIG_DM_MMC struct mmc_uclass_priv *upriv = dev_get_uclass_priv(mmc->dev); diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index ad72e97f84..2ad6e80645 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -145,7 +145,7 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, u32 mask, flags, mode; unsigned int time = 0, start_addr = 0; int mmc_dev = mmc_get_blk_desc(mmc)->devnum; - unsigned start = get_timer(0); + unsigned long start = get_timer(0); /* Timeout unit - ms */ unsigned int cmd_timeout; -- 2.39.2