Skip to content

Commit f68c834

Browse files
committed
Merge branch 'for-linus/i2c/2636-rc8' of git://git.fluff.org/bjdooks/linux
* 'for-linus/i2c/2636-rc8' of git://git.fluff.org/bjdooks/linux: i2c-imx: do not allow interruptions when waiting for I2C to complete i2c-davinci: Fix TX setup for more SoCs
2 parents 822a2e4 + e39428d commit f68c834

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

drivers/i2c/busses/i2c-davinci.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,21 +331,16 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
331331
INIT_COMPLETION(dev->cmd_complete);
332332
dev->cmd_err = 0;
333333

334-
/* Take I2C out of reset, configure it as master and set the
335-
* start bit */
336-
flag = DAVINCI_I2C_MDR_IRS | DAVINCI_I2C_MDR_MST | DAVINCI_I2C_MDR_STT;
334+
/* Take I2C out of reset and configure it as master */
335+
flag = DAVINCI_I2C_MDR_IRS | DAVINCI_I2C_MDR_MST;
337336

338337
/* if the slave address is ten bit address, enable XA bit */
339338
if (msg->flags & I2C_M_TEN)
340339
flag |= DAVINCI_I2C_MDR_XA;
341340
if (!(msg->flags & I2C_M_RD))
342341
flag |= DAVINCI_I2C_MDR_TRX;
343-
if (stop)
344-
flag |= DAVINCI_I2C_MDR_STP;
345-
if (msg->len == 0) {
342+
if (msg->len == 0)
346343
flag |= DAVINCI_I2C_MDR_RM;
347-
flag &= ~DAVINCI_I2C_MDR_STP;
348-
}
349344

350345
/* Enable receive or transmit interrupts */
351346
w = davinci_i2c_read_reg(dev, DAVINCI_I2C_IMR_REG);
@@ -357,18 +352,29 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
357352

358353
dev->terminate = 0;
359354

355+
/*
356+
* Write mode register first as needed for correct behaviour
357+
* on OMAP-L138, but don't set STT yet to avoid a race with XRDY
358+
* occuring before we have loaded DXR
359+
*/
360+
davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag);
361+
360362
/*
361363
* First byte should be set here, not after interrupt,
362364
* because transmit-data-ready interrupt can come before
363365
* NACK-interrupt during sending of previous message and
364366
* ICDXR may have wrong data
367+
* It also saves us one interrupt, slightly faster
365368
*/
366369
if ((!(msg->flags & I2C_M_RD)) && dev->buf_len) {
367370
davinci_i2c_write_reg(dev, DAVINCI_I2C_DXR_REG, *dev->buf++);
368371
dev->buf_len--;
369372
}
370373

371-
/* write the data into mode register; start transmitting */
374+
/* Set STT to begin transmit now DXR is loaded */
375+
flag |= DAVINCI_I2C_MDR_STT;
376+
if (stop && msg->len != 0)
377+
flag |= DAVINCI_I2C_MDR_STP;
372378
davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag);
373379

374380
r = wait_for_completion_interruptible_timeout(&dev->cmd_complete,

drivers/i2c/busses/i2c-imx.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,9 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy)
159159

160160
static int i2c_imx_trx_complete(struct imx_i2c_struct *i2c_imx)
161161
{
162-
int result;
163-
164-
result = wait_event_interruptible_timeout(i2c_imx->queue,
165-
i2c_imx->i2csr & I2SR_IIF, HZ / 10);
162+
wait_event_timeout(i2c_imx->queue, i2c_imx->i2csr & I2SR_IIF, HZ / 10);
166163

167-
if (unlikely(result < 0)) {
168-
dev_dbg(&i2c_imx->adapter.dev, "<%s> result < 0\n", __func__);
169-
return result;
170-
} else if (unlikely(!(i2c_imx->i2csr & I2SR_IIF))) {
164+
if (unlikely(!(i2c_imx->i2csr & I2SR_IIF))) {
171165
dev_dbg(&i2c_imx->adapter.dev, "<%s> Timeout\n", __func__);
172166
return -ETIMEDOUT;
173167
}
@@ -295,7 +289,7 @@ static irqreturn_t i2c_imx_isr(int irq, void *dev_id)
295289
i2c_imx->i2csr = temp;
296290
temp &= ~I2SR_IIF;
297291
writeb(temp, i2c_imx->base + IMX_I2C_I2SR);
298-
wake_up_interruptible(&i2c_imx->queue);
292+
wake_up(&i2c_imx->queue);
299293
return IRQ_HANDLED;
300294
}
301295

0 commit comments

Comments
 (0)