Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2520540ybc; Sun, 17 Nov 2019 23:48:38 -0800 (PST) X-Google-Smtp-Source: APXvYqwmF8mdkZ9w91BeAw8Q7RovK3RgJleF8Brpvtvp+6hk/tY4M6dViRpjfIbSqzbXZdN6hj7e X-Received: by 2002:a17:906:7e41:: with SMTP id z1mr24386755ejr.63.1574063318321; Sun, 17 Nov 2019 23:48:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574063318; cv=none; d=google.com; s=arc-20160816; b=0jws00fXOHo754XKMxwSF1T7CPx+fiyppclIP7eoMWhCzsgmIQRJdXlOcaryN3Y5y0 WaabZX+Ix/igBinxsETembEg+mV9tIzekV9/WPZLouFDSq952DimTFVXshpG610PUSc8 nKvONcP6KFSxvmQchyu4heR6W8755nnzD00B43PmJryJlhePMdjAYJadeD/RHIQ3nSFT LqKjrml1B66dID+x9zBV3FmslTIeihlDFvsrEs4wii7aFgAXDixac/hzE8yrMrAOP/Jo orKqx4xdcYPIm9A1QkcFSHWaVgmpMPwI39L0peix7cYT/ZvV2z8nlCTCvzHhFZEI+qxl HqEA== 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=hGfOfxSv42KjuwX2lWt4sBeQ38azprJ/kPvDleeR7hU=; b=0cJPEuwTUb3U/hK2d1G4rryg/5FLY8fd6FqHmEufRPnLdxAfdn/g74Xy1DS66/+V+1 S+X4S+21krGJOCAD5WXc3+ck7TXo/bcSEBc2ChTYJ3UKIU4MYPLBo/9Hh6mBvGrnkqpj YHU4YvI4S5OQIVvLqj4jfIGuUvq2guZNFpAaxf2IBdspceEdmU8Xulo1tDX56s7xEFJx OpaA5X3lhFZUbbG0DspY8T1n03N6QzRu9ANjo7593VbZ9sKdOfD4aKfiuFhfEyScTivj ZiDgDi2hFXBqkePXt36jRRulIuQU/a/Oieg90reiSbCC04L4yiB/zcPxTUwzt5EPQFNJ +7Cw== 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 w27si12648191eda.296.2019.11.17.23.48.13; Sun, 17 Nov 2019 23:48:38 -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 S1726814AbfKRHoR (ORCPT + 99 others); Mon, 18 Nov 2019 02:44:17 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:39563 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726414AbfKRHoQ (ORCPT ); Mon, 18 Nov 2019 02:44:16 -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 1iWbhR-0006Ng-Ks; Mon, 18 Nov 2019 08:43:53 +0100 Received: from ukl by ptx.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1iWbhN-0006X4-QV; Mon, 18 Nov 2019 08:43:49 +0100 Date: Mon, 18 Nov 2019 08:43:49 +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, Jonathan Cameron , Hartmut Knaack , Jonathan Cameron , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: Re: [PATCH v3 1/3] i2c: use void pointers for supplying data for reads and writes Message-ID: <20191118074349.ags3c4tmvapguqcp@pengutronix.de> References: <20191112203132.163306-1-dmitry.torokhov@gmail.com> <20191112203132.163306-2-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-2-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:30PM -0800, Dmitry Torokhov wrote: > There is no need to force users of i2c_master_send()/i2c_master_recv() > and other i2c read/write bulk data API to cast everything into u8 pointers. > While everything can be considered byte stream, the drivers are usually > work with more structured data. > > Let's switch the APIs to accept [const] void pointers to cut amount of > casting needed. > > Acked-by: Jonathan Cameron > Signed-off-by: Dmitry Torokhov Can you give an example where you save some casts? Given that i2c is a byte oriented protocol (as opposed to for example spi) I think it's a good idea to expose this in the API. > diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c > index 5c2cc61b666e7..48ed76a0e83d4 100644 > --- a/drivers/iio/adc/max1363.c > +++ b/drivers/iio/adc/max1363.c This change isn't motivated in the commit log. Is this here by mistake? > @@ -182,9 +182,9 @@ struct max1363_state { > struct regulator *vref; > u32 vref_uv; > int (*send)(const struct i2c_client *client, > - const char *buf, int count); > + const void *buf, int count); > int (*recv)(const struct i2c_client *client, > - char *buf, int count); > + void *buf, int count); > }; > > #define MAX1363_MODE_SINGLE(_num, _mask) { \ > @@ -310,27 +310,29 @@ static const struct max1363_mode > return NULL; > } > > -static int max1363_smbus_send(const struct i2c_client *client, const char *buf, > +static int max1363_smbus_send(const struct i2c_client *client, const void *buf, > int count) > { > + const u8 *data = buf; > int i, err; > > for (i = err = 0; err == 0 && i < count; ++i) > - err = i2c_smbus_write_byte(client, buf[i]); > + err = i2c_smbus_write_byte(client, data[i]); Isn't this hunk an indicator that keeping char (or u8) as type of the members of buf is a good idea? > return err ? err : count; > } > > -static int max1363_smbus_recv(const struct i2c_client *client, char *buf, > +static int max1363_smbus_recv(const struct i2c_client *client, void *buf, > int count) > { > + u8 *data = buf; > int i, ret; > > for (i = 0; i < count; ++i) { > ret = i2c_smbus_read_byte(client); > if (ret < 0) > return ret; > - buf[i] = ret; > + data[i] = ret; > } > > return count; Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | https://www.pengutronix.de/ |