linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kishon Vijay Abraham I <kishon@ti.com>
To: Ulf Hansson <ulf.hansson@linaro.org>,
	Adrian Hunter <adrian.hunter@intel.com>
Cc: Rob Herring <robh+dt@kernel.org>,
	Tony Lindgren <tony@atomide.com>, Sekhar Nori <nsekhar@ti.com>,
	Russell King <linux@armlinux.org.uk>,
	Ravikumar Kattekola <rk@ti.com>, <linux-mmc@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-omap@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	Kishon Vijay Abraham I <kishon@ti.com>
Subject: [PATCH 1/5] mmc: sdhci: Tidy reading 136-bit responses
Date: Mon, 21 Aug 2017 13:11:28 +0530	[thread overview]
Message-ID: <20170821074132.4622-2-kishon@ti.com> (raw)
In-Reply-To: <20170821074132.4622-1-kishon@ti.com>

From: Adrian Hunter <adrian.hunter@intel.com>

Read each register only once and move the code to a separate function so
that it is not jammed against the 80 column margin.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/mmc/host/sdhci.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index a1ad2ddadca1..ba639b7851cb 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1173,24 +1173,32 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
 }
 EXPORT_SYMBOL_GPL(sdhci_send_command);
 
+static void sdhci_read_rsp_136(struct sdhci_host *host, struct mmc_command *cmd)
+{
+	int i, reg;
+
+	for (i = 0; i < 4; i++) {
+		reg = SDHCI_RESPONSE + (3 - i) * 4;
+		cmd->resp[i] = sdhci_readl(host, reg);
+	}
+
+	/* CRC is stripped so we need to do some shifting */
+	for (i = 0; i < 4; i++) {
+		cmd->resp[i] <<= 8;
+		if (i != 3)
+			cmd->resp[i] |= cmd->resp[i + 1] >> 24;
+	}
+}
+
 static void sdhci_finish_command(struct sdhci_host *host)
 {
 	struct mmc_command *cmd = host->cmd;
-	int i;
 
 	host->cmd = NULL;
 
 	if (cmd->flags & MMC_RSP_PRESENT) {
 		if (cmd->flags & MMC_RSP_136) {
-			/* CRC is stripped so we need to do some shifting. */
-			for (i = 0;i < 4;i++) {
-				cmd->resp[i] = sdhci_readl(host,
-					SDHCI_RESPONSE + (3-i)*4) << 8;
-				if (i != 3)
-					cmd->resp[i] |=
-						sdhci_readb(host,
-						SDHCI_RESPONSE + (3-i)*4-1);
-			}
+			sdhci_read_rsp_136(host, cmd);
 		} else {
 			cmd->resp[0] = sdhci_readl(host, SDHCI_RESPONSE);
 		}
-- 
2.11.0

  reply	other threads:[~2017-08-21  7:42 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-21  7:41 [PATCH 0/5] mmc: Add OMAP SDHCI driver Kishon Vijay Abraham I
2017-08-21  7:41 ` Kishon Vijay Abraham I [this message]
2017-08-30 13:13   ` [PATCH 1/5] mmc: sdhci: Tidy reading 136-bit responses Ulf Hansson
2017-08-21  7:41 ` [PATCH 2/5] mmc: sdhci: Add quirk to indicate MMC_RSP_136 has CRC Kishon Vijay Abraham I
2017-08-28  7:57   ` Adrian Hunter
2017-08-30 13:13   ` Ulf Hansson
2017-08-21  7:41 ` [PATCH 3/5] dt-bindings: ti-omap-hsmmc: Document new compatible for sdhci omap Kishon Vijay Abraham I
2017-08-21 14:21   ` Tony Lindgren
2017-08-22 13:39     ` [PATCH v2 3/5] dt-bindings: sdhci-omap: Add bindings for the sdhci-omap controller Kishon Vijay Abraham I
2017-08-22 17:39       ` Tony Lindgren
2017-08-23  5:42     ` [PATCH v3 " Kishon Vijay Abraham I
2017-08-23 13:07       ` Ulf Hansson
2017-08-23 13:56         ` Kishon Vijay Abraham I
2017-08-24 11:29           ` Ulf Hansson
2017-08-29 11:20             ` Kishon Vijay Abraham I
2017-08-29 11:50               ` Sebastian Reichel
2017-08-29 13:58                 ` Tony Lindgren
2017-08-29 14:43                   ` Tony Lindgren
2017-08-29 17:09                   ` Rob Herring
2017-08-29 17:39                     ` Tony Lindgren
2017-09-05  8:52                       ` Kishon Vijay Abraham I
2017-09-05 16:51                         ` Tony Lindgren
2017-08-29 17:11       ` Rob Herring
2017-09-05  8:53         ` Kishon Vijay Abraham I
2017-08-21  7:41 ` [PATCH 4/5] mmc: sdhci-omap: Add OMAP SDHCI driver Kishon Vijay Abraham I
2017-08-28  9:06   ` Adrian Hunter
2017-08-30 13:53     ` Kishon Vijay Abraham I
2017-08-31 13:02       ` Adrian Hunter
2017-09-05  8:57         ` Kishon Vijay Abraham I
2017-08-21  7:41 ` [PATCH 5/5] MAINTAINERS: Add TI OMAP SDHCI Maintainer Kishon Vijay Abraham I
2017-08-28  9:07   ` Adrian Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170821074132.4622-2-kishon@ti.com \
    --to=kishon@ti.com \
    --cc=adrian.hunter@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=nsekhar@ti.com \
    --cc=rk@ti.com \
    --cc=robh+dt@kernel.org \
    --cc=tony@atomide.com \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).