From 6e719a67ff9d62a40bb9bd5f40989c2a934e1067 Mon Sep 17 00:00:00 2001 From: Shawn Lin Date: Fri, 22 May 2015 17:39:26 +0800 Subject: [PATCH] mmc: core: add wrapper for timeout value Signed-off-by: Shawn Lin cc: Xiao yao --- drivers/mmc/core/core.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 012de1e5aedc..df838e526748 100755 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "core.h" #include "bus.h" @@ -432,29 +433,37 @@ static int mmc_wait_for_data_req_done(struct mmc_host *host, return err; } -static void mmc_wait_for_req_done(struct mmc_host *host, - struct mmc_request *mrq) +static void mmc_get_req_timeout(struct mmc_request *mrq, u32 *timeout) { - struct mmc_command *cmd; - u32 timeout = 0; - if (!mrq->cmd->data) { if (mrq->cmd->opcode == MMC_ERASE || (mrq->cmd->opcode == MMC_ERASE_GROUP_START) || (mrq->cmd->opcode == MMC_ERASE_GROUP_END) || (mrq->cmd->opcode == MMC_SEND_STATUS)) - timeout = 2500000; + *timeout = 2500000; else - timeout = 500; + *timeout = 500; } else { - timeout = mrq->cmd->data->blocks * + *timeout = mrq->cmd->data->blocks * mrq->cmd->data->blksz * 500; - - timeout = timeout ? timeout : 1000; - if (timeout > 8000) - timeout = 8000; + *timeout = (*timeout) ? (*timeout) : 1000; + if (*timeout > 8000) + *timeout = 8000; } + if ((mrq->cmd->opcode == SD_IO_RW_DIRECT) || + (mrq->cmd->opcode == SD_IO_RW_EXTENDED)) + *timeout = 8000; +} + +static void mmc_wait_for_req_done(struct mmc_host *host, + struct mmc_request *mrq) +{ + struct mmc_command *cmd; + u32 timeout = 0; + + mmc_get_req_timeout(mrq, &timeout); + while (1) { if (!wait_for_completion_timeout(&mrq->completion, msecs_to_jiffies(timeout))) { -- 2.34.1