Skip to content

Commit f34bdd2

Browse files
ahunter6storulf
authored andcommitted
mmc: core: Factor out mrq preparation from mmc_start_request()
In preparation to reuse the code for CQE support. Signed-off-by: Adrian Hunter <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
1 parent 4b67e63 commit f34bdd2

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

drivers/mmc/core/core.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -292,23 +292,18 @@ static void mmc_mrq_pr_debug(struct mmc_host *host, struct mmc_request *mrq)
292292
}
293293
}
294294

295-
static int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
295+
static int mmc_mrq_prep(struct mmc_host *host, struct mmc_request *mrq)
296296
{
297297
#ifdef CONFIG_MMC_DEBUG
298298
unsigned int i, sz;
299299
struct scatterlist *sg;
300300
#endif
301-
mmc_retune_hold(host);
302-
303-
if (mmc_card_removed(host->card))
304-
return -ENOMEDIUM;
305-
306-
mmc_mrq_pr_debug(host, mrq);
307-
308-
WARN_ON(!host->claimed);
309301

310-
mrq->cmd->error = 0;
311-
mrq->cmd->mrq = mrq;
302+
if (mrq->cmd) {
303+
mrq->cmd->error = 0;
304+
mrq->cmd->mrq = mrq;
305+
mrq->cmd->data = mrq->data;
306+
}
312307
if (mrq->sbc) {
313308
mrq->sbc->error = 0;
314309
mrq->sbc->mrq = mrq;
@@ -325,8 +320,6 @@ static int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
325320
if (sz != mrq->data->blocks * mrq->data->blksz)
326321
return -EINVAL;
327322
#endif
328-
329-
mrq->cmd->data = mrq->data;
330323
mrq->data->error = 0;
331324
mrq->data->mrq = mrq;
332325
if (mrq->stop) {
@@ -335,6 +328,27 @@ static int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
335328
mrq->stop->mrq = mrq;
336329
}
337330
}
331+
332+
return 0;
333+
}
334+
335+
static int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
336+
{
337+
int err;
338+
339+
mmc_retune_hold(host);
340+
341+
if (mmc_card_removed(host->card))
342+
return -ENOMEDIUM;
343+
344+
mmc_mrq_pr_debug(host, mrq);
345+
346+
WARN_ON(!host->claimed);
347+
348+
err = mmc_mrq_prep(host, mrq);
349+
if (err)
350+
return err;
351+
338352
led_trigger_event(host->led, LED_FULL);
339353
__mmc_start_request(host, mrq);
340354

0 commit comments

Comments
 (0)