mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Merged in david_s5/nuttx/master_kinetis_i2c_fix_txfer (pull request #965)
kinetis:i2c transfer ensure correct result returned kinetis_i2c_transfer released the mutex then fetched the state, this resulted in returning the correct results. Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
committed by
Gregory Nutt
parent
cb1672a05a
commit
1881a7216e
@@ -1134,6 +1134,7 @@ static int kinetis_i2c_transfer(struct i2c_master_s *dev,
|
|||||||
{
|
{
|
||||||
struct kinetis_i2cdev_s *priv = (struct kinetis_i2cdev_s *)dev;
|
struct kinetis_i2cdev_s *priv = (struct kinetis_i2cdev_s *)dev;
|
||||||
int msg_n;
|
int msg_n;
|
||||||
|
int rv;
|
||||||
|
|
||||||
i2cinfo("msgs=%p count=%d\n", msgs, count);
|
i2cinfo("msgs=%p count=%d\n", msgs, count);
|
||||||
DEBUGASSERT(dev != NULL && msgs != NULL && (unsigned)count <= UINT16_MAX);
|
DEBUGASSERT(dev != NULL && msgs != NULL && (unsigned)count <= UINT16_MAX);
|
||||||
@@ -1220,11 +1221,15 @@ static int kinetis_i2c_transfer(struct i2c_master_s *dev,
|
|||||||
timeout:
|
timeout:
|
||||||
kinetis_i2c_putreg(priv, I2C_C1_IICEN, KINETIS_I2C_C1_OFFSET);
|
kinetis_i2c_putreg(priv, I2C_C1_IICEN, KINETIS_I2C_C1_OFFSET);
|
||||||
|
|
||||||
|
/* Get the result before releasing the bus */
|
||||||
|
|
||||||
|
rv = (priv->state != STATE_OK) ? -EIO : 0;
|
||||||
|
|
||||||
/* Release access to I2C bus */
|
/* Release access to I2C bus */
|
||||||
|
|
||||||
kinetis_i2c_sem_post(priv);
|
kinetis_i2c_sem_post(priv);
|
||||||
|
|
||||||
return (priv->state != STATE_OK) ? -EIO : 0;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user