Skip to content

Commit 7c8a282

Browse files
perforcjb
authored andcommitted
mmc: core: clarify how to use post_req in case of errors
The err condition in post_req() is set to undo a call made to pre_req() that hasn't been started yet. The err condition is not set if an MMC request returns an error. Signed-off-by: Per Forlin <per.forlin@linaro.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Chris Ball <cjb@laptop.org>
1 parent 4466903 commit 7c8a282

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎drivers/mmc/core/core.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,14 @@ struct mmc_async_req *mmc_start_req(struct mmc_host *host,
320320
mmc_wait_for_req_done(host, host->areq->mrq);
321321
err = host->areq->err_check(host->card, host->areq);
322322
if (err) {
323+
/* post process the completed failed request */
323324
mmc_post_req(host, host->areq->mrq, 0);
324325
if (areq)
326+
/*
327+
* Cancel the new prepared request, because
328+
* it can't run until the failed
329+
* request has been properly handled.
330+
*/
325331
mmc_post_req(host, areq->mrq, -EINVAL);
326332

327333
host->areq = NULL;

‎include/linux/mmc/host.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ struct mmc_host_ops {
109109
* It is optional for the host to implement pre_req and post_req in
110110
* order to support double buffering of requests (prepare one
111111
* request while another request is active).
112+
* pre_req() must always be followed by a post_req().
113+
* To undo a call made to pre_req(), call post_req() with
114+
* a nonzero err condition.
112115
*/
113116
void (*post_req)(struct mmc_host *host, struct mmc_request *req,
114117
int err);

0 commit comments

Comments
 (0)