Commit 73f4a521 authored by Rui Miguel Silva's avatar Rui Miguel Silva Committed by Greg Kroah-Hartman

greybus: sdio: check number of blocks in transfer

Before initiating a transfers, check if the command (for single block)
match the number of blocks in the request.

While at it, fix also a missing break.
Signed-off-by: default avatarRui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 882edf59
...@@ -47,6 +47,14 @@ define_get_version(gb_sdio_host, SDIO); ...@@ -47,6 +47,14 @@ define_get_version(gb_sdio_host, SDIO);
#define GB_SDIO_RSP_R1B (GB_SDIO_RSP_PRESENT | GB_SDIO_RSP_CRC | \ #define GB_SDIO_RSP_R1B (GB_SDIO_RSP_PRESENT | GB_SDIO_RSP_CRC | \
GB_SDIO_RSP_OPCODE | GB_SDIO_RSP_BUSY) GB_SDIO_RSP_OPCODE | GB_SDIO_RSP_BUSY)
static inline bool single_op(struct mmc_command *cmd)
{
uint32_t opcode = cmd->opcode;
return opcode == MMC_WRITE_BLOCK ||
opcode == MMC_READ_SINGLE_BLOCK;
}
static void _gb_sdio_set_host_caps(struct gb_sdio_host *host, u32 r) static void _gb_sdio_set_host_caps(struct gb_sdio_host *host, u32 r)
{ {
u32 caps = 0; u32 caps = 0;
...@@ -292,6 +300,11 @@ static int gb_sdio_transfer(struct gb_sdio_host *host, struct mmc_data *data) ...@@ -292,6 +300,11 @@ static int gb_sdio_transfer(struct gb_sdio_host *host, struct mmc_data *data)
int ret = 0; int ret = 0;
u16 nblocks; u16 nblocks;
if (single_op(data->mrq->cmd) && data->blocks > 1) {
ret = -ETIMEDOUT;
goto out;
}
left = data->blksz * data->blocks; left = data->blksz * data->blocks;
while (left) { while (left) {
...@@ -351,6 +364,7 @@ static int gb_sdio_command(struct gb_sdio_host *host, struct mmc_command *cmd) ...@@ -351,6 +364,7 @@ static int gb_sdio_command(struct gb_sdio_host *host, struct mmc_command *cmd)
break; break;
case MMC_RSP_R3: case MMC_RSP_R3:
cmd_flags = GB_SDIO_RSP_R3_R4; cmd_flags = GB_SDIO_RSP_R3_R4;
break;
default: default:
dev_err(mmc_dev(host->mmc), "cmd flag invalid %04x\n", dev_err(mmc_dev(host->mmc), "cmd flag invalid %04x\n",
mmc_resp_type(cmd)); mmc_resp_type(cmd));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment