From patchwork Tue May 4 16:12:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 430880 Delivered-To: patches@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp3936382jao; Tue, 4 May 2021 09:12:39 -0700 (PDT) X-Received: by 2002:a05:651c:105a:: with SMTP id x26mr6637148ljm.440.1620144759191; Tue, 04 May 2021 09:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620144759; cv=none; d=google.com; s=arc-20160816; b=R8ycRbYs5JoaEJCq2HVNE+GD6OmMnk075Z/gfFOUrn2uE8+CkeflqEsxulErXc2qtw WUnk0J1yk3WBPnk2ko8dhcNanvBR8xIBGt8oPUF1bN6lhuQIFL36qtv1gPl6d/HyINto Ru0XXPzxSJhIeYPCTibCkB5DMIaGAPd2hVqULN2IMNjRu6iBcsR+dQK4iwKy/Y8HmCZU BAWRBDw2qLkt+BG1d7ZlH7kr4AGyr+8VZhTrlgb/zBhHzS58TCpj4t7nXisIGszdEDDH OedrSeVVdu9Lst5AsvvPC2kFHEGM7LO7LIBmc4KRUhuNO0vrI9PAXwVESNEHnoQX69Xb gQFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=/ee795yxnzHs29v3TjQa721b4l02PWsrUGNagPQX+uQ=; b=EVbIkdErvPOMOZmiEKhIFdZc8fcx3IxCi94pr6CSoHusZbpHxx+EDQn8WwDY9dEicL j20r7hp1JSnfZ0bLxWCJ3pX/LPg/WeZvNDOcmkgOvjVjA0oO/BX8xbwynou/YU8+xcix Y+X7oq0RtGKKnjSCuLkrn4BQE1d3EBusxL6YTi2CyDfTdQjVyFKYlgp7Sd0AF734MuRa /WjT6lytWLoPTfzfiRsNkGmQZOfmw8bL8550LVHButlN6o4MrLQHATHsFRJdPap4hEyc SRrhdLvk0ZZWX9vw8ENRGlhstoZ63lE8+68mRW0dKV72qClD1PXcnP7t5AICfVkI9q0R UaGA== 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 ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id j10sor445107lfe.35.2021.05.04.09.12.39 for (Google Transport Security); Tue, 04 May 2021 09:12:39 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dHVCBXhe; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=IRT7LGUoGbVYzN2BDFoTbxDHUd7W4PX3FJoIzBcNOxaBYX42jCfNi1J4EdIW5gBdIz +bzFyeGl4k//NZqC6ghGhuo5xgJy+U1v4kssuzsgHVEaoG0bNw87hRzhFZkgwS0+O1fS C4m0+hPx45U8HPWcdSbSNV8/tDtDhpuYu6inUEEbJlV1NSY0n8pjtEn0YQ1EMW+H7H2C 4+tNlzofO+V+iXCqSAjy9KprLNzcxP3JsgeUuvt4ZqK2jhOMRouH+EpBGMfCGt/4unTF MqoxxbsFV+V6ddhvBS3ut3uNIzYHSFjdSUkF119m8Q82GOCokEGcHkxrcy1CFUx4F7ng pQXw== X-Gm-Message-State: AOAM530zI3eyxwMDACxtpyeFjA5QwbVidngoLV1L33C28sXQ8aRipc16 Bz1R9DsqKFhZ0Igm2sZ4ZYAIwufS X-Google-Smtp-Source: ABdhPJwaLC553y4EWUnONr50m/PHQiryaxLapFqcwSYnqXkOCKi79+Q6m6D8DiB+LSijTT4KL2vyaw== X-Received: by 2002:a19:4849:: with SMTP id v70mr17190047lfa.590.1620144758840; Tue, 04 May 2021 09:12:38 -0700 (PDT) Return-Path: 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 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(-) -- 2.25.1 Reviewed-by: Linus Walleij Reviewed-by: Shawn Lin 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;