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: 93730 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp83559obz; Thu, 9 Feb 2017 07:41:05 -0800 (PST) X-Received: by 10.99.48.68 with SMTP id w65mr4690743pgw.107.1486654865372; Thu, 09 Feb 2017 07:41:05 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7si10324262pgn.352.2017.02.09.07.41.05; Thu, 09 Feb 2017 07:41:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751318AbdBIPlE (ORCPT + 5 others); 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 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 --- drivers/mmc/core/core.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Bartlomiej Zolnierkiewicz 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);