Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2566982ybc; Mon, 18 Nov 2019 00:51:20 -0800 (PST) X-Google-Smtp-Source: APXvYqwTOzzV/jBwkPn4l5T/YqI0qtAu2dmMRs/05MqXkSu3YTfvBMgOKMxyvIa4QTHinnGoGtJC X-Received: by 2002:a17:906:b246:: with SMTP id ce6mr24332714ejb.298.1574067080767; Mon, 18 Nov 2019 00:51:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574067080; cv=none; d=google.com; s=arc-20160816; b=Xs4vJkanDRp4GFr3U3bq9Xe2tKtOjeQ3T6ohJVa3YJ2xHmOfpV/vV/HRRZCradU6/f ZKxrxsrVP/3U4AfWNeibj0hL5fsV3yQoamYbDPRmUSaojOxgoN97YH9/+VOSTjMSp9GY i2PMndjtVYBoyBcc8pmW9MJxLkez10g89zfYySnX69yyaCWiQ0y85BYElHskS3dzRGMA knEuZo7wbU3XreDU05m0ZuMN+epE9Qt8yiSRiuOOeggCHxpwF5qj4HU3x0tb31BSjk8A sgr9LCAsqmHntisMrTHm0UFAgRAsjpHoK5beOOJhir3DeSTanxC7hjzwEsKHdtt69suW ycOw== 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=E++A9cFu+RuODjxtUYU7qoT2nga36C9wZmSCAnOnix4=; b=Cy/QVcPqExLAtUSeSG4fAFlBRyT9IG/G0/tgdejBSXqYuciokSVuwuvExJJexx1sAE g+IYrqd/I+Uf/7cANwlLkcMQFnq3vTvuTY23/C4vmzSh/WNI9o+irNIpQKhdPz/JTFWu Lz8C4lbmvFi5Z1GvMjHWelFor9CXJWZ4YhoPAngVeqVe2xfBs1+ZIDtVU6CWLd6M0CLB rAQgi+3if3A/xDPGzOQYwdrjsR8IApE7mPkCKM2jqSdb+Tjb0/TBo/S60l7US+izLJwZ D7sGbBLt5jRdrZIVJXVBQWWCLOKZTXdnxjhR4/IOAFVQBe7d/UH+7WdfaeNWiaB0iTsq lIPQ== 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 va6si10691652ejb.73.2019.11.18.00.50.55; Mon, 18 Nov 2019 00:51:20 -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 S1726695AbfKRIrY (ORCPT + 99 others); Mon, 18 Nov 2019 03:47:24 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:34679 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726631AbfKRIrX (ORCPT ); Mon, 18 Nov 2019 03:47:23 -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 1iWcgo-0004FT-A3; Mon, 18 Nov 2019 09:47:18 +0100 Received: from ukl by ptx.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1iWcgn-0001PK-VT; Mon, 18 Nov 2019 09:47:17 +0100 Date: Mon, 18 Nov 2019 09:47:17 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Dmitry Torokhov Cc: Wolfram Sang , linux-iio@vger.kernel.org, Luca Ceresoli , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: Re: [PATCH v3 3/3] i2c: smbus: switch from loops to memcpy Message-ID: <20191118084717.rv2f24fg523gq6dr@pengutronix.de> References: <20191112203132.163306-1-dmitry.torokhov@gmail.com> <20191112203132.163306-4-dmitry.torokhov@gmail.com> <20191118074757.edyfvz5s3pqnu67y@pengutronix.de> <20191118080939.GC251795@dtor-ws> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191118080939.GC251795@dtor-ws> 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 On Mon, Nov 18, 2019 at 12:09:39AM -0800, Dmitry Torokhov wrote: > 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 > > > > > > --- > > > > > > 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. OK, and as passing data with data->block[0] = 254 also makes the code do strange things already without your patch. I now also checked the other conversions for similar problems and didn't find any. So: Acked-by: Uwe Kleine-K?nig Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | https://www.pengutronix.de/ |