Skip to content

Commit

Permalink
i2c: fix i2c_bcm2708: avoid extra peripheral read
Browse files Browse the repository at this point in the history
Check if FIFO can accept data before writing.
To avoid a peripheral read on the last iteration of a loop,
both bcm2708_bsc_fifo_fill and ~drain are changed.
  • Loading branch information
SimonMaes committed Aug 29, 2016
1 parent 3a46cfd commit c589fc9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/i2c/busses/i2c-bcm2708.c
Expand Up @@ -115,13 +115,13 @@ static inline void bcm2708_bsc_reset(struct bcm2708_i2c *bi)

static inline void bcm2708_bsc_fifo_drain(struct bcm2708_i2c *bi)
{
while ((bcm2708_rd(bi, BSC_S) & BSC_S_RXD) && (bi->pos < bi->msg->len))
while ((bi->pos < bi->msg->len) && (bcm2708_rd(bi, BSC_S) & BSC_S_RXD))
bi->msg->buf[bi->pos++] = bcm2708_rd(bi, BSC_FIFO);
}

static inline void bcm2708_bsc_fifo_fill(struct bcm2708_i2c *bi)
{
while ((bcm2708_rd(bi, BSC_S) & BSC_S_TXD) && (bi->pos < bi->msg->len))
while ((bi->pos < bi->msg->len) && (bcm2708_rd(bi, BSC_S) & BSC_S_TXD))
bcm2708_wr(bi, BSC_FIFO, bi->msg->buf[bi->pos++]);
}

Expand Down

0 comments on commit c589fc9

Please sign in to comment.