Skip to content

Commit 0e72f95

Browse files
linuswstorulf
authored andcommitted
mmc: core: refactor asynchronous request finalization
mmc_wait_for_data_req_done() is called in exactly one place, and having it spread out is making things hard to oversee. Factor this function into mmc_finalize_areq(). Reviewed-by: Bartlomiej Zolnierkiewicz <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
1 parent 5744d50 commit 0e72f95

File tree

1 file changed

+33
-53
lines changed

1 file changed

+33
-53
lines changed

drivers/mmc/core/core.c

Lines changed: 33 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -506,56 +506,6 @@ static int __mmc_start_req(struct mmc_host *host, struct mmc_request *mrq)
506506
return err;
507507
}
508508

509-
/*
510-
* mmc_wait_for_data_req_done() - wait for request completed
511-
* @host: MMC host to prepare the command.
512-
* @mrq: MMC request to wait for
513-
*
514-
* Blocks MMC context till host controller will ack end of data request
515-
* execution or new request notification arrives from the block layer.
516-
* Handles command retries.
517-
*
518-
* Returns enum mmc_blk_status after checking errors.
519-
*/
520-
static enum mmc_blk_status mmc_wait_for_data_req_done(struct mmc_host *host,
521-
struct mmc_request *mrq)
522-
{
523-
struct mmc_command *cmd;
524-
struct mmc_context_info *context_info = &host->context_info;
525-
enum mmc_blk_status status;
526-
527-
while (1) {
528-
wait_event_interruptible(context_info->wait,
529-
(context_info->is_done_rcv ||
530-
context_info->is_new_req));
531-
532-
if (context_info->is_done_rcv) {
533-
context_info->is_done_rcv = false;
534-
cmd = mrq->cmd;
535-
536-
if (!cmd->error || !cmd->retries ||
537-
mmc_card_removed(host->card)) {
538-
status = host->areq->err_check(host->card,
539-
host->areq);
540-
break; /* return status */
541-
} else {
542-
mmc_retune_recheck(host);
543-
pr_info("%s: req failed (CMD%u): %d, retrying...\n",
544-
mmc_hostname(host),
545-
cmd->opcode, cmd->error);
546-
cmd->retries--;
547-
cmd->error = 0;
548-
__mmc_start_request(host, mrq);
549-
continue; /* wait for done/new event again */
550-
}
551-
}
552-
553-
return MMC_BLK_NEW_REQUEST;
554-
}
555-
mmc_retune_release(host);
556-
return status;
557-
}
558-
559509
void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq)
560510
{
561511
struct mmc_command *cmd;
@@ -660,14 +610,44 @@ static void mmc_post_req(struct mmc_host *host, struct mmc_request *mrq,
660610
*/
661611
static enum mmc_blk_status mmc_finalize_areq(struct mmc_host *host)
662612
{
613+
struct mmc_context_info *context_info = &host->context_info;
663614
enum mmc_blk_status status;
664615

665616
if (!host->areq)
666617
return MMC_BLK_SUCCESS;
667618

668-
status = mmc_wait_for_data_req_done(host, host->areq->mrq);
669-
if (status == MMC_BLK_NEW_REQUEST)
670-
return status;
619+
while (1) {
620+
wait_event_interruptible(context_info->wait,
621+
(context_info->is_done_rcv ||
622+
context_info->is_new_req));
623+
624+
if (context_info->is_done_rcv) {
625+
struct mmc_command *cmd;
626+
627+
context_info->is_done_rcv = false;
628+
cmd = host->areq->mrq->cmd;
629+
630+
if (!cmd->error || !cmd->retries ||
631+
mmc_card_removed(host->card)) {
632+
status = host->areq->err_check(host->card,
633+
host->areq);
634+
break; /* return status */
635+
} else {
636+
mmc_retune_recheck(host);
637+
pr_info("%s: req failed (CMD%u): %d, retrying...\n",
638+
mmc_hostname(host),
639+
cmd->opcode, cmd->error);
640+
cmd->retries--;
641+
cmd->error = 0;
642+
__mmc_start_request(host, host->areq->mrq);
643+
continue; /* wait for done/new event again */
644+
}
645+
}
646+
647+
return MMC_BLK_NEW_REQUEST;
648+
}
649+
650+
mmc_retune_release(host);
671651

672652
/*
673653
* Check BKOPS urgency for each R1 response

0 commit comments

Comments
 (0)