From 6452b2e5e27571d10e1fe65749fe66581b9a9325 Mon Sep 17 00:00:00 2001 From: Vitor Massaru Iha Date: Thu, 25 Jan 2018 13:37:24 -0200 Subject: [PATCH] drivers: i2c: esp32: Fix command address on i2c_esp32_write_msg() The wait address command must be the last command address. Unncessary variable was removed. Signed-off-by: Vitor Massaru Iha --- drivers/i2c/i2c_esp32.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/i2c_esp32.c b/drivers/i2c/i2c_esp32.c index b5cadeda87a..b735ec20214 100644 --- a/drivers/i2c/i2c_esp32.c +++ b/drivers/i2c/i2c_esp32.c @@ -497,7 +497,6 @@ static int i2c_esp32_write_msg(struct device *dev, u16_t addr, cmd = i2c_esp32_write_addr(dev, cmd, &msg, addr); for (; msg.len; cmd = (void *)I2C_COMD0_REG(config->index)) { - volatile struct i2c_esp32_cmd *wait_cmd = cmd; u32_t to_send = min(I2C_ESP32_BUFFER_SIZE, msg.len); u32_t i; int ret; @@ -515,16 +514,16 @@ static int i2c_esp32_write_msg(struct device *dev, u16_t addr, msg.len -= to_send; if (!msg.len && (msg.flags & I2C_MSG_STOP)) { - *cmd++ = (struct i2c_esp32_cmd) { + *cmd = (struct i2c_esp32_cmd) { .opcode = I2C_ESP32_OP_STOP }; } else { - *cmd++ = (struct i2c_esp32_cmd) { + *cmd = (struct i2c_esp32_cmd) { .opcode = I2C_ESP32_OP_END }; } - ret = i2c_esp32_transmit_wait(dev, wait_cmd); + ret = i2c_esp32_transmit_wait(dev, cmd); if (ret < 0) { return ret; }