summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Lin <shawn.lin@rock-chips.com>2017-07-19 15:55:45 +0800
committerUlf Hansson <ulf.hansson@linaro.org>2017-08-30 14:01:33 +0200
commitb044b1bcc5de194688c33e5911b96ee93fd9ce48 (patch)
treef43863fd39fe976411b8a225d2dff863260f5b84
parent1896f14006b28a7ed6881666d18a244827af0a5b (diff)
mmc: core: always check the length of sglist with total data size
All the check within mmc_mrq_prep seems to be all-or-none proposition, so it doesn't make sense to only check the length of sglist only under the CONFIG_MMC_DEBUG context. I'd prefer to always keep the check there unconditionally. Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/core/core.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index b311ec974c6a..634f9caecb88 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -295,10 +295,8 @@ static void mmc_mrq_pr_debug(struct mmc_host *host, struct mmc_request *mrq)
static int mmc_mrq_prep(struct mmc_host *host, struct mmc_request *mrq)
{
-#ifdef CONFIG_MMC_DEBUG
- unsigned int i, sz;
+ unsigned int i, sz = 0;
struct scatterlist *sg;
-#endif
if (mrq->cmd) {
mrq->cmd->error = 0;
@@ -314,13 +312,12 @@ static int mmc_mrq_prep(struct mmc_host *host, struct mmc_request *mrq)
mrq->data->blocks > host->max_blk_count ||
mrq->data->blocks * mrq->data->blksz > host->max_req_size)
return -EINVAL;
-#ifdef CONFIG_MMC_DEBUG
- sz = 0;
+
for_each_sg(mrq->data->sg, sg, mrq->data->sg_len, i)
sz += sg->length;
if (sz != mrq->data->blocks * mrq->data->blksz)
return -EINVAL;
-#endif
+
mrq->data->error = 0;
mrq->data->mrq = mrq;
if (mrq->stop) {