From patchwork Fri Nov 17 11:31:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Shih X-Patchwork-Id: 13458845 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZgZetg5e" Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BF511985; Fri, 17 Nov 2023 03:32:16 -0800 (PST) Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-6ce37683cf6so1033178a34.3; Fri, 17 Nov 2023 03:32:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700220735; x=1700825535; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=elnfGKAy/7+HbOAzxPXIpLPWv33SV0UOKZl7RY/LQJw=; b=ZgZetg5eEJr2YkXWvmgpUWlrxC1uzpO6YdKcz4toZCXz6CmanZpmQ1ea0L81ulqXvV 9hv3ee4p8eew8anQlZNbI8T7y4GqbYzRQku2sy3T3ga/slW8jC6fRkHXKNiSN+HeCKgb ZikpK4bAN71q84GhZjTqMKZBIHEZCUgW2Mkosri/DKpBRdmbpoD7I6K6z6ZJUeLLPk3E si1bujXQJhp7t9U/EXzqvB5Xp+gAoZbkPNnjFy2luyZ93NLcZ7EDL5YeE6DHVTqDPYOl 0N8Uctus9L8OE3B/h8BMovsejEdRqMfxgzjtgGa9O11ZaYkt6LArjNfeptnu+MKuzip/ Sdtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700220735; x=1700825535; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=elnfGKAy/7+HbOAzxPXIpLPWv33SV0UOKZl7RY/LQJw=; b=ZPfHbWG1hko+81MTJbonD4GvaVBNQ7Eu5KwGGeoKsIzLwNCpxdEMzxnn9VONjGYuwU kfZIsRxOBjmGc3RlfUwYVfbn5ph3K/TyESTyFFji9iA7KQS95+aCRz2gf/sNO62Xg7PW 0X2/2UoSvH3w0YhC0z1cpEVWrvzptPY8BytDvVies7MA68Qo9D8XzFrcS0xLMEryXOiK nbP7HCycnQB4nYtRdzfDlV+mB9KYN71B66hO9nYlTrxlkF89McHTuZddN08xspfuDxEm e6kd1DMGK74egQPHP61AOUkR66XbUjbTEzPR3EbKS0YkbNAlUQgc8ys6mwHP3ehjFutO kMxg== X-Gm-Message-State: AOJu0YyVmaNQmiUTQ5cGK7w7A8fXwbUrAqBkEe+zLbP6gPYRSq4pcARa P7kDVtXNy/VA43FGsRMRwKo= X-Google-Smtp-Source: AGHT+IFpv7M8EL6ktXp3UEyuXHLG+lQclvuzqB3sx9bbkTLj65dIJjqfkjXy8o5TQ1NrprN8DqBkqw== X-Received: by 2002:a9d:75cc:0:b0:6d6:4c28:5579 with SMTP id c12-20020a9d75cc000000b006d64c285579mr12780034otl.8.1700220735214; Fri, 17 Nov 2023 03:32:15 -0800 (PST) Received: from localhost.localdomain (2001-b400-e286-d458-bc89-d4cd-bd42-ffb5.emome-ip6.hinet.net. [2001:b400:e286:d458:bc89:d4cd:bd42:ffb5]) by smtp.gmail.com with ESMTPSA id u2-20020a631402000000b005b4b70738e5sm1229224pgl.8.2023.11.17.03.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 03:32:15 -0800 (PST) From: Victor Shih To: ulf.hansson@linaro.org, adrian.hunter@intel.com Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, benchuanggli@gmail.com, HL.Liu@genesyslogic.com.tw, Greg.tu@genesyslogic.com.tw, takahiro.akashi@linaro.org, dlunev@chromium.org, Victor Shih , Victor Shih Subject: [PATCH V13 06/21] mmc: core: Add New function to re-factoring the code Date: Fri, 17 Nov 2023 19:31:34 +0800 Message-Id: <20231117113149.9069-7-victorshihgli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231117113149.9069-1-victorshihgli@gmail.com> References: <20231117113149.9069-1-victorshihgli@gmail.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Victor Shih Add __mmc_go_idle function to re-factoring mmc_go_idle function. Signed-off-by: Ulf Hansson Signed-off-by: Victor Shih --- drivers/mmc/core/mmc_ops.c | 24 ++++++++++++++++-------- drivers/mmc/core/mmc_ops.h | 1 + 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 3b3adbddf664..5c8e62e8f331 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -144,10 +144,24 @@ int mmc_set_dsr(struct mmc_host *host) return mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES); } +int __mmc_go_idle(struct mmc_host *host) +{ + struct mmc_command cmd = {}; + int err; + + cmd.opcode = MMC_GO_IDLE_STATE; + cmd.arg = 0; + cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_NONE | MMC_CMD_BC; + + err = mmc_wait_for_cmd(host, &cmd, 0); + mmc_delay(1); + + return err; +} + int mmc_go_idle(struct mmc_host *host) { int err; - struct mmc_command cmd = {}; /* * Non-SPI hosts need to prevent chipselect going active during @@ -163,13 +177,7 @@ int mmc_go_idle(struct mmc_host *host) mmc_delay(1); } - cmd.opcode = MMC_GO_IDLE_STATE; - cmd.arg = 0; - cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_NONE | MMC_CMD_BC; - - err = mmc_wait_for_cmd(host, &cmd, 0); - - mmc_delay(1); + err = __mmc_go_idle(host); if (!mmc_host_is_spi(host)) { mmc_set_chip_select(host, MMC_CS_DONTCARE); diff --git a/drivers/mmc/core/mmc_ops.h b/drivers/mmc/core/mmc_ops.h index 92d4194c7893..3eaefe989c80 100644 --- a/drivers/mmc/core/mmc_ops.h +++ b/drivers/mmc/core/mmc_ops.h @@ -25,6 +25,7 @@ struct mmc_command; int mmc_select_card(struct mmc_card *card); int mmc_deselect_cards(struct mmc_host *host); int mmc_set_dsr(struct mmc_host *host); +int __mmc_go_idle(struct mmc_host *host); int mmc_go_idle(struct mmc_host *host); int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr); int mmc_set_relative_addr(struct mmc_card *card);