Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <b.zolnierkie@samsung.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Linus Walleij and committed by
Ulf Hansson
67b8360a 0e72f95b

+16 -11
+16 -11
drivers/mmc/core/core.c
··· 172 172 173 173 trace_mmc_request_done(host, mrq); 174 174 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)) { 183 185 mmc_should_fail_request(host, mrq); 184 186 185 187 if (!host->ongoing_mrq) ··· 213 211 mrq->stop->resp[0], mrq->stop->resp[1], 214 212 mrq->stop->resp[2], mrq->stop->resp[3]); 215 213 } 216 - 217 - if (mrq->done) 218 - mrq->done(mrq); 219 214 } 215 + /* 216 + * Request starter must handle retries - see 217 + * mmc_wait_for_req_done(). 218 + */ 219 + if (mrq->done) 220 + mrq->done(mrq); 220 221 } 221 222 222 223 EXPORT_SYMBOL(mmc_request_done);