mmc: core: refactor mmc_request_done()
authorLinus Walleij <linus.walleij@linaro.org>
Tue, 28 Mar 2017 08:40:31 +0000 (10:40 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 24 Apr 2017 19:42:08 +0000 (21:42 +0200)
We have this construction:

if (a && b && !c)
   finalize;
else
   block;
   finalize;

Which is equivalent by boolean logic to:

if (!a || !b || c)
   block;
finalize;

Which is simpler code.

Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/core.c

index d6831dc05d98b8126f548086ac685a55d8460591..0bb39795d48497f5b66bcdce0ed8d89c56aded24 100644 (file)
@@ -172,14 +172,16 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
 
        trace_mmc_request_done(host, mrq);
 
-       if (err && cmd->retries && !mmc_card_removed(host->card)) {
-               /*
-                * Request starter must handle retries - see
-                * mmc_wait_for_req_done().
-                */
-               if (mrq->done)
-                       mrq->done(mrq);
-       } else {
+       /*
+        * We list various conditions for the command to be considered
+        * properly done:
+        *
+        * - There was no error, OK fine then
+        * - We are not doing some kind of retry
+        * - The card was removed (...so just complete everything no matter
+        *   if there are errors or retries)
+        */
+       if (!err || !cmd->retries || mmc_card_removed(host->card)) {
                mmc_should_fail_request(host, mrq);
 
                if (!host->ongoing_mrq)
@@ -211,10 +213,13 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
                                mrq->stop->resp[0], mrq->stop->resp[1],
                                mrq->stop->resp[2], mrq->stop->resp[3]);
                }
-
-               if (mrq->done)
-                       mrq->done(mrq);
        }
+       /*
+        * Request starter must handle retries - see
+        * mmc_wait_for_req_done().
+        */
+       if (mrq->done)
+               mrq->done(mrq);
 }
 
 EXPORT_SYMBOL(mmc_request_done);