Skip to content

Commit 1653c2f

Browse files
committed
Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang: "Two more driver bugfixes" * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: i2c: bcm2835: Clear current buffer pointers and counts after a transfer i2c: cadence: Fix the hold bit setting
2 parents b8c82b6 + f275a46 commit 1653c2f

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

drivers/i2c/busses/i2c-bcm2835.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,15 @@ static void bcm2835_i2c_start_transfer(struct bcm2835_i2c_dev *i2c_dev)
183183
bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, c);
184184
}
185185

186+
static void bcm2835_i2c_finish_transfer(struct bcm2835_i2c_dev *i2c_dev)
187+
{
188+
i2c_dev->curr_msg = NULL;
189+
i2c_dev->num_msgs = 0;
190+
191+
i2c_dev->msg_buf = NULL;
192+
i2c_dev->msg_buf_remaining = 0;
193+
}
194+
186195
/*
187196
* Note about I2C_C_CLEAR on error:
188197
* The I2C_C_CLEAR on errors will take some time to resolve -- if you were in
@@ -283,6 +292,9 @@ static int bcm2835_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
283292

284293
time_left = wait_for_completion_timeout(&i2c_dev->completion,
285294
adap->timeout);
295+
296+
bcm2835_i2c_finish_transfer(i2c_dev);
297+
286298
if (!time_left) {
287299
bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C,
288300
BCM2835_I2C_C_CLEAR);

drivers/i2c/busses/i2c-cadence.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,10 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id)
382382
* Check for the message size against FIFO depth and set the
383383
* 'hold bus' bit if it is greater than FIFO depth.
384384
*/
385-
if (id->recv_count > CDNS_I2C_FIFO_DEPTH)
385+
if ((id->recv_count > CDNS_I2C_FIFO_DEPTH) || id->bus_hold_flag)
386386
ctrl_reg |= CDNS_I2C_CR_HOLD;
387+
else
388+
ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD;
387389

388390
cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
389391

@@ -440,8 +442,11 @@ static void cdns_i2c_msend(struct cdns_i2c *id)
440442
* Check for the message size against FIFO depth and set the
441443
* 'hold bus' bit if it is greater than FIFO depth.
442444
*/
443-
if (id->send_count > CDNS_I2C_FIFO_DEPTH)
445+
if ((id->send_count > CDNS_I2C_FIFO_DEPTH) || id->bus_hold_flag)
444446
ctrl_reg |= CDNS_I2C_CR_HOLD;
447+
else
448+
ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD;
449+
445450
cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
446451

447452
/* Clear the interrupts in interrupt status register. */

0 commit comments

Comments
 (0)