Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3856533pxy; Tue, 4 May 2021 11:25:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylkYFa8/igaU5nBuIn4VkWLS4fHoql+vDEuwDySd4JRWB0CixoFbJbndIs7EHChcVvYijR X-Received: by 2002:a17:90b:956:: with SMTP id dw22mr4100477pjb.211.1620152749531; Tue, 04 May 2021 11:25:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620152749; cv=none; d=google.com; s=arc-20160816; b=fnZIV+XUgEkgdWPrfknHtupRNH3hEFdKqf+z1d9rIYRaPaGnhK0aFvl8MyXel3UznJ rggQl3Bl0m2Xi7A3BwUJWVGR5TamQTC9E303J8I7YSLirhH/XHdQB3dGBM3RfIS9kucF RFq5Z3Xs5i5zG8HMV4bz2zehVj65CPs2HiD/Wux7D4BvhUUJ01KSBPrhox1EiZKAkA0N BXn8jCmBAsv/eK+kjXuWIc5yTOQ4YEyMglB36lew1Bc+fBcEsIqQG4cry3H3tFSkxm6B qeo7xsyKRn0dG8b4zokdVyyUr/uecM1ZsrE8Z77LX3zum/mUvj55gU9ReGxA2D4sY6mM xtwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/ee795yxnzHs29v3TjQa721b4l02PWsrUGNagPQX+uQ=; b=l2/OETF2+q6Q3+3QS7/AKBZvmWovRytLLtC7GeaSQjdEF7/0rxTkvM30qG05RB2NLI kX/jbtUr/SgjmRDBnMb27xOfxEeFgvagHL5GxTZqaV4g7XaUQvZ+xZ/e/vK/u9sc4Mcb 5s4nx6g/hRxQxYbJIPOqlmKQ4SlNfZ/LPGykuNgLIpeCr125Bo1xL3AG1PGzrLuhEeRh jq43DpYId0o0OgV849UIVSHjOXlqPFAOUXJ9smn7N1qAZf6y5ZlrzZQzC7gCc/3Ke8cv l6U6qlbt1nqds7TZd6tw8ZVrAbEV4rvdjsiTXmrRKD8FgDdPc3Mgg9d2aNPP3PpSwxEv 8Glg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dHVCBXhe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l6si4440232pgq.519.2021.05.04.11.25.34; Tue, 04 May 2021 11:25:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dHVCBXhe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231700AbhEDQNh (ORCPT + 99 others); Tue, 4 May 2021 12:13:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231735AbhEDQNg (ORCPT ); Tue, 4 May 2021 12:13:36 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F535C06174A for ; Tue, 4 May 2021 09:12:40 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 12so14038137lfq.13 for ; Tue, 04 May 2021 09:12:40 -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 :mime-version:content-transfer-encoding; bh=/ee795yxnzHs29v3TjQa721b4l02PWsrUGNagPQX+uQ=; b=dHVCBXheSA/nPVW+TvqCQLGQZ10Py/jY6VqG4/6GNO7B5xKIefq2DXnenApc2gSdUp LP0AhRlyrY2mAHLH5pEaY894wET3dw1t3OcPjOeGQBDR3LhjKQfGucKOHTk5Y6pKT93f AR6uaY5SgrPu9fbqt4QgOsjNRWz4n997XqkGaqJpv53dnQtL0VZ2Jnwf3OhUjzxLeb9G ZgcW+q0mWP3l2y9syoSGF1+Dele0STkqqimV2XS0jpUoKnw5xl1wswtj00ZM5/V0MJ35 jsTFwUki0BL0LkhtTiIX15Wn3zlmim4qHrxgnSB9MOlGtPwqzjVInl6MCzas7VubLfKO Asuw== 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:mime-version:content-transfer-encoding; bh=/ee795yxnzHs29v3TjQa721b4l02PWsrUGNagPQX+uQ=; b=nfeNbatWaly7S4dEuTsD/ICGks1Ssu+kaqNQzsjsUqTdcxMbRBEZ/2ksfOirVbicfo p+tJVfmIGlP52rHkLIEskBTDDSjpyUby48nUdPnpb/BQIFlRiOWIJpDuV1Z8KnjvYF6V CkbR2PweIjewxtn3Y2eRilza36bFbG1u/HREvN4T8ycRQ6tnhcxxkbBPMrHIzZT3Z8wh 5cvvvWk12ql1J9BTT/mLck5iLwQ0yNJoqZ6gn7ioR0IjkX7HLj/rFv6aL+q9lQoJI0N7 z24z3Rz2gf2oHiCQu6UyhXkUR4EzSwsgaSZ/6nygj/JsqfATFOp6fVBOFv6/WZ6J+/JN 9c6w== X-Gm-Message-State: AOAM533JJorRPQSN7X0C9GVNWJ4XDmI+6N1jDHy+PRDGtN1Law1YpGGp z8g7H/u96gdxmxR+xS1etbB8WA== X-Received: by 2002:a19:4849:: with SMTP id v70mr17190047lfa.590.1620144758840; Tue, 04 May 2021 09:12:38 -0700 (PDT) Received: from localhost.localdomain (h-98-128-180-197.NA.cust.bahnhof.se. [98.128.180.197]) by smtp.gmail.com with ESMTPSA id s20sm164193ljs.116.2021.05.04.09.12.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 May 2021 09:12:37 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter Cc: Linus Walleij , Wolfram Sang , Shawn Lin , Avri Altman , Masami Hiramatsu , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/11] mmc: core: Re-structure some code in __mmc_poll_for_busy() Date: Tue, 4 May 2021 18:12:14 +0200 Message-Id: <20210504161222.101536-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210504161222.101536-1-ulf.hansson@linaro.org> References: <20210504161222.101536-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To make the code a bit more understandable, let's move the check about whether polling is allowed or not, out to the caller instead. In this way, we can also drop the send_status in-parameter, so let's do that. Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc_ops.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 66ae699a410f..ccaee1cb7ff5 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -465,8 +465,7 @@ static int mmc_busy_status(struct mmc_card *card, bool retry_crc_err, } static int __mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, - bool send_status, bool retry_crc_err, - enum mmc_busy_cmd busy_cmd) + bool retry_crc_err, enum mmc_busy_cmd busy_cmd) { struct mmc_host *host = card->host; int err; @@ -475,16 +474,6 @@ static int __mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, bool expired = false; bool busy = false; - /* - * In cases when not allowed to poll by using CMD13 or because we aren't - * capable of polling by using ->card_busy(), then rely on waiting the - * stated timeout to be sufficient. - */ - if (!send_status && !host->ops->card_busy) { - mmc_delay(timeout_ms); - return 0; - } - timeout = jiffies + msecs_to_jiffies(timeout_ms) + 1; do { /* @@ -518,7 +507,7 @@ static int __mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, enum mmc_busy_cmd busy_cmd) { - return __mmc_poll_for_busy(card, timeout_ms, true, false, busy_cmd); + return __mmc_poll_for_busy(card, timeout_ms, false, busy_cmd); } bool mmc_prepare_busy_cmd(struct mmc_host *host, struct mmc_command *cmd, @@ -591,8 +580,18 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, mmc_host_is_spi(host)) goto out_tim; + /* + * If the host doesn't support HW polling via the ->card_busy() ops and + * when it's not allowed to poll by using CMD13, then we need to rely on + * waiting the stated timeout to be sufficient. + */ + if (!send_status && !host->ops->card_busy) { + mmc_delay(timeout_ms); + goto out_tim; + } + /* Let's try to poll to find out when the command is completed. */ - err = __mmc_poll_for_busy(card, timeout_ms, send_status, retry_crc_err, + err = __mmc_poll_for_busy(card, timeout_ms, retry_crc_err, MMC_BUSY_CMD6); if (err) goto out; -- 2.25.1