Skip to content

Commit 67b8360

Browse files
linuswstorulf
authored andcommitted
mmc: core: refactor mmc_request_done()
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 <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
1 parent 0e72f95 commit 67b8360

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

drivers/mmc/core/core.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,16 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
172172

173173
trace_mmc_request_done(host, mrq);
174174

175-
if (err && cmd->retries && !mmc_card_removed(host->card)) {
176-
/*
177-
* Request starter must handle retries - see
178-
* mmc_wait_for_req_done().
179-
*/
180-
if (mrq->done)
181-
mrq->done(mrq);
182-
} else {
175+
/*
176+
* We list various conditions for the command to be considered
177+
* properly done:
178+
*
179+
* - There was no error, OK fine then
180+
* - We are not doing some kind of retry
181+
* - The card was removed (...so just complete everything no matter
182+
* if there are errors or retries)
183+
*/
184+
if (!err || !cmd->retries || mmc_card_removed(host->card)) {
183185
mmc_should_fail_request(host, mrq);
184186

185187
if (!host->ongoing_mrq)
@@ -211,10 +213,13 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
211213
mrq->stop->resp[0], mrq->stop->resp[1],
212214
mrq->stop->resp[2], mrq->stop->resp[3]);
213215
}
214-
215-
if (mrq->done)
216-
mrq->done(mrq);
217216
}
217+
/*
218+
* Request starter must handle retries - see
219+
* mmc_wait_for_req_done().
220+
*/
221+
if (mrq->done)
222+
mrq->done(mrq);
218223
}
219224

220225
EXPORT_SYMBOL(mmc_request_done);

0 commit comments

Comments
 (0)