Skip to content

Commit

Permalink
drivers: i2c: esp32: Fix to_read value on i2c_esp32_read_msg()
Browse files Browse the repository at this point in the history
to_read is the minimum value between I2C_ESP32_BUFFER_SIZE
and (msg.len - 1) rather than the maximum value.

Signed-off-by: Vitor Massaru Iha <[email protected]>
  • Loading branch information
iha authored and Anas Nashif committed Feb 7, 2018
1 parent 74321ec commit e9d1015
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/i2c/i2c_esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ static int i2c_esp32_read_msg(struct device *dev, u16_t addr,

for (; msg.len; cmd = (void *)I2C_COMD0_REG(config->index)) {
volatile struct i2c_esp32_cmd *wait_cmd = NULL;
u32_t to_read = max(I2C_ESP32_BUFFER_SIZE, msg.len - 1);
u32_t to_read = min(I2C_ESP32_BUFFER_SIZE, msg.len - 1);

/* Might be the last byte, in which case, `to_read` will
* be 0 here. See comment below.
Expand Down

0 comments on commit e9d1015

Please sign in to comment.