diff --git a/drivers/sensor/asahi_kasei/akm09918c/akm09918c.h b/drivers/sensor/asahi_kasei/akm09918c/akm09918c.h index 742c7d3be38..a4b35c64dd8 100644 --- a/drivers/sensor/asahi_kasei/akm09918c/akm09918c.h +++ b/drivers/sensor/asahi_kasei/akm09918c/akm09918c.h @@ -93,6 +93,6 @@ int akm09918c_sample_fetch_helper(const struct device *dev, enum sensor_channel int akm09918c_get_decoder(const struct device *dev, const struct sensor_decoder_api **decoder); -int akm09918c_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe); +void akm09918c_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe); #endif /* ZEPHYR_DRIVERS_SENSOR_AKM09918C_AKM09918C_H_ */ diff --git a/drivers/sensor/asahi_kasei/akm09918c/akm09918c_async.c b/drivers/sensor/asahi_kasei/akm09918c/akm09918c_async.c index 438ca24780d..6fb5d901ec4 100644 --- a/drivers/sensor/asahi_kasei/akm09918c/akm09918c_async.c +++ b/drivers/sensor/asahi_kasei/akm09918c/akm09918c_async.c @@ -9,7 +9,7 @@ LOG_MODULE_DECLARE(AKM09918C, CONFIG_SENSOR_LOG_LEVEL); -int akm09918c_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) +void akm09918c_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) { uint32_t min_buf_len = sizeof(struct akm09918c_encoded_data); int rc; @@ -22,7 +22,7 @@ int akm09918c_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) if (rc != 0) { LOG_ERR("Failed to get a read buffer of size %u bytes", min_buf_len); rtio_iodev_sqe_err(iodev_sqe, rc); - return rc; + return; } edata = (struct akm09918c_encoded_data *)buf; @@ -33,10 +33,8 @@ int akm09918c_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) if (rc != 0) { LOG_ERR("Failed to fetch samples"); rtio_iodev_sqe_err(iodev_sqe, rc); - return rc; + return; } rtio_iodev_sqe_ok(iodev_sqe, 0); - - return 0; } diff --git a/drivers/sensor/bosch/bma4xx/bma4xx.c b/drivers/sensor/bosch/bma4xx/bma4xx.c index db717cc0c04..1d1609c64b3 100644 --- a/drivers/sensor/bosch/bma4xx/bma4xx.c +++ b/drivers/sensor/bosch/bma4xx/bma4xx.c @@ -338,7 +338,7 @@ static int bma4xx_temp_fetch(const struct device *dev, int8_t *temp) * RTIO submit and encoding */ -static int bma4xx_submit_one_shot(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) +static void bma4xx_submit_one_shot(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) { struct bma4xx_data *bma4xx = dev->data; @@ -357,7 +357,7 @@ static int bma4xx_submit_one_shot(const struct device *dev, struct rtio_iodev_sq if (rc != 0) { LOG_ERR("Failed to get a read buffer of size %u bytes", min_buf_len); rtio_iodev_sqe_err(iodev_sqe, rc); - return rc; + return; } /* Prepare response */ @@ -372,7 +372,8 @@ static int bma4xx_submit_one_shot(const struct device *dev, struct rtio_iodev_sq for (int i = 0; i < num_channels; i++) { if (channels[i].chan_idx != 0) { LOG_ERR("Only channel index 0 supported"); - return -ENOTSUP; + rtio_iodev_sqe_err(iodev_sqe, -ENOTSUP); + return; } switch (channels[i].chan_type) { case SENSOR_CHAN_ALL: @@ -395,7 +396,8 @@ static int bma4xx_submit_one_shot(const struct device *dev, struct rtio_iodev_sq default: LOG_ERR("Requested unsupported channel type %d, idx %d", channels[i].chan_type, channels[i].chan_idx); - return -ENOTSUP; + rtio_iodev_sqe_err(iodev_sqe, -ENOTSUP); + return; } } @@ -405,7 +407,7 @@ static int bma4xx_submit_one_shot(const struct device *dev, struct rtio_iodev_sq if (rc != 0) { LOG_ERR("Failed to fetch accel samples"); rtio_iodev_sqe_err(iodev_sqe, rc); - return rc; + return; } } @@ -415,26 +417,24 @@ static int bma4xx_submit_one_shot(const struct device *dev, struct rtio_iodev_sq if (rc != 0) { LOG_ERR("Failed to fetch temp sample"); rtio_iodev_sqe_err(iodev_sqe, rc); - return rc; + return; } } #endif /* CONFIG_BMA4XX_TEMPERATURE */ rtio_iodev_sqe_ok(iodev_sqe, 0); - - return 0; } -static int bma4xx_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) +static void bma4xx_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) { const struct sensor_read_config *cfg = iodev_sqe->sqe.iodev->data; - if (!cfg->is_streaming) { - return bma4xx_submit_one_shot(dev, iodev_sqe); - } /* TODO: Add streaming support */ - - return -ENOTSUP; + if (!cfg->is_streaming) { + bma4xx_submit_one_shot(dev, iodev_sqe); + } else { + rtio_iodev_sqe_err(iodev_sqe, -ENOTSUP); + } } /* diff --git a/drivers/sensor/bosch/bme280/bme280.h b/drivers/sensor/bosch/bme280/bme280.h index 125659cb586..2499174d5e6 100644 --- a/drivers/sensor/bosch/bme280/bme280.h +++ b/drivers/sensor/bosch/bme280/bme280.h @@ -211,7 +211,7 @@ struct bme280_encoded_data { int bme280_get_decoder(const struct device *dev, const struct sensor_decoder_api **decoder); -int bme280_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe); +void bme280_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe); int bme280_sample_fetch(const struct device *dev, enum sensor_channel chan); diff --git a/drivers/sensor/bosch/bme280/bme280_async.c b/drivers/sensor/bosch/bme280/bme280_async.c index 562beb4f090..780a7a28c1e 100644 --- a/drivers/sensor/bosch/bme280/bme280_async.c +++ b/drivers/sensor/bosch/bme280/bme280_async.c @@ -9,7 +9,7 @@ LOG_MODULE_DECLARE(BME280, CONFIG_SENSOR_LOG_LEVEL); -int bme280_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) +void bme280_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) { uint32_t min_buf_len = sizeof(struct bme280_encoded_data); int rc; @@ -31,7 +31,7 @@ int bme280_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) default: LOG_ERR("Unsupported channel type %d", channels[i].chan_type); rtio_iodev_sqe_err(iodev_sqe, -ENOTSUP); - return -ENOTSUP; + return; } } @@ -39,7 +39,7 @@ int bme280_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) if (rc != 0) { LOG_ERR("Failed to get a read buffer of size %u bytes", min_buf_len); rtio_iodev_sqe_err(iodev_sqe, rc); - return rc; + return; } struct bme280_encoded_data *edata; @@ -52,10 +52,8 @@ int bme280_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) if (rc != 0) { LOG_ERR("Failed to fetch samples"); rtio_iodev_sqe_err(iodev_sqe, rc); - return rc; + return; } rtio_iodev_sqe_ok(iodev_sqe, 0); - - return 0; } diff --git a/drivers/sensor/tdk/icm42688/icm42688_rtio.c b/drivers/sensor/tdk/icm42688/icm42688_rtio.c index ad00fd7abf2..b9e86c3d9a1 100644 --- a/drivers/sensor/tdk/icm42688/icm42688_rtio.c +++ b/drivers/sensor/tdk/icm42688/icm42688_rtio.c @@ -43,7 +43,7 @@ static int icm42688_rtio_sample_fetch(const struct device *dev, int16_t readings return 0; } -static int icm42688_submit_one_shot(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) +static void icm42688_submit_one_shot(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) { const struct sensor_read_config *cfg = iodev_sqe->sqe.iodev->data; const struct sensor_chan_spec *const channels = cfg->channels; @@ -59,7 +59,7 @@ static int icm42688_submit_one_shot(const struct device *dev, struct rtio_iodev_ if (rc != 0) { LOG_ERR("Failed to get a read buffer of size %u bytes", min_buf_len); rtio_iodev_sqe_err(iodev_sqe, rc); - return rc; + return; } edata = (struct icm42688_encoded_data *)buf; @@ -71,24 +71,22 @@ static int icm42688_submit_one_shot(const struct device *dev, struct rtio_iodev_ if (rc != 0) { LOG_ERR("Failed to fetch samples"); rtio_iodev_sqe_err(iodev_sqe, rc); - return rc; + return; } rtio_iodev_sqe_ok(iodev_sqe, 0); - - return 0; } -int icm42688_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) +void icm42688_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) { const struct sensor_read_config *cfg = iodev_sqe->sqe.iodev->data; if (!cfg->is_streaming) { - return icm42688_submit_one_shot(dev, iodev_sqe); + icm42688_submit_one_shot(dev, iodev_sqe); } else if (IS_ENABLED(CONFIG_ICM42688_STREAM)) { - return icm42688_submit_stream(dev, iodev_sqe); + icm42688_submit_stream(dev, iodev_sqe); } else { - return -ENOTSUP; + rtio_iodev_sqe_err(iodev_sqe, -ENOTSUP); } } diff --git a/drivers/sensor/tdk/icm42688/icm42688_rtio.h b/drivers/sensor/tdk/icm42688/icm42688_rtio.h index 888e8e95357..a4d12b82a18 100644 --- a/drivers/sensor/tdk/icm42688/icm42688_rtio.h +++ b/drivers/sensor/tdk/icm42688/icm42688_rtio.h @@ -10,9 +10,9 @@ #include #include -int icm42688_submit(const struct device *sensor, struct rtio_iodev_sqe *iodev_sqe); +void icm42688_submit(const struct device *sensor, struct rtio_iodev_sqe *iodev_sqe); -int icm42688_submit_stream(const struct device *sensor, struct rtio_iodev_sqe *iodev_sqe); +void icm42688_submit_stream(const struct device *sensor, struct rtio_iodev_sqe *iodev_sqe); void icm42688_fifo_event(const struct device *dev); diff --git a/include/zephyr/drivers/sensor.h b/include/zephyr/drivers/sensor.h index 4e1a41c4e1d..a33a320f903 100644 --- a/include/zephyr/drivers/sensor.h +++ b/include/zephyr/drivers/sensor.h @@ -687,7 +687,7 @@ struct sensor_read_config { RTIO_IODEV_DEFINE(name, &__sensor_iodev_api, &_CONCAT(__sensor_read_config_, name)) /* Used to submit an RTIO sqe to the sensor's iodev */ -typedef int (*sensor_submit_t)(const struct device *sensor, struct rtio_iodev_sqe *sqe); +typedef void (*sensor_submit_t)(const struct device *sensor, struct rtio_iodev_sqe *sqe); /* The default decoder API */ extern const struct sensor_decoder_api __sensor_default_decoder; diff --git a/subsys/sensing/sensing_sensor.c b/subsys/sensing/sensing_sensor.c index a2ebd9ff7d3..6bd68ce5b2c 100644 --- a/subsys/sensing/sensing_sensor.c +++ b/subsys/sensing/sensing_sensor.c @@ -22,6 +22,7 @@ static void sensing_iodev_submit(struct rtio_iodev_sqe *iodev_sqe) if (api->submit != NULL) { api->submit(dev, iodev_sqe); } else { + LOG_ERR("submit function not supported for device %p %s!\n", dev, dev->name); rtio_iodev_sqe_err(iodev_sqe, -ENOTSUP); } } diff --git a/subsys/sensing/sensor/hinge_angle/hinge_angle.c b/subsys/sensing/sensor/hinge_angle/hinge_angle.c index 077f7ca3774..db86f4081a3 100644 --- a/subsys/sensing/sensor/hinge_angle/hinge_angle.c +++ b/subsys/sensing/sensor/hinge_angle/hinge_angle.c @@ -79,17 +79,16 @@ static int hinge_attr_set(const struct device *dev, return ret; } -static int hinge_submit(const struct device *dev, +static void hinge_submit(const struct device *dev, struct rtio_iodev_sqe *sqe) { struct hinge_angle_context *data = dev->data; if (data->sqe) { - return -EBUSY; + rtio_iodev_sqe_err(sqe, -EBUSY); + } else { + data->sqe = sqe; } - - data->sqe = sqe; - return 0; } static const struct sensor_driver_api hinge_api = { @@ -146,7 +145,10 @@ static void hinge_reporter_on_data_event(sensing_sensor_handle_t handle, sample->readings[0].v = calc_hinge_angle(data); - rtio_iodev_sqe_ok(data->sqe, 0); + struct rtio_iodev_sqe *sqe = data->sqe; + + data->sqe = NULL; + rtio_iodev_sqe_ok(sqe, 0); } } diff --git a/subsys/sensing/sensor/phy_3d_sensor/phy_3d_sensor.c b/subsys/sensing/sensor/phy_3d_sensor/phy_3d_sensor.c index 3ad2e499fff..12f2026636d 100644 --- a/subsys/sensing/sensor/phy_3d_sensor/phy_3d_sensor.c +++ b/subsys/sensing/sensor/phy_3d_sensor/phy_3d_sensor.c @@ -159,7 +159,7 @@ static int phy_3d_sensor_attr_set(const struct device *dev, return ret; } -static int phy_3d_sensor_submit(const struct device *dev, +static void phy_3d_sensor_submit(const struct device *dev, struct rtio_iodev_sqe *sqe) { struct sensing_submit_config *config = (struct sensing_submit_config *)sqe->sqe.iodev->data; @@ -175,21 +175,21 @@ static int phy_3d_sensor_submit(const struct device *dev, (uint8_t **)&sample, &buffer_len); if (ret) { rtio_iodev_sqe_err(sqe, ret); - return ret; + return; } ret = sensor_sample_fetch_chan(cfg->hw_dev, custom->chan_all); if (ret) { LOG_ERR("%s: sample fetch failed: %d", dev->name, ret); rtio_iodev_sqe_err(sqe, ret); - return ret; + return; } ret = sensor_channel_get(cfg->hw_dev, custom->chan_all, value); if (ret) { LOG_ERR("%s: channel get failed: %d", dev->name, ret); rtio_iodev_sqe_err(sqe, ret); - return ret; + return; } for (i = 0; i < ARRAY_SIZE(value); ++i) { @@ -206,7 +206,7 @@ static int phy_3d_sensor_submit(const struct device *dev, sample->readings[0].z); rtio_iodev_sqe_ok(sqe, 0); - return 0; + return; } static const struct sensor_driver_api phy_3d_sensor_api = {