drivers: i2c: qmsi shim driver bug fix

Fix a bug in i2c_qmsi_transfer function in the shim driver.
The function did not wait for the completion of a msg transfer
before starting another msg transfer. Similar issue exists in
the i2c sensor shim driver. It is also fixed.

Change-Id: I1f8ad2281fa185d85db25a4682ed596c02ea322e
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
This commit is contained in:
Baohong Liu 2016-06-28 14:26:19 -07:00 committed by Inaky Perez-Gonzalez
parent a09a696ff0
commit 5846bb6d65
2 changed files with 15 additions and 13 deletions

View file

@ -132,11 +132,13 @@ static int i2c_qmsi_transfer(struct device *dev, struct i2c_msg *msgs,
int rc;
qm_i2c_get_status(instance, &status);
if (status != QM_I2C_IDLE)
if (status != QM_I2C_IDLE) {
return -EBUSY;
}
if (msgs == NULL || num_msgs == 0)
if (msgs == NULL || num_msgs == 0) {
return -ENOTSUP;
}
for (int i = 0; i < num_msgs; i++) {
uint8_t op = msgs[i].flags & I2C_MSG_RW_MASK;
@ -158,15 +160,15 @@ static int i2c_qmsi_transfer(struct device *dev, struct i2c_msg *msgs,
rc = qm_i2c_master_irq_transfer(instance, &xfer, addr);
nano_sem_give(&driver_data->sem);
if (rc != 0)
if (rc != 0) {
return -EIO;
}
/* Block current thread until the I2C transfer completes. */
if (stop || op != I2C_MSG_WRITE) {
device_sync_call_wait(&driver_data->sync);
if (driver_data->transfer_status != 0) {
return -EIO;
}
device_sync_call_wait(&driver_data->sync);
if (driver_data->transfer_status != 0) {
return -EIO;
}
}

View file

@ -254,15 +254,15 @@ static int i2c_qmsi_ss_transfer(struct device *dev, struct i2c_msg *msgs,
nano_sem_take(&driver_data->sem, TICKS_UNLIMITED);
rc = qm_ss_i2c_master_irq_transfer(instance, &xfer, addr);
nano_sem_give(&driver_data->sem);
if (rc != 0)
if (rc != 0) {
return -EIO;
}
/* Block current thread until the I2C transfer completes. */
if (stop || op != I2C_MSG_WRITE) {
device_sync_call_wait(&driver_data->sync);
device_sync_call_wait(&driver_data->sync);
if (driver_data->transfer_status != 0)
return -EIO;
if (driver_data->transfer_status != 0) {
return -EIO;
}
}