Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2515433ybc; Sun, 17 Nov 2019 23:41:04 -0800 (PST) X-Google-Smtp-Source: APXvYqz6KTx58wm4t1e3uSM08IcTZOIAP4IZlaiEwdAKewq6fWG9B20Rii3Ebc2lGVEyYZ7Rjr9c X-Received: by 2002:a17:906:459:: with SMTP id e25mr24423646eja.259.1574062864040; Sun, 17 Nov 2019 23:41:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574062864; cv=none; d=google.com; s=arc-20160816; b=XrSUJRVOM8gDlJOXZlJ0ONR0G3iu1nTfQVYSa36u7fvjskHqA3py7h5wrUA7rLo+cN lf0wFZCtrh1l65qpSb7PBqdaUSsdSGpNHCTiCnZGud7cksl+3uIPEkWLTG/fbOEE7Hf5 6XGl0EcuQKqtdT+L2WsDpQgG0mucNMxBwkcqrokWmwJpd3EDP4ENr3UvL4KIR7NrknNJ ONcpCFEloUNFC5Kr+Oiklo8KxrHLurnCqbeVBp6kR+4uMATe/NE4lHyNwZiGutI122HY ndKkPbb7lxht0UI+y5rc5BgW/IhWKk2IzC2qbCAQja4V52l3UqpqZe2QoghuhwrjU/6c Fqvg== 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=TQuV5nll9cMunltvz4SjBrmQo4hKmN3IHhjUzdh6GPs=; b=vwrx4cheh+2Zk6SFLe9tVZO9iCuEZsw8grPSjLsr6HGtB72FJ5gBJSZlFokZAY8Phi QfEKe8l1tMINs6LC1XrBrEOukGGKStifN/IEFMgoj7wcwQMRkyyIxfjjrBpcqcW/MCJz OIklHBPP9AXFIf8MEvcXdrxek/Y5D8erWxB/T0xG8ghj30ZrmVchktSHVpbPRg16h2/I eycPfrPViLxt0YT0AoZBJLR2iqGHvNbpwYreaYnC/Ywuzd11mpBrwclp8kG0y3z0HGBz 3T+1Y/GhtOSk3/8WcMmEJo67QIJLrv7tMDGCUTJwO+OLYOPWWzhipQo4LUYxWRGorMUB R8fA== 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 m2si10311993ejj.70.2019.11.17.23.40.39; Sun, 17 Nov 2019 23:41:04 -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 S1727001AbfKRHhD (ORCPT + 99 others); Mon, 18 Nov 2019 02:37:03 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:52091 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726607AbfKRHhC (ORCPT ); Mon, 18 Nov 2019 02:37:02 -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 1iWbal-0005qx-Ti; Mon, 18 Nov 2019 08:36:59 +0100 Received: from ukl by ptx.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1iWbal-0006MR-7C; Mon, 18 Nov 2019 08:36:59 +0100 Date: Mon, 18 Nov 2019 08:36:59 +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 2/3] i2c: smbus: use get/put_unaligned_le16 when working with word data Message-ID: <20191118073659.7yomkvqthuenqjpu@pengutronix.de> References: <20191112203132.163306-1-dmitry.torokhov@gmail.com> <20191112203132.163306-3-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-3-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:31PM -0800, Dmitry Torokhov wrote: > It is potentially more performant, and also shows intent more clearly, > to use get_unaligned_le16() and put_unaligned_le16() when working with > word data. > > Signed-off-by: Dmitry Torokhov > > --- > > Changes in v3: > - split put_unaligned_le16 into a separate patch > - more call sites converted to get/put_unaligned_le16 > > drivers/i2c/i2c-core-smbus.c | 12 +++++------- > 1 file changed, 5 insertions(+), 7 deletions(-) > > diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c > index f8708409b4dbc..7b4e2270eeda1 100644 > --- a/drivers/i2c/i2c-core-smbus.c > +++ b/drivers/i2c/i2c-core-smbus.c > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > > #include "i2c-core.h" > > @@ -370,8 +371,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr, > msg[1].len = 2; > else { > msg[0].len = 3; > - msgbuf0[1] = data->word & 0xff; > - msgbuf0[2] = data->word >> 8; > + put_unaligned_le16(data->word, msgbuf0 + 1); You claim this was clearer. For me it is not. With the explicit assignment to msgbuf0[1] and msbbuf0[2] it is immediatly obvious to me what happens. Even though the endianness is explicitly mentioned in put_unaligned_le16, it takes a bit longer for me to understand what it does and which part of data->word ends up in which byte. Concerning the "potentially more performant" part: I wonder if this is backed by numbers and if it is indeed benificial on some platforms if this is a compiler problem. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | https://www.pengutronix.de/ |