Some MMC/SD host controllers require the "data" member of "struct mmc_request" to be NULL when the command has no data attached. Change the MMC ioctl method to not initialize the "data" member when the supplied data size (blksz * blocks) is zero. Signed-off-by: Alon Ziv <alonz@xxxxxxxxxxxxx> --- drivers/mmc/card/block.c | 45 +++++++++++++++++++++++++-------------------- 1 files changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 1e0e27c..a0ab6c1 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -266,16 +266,18 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user( goto idata_err; } - idata->buf = kzalloc(idata->buf_bytes, GFP_KERNEL); - if (!idata->buf) { - err = -ENOMEM; - goto idata_err; - } + if (idata->buf_bytes != 0) { + idata->buf = kzalloc(idata->buf_bytes, GFP_KERNEL); + if (!idata->buf) { + err = -ENOMEM; + goto idata_err; + } - if (copy_from_user(idata->buf, (void __user *)(unsigned long) - idata->ic.data_ptr, idata->buf_bytes)) { - err = -EFAULT; - goto copy_err; + if (copy_from_user(idata->buf, (void __user *)(unsigned long) + idata->ic.data_ptr, idata->buf_bytes)) { + err = -EFAULT; + goto copy_err; + } } return idata; @@ -315,21 +317,23 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, cmd.opcode = idata->ic.opcode; cmd.arg = idata->ic.arg; cmd.flags = idata->ic.flags; + mrq.cmd = &cmd; - data.sg = &sg; - data.sg_len = 1; - data.blksz = idata->ic.blksz; - data.blocks = idata->ic.blocks; + if (idata->buf_bytes != 0) { + data.sg = &sg; + data.sg_len = 1; + data.blksz = idata->ic.blksz; + data.blocks = idata->ic.blocks; - sg_init_one(data.sg, idata->buf, idata->buf_bytes); + sg_init_one(data.sg, idata->buf, idata->buf_bytes); - if (idata->ic.write_flag) - data.flags = MMC_DATA_WRITE; - else - data.flags = MMC_DATA_READ; + if (idata->ic.write_flag) + data.flags = MMC_DATA_WRITE; + else + data.flags = MMC_DATA_READ; - mrq.cmd = &cmd; - mrq.data = &data; + mrq.data = &data; + } md = mmc_blk_get(bdev->bd_disk); if (!md) { @@ -353,6 +357,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, /* data.flags must already be set before doing this. */ mmc_set_data_timeout(&data, card); + /* Allow overriding the timeout_ns for empirical tuning. */ if (idata->ic.data_timeout_ns) data.timeout_ns = idata->ic.data_timeout_ns; -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html