From c1c31e68b5d1413409748d74bc496f5c105e6dba Mon Sep 17 00:00:00 2001 From: Tahsin Mutlugun Date: Thu, 17 Apr 2025 14:47:06 +0300 Subject: [PATCH] drivers: i2c_rtio: max32: Inform the rtio executor on errors Call i2c_rtio_complete with a non-zero status code in case of an error so that application does not get stuck waiting for the completion queue event. An example to this situation could be an I2C target device responding with a NACK to a read or write request by the controller. Signed-off-by: Tahsin Mutlugun --- drivers/i2c/i2c_max32_rtio.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c_max32_rtio.c b/drivers/i2c/i2c_max32_rtio.c index 5cd7a41ac1b..411044bef2f 100644 --- a/drivers/i2c/i2c_max32_rtio.c +++ b/drivers/i2c/i2c_max32_rtio.c @@ -199,6 +199,7 @@ static void i2c_max32_isr_controller(const struct device *dev, mxc_i2c_regs_t *i if (int_fl0 & ADI_MAX32_I2C_INT_FL0_ERR) { data->err = -EIO; Wrap_MXC_I2C_SetIntEn(i2c, 0, 0); + max32_complete(dev, data->err); return; } @@ -303,7 +304,6 @@ static void max32_complete(const struct device *dev, int status) struct max32_i2c_data *data = dev->data; struct i2c_rtio *const ctx = data->ctx; const struct max32_i2c_config *const cfg = dev->config; - int ret = 0; if (cfg->regs->clkhi == I2C_STANDAR_BITRATE_CLKHI) { /* When I2C is configured in Standard Bitrate 100KHz @@ -319,9 +319,12 @@ static void max32_complete(const struct device *dev, int status) LOG_ERR("For Standard speed HW needs more time to run"); return; } - if (i2c_rtio_complete(ctx, ret)) { + + if (i2c_rtio_complete(ctx, status)) { data->second_msg_flag = 1; max32_start(dev); + } else { + data->second_msg_flag = 0; } }