Received: from milmhbs1.lsil.com (147.145.21.209) by coscas01.lsi.com
 (172.21.36.60) with Microsoft SMTP Server id 8.1.393.1; Mon, 12 Oct 2009
 20:54:51 -0600
Received: from mail2.lsil.com (mail2.lsil.com [147.145.40.22])	by
 milmhbs1.lsil.com (8.12.11/8.12.11) with ESMTP id n9D2spG4025909	for
 <andy.sharp@lsi.com>; Mon, 12 Oct 2009 19:54:51 -0700
Received: from psmtp.com (na3sys009amx243.postini.com [74.125.149.127])	by
 mail2.lsil.com (8.12.11/8.12.11) with SMTP id n9D2pCdi009648	for
 <andy.sharp@lsi.com>; Mon, 12 Oct 2009 19:51:13 -0700 (PDT)
Received: from source ([78.24.191.182]) by na3sys009amx243.postini.com
 ([74.125.148.14]) with SMTP;	Tue, 13 Oct 2009 02:54:50 GMT
Received: from localhost.localdomain ([127.0.0.1]:45675 "EHLO
	eddie.linux-mips.org" rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org	with
 ESMTP id S1492079AbZJMCys (ORCPT <rfc822;andy.sharp@lsi.com>);	Tue, 13 Oct
 2009 04:54:48 +0200
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 13 Oct 2009 04:54:30
 +0200 (CEST)
Received: from TYO201.gate.nec.co.jp ([202.32.8.193]:45459 "EHLO
	tyo201.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org	with
 ESMTP id S1492012AbZJMCxo (ORCPT	<rfc822;linux-mips@linux-mips.org>); Tue, 13
 Oct 2009 04:53:44 +0200
Received: from relay21.aps.necel.com ([10.29.19.50])	by tyo201.gate.nec.co.jp
 (8.13.8/8.13.4) with ESMTP id n9D2rRhZ011976;	Tue, 13 Oct 2009 11:53:27 +0900
 (JST)
Received: from realmbox31.aps.necel.com ([10.29.19.36] [10.29.19.36]) by
 relay21.aps.necel.com with ESMTP; Tue, 13 Oct 2009 11:53:27 +0900
Received: from [10.114.180.134] ([10.114.180.134] [10.114.180.134]) by
 mbox02.aps.necel.com with ESMTP; Tue, 13 Oct 2009 11:53:27 +0900
From: Shinya Kuribayashi <shinya.kuribayashi@necel.com>
To: "baruch@tkos.co.il" <baruch@tkos.co.il>, "linux-i2c@vger.kernel.org"
	<linux-i2c@vger.kernel.org>
CC: "ben-linux@fluff.org" <ben-linux@fluff.org>, "linux-mips@linux-mips.org"
	<linux-mips@linux-mips.org>, "linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Sender: "linux-mips-bounce@linux-mips.org" <linux-mips-bounce@linux-mips.org>
Date: Mon, 12 Oct 2009 20:53:35 -0600
Subject: [PATCH 14/16] i2c-designware: Deferred FIFO-data-counting variables
 initialization
Thread-Topic: [PATCH 14/16] i2c-designware: Deferred FIFO-data-counting
 variables initialization
Thread-Index: AcpLsIlJ/iMqGEFyTx2FhfrhOJJhWQ==
Message-ID: <4AD3EBAF.2040903@necel.com>
References: <4AD3E974.8080200@necel.com>
In-Reply-To: <4AD3E974.8080200@necel.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Anonymous
X-MS-Exchange-Organization-AuthSource: coscas01.lsi.com
X-MS-Has-Attach:
X-Auto-Response-Suppress: All
X-MS-TNEF-Correlator:
x-scanned-by: MIMEDefang 2.39
errors-to: linux-mips-bounce@linux-mips.org
x-pstn-levels: (S:99.90000/99.90000 CV:99.9000 FC:95.5390 LC:95.5390
 R:95.9108 P:95.9108 M:97.0282 C:98.6951 )
x-pstn-settings: 3 (1.0000:1.0000) s cv gt3 gt2 gt1 r p m c 
x-pstn-addresses: from <shinya.kuribayashi@necel.com> [db-null] 
x-pstn-neptune: 0/0/0.00/0
user-agent: Thunderbird 2.0.0.23 (Windows/20090812)
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

As the driver and hardware always process the given data in parallel,
it would be better to initialize those {tx,rx}_limit or rx_valid
variables just prior to be used.

This will help to send/receive data as much as possible.

Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi@necel.com>
---
 drivers/i2c/busses/i2c-designware.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-d=
esignware.c
index b3152c2..f7ea032 100644
--- a/drivers/i2c/busses/i2c-designware.c
+++ b/drivers/i2c/busses/i2c-designware.c
@@ -359,8 +359,7 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
 {
 	struct i2c_msg *msgs =3D dev->msgs;
 	u32 intr_mask;
-	int tx_limit =3D dev->tx_fifo_depth - readl(dev->base + DW_IC_TXFLR);
-	int rx_limit =3D dev->rx_fifo_depth - readl(dev->base + DW_IC_RXFLR);
+	int tx_limit, rx_limit;
 	u32 addr =3D msgs[dev->msg_write_idx].addr;
 	u32 buf_len =3D dev->tx_buf_len;
 	u8 *buf =3D dev->tx_buf;;
@@ -386,6 +385,9 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
 			buf_len =3D msgs[dev->msg_write_idx].len;
 		}
=20
+		tx_limit =3D dev->tx_fifo_depth - readl(dev->base + DW_IC_TXFLR);
+		rx_limit =3D dev->rx_fifo_depth - readl(dev->base + DW_IC_RXFLR);
+
 		while (buf_len > 0 && tx_limit > 0 && rx_limit > 0) {
 			if (msgs[dev->msg_write_idx].flags & I2C_M_RD) {
 				writel(0x100, dev->base + DW_IC_DATA_CMD);
@@ -418,7 +420,7 @@ i2c_dw_read(struct dw_i2c_dev *dev)
 {
 	struct i2c_msg *msgs =3D dev->msgs;
 	u32 addr =3D msgs[dev->msg_read_idx].addr;
-	int rx_valid =3D readl(dev->base + DW_IC_RXFLR);
+	int rx_valid;
=20
 	for (; dev->msg_read_idx < dev->msgs_num; dev->msg_read_idx++) {
 		u32 len;
@@ -439,6 +441,8 @@ i2c_dw_read(struct dw_i2c_dev *dev)
 			buf =3D dev->rx_buf;
 		}
=20
+		rx_valid =3D readl(dev->base + DW_IC_RXFLR);
+
 		for (; len > 0 && rx_valid > 0; len--, rx_valid--)
 			*buf++ =3D readl(dev->base + DW_IC_DATA_CMD);
=20
--=20
1.6.5


