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: 9564965 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 2910360236 for ; Thu, 9 Feb 2017 15:41:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16EA428537 for ; Thu, 9 Feb 2017 15:41:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0AEF52853C; Thu, 9 Feb 2017 15:41:06 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 866ED28537 for ; Thu, 9 Feb 2017 15:41:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751318AbdBIPlE (ORCPT ); Thu, 9 Feb 2017 10:41:04 -0500 Received: from mail-lf0-f45.google.com ([209.85.215.45]:33511 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751226AbdBIPlD (ORCPT ); Thu, 9 Feb 2017 10:41:03 -0500 Received: by mail-lf0-f45.google.com with SMTP id x1so4693142lff.0 for ; Thu, 09 Feb 2017 07:41:03 -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=CWEPyLV8SwKalEiIuc3ZesRZK5lI0kE5Cru5xB7j6l6u0X97lv5BV6NPS3epddLxQo OGrbFLHEYx772qinYVFhQAVoYGEYWs3SRnAVrCif5tHvp0IHeT1AsltzChyazjzfKDnF tWVCE3nu1dIr8hbnpFIKQfZiKroHac5J8w6LreLMBDj4R471Yh/A5hJ1EN51chc2u9Pn Ytxl3Q9Y4RxluAXewEED8qkRAywhlXKZh0IJ3yjBUCTOCieL5/bh855CCIAkAPYWba0f EIl3OKFTbvCS8rXFAYKciq96wO0UkKTdK5ERopo42cWz18YLqC5C/qXcdkJn2OGZBrhP orXQ== X-Gm-Message-State: AMke39lkKUNfLHgIQQkEoSYCN8MT2wOnvubOifkqE9NDLxNrIi0iU7LZ2nQkq5pgn0D8M9Lb 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-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@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);