Skip to content

Commit 4a5fc11

Browse files
ahunter6storulf
authored andcommitted
mmc: sdhci: Tidy reading 136-bit responses
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 <[email protected]> Signed-off-by: Kishon Vijay Abraham I <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
1 parent 52899b9 commit 4a5fc11

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

drivers/mmc/host/sdhci.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,24 +1173,32 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
11731173
}
11741174
EXPORT_SYMBOL_GPL(sdhci_send_command);
11751175

1176+
static void sdhci_read_rsp_136(struct sdhci_host *host, struct mmc_command *cmd)
1177+
{
1178+
int i, reg;
1179+
1180+
for (i = 0; i < 4; i++) {
1181+
reg = SDHCI_RESPONSE + (3 - i) * 4;
1182+
cmd->resp[i] = sdhci_readl(host, reg);
1183+
}
1184+
1185+
/* CRC is stripped so we need to do some shifting */
1186+
for (i = 0; i < 4; i++) {
1187+
cmd->resp[i] <<= 8;
1188+
if (i != 3)
1189+
cmd->resp[i] |= cmd->resp[i + 1] >> 24;
1190+
}
1191+
}
1192+
11761193
static void sdhci_finish_command(struct sdhci_host *host)
11771194
{
11781195
struct mmc_command *cmd = host->cmd;
1179-
int i;
11801196

11811197
host->cmd = NULL;
11821198

11831199
if (cmd->flags & MMC_RSP_PRESENT) {
11841200
if (cmd->flags & MMC_RSP_136) {
1185-
/* CRC is stripped so we need to do some shifting. */
1186-
for (i = 0;i < 4;i++) {
1187-
cmd->resp[i] = sdhci_readl(host,
1188-
SDHCI_RESPONSE + (3-i)*4) << 8;
1189-
if (i != 3)
1190-
cmd->resp[i] |=
1191-
sdhci_readb(host,
1192-
SDHCI_RESPONSE + (3-i)*4-1);
1193-
}
1201+
sdhci_read_rsp_136(host, cmd);
11941202
} else {
11951203
cmd->resp[0] = sdhci_readl(host, SDHCI_RESPONSE);
11961204
}

0 commit comments

Comments
 (0)