Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2428643ybh; Mon, 16 Mar 2020 03:02:40 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvG+DpSxQoarWohXOFewkOexFhk8Sp/cDqp0rWMDyr7ShSA7vAg3zZHQgJANt68gjcGWEPl X-Received: by 2002:a9d:12cc:: with SMTP id g70mr20741975otg.115.1584352960502; Mon, 16 Mar 2020 03:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584352960; cv=none; d=google.com; s=arc-20160816; b=XqvohMSONJ5MdSfFscbsXM+CP3sVSwMW1ep07ZSDOPSqeGg3rehfOmu3pTN4VEKtsI 4FJGlQvk6zBoiLtADYEJgJohpANdwGHm3vpBRkj0l7FYoqZ7p1sN6jSAJXDXes1rDoF1 HfqeqhHXA/qNx1fVEkEtdsBBtpDC3aWldrfziDsN/4Z/QKY8z4PiCrI02KfxTf6OE4oM ynBGEWOo2zd5plBFdz9vn4W1VcALJmUQgnjfKfk3qBKj+gJhI95Pw1/iM+uBK4l0mLSX LvDebKHN7SdwiSp9yx0O9uZS77GrlNbJQqyfksvS1GH+R/AruixqBrCXZLB9Rk/fEMsR Fpmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=Q4WERU23Ab7PcOBZcBpvQyi0PCrcF6eJaP+MB28aUbM=; b=MSA4D5+L13X5N3WhUdTZdR7oqpLY1nVhllUxXcg//KVUwYnNKFv8GOh8gpqGYPIGvh SLf3Dy+DxGmavnYS7HDbsEuzSkzFaefMkUKX6lCrbRzEjSANX7xh8iiJ1B1dAbygLjKW ZjK8lsCcBmfXw7e7V3XcUNMA/9i39KS7UoPp/KeIh/ck9ha7GsP3JYL+9ABIaRdbncBj SQw8cKu3ODAeT7MhFvP9JvLrY9ZULK+lXVjSjeta85Oj/xla2ySF/dmfnLKIrx+0B0wD VOgiOOGFS8Hyrpz4tdZwHWD772hEsk7/26Vv0B6o3ngkvDbHOOOc7LesqhrV8OD/K/7/ XvyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SzBGmC2x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g9si3532469otk.97.2020.03.16.03.02.28; Mon, 16 Mar 2020 03:02:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SzBGmC2x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730594AbgCPKB6 (ORCPT + 99 others); Mon, 16 Mar 2020 06:01:58 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:39478 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730578AbgCPKB6 (ORCPT ); Mon, 16 Mar 2020 06:01:58 -0400 Received: by mail-pg1-f196.google.com with SMTP id b22so3465273pgb.6; Mon, 16 Mar 2020 03:01:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=Q4WERU23Ab7PcOBZcBpvQyi0PCrcF6eJaP+MB28aUbM=; b=SzBGmC2xzyNqEKrq6zmZ/gWFxo0axM7r5PoB4ZwwLa3UCvtF7iagYTXmDw2qwnZl4i UYVwBE82t0vztwiTjzcaVqBdTVKFUNHz8wYcgWBcuDhqsUlAxdUnt/DFBR91js6Mg0tC QDZqI7lhpCIMIfVmyRzh1UOYhIXBVvr0xFb8lMgOqSf4UyTuEUlTEArpcYTJVIPiGGB1 77C9KW4gV0GYi60w0vtRFbwHkMuRTNuf4NAfeYpN71svZdGX0cW6ZRQXAQoXFc3Q9Hib gjSGmTQ9XGMsvAymXl23yLdbdMh4MRYmvQUM25qgRYmrXBZE5KyFSet+rLNOfcaKbe4m xP1A== 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:in-reply-to:references; bh=Q4WERU23Ab7PcOBZcBpvQyi0PCrcF6eJaP+MB28aUbM=; b=X2Iuugui9LE2Rs0C9aoB3QWDe/3hcoVscoSKN9tzX5pr7EotJjdo/V1vI9LU+ATzQd VcDBaF1va0nrOTMxsw6z3qK7aOlxEMeDZnNLZ/3owg88jKm7ECH2GSk5LeKOF5VCbxLm r4B52coRwM6UzLtS+QacKgSWB4V8Wul+p8oEL9WdBrsaHCuKrkdXK/LtA89tAVM3fEV8 7C9Nwrh66UCPAhrDTRkr3zv9FfrUjLgd0L8/0GDZuarR5Kcp9tNGmYPNLRTnRh5qALcH c4wxXaGTG9Co96liYmV1mu1GuIpO1hDepHOIM/cB09mC0bx4vRdsGsxIbvjklnxPrtUO uPng== X-Gm-Message-State: ANhLgQ1CisC2l9gCoyPOxZ7nqqDeXU9gW0qVwR3nLmIcIgEqCyrYiyOM FCLsJ2nMUlQ3AegIQlqY5ke4hZzp X-Received: by 2002:a63:7c4:: with SMTP id 187mr25515308pgh.369.1584352917078; Mon, 16 Mar 2020 03:01:57 -0700 (PDT) Received: from sh03840pcu.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id 136sm63970411pgh.26.2020.03.16.03.01.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Mar 2020 03:01:56 -0700 (PDT) From: Baolin Wang To: axboe@kernel.dk, paolo.valente@linaro.org, ulf.hansson@linaro.org, adrian.hunter@intel.com Cc: ming.lei@redhat.com, arnd@arndb.de, linus.walleij@linaro.org, baolin.wang7@gmail.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, linux-mmc@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND RFC PATCH 5/8] mmc: host: sdhci: Factor out the command configuration Date: Mon, 16 Mar 2020 18:01:22 +0800 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move the SD command configuration into one separate function to simplify the sdhci_send_command(). Moreover this function can be used to support ADMA3 transfer mode in following patches. Signed-off-by: Baolin Wang --- drivers/mmc/host/sdhci.c | 65 ++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 6238b5c..4de0f48 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1546,9 +1546,43 @@ static void sdhci_finish_data(struct sdhci_host *host) } } -void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) +static int sdhci_get_command(struct sdhci_host *host, struct mmc_command *cmd) { int flags; + + if ((cmd->flags & MMC_RSP_136) && (cmd->flags & MMC_RSP_BUSY)) { + pr_err("%s: Unsupported response type!\n", + mmc_hostname(host->mmc)); + cmd->error = -EINVAL; + sdhci_finish_mrq(host, cmd->mrq); + return -EINVAL; + } + + if (!(cmd->flags & MMC_RSP_PRESENT)) + flags = SDHCI_CMD_RESP_NONE; + else if (cmd->flags & MMC_RSP_136) + flags = SDHCI_CMD_RESP_LONG; + else if (cmd->flags & MMC_RSP_BUSY) + flags = SDHCI_CMD_RESP_SHORT_BUSY; + else + flags = SDHCI_CMD_RESP_SHORT; + + if (cmd->flags & MMC_RSP_CRC) + flags |= SDHCI_CMD_CRC; + if (cmd->flags & MMC_RSP_OPCODE) + flags |= SDHCI_CMD_INDEX; + + /* CMD19 is special in that the Data Present Select should be set */ + if (cmd->data || cmd->opcode == MMC_SEND_TUNING_BLOCK || + cmd->opcode == MMC_SEND_TUNING_BLOCK_HS200) + flags |= SDHCI_CMD_DATA; + + return SDHCI_MAKE_CMD(cmd->opcode, flags); +} + +void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) +{ + int command; u32 mask; unsigned long timeout; @@ -1605,32 +1639,9 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) sdhci_set_transfer_mode(host, cmd); - if ((cmd->flags & MMC_RSP_136) && (cmd->flags & MMC_RSP_BUSY)) { - pr_err("%s: Unsupported response type!\n", - mmc_hostname(host->mmc)); - cmd->error = -EINVAL; - sdhci_finish_mrq(host, cmd->mrq); + command = sdhci_get_command(host, cmd); + if (command < 0) return; - } - - if (!(cmd->flags & MMC_RSP_PRESENT)) - flags = SDHCI_CMD_RESP_NONE; - else if (cmd->flags & MMC_RSP_136) - flags = SDHCI_CMD_RESP_LONG; - else if (cmd->flags & MMC_RSP_BUSY) - flags = SDHCI_CMD_RESP_SHORT_BUSY; - else - flags = SDHCI_CMD_RESP_SHORT; - - if (cmd->flags & MMC_RSP_CRC) - flags |= SDHCI_CMD_CRC; - if (cmd->flags & MMC_RSP_OPCODE) - flags |= SDHCI_CMD_INDEX; - - /* CMD19 is special in that the Data Present Select should be set */ - if (cmd->data || cmd->opcode == MMC_SEND_TUNING_BLOCK || - cmd->opcode == MMC_SEND_TUNING_BLOCK_HS200) - flags |= SDHCI_CMD_DATA; timeout = jiffies; if (host->data_timeout) @@ -1644,7 +1655,7 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) if (host->use_external_dma) sdhci_external_dma_pre_transfer(host, cmd); - sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND); + sdhci_writew(host, command, SDHCI_COMMAND); } EXPORT_SYMBOL_GPL(sdhci_send_command); -- 1.9.1