Commit c1c31e68 authored by Tahsin Mutlugun's avatar Tahsin Mutlugun Committed by Benjamin Cabé
Browse files

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: default avatarTahsin Mutlugun <Tahsin.Mutlugun@analog.com>
parent f28f4120
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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;
	}
}