mmc: core: add wrapper for timeout value
authorShawn Lin <shawn.lin@rock-chips.com>
Fri, 22 May 2015 09:39:26 +0000 (17:39 +0800)
committerShawn Lin <shawn.lin@rock-chips.com>
Fri, 22 May 2015 09:41:04 +0000 (17:41 +0800)
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
cc: Xiao yao <xiaoyao@rock-chips.com>

drivers/mmc/core/core.c

index 012de1e5aedc9649b95acb9ab8a79e34971699a4..df838e5267486ab42e13263eb7d0eb465be7d363 100755 (executable)
@@ -34,6 +34,7 @@
 #include <linux/mmc/host.h>
 #include <linux/mmc/mmc.h>
 #include <linux/mmc/sd.h>
+#include <linux/mmc/sdio.h>
 
 #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))) {