Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2522294ybc; Sun, 17 Nov 2019 23:51:31 -0800 (PST) X-Google-Smtp-Source: APXvYqzdnWRKDLb5mHGjYJss6+t9DTIJaERFGFDSd0Z9mswfz7VUS7YFI2ehr7Vgm6N9kJdIyY/M X-Received: by 2002:a17:906:c57:: with SMTP id t23mr24686479ejf.240.1574063491722; Sun, 17 Nov 2019 23:51:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574063491; cv=none; d=google.com; s=arc-20160816; b=dZlAaaexFiQ5ExTVnuLwZHjdZllEI2EXzcxr9jDDRDMiE3+CoaIYD1aR5Jy+u0OKG3 4DS/zFQ8QM0SOvMgL/n9Jx9FlIQc3Q2uhPvpnl/e6gtUh9dYxDc407vCgeNePje3JeMS t6FF5rC4GelyniGcYgtDfTJQHE1ZCLoEm0bJRwDdX2ouGEzG/rfmPJ/2suW0E3WVOX3Y 4ekQEOF5MXy0LTGWf5Qzm3gOt2et/BFwG/3Yk8HaYr4vcmvG3oE2MtutCn5JqIca+IYl RSdufTLmSMLmwrivEkseCQLD/KCGrFTqE8b7J9v72Ad1peG7xCf17OoNWPBIhZ5ZZOr6 +b5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Lyqf4QVVBM3PfKfOtCMEca4bdYbmHnVgpkMz0hVRqEk=; b=Mysy0eXT4S8oVoPPOHlKJ5vgzm5bdUCc2J+Rlxc+PdpcU+kBfdwNlzgW8AoRpfG1d0 3nN4I3pOxZETA7PzDZ1tU8d8G/V9kfu0e/WQ6s6N7kDDUho7a8GKanRXejVlGD4W8AiX CqKJ6uxWusm+rFw61xERfieytlUtH+PADnbHKDAeH8cAz47Nm6o3svNpjntqAFBI5wpg mCVLF1VX2aiGtKsosMlCBitW1YqLsDgP05HJt7olLgf5p566QAxY6jYQBv2P8xSLmPAf g31RvIGzLur1lKFjTCmIYOYbzgRKJiEu9MLYgG/V5vcRkug3tKKGaDefTi5ipgDjsDKb F0IQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id np1si11177033ejb.370.2019.11.17.23.51.06; Sun, 17 Nov 2019 23:51:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726460AbfKRHsB (ORCPT + 99 others); Mon, 18 Nov 2019 02:48:01 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:40529 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726283AbfKRHsB (ORCPT ); Mon, 18 Nov 2019 02:48:01 -0500 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iWblN-0006ki-Ms; Mon, 18 Nov 2019 08:47:57 +0100 Received: from ukl by ptx.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1iWblN-0006g1-Cz; Mon, 18 Nov 2019 08:47:57 +0100 Date: Mon, 18 Nov 2019 08:47:57 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Dmitry Torokhov Cc: Wolfram Sang , linux-iio@vger.kernel.orgi, Luca Ceresoli , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/3] i2c: smbus: switch from loops to memcpy Message-ID: <20191118074757.edyfvz5s3pqnu67y@pengutronix.de> References: <20191112203132.163306-1-dmitry.torokhov@gmail.com> <20191112203132.163306-4-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191112203132.163306-4-dmitry.torokhov@gmail.com> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > --- > > 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/ |