Skip to content

Commit 7c8cb78

Browse files
MulinChaonashif
authored andcommitted
driver: i2c: npcx: reset i2c semaphore before start transaction.
This CL reset i2c event-completed semaphore before starting transactions. Some interrupt events such as BUS_ERROR might change its counter when i2c bus is idle. It causes that the driver cannot wait for the event completed and return immediately. Signed-off-by: Mulin Chao <[email protected]>
1 parent 5ccb89c commit 7c8cb78

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/i2c/i2c_npcx_controller.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,13 @@ int npcx_i2c_ctrl_transfer(const struct device *i2c_dev, struct i2c_msg *msgs,
790790
data->trans_err = 0;
791791
data->addr = addr;
792792

793+
/*
794+
* Reset i2c event-completed semaphore before starting transactions.
795+
* Some interrupt events such as BUS_ERROR might change its counter
796+
* when bus is idle.
797+
*/
798+
k_sem_reset(&data->sync_sem);
799+
793800
for (i = 0U; i < num_msgs; i++) {
794801
struct i2c_msg *msg = msgs + i;
795802

0 commit comments

Comments
 (0)