lkml.org 
[lkml]   [2019]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 3/3] i2c: smbus: switch from loops to memcpy
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?

> }
> break;
> case I2C_SMBUS_BLOCK_PROC_CALL:

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |

\
 
 \ /
  Last update: 2019-11-18 08:49    [W:0.200 / U:0.384 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site