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

From: Grant Grundler
Date: Thu Sep 26 2013 - 15:23:51 EST


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@xxxxxxxxxxxx>
---
drivers/mmc/core/core.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)

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;
--
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/