summaryrefslogtreecommitdiff
path: root/drivers/i2c
diff options
context:
space:
mode:
authorShinya Kuribayashi <shinya.kuribayashi@necel.com>2009-11-06 15:49:39 +0300
committerBen Dooks <ben-linux@fluff.org>2009-12-09 03:19:11 +0300
commitae72222d03fea3ff561e2a3aee483ef7bd1a2bbb (patch)
treee08e9e5d81fbbec97d2c6b47a09c1e7bf4be24b5 /drivers/i2c
parent26ea15b1f584de02bc85e9c3968d523386332f65 (diff)
downloadlinux-ae72222d03fea3ff561e2a3aee483ef7bd1a2bbb.tar.xz
i2c-designware: Initialize byte count variables just prior to being used
As the driver and hardware always process the given data in parallel, then it would be better to initialize tx_limit, rx_limit and rx_valid variables just prior to being used. This will help us to send / receive as much data as possible. Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi@necel.com> Acked-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-designware.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c
index e8e2212d576e..c3702a8647cb 100644
--- a/drivers/i2c/busses/i2c-designware.c
+++ b/drivers/i2c/busses/i2c-designware.c
@@ -360,8 +360,7 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
{
struct i2c_msg *msgs = dev->msgs;
u32 intr_mask;
- int tx_limit = dev->tx_fifo_depth - readl(dev->base + DW_IC_TXFLR);
- int rx_limit = dev->rx_fifo_depth - readl(dev->base + DW_IC_RXFLR);
+ int tx_limit, rx_limit;
u32 addr = msgs[dev->msg_write_idx].addr;
u32 buf_len = dev->tx_buf_len;
u8 *buf = dev->tx_buf;;
@@ -389,6 +388,9 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
buf_len = msgs[dev->msg_write_idx].len;
}
+ tx_limit = dev->tx_fifo_depth - readl(dev->base + DW_IC_TXFLR);
+ rx_limit = 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 = dev->msgs;
u32 addr = msgs[dev->msg_read_idx].addr;
- int rx_valid = readl(dev->base + DW_IC_RXFLR);
+ int rx_valid;
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 = dev->rx_buf;
}
+ rx_valid = readl(dev->base + DW_IC_RXFLR);
+
for (; len > 0 && rx_valid > 0; len--, rx_valid--)
*buf++ = readl(dev->base + DW_IC_DATA_CMD);