public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Wolfram Sang <wsa@the-dreams.de>,
	linux-iio@vger.kernel.org, Luca Ceresoli <luca@lucaceresoli.net>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/3] i2c: smbus: switch from loops to memcpy
Date: Mon, 18 Nov 2019 00:09:39 -0800	[thread overview]
Message-ID: <20191118080939.GC251795@dtor-ws> (raw)
In-Reply-To: <20191118074757.edyfvz5s3pqnu67y@pengutronix.de>

On Mon, Nov 18, 2019 at 08:47:57AM +0100, Uwe Kleine-König wrote:
> Hello Dmitry,
> 
> On Tue, Nov 12, 2019 at 12:31:32PM -0800, Dmitry Torokhov wrote:
> > When copying memory from one buffer to another, instead of open-coding
> > loops with byte-by-byte copies let's use memcpy() which might be a bit
> > faster and makes intent more clear.
> > 
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > 
> > ---
> > 
> > Changes in v3:
> > - new patch using memcpy() for moving data around
> > 
> >  drivers/i2c/i2c-core-smbus.c | 15 +++++----------
> >  1 file changed, 5 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c
> > index 7b4e2270eeda1..bbafdd3b1b114 100644
> > --- a/drivers/i2c/i2c-core-smbus.c
> > +++ b/drivers/i2c/i2c-core-smbus.c
> > @@ -397,8 +397,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
> >  			}
> >  
> >  			i2c_smbus_try_get_dmabuf(&msg[0], command);
> > -			for (i = 1; i < msg[0].len; i++)
> > -				msg[0].buf[i] = data->block[i - 1];
> > +			memcpy(msg[0].buf + 1, data->block, msg[0].len - 1);
> 
> Can it happen that msg[0].len is zero?

No, it can not, because of the "msg[0].len = data->block[0] + 2;" line
above.

Thanks.

-- 
Dmitry

  parent reply	other threads:[~2019-11-18  8:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-12 20:31 [PATCH v3 0/3] Use void pointers instead of char in I2C transfer APIs Dmitry Torokhov
2019-11-12 20:31 ` [PATCH v3 1/3] i2c: use void pointers for supplying data for reads and writes Dmitry Torokhov
2019-11-13  9:47   ` Luca Ceresoli
2019-11-18  7:43   ` Uwe Kleine-König
2019-11-18  8:04     ` Dmitry Torokhov
2019-11-18  8:38       ` Uwe Kleine-König
2021-01-11 21:02         ` Wolfram Sang
     [not found] ` <20191112203132.163306-4-dmitry.torokhov@gmail.com>
     [not found]   ` <20191118074757.edyfvz5s3pqnu67y@pengutronix.de>
2019-11-18  8:09     ` Dmitry Torokhov [this message]
2019-11-18  8:47       ` [PATCH v3 3/3] i2c: smbus: switch from loops to memcpy Uwe Kleine-König
2021-01-11 21:01 ` [PATCH v3 0/3] Use void pointers instead of char in I2C transfer APIs 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=20191118080939.GC251795@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca@lucaceresoli.net \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=wsa@the-dreams.de \
    /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