diff mbox

[3/7] mmc: core: restructure error handling for start req

Message ID 1380223380-22451-4-git-send-email-grundler@chromium.org (mailing list archive)
State New, archived
Headers show

Commit Message

Grant Grundler Sept. 26, 2013, 7:22 p.m. UTC
This is an intermediate step to fixing the locking around the
access to host->areq. Reduce the number of "if (saved_areq) vs
"if (areq)" tests in the main code path since I'm going to add
references to "host->lock" in the next patch.

Signed-off-by: Grant Grundler <grundler@chromium.org>
---
 drivers/mmc/core/core.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 675139e..4d5de98 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -556,21 +556,20 @@  struct mmc_async_req *mmc_start_req(struct mmc_host *host,
 			mmc_start_bkops(host->card, true);
 	}
 
-	if (!saved_err && areq)
+	/* Don't start something new if previous one failed. */
+	if (!saved_err && areq) {
 		start_err = __mmc_start_data_req(host, areq->mrq);
+		/* Cancel a prepared request if it was not started. */
+		if (start_err) {
+			mmc_post_req(host, areq->mrq, -EINVAL);
+			host->areq = NULL;
+		} else 
+			host->areq = areq;
+	}
 
 	if (saved_areq)
 		mmc_post_req(host, saved_areq->mrq, 0);
 
-	 /* Cancel a prepared request if it was not started. */
-	if ((saved_err || start_err) && areq)
-		mmc_post_req(host, areq->mrq, -EINVAL);
-
-	if (saved_err)
-		host->areq = NULL;
-	else
-		host->areq = areq;
-
 	if (error)
 		*error = saved_err;
 	return saved_areq;