@@ -277,9 +277,20 @@ struct rtio_iodev_sqe;
277
277
* @brief Callback signature for RTIO_OP_CALLBACK
278
278
* @param r RTIO context being used with the callback
279
279
* @param sqe Submission for the callback op
280
- * @param arg0 Argument option as part of the sqe
280
+ * @param res Result of the previously linked submission.
281
+ * @param arg0 Pointer to immutable argument option as part of the sqe
281
282
*/
282
- typedef void (* rtio_callback_t )(struct rtio * r , const struct rtio_sqe * sqe , void * arg0 );
283
+ typedef void (* rtio_callback_t )(struct rtio * r , const struct rtio_sqe * sqe , int res , const void * arg0 );
284
+
285
+ /**
286
+ * @typedef rtio_callback_mut_t
287
+ * @brief Callback signature for RTIO_OP_CALLBACK
288
+ * @param r RTIO context being used with the callback
289
+ * @param sqe Submission for the callback op
290
+ * @param res Result of the previously linked submission.
291
+ * @param arg0 Pointer to mutable argument option as part of the sqe
292
+ */
293
+ typedef void (* rtio_callback_mut_t )(struct rtio * r , const struct rtio_sqe * sqe , int res , void * arg0 );
283
294
284
295
/**
285
296
* @typedef rtio_signaled_t
@@ -335,9 +346,15 @@ struct rtio_sqe {
335
346
/** OP_CALLBACK */
336
347
struct {
337
348
rtio_callback_t callback ;
338
- void * arg0 ; /**< Last argument given to callback */
349
+ const void * arg0 ; /**< Last argument given to callback */
339
350
} callback ;
340
351
352
+ /** OP_CALLBACK_MUT */
353
+ struct {
354
+ rtio_callback_t callback ;
355
+ void * arg0 ; /**< Last argument given to callback */
356
+ } callback_mut ;
357
+
341
358
/** OP_TXRX */
342
359
struct {
343
360
uint32_t buf_len ; /**< Length of tx and rx buffers */
@@ -556,11 +573,14 @@ struct rtio_iodev {
556
573
/** An operation that transmits tiny writes by copying the data to write */
557
574
#define RTIO_OP_TINY_TX (RTIO_OP_TX+1)
558
575
559
- /** An operation that calls a given function (callback) */
576
+ /** An operation that calls a given function (callback) with immutable data */
560
577
#define RTIO_OP_CALLBACK (RTIO_OP_TINY_TX+1)
561
578
579
+ /** An operation that calls a given function (callback) with mutable data */
580
+ #define RTIO_OP_CALLBACK_MUT (RTIO_OP_CALLBACK+1)
581
+
562
582
/** An operation that transceives (reads and writes simultaneously) */
563
- #define RTIO_OP_TXRX (RTIO_OP_CALLBACK +1)
583
+ #define RTIO_OP_TXRX (RTIO_OP_CALLBACK_MUT +1)
564
584
565
585
/** An operation that takes a specified amount of time (asynchronously) before completing */
566
586
#define RTIO_OP_DELAY (RTIO_OP_TXRX+1)
@@ -693,7 +713,7 @@ static inline void rtio_sqe_prep_tiny_write(struct rtio_sqe *sqe,
693
713
*/
694
714
static inline void rtio_sqe_prep_callback (struct rtio_sqe * sqe ,
695
715
rtio_callback_t callback ,
696
- void * arg0 ,
716
+ const void * arg0 ,
697
717
void * userdata )
698
718
{
699
719
memset (sqe , 0 , sizeof (struct rtio_sqe ));
@@ -724,6 +744,43 @@ static inline void rtio_sqe_prep_callback_no_cqe(struct rtio_sqe *sqe,
724
744
sqe -> flags |= RTIO_SQE_NO_RESPONSE ;
725
745
}
726
746
747
+
748
+ /**
749
+ * @brief Prepare a callback mut op submission
750
+ *
751
+ * A somewhat special operation in that it may only be done in kernel mode.
752
+ *
753
+ * Used where general purpose logic is required in a queue of io operations to do
754
+ * transforms or logic with a mutable argument passed to the function
755
+ */
756
+ static inline void rtio_sqe_prep_callback_mut (struct rtio_sqe * sqe ,
757
+ rtio_callback_t callback ,
758
+ void * arg0 ,
759
+ void * userdata )
760
+ {
761
+ memset (sqe , 0 , sizeof (struct rtio_sqe ));
762
+ sqe -> op = RTIO_OP_CALLBACK ;
763
+ sqe -> prio = 0 ;
764
+ sqe -> iodev = NULL ;
765
+ sqe -> callback .callback = callback ;
766
+ sqe -> callback .arg0 = arg0 ;
767
+ sqe -> userdata = userdata ;
768
+ }
769
+
770
+ /**
771
+ * @brief Prepare a callback op submission that does not create a CQE
772
+ *
773
+ * Similar to @ref rtio_sqe_prep_callback_no_cqe, but the arg0 is mutable.
774
+ */
775
+ static inline void rtio_sqe_prep_callback_mut_no_cqe (struct rtio_sqe * sqe ,
776
+ rtio_callback_t callback ,
777
+ void * arg0 ,
778
+ void * userdata )
779
+ {
780
+ rtio_sqe_prep_callback_mut (sqe , callback , arg0 , userdata );
781
+ sqe -> flags |= RTIO_SQE_NO_RESPONSE ;
782
+ }
783
+
727
784
/**
728
785
* @brief Prepare a transceive op submission
729
786
*/
0 commit comments