Skip to content

Commit debbb69

Browse files
teburdMaureenHelm
authored andcommitted
rtio: Adds rtio_iodev_cancel_all
Ability to cancel all pending requests in the queue turns out to be useful and shareable. Signed-off-by: Tom Burdick <[email protected]>
1 parent bfecb77 commit debbb69

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

include/zephyr/rtio/rtio.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,24 @@ static inline void rtio_iodev_sqe_err(struct rtio_iodev_sqe *iodev_sqe, int resu
588588
iodev_sqe->r->executor->api->err(iodev_sqe, result);
589589
}
590590

591+
/**
592+
* @brief Cancel all requests that are pending for the iodev
593+
*
594+
* @param iodev IODev to cancel all requests for
595+
*/
596+
static inline void rtio_iodev_cancel_all(struct rtio_iodev *iodev)
597+
{
598+
/* Clear pending requests as -ENODATA */
599+
struct rtio_mpsc_node *node = rtio_mpsc_pop(&iodev->iodev_sq);
600+
601+
while (node != NULL) {
602+
struct rtio_iodev_sqe *iodev_sqe = CONTAINER_OF(node, struct rtio_iodev_sqe, q);
603+
604+
rtio_iodev_sqe_err(iodev_sqe, -ECANCELED);
605+
node = rtio_mpsc_pop(&iodev->iodev_sq);
606+
}
607+
}
608+
591609
/**
592610
* Submit a completion queue event with a given result and userdata
593611
*

0 commit comments

Comments
 (0)