linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fan Du <fan.du-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: seth.heasley-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org
Cc: fengyuleidian0615-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Fan Du <fan.du-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: [PATCH 2/2] i2c-ismt: use correct length when copy buffer
Date: Tue, 16 Sep 2014 17:21:04 +0800	[thread overview]
Message-ID: <1410859264-7118-3-git-send-email-fan.du@intel.com> (raw)
In-Reply-To: <1410859264-7118-1-git-send-email-fan.du-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

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-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 drivers/i2c/busses/i2c-ismt.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c
index 8a0275c..3f6ecbf 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,
 			desc->wr_len_cmd = dma_size;
 			desc->control |= ISMT_DESC_BLK;
 			priv->dma_buffer[0] = command;
-			memcpy(&priv->dma_buffer[1], &data->block[1], dma_size);
+			memcpy(&priv->dma_buffer[1], &data->block[1], dma_size - 1);
 		} else {
 			/* Block Read */
 			dev_dbg(dev, "I2C_SMBUS_BLOCK_DATA:  READ\n");
@@ -525,7 +525,7 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,
 			desc->wr_len_cmd = dma_size;
 			desc->control |= ISMT_DESC_I2C;
 			priv->dma_buffer[0] = command;
-			memcpy(&priv->dma_buffer[1], &data->block[1], dma_size);
+			memcpy(&priv->dma_buffer[1], &data->block[1], dma_size - 1);
 		} else {
 			/* i2c Block Read */
 			dev_dbg(dev, "I2C_SMBUS_I2C_BLOCK_DATA:  READ\n");
-- 
1.7.9.5

  parent reply	other threads:[~2014-09-16  9:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-16  9:21 [PATCH 0/2] Small fix with i2c-ismt driver Fan Du
     [not found] ` <1410859264-7118-1-git-send-email-fan.du-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-09-16  9:21   ` [PATCH 1/2] i2c-ismt: Use minimum descriptor size Fan Du
     [not found]     ` <1410859264-7118-2-git-send-email-fan.du-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-09-16 10:18       ` Neil Horman
2014-09-20 12:55       ` Wolfram Sang
2014-09-16  9:21   ` Fan Du [this message]
     [not found]     ` <1410859264-7118-3-git-send-email-fan.du-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-09-16 10:18       ` [PATCH 2/2] i2c-ismt: use correct length when copy buffer Neil Horman
2014-09-20 12:58       ` Wolfram Sang

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=1410859264-7118-3-git-send-email-fan.du@intel.com \
    --to=fan.du-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=fengyuleidian0615-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org \
    --cc=seth.heasley-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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).