aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFan Du <fan.du@intel.com>2014-09-16 05:21:04 -0400
committerWolfram Sang <wsa@the-dreams.de>2014-09-20 08:56:19 -0400
commit979bbf7b7ae75cfc06e09d09eda38009a3bdc4a4 (patch)
tree21a516ee7c162ac5d7b7718aec594a729e875087
parent938916fbb8e8cb67eacb784f4eda17e2950c16c5 (diff)
i2c: ismt: use correct length when copy buffer
In block write mode, when encapsulating dma_buffer, first element is 'command', the rest is data buffer, so only copy actual data buffer starting from block[1] with the size indicating by block[0]. Signed-off-by: Fan Du <fan.du@intel.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Cc: stable@kernel.org
-rw-r--r--drivers/i2c/busses/i2c-ismt.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c
index 984492553e95..d9ee43c80cde 100644
--- a/drivers/i2c/busses/i2c-ismt.c
+++ b/drivers/i2c/busses/i2c-ismt.c
@@ -497,7 +497,7 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,
497 desc->wr_len_cmd = dma_size; 497 desc->wr_len_cmd = dma_size;
498 desc->control |= ISMT_DESC_BLK; 498 desc->control |= ISMT_DESC_BLK;
499 priv->dma_buffer[0] = command; 499 priv->dma_buffer[0] = command;
500 memcpy(&priv->dma_buffer[1], &data->block[1], dma_size); 500 memcpy(&priv->dma_buffer[1], &data->block[1], dma_size - 1);
501 } else { 501 } else {
502 /* Block Read */ 502 /* Block Read */
503 dev_dbg(dev, "I2C_SMBUS_BLOCK_DATA: READ\n"); 503 dev_dbg(dev, "I2C_SMBUS_BLOCK_DATA: READ\n");
@@ -525,7 +525,7 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,
525 desc->wr_len_cmd = dma_size; 525 desc->wr_len_cmd = dma_size;
526 desc->control |= ISMT_DESC_I2C; 526 desc->control |= ISMT_DESC_I2C;
527 priv->dma_buffer[0] = command; 527 priv->dma_buffer[0] = command;
528 memcpy(&priv->dma_buffer[1], &data->block[1], dma_size); 528 memcpy(&priv->dma_buffer[1], &data->block[1], dma_size - 1);
529 } else { 529 } else {
530 /* i2c Block Read */ 530 /* i2c Block Read */
531 dev_dbg(dev, "I2C_SMBUS_I2C_BLOCK_DATA: READ\n"); 531 dev_dbg(dev, "I2C_SMBUS_I2C_BLOCK_DATA: READ\n");