Commit b044b1bc authored by Shawn Lin's avatar Shawn Lin Committed by Ulf Hansson

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: default avatarShawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 1896f140
...@@ -295,10 +295,8 @@ static void mmc_mrq_pr_debug(struct mmc_host *host, struct mmc_request *mrq) ...@@ -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) static int mmc_mrq_prep(struct mmc_host *host, struct mmc_request *mrq)
{ {
#ifdef CONFIG_MMC_DEBUG unsigned int i, sz = 0;
unsigned int i, sz;
struct scatterlist *sg; struct scatterlist *sg;
#endif
if (mrq->cmd) { if (mrq->cmd) {
mrq->cmd->error = 0; mrq->cmd->error = 0;
...@@ -314,13 +312,12 @@ static int mmc_mrq_prep(struct mmc_host *host, struct mmc_request *mrq) ...@@ -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 > host->max_blk_count ||
mrq->data->blocks * mrq->data->blksz > host->max_req_size) mrq->data->blocks * mrq->data->blksz > host->max_req_size)
return -EINVAL; return -EINVAL;
#ifdef CONFIG_MMC_DEBUG
sz = 0;
for_each_sg(mrq->data->sg, sg, mrq->data->sg_len, i) for_each_sg(mrq->data->sg, sg, mrq->data->sg_len, i)
sz += sg->length; sz += sg->length;
if (sz != mrq->data->blocks * mrq->data->blksz) if (sz != mrq->data->blocks * mrq->data->blksz)
return -EINVAL; return -EINVAL;
#endif
mrq->data->error = 0; mrq->data->error = 0;
mrq->data->mrq = mrq; mrq->data->mrq = mrq;
if (mrq->stop) { if (mrq->stop) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment