From patchwork Tue Mar 28 08:40:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 9648371 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 98802601D7 for ; Tue, 28 Mar 2017 08:42:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C56720855 for ; Tue, 28 Mar 2017 08:42:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 802A528338; Tue, 28 Mar 2017 08:42:01 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 EA70220855 for ; Tue, 28 Mar 2017 08:42:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754563AbdC1Ila (ORCPT ); Tue, 28 Mar 2017 04:41:30 -0400 Received: from mail-lf0-f45.google.com ([209.85.215.45]:33821 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754678AbdC1Il3 (ORCPT ); Tue, 28 Mar 2017 04:41:29 -0400 Received: by mail-lf0-f45.google.com with SMTP id z15so33934770lfd.1 for ; Tue, 28 Mar 2017 01:40:53 -0700 (PDT) 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=8N3VKfwaZhhOGWfaoUMVbFf50ocncLdFHhWvQCIjahY=; b=Z0I+o1NzmmUz7REhsFRm91rvYeLo3g1AoNrcnW0XGrFdwfWyKIQZd/9kwtbkfk4fTM 9UVmZLCi8fHZl2G26838Hcvk3MQwYyQrWa7xhar25r9zBO1Zp6FvsPHm/6X3T9PMKHdq KdRkBS/sXFkQMQ1yc/YBmEoRmVUc3hEWRI1yE= 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=8N3VKfwaZhhOGWfaoUMVbFf50ocncLdFHhWvQCIjahY=; b=TQMzK0T5YYsUc074vBpIl8t+VKH00rxn2UixXPHpa6c2j/Alji5LanrKJkePWPBdlo XYIXKRpyW7fdxShVs1faHGS3Xjas+0BBP/xMPI20dlMMiM/2z+RWjcSs6ysLd+pZOXIa 6X9lKqP28+nMDFo2xMNIGziokadmB8Jclp8rZOiUWZDdgLlW0gyzQG378DwhzAJMjKvf iMcKtBH3P6YfHp8LtQWbgd74NQxfodvouaKkDeqPPgJqY14THz1YZOd29CJqTF2h/sx5 kqK6aXHv2xnH9IAQj6iDC7laDXhFYCpLp0GPxLSVh1KMZPu3Lmi01XfGsiVZGFsCCOYS uz6g== X-Gm-Message-State: AFeK/H2pBpI3DZE41wT+f6b26/IzCq0TsOIJm5Ij0HoQZtDt8JN9v/9F+G2MT8lgSlZIlm26 X-Received: by 10.25.190.2 with SMTP id o2mr6200274lff.80.1490690452141; Tue, 28 Mar 2017 01:40:52 -0700 (PDT) Received: from localhost.localdomain (c-357171d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.113.53]) by smtp.gmail.com with ESMTPSA id s13sm539590ljd.3.2017.03.28.01.40.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Mar 2017 01:40:50 -0700 (PDT) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter Cc: Bartlomiej Zolnierkiewicz , Linus Walleij Subject: [PATCH 3/3] mmc: core: refactor mmc_request_done() Date: Tue, 28 Mar 2017 10:40:31 +0200 Message-Id: <20170328084031.11995-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170328084031.11995-1-linus.walleij@linaro.org> References: <20170328084031.11995-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. Reviewed-by: Bartlomiej Zolnierkiewicz Signed-off-by: Linus Walleij --- 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 c0b3f80c1f39..86314fa85dd2 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);