From patchwork Thu Feb 9 15:33:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 9565079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B3BC9601C3 for ; Thu, 9 Feb 2017 16:38:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F0CF28576 for ; Thu, 9 Feb 2017 16:38:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FAE72857B; Thu, 9 Feb 2017 16:38:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BA8528576 for ; Thu, 9 Feb 2017 16:38:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753029AbdBIQij (ORCPT ); Thu, 9 Feb 2017 11:38:39 -0500 Received: from mail-lf0-f53.google.com ([209.85.215.53]:33142 "EHLO mail-lf0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752355AbdBIQii (ORCPT ); Thu, 9 Feb 2017 11:38:38 -0500 Received: by mail-lf0-f53.google.com with SMTP id x1so5739055lff.0 for ; Thu, 09 Feb 2017 08:37:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qz73lq1NQDQPVN270XPQxljELWQtHmR+4hg3oEAsqRQ=; b=Tkm7LkyQ24TZPHz5qij2GXX/sKE3RgvwiFP+OjbyWaAgtVOSH6nw+M5iuvHNIBO+fz 2musbu+jeC8T064Yc8+XCSqxdoK8lyKhgzag9L1fpw0xON3FXtYXm/66I1RrnaaLTQ5Z F8Ba2ngZxsnYlR1NDXdnQzAuXRGk0IxMHB7Ag= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qz73lq1NQDQPVN270XPQxljELWQtHmR+4hg3oEAsqRQ=; b=cyRbjfrcuDTd4ZYI4VvCguQwAnbbu37zgRJFZ3GEF3/05JiHe6aB9ExHEx4SlF+w++ O5TLeLmQ0AfY6RZybkaFhHOS2QXtH2oT9LP2v6vbU+oyHytq8cJOZdLsajHDSSFXxRLD OGdO5t2c5LH+Y57cHAR2Ug/yEMkrCQ6bVzcPWK68BKC3Q5oXlSDYZhT4WH0CZIQitDqD cuXhJVkd2fpRQUQOLBbHNajEcPIvnNLn174Idwx+LyKpiGYF0jlBFP7/1aGAoZFZtxZB lFkNxPol4wVknQFBKRUtzieQfSL3goO36eXRY8T140ELXAOBxMo7vTRcPHs4s23gQP1v e1SQ== X-Gm-Message-State: AMke39nksaq7oA/H3cydRpNSrcRY7FJX1Q+17CvrBOxzRooksKCWZjFZwOcvcMeYwt1lDnkR X-Received: by 10.25.199.66 with SMTP id x63mr1441861lff.161.1486654480398; Thu, 09 Feb 2017 07:34:40 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e86sm3670614lji.32.2017.02.09.07.34.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 07:34:39 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter , Paolo Valente Cc: Chunyan Zhang , Baolin Wang , linux-block@vger.kernel.org, Jens Axboe , Christoph Hellwig , Arnd Bergmann , Linus Walleij Subject: [PATCH 03/16] mmc: core: refactor mmc_request_done() Date: Thu, 9 Feb 2017 16:33:50 +0100 Message-Id: <20170209153403.9730-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170209153403.9730-1-linus.walleij@linaro.org> References: <20170209153403.9730-1-linus.walleij@linaro.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Linus Walleij Reviewed-by: Bartlomiej Zolnierkiewicz --- drivers/mmc/core/core.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index b2e7a6dfcbf0..8dbed198750f 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -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);