From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.active-venture.com ([67.228.131.205]:61519 "EHLO mail.active-venture.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757400Ab3BSBbf (ORCPT ); Mon, 18 Feb 2013 20:31:35 -0500 Date: Mon, 18 Feb 2013 17:32:04 -0800 From: Guenter Roeck To: Lars-Peter Clausen Cc: Jean Delvare , Hartmut Knaack , Jonathan Cameron , lm-sensors@lm-sensors.org, linux-iio@vger.kernel.org Subject: Re: [PATCH v2 1/4] hwmon: (adt7410) Don't re-read non-volatile registers Message-ID: <20130219013204.GC25124@roeck-us.net> References: <1361194739-16525-1-git-send-email-lars@metafoo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <1361194739-16525-1-git-send-email-lars@metafoo.de> Sender: linux-iio-owner@vger.kernel.org List-Id: linux-iio@vger.kernel.org On Mon, Feb 18, 2013 at 02:38:56PM +0100, Lars-Peter Clausen wrote: > Currently each time the temperature register is read the driver also reads the > threshold and hysteresis registers. This increases the amount of I2C traffic and > time needed to read the temperature by a factor of ~5. Neither the threshold nor > the hysteresis change on their own, so once we've read them, we should be able > to just use the cached value of the registers. This patch modifies the code > accordingly and only reads the threshold and hysteresis registers once during > probe. > > Signed-off-by: Lars-Peter Clausen > Just one comment (thanks to Hartmut), otherwise looks good. > --- > Changes since v1: > * Fix error checking for i2c reads > --- [ ... ] > +static int adt7410_fill_cache(struct i2c_client *client) > +{ > + struct adt7410_data *data = i2c_get_clientdata(client); > + int ret; > + int i; > + > + for (i = 1; i < ARRAY_SIZE(ADT7410_REG_TEMP); i++) { > + ret = i2c_smbus_read_word_swapped(client, ADT7410_REG_TEMP[i]); > + if (ret < 0) { > + dev_dbg(&client->dev, > + "Failed to read value: reg %d, error %d\n", > + ADT7410_REG_TEMP[0], ret); ADT7410_REG_TEMP[i] Thanks, Guenter From mboxrd@z Thu Jan 1 00:00:00 1970 From: Guenter Roeck Date: Tue, 19 Feb 2013 01:32:04 +0000 Subject: Re: [lm-sensors] [PATCH v2 1/4] hwmon: (adt7410) Don't re-read non-volatile registers Message-Id: <20130219013204.GC25124@roeck-us.net> List-Id: References: <1361194739-16525-1-git-send-email-lars@metafoo.de> In-Reply-To: <1361194739-16525-1-git-send-email-lars@metafoo.de> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Lars-Peter Clausen Cc: Jean Delvare , Hartmut Knaack , Jonathan Cameron , lm-sensors@lm-sensors.org, linux-iio@vger.kernel.org On Mon, Feb 18, 2013 at 02:38:56PM +0100, Lars-Peter Clausen wrote: > Currently each time the temperature register is read the driver also reads the > threshold and hysteresis registers. This increases the amount of I2C traffic and > time needed to read the temperature by a factor of ~5. Neither the threshold nor > the hysteresis change on their own, so once we've read them, we should be able > to just use the cached value of the registers. This patch modifies the code > accordingly and only reads the threshold and hysteresis registers once during > probe. > > Signed-off-by: Lars-Peter Clausen > Just one comment (thanks to Hartmut), otherwise looks good. > --- > Changes since v1: > * Fix error checking for i2c reads > --- [ ... ] > +static int adt7410_fill_cache(struct i2c_client *client) > +{ > + struct adt7410_data *data = i2c_get_clientdata(client); > + int ret; > + int i; > + > + for (i = 1; i < ARRAY_SIZE(ADT7410_REG_TEMP); i++) { > + ret = i2c_smbus_read_word_swapped(client, ADT7410_REG_TEMP[i]); > + if (ret < 0) { > + dev_dbg(&client->dev, > + "Failed to read value: reg %d, error %d\n", > + ADT7410_REG_TEMP[0], ret); ADT7410_REG_TEMP[i] Thanks, Guenter _______________________________________________ lm-sensors mailing list lm-sensors@lm-sensors.org http://lists.lm-sensors.org/mailman/listinfo/lm-sensors