From patchwork Tue Feb 4 08:54:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 183061 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp5064257ile; Tue, 4 Feb 2020 00:55:16 -0800 (PST) X-Received: by 2002:a2e:9b03:: with SMTP id u3mr16761966lji.87.1580806516429; Tue, 04 Feb 2020 00:55:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580806516; cv=none; d=google.com; s=arc-20160816; b=FV6AI2pLQxiitzT7m3WvcE6J617DX8hTyimqBiLx90cXlZ7WUkp4SQxDapnl92NjYj PH+uKr3pt529ZmGBZzjRTUvMMDBI7gPfWIyxwyU2hqeArBjDUPJaSnIiUHBUkPcn9Lq9 +sa9Y8eBCTa0K05yQnVVFdbQsfrLgM6WrPDRSfPT1vI/iQ4RlUD83q696Wqo4u9AaTjs ySIGqQrm7Pw/dUBJqPO1/OWCD/aev4FPVS7fG0q+BsPD1yAcG/zdsZWo1fXIUUGBcQlz UmLCcauuyxmkDGi/ubHWLSHcqFH7qffyruxSH8g6yPxoCSrXKJYoPNUZ8N+NTQHjRsub Lu7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EK9v+jTcdBM1CQqLn/KDsjlxwnI1HlWWrKAGRPO/Vyc=; b=aqM+10pm7M1YoiEyeWC54qtCgVhiQ5QrjB3aTUB9c3k4CB8YvBFjcWL9vlqH+7WLXk 2kxg+rB2Jn3/MOoA6/BdA2oFI4rkb8Q13Ui5oAQNzN+D0LIIO5SGylJWNfHUGwfC9QoH zaWZedAIHxp7Wrh2wdNb0t0LlY9+zg2TIpcHD1OufC0Dkwmy37098WbPcWll2DEBvFfJ indxkdr9UU5/Ov8OkZCDGqMgcrAqiqaTSQRUQN9uPrzFidRg+DIv2m7IeVtE++iZfZio Dr+A6oWrdLa/vZRYAKJALF74+eZ7wLGVi3aDwHdcXrCMCuFxOwZnUEPkClJF0spWS8sV +VMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ha6oLgAs; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 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-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a26sor12365835ljn.0.2020.02.04.00.55.16 for (Google Transport Security); Tue, 04 Feb 2020 00:55:16 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ha6oLgAs; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 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; bh=EK9v+jTcdBM1CQqLn/KDsjlxwnI1HlWWrKAGRPO/Vyc=; b=ha6oLgAsulQR18W68tnvXp5MLS5yfM9h3Q19tvLAUsoBRkcJHx/JJ/yGhc1wY8PpU8 wrclzY/BzdTJoWoxXBASOKu4XftVufVPzvBuS1cxTlTytBnhXjcigZ+fx+Z0quSQuAZh eNHj6mVVsDRenvF4OL9qvYPxr/yOVynAHJLi5pecRrVSFHepZfCraVjC84CATuohZHeu jpj6GfiPP5OfT9n45RaGsGyBoUd20EQ5DfwG52nLPRzQTfUXZftlulNHE8sEHIyXFsIx v9lUrPMa9TsWWRVJcBHMNdD+/VHbmgNgEz+8yzvY5DFATcpHsQnggs/lIt4cynhZWXNq HHWQ== 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=EK9v+jTcdBM1CQqLn/KDsjlxwnI1HlWWrKAGRPO/Vyc=; b=ptl4tfmHFLrFkEcSYeKiLJbH+ms2gezYJgibLRu9mZLc7xdXNbwR39ZDfw5uqEqSb6 DzVdjLE0hnFkN7N7Vn4yD+CVgU99m/XNT6jjH6Wmjjp9c08yk9LtgyvAtoWDFwGuoAM7 tC3BThWhvSZZ1uXqa29M33rUhxsQbR7oRI29EPGKH9W22Bo8gn6dVvGj7/koOME8zawW ISordPMvUkXBvEzeggCvMLyWqFzKtKF+XYVp4xJRetrlcZU+4ND4z3/ogiOoUDBt/ezT fKPr87eiolmoXKoWExA54W53TYeBE1V5YgALlLmmIv1v2r9Y0IADq4+CYi/D/8d/of+O 8spg== X-Gm-Message-State: APjAAAUFB9WyQ9fgXRFuoxUuPnMa6ykWwwILx5GirT2BXkDLdKJM0vIy xOXlwTElOXIcfVEo0b15Qc75+Sk8 X-Google-Smtp-Source: APXvYqyMUlhNDDLuQnCnx3vW7zBKi3KAOhXIBQCsZHigT9gEe0pQfFAFeaXBGykKRdwwJxB5h8gsHg== X-Received: by 2002:a2e:995a:: with SMTP id r26mr17410355ljj.78.1580806516016; Tue, 04 Feb 2020 00:55:16 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id n2sm11156283ljj.1.2020.02.04.00.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 00:55:15 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Wolfram Sang , Ludovic Barre , Baolin Wang , Linus Walleij , Chaotian Jing , Shawn Lin , mirq-linux@rere.qmqm.pl Subject: [PATCH 06/12] mmc: core: Enable re-use of mmc_blk_in_tran_state() Date: Tue, 4 Feb 2020 09:54:43 +0100 Message-Id: <20200204085449.32585-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204085449.32585-1-ulf.hansson@linaro.org> References: <20200204085449.32585-1-ulf.hansson@linaro.org> To allow subsequent changes to re-use the code from the static function mmc_blk_in_tran_state(), let's move it to a public header. While at it, let's also rename it to mmc_ready_for_data(), as to try to better describe its purpose. Signed-off-by: Ulf Hansson --- drivers/mmc/core/block.c | 24 ++++-------------------- include/linux/mmc/mmc.h | 10 ++++++++++ 2 files changed, 14 insertions(+), 20 deletions(-) -- 2.17.1 diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 663d87924e5e..8ac12e3fff27 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -436,16 +436,6 @@ static int ioctl_do_sanitize(struct mmc_card *card) return err; } -static inline bool mmc_blk_in_tran_state(u32 status) -{ - /* - * Some cards mishandle the status bits, so make sure to check both the - * busy indication and the card state. - */ - return status & R1_READY_FOR_DATA && - (R1_CURRENT_STATE(status) == R1_STATE_TRAN); -} - static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms, u32 *resp_errs) { @@ -477,13 +467,7 @@ static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms, __func__, status); return -ETIMEDOUT; } - - /* - * Some cards mishandle the status bits, - * so make sure to check both the busy - * indication and the card state. - */ - } while (!mmc_blk_in_tran_state(status)); + } while (!mmc_ready_for_data(status)); return err; } @@ -1666,7 +1650,7 @@ static void mmc_blk_read_single(struct mmc_queue *mq, struct request *req) goto error_exit; if (!mmc_host_is_spi(host) && - !mmc_blk_in_tran_state(status)) { + !mmc_ready_for_data(status)) { err = mmc_blk_fix_state(card, req); if (err) goto error_exit; @@ -1726,7 +1710,7 @@ static bool mmc_blk_status_error(struct request *req, u32 status) return brq->cmd.resp[0] & CMD_ERRORS || brq->stop.resp[0] & stop_err_bits || status & stop_err_bits || - (rq_data_dir(req) == WRITE && !mmc_blk_in_tran_state(status)); + (rq_data_dir(req) == WRITE && !mmc_ready_for_data(status)); } static inline bool mmc_blk_cmd_started(struct mmc_blk_request *brq) @@ -1788,7 +1772,7 @@ static void mmc_blk_mq_rw_recovery(struct mmc_queue *mq, struct request *req) /* Try to get back to "tran" state */ if (!mmc_host_is_spi(mq->card->host) && - (err || !mmc_blk_in_tran_state(status))) + (err || !mmc_ready_for_data(status))) err = mmc_blk_fix_state(mq->card, req); /* diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h index 897a87c4c827..4b85ef05a906 100644 --- a/include/linux/mmc/mmc.h +++ b/include/linux/mmc/mmc.h @@ -161,6 +161,16 @@ static inline bool mmc_op_multi(u32 opcode) #define R1_STATE_PRG 7 #define R1_STATE_DIS 8 +static inline bool mmc_ready_for_data(u32 status) +{ + /* + * Some cards mishandle the status bits, so make sure to check both the + * busy indication and the card state. + */ + return status & R1_READY_FOR_DATA && + R1_CURRENT_STATE(status) == R1_STATE_TRAN; +} + /* * MMC/SD in SPI mode reports R1 status always, and R2 for SEND_STATUS * R1 is the low order byte; R2 is the next highest byte, when present.