@@ -277,17 +277,28 @@ 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
286
297
* @brief Callback signature for RTIO_OP_AWAIT signaled
287
298
* @param iodev_sqe IODEV submission for the await op
288
299
* @param userdata Userdata
289
300
*/
290
- typedef void (* rtio_signaled_t )(struct rtio_iodev_sqe * iodev_sqe , void * userdata );
301
+ typedef void (* rtio_signaled_t )(struct rtio_iodev_sqe * iodev_sqe , const void * userdata );
291
302
292
303
/**
293
304
* @brief A submission queue event
@@ -310,7 +321,7 @@ struct rtio_sqe {
310
321
* If unique identification of completions is desired this should be
311
322
* unique as well.
312
323
*/
313
- void * userdata ;
324
+ const void * userdata ;
314
325
315
326
union {
316
327
@@ -556,11 +567,14 @@ struct rtio_iodev {
556
567
/** An operation that transmits tiny writes by copying the data to write */
557
568
#define RTIO_OP_TINY_TX (RTIO_OP_TX+1)
558
569
559
- /** An operation that calls a given function (callback) */
570
+ /** An operation that calls a given function (callback) with immutable data */
560
571
#define RTIO_OP_CALLBACK (RTIO_OP_TINY_TX+1)
561
572
573
+ /** An operation that calls a given function (callback) with mutable data */
574
+ #define RTIO_OP_CALLBACK_MUT (RTIO_OP_CALLBACK+1)
575
+
562
576
/** An operation that transceives (reads and writes simultaneously) */
563
- #define RTIO_OP_TXRX (RTIO_OP_CALLBACK +1)
577
+ #define RTIO_OP_TXRX (RTIO_OP_CALLBACK_MUT +1)
564
578
565
579
/** An operation that takes a specified amount of time (asynchronously) before completing */
566
580
#define RTIO_OP_DELAY (RTIO_OP_TXRX+1)
@@ -588,7 +602,7 @@ struct rtio_iodev {
588
602
*/
589
603
static inline void rtio_sqe_prep_nop (struct rtio_sqe * sqe ,
590
604
const struct rtio_iodev * iodev ,
591
- void * userdata )
605
+ const void * userdata )
592
606
{
593
607
memset (sqe , 0 , sizeof (struct rtio_sqe ));
594
608
sqe -> op = RTIO_OP_NOP ;
@@ -604,7 +618,7 @@ static inline void rtio_sqe_prep_read(struct rtio_sqe *sqe,
604
618
int8_t prio ,
605
619
uint8_t * buf ,
606
620
uint32_t len ,
607
- void * userdata )
621
+ const void * userdata )
608
622
{
609
623
memset (sqe , 0 , sizeof (struct rtio_sqe ));
610
624
sqe -> op = RTIO_OP_RX ;
@@ -622,15 +636,15 @@ static inline void rtio_sqe_prep_read(struct rtio_sqe *sqe,
622
636
*/
623
637
static inline void rtio_sqe_prep_read_with_pool (struct rtio_sqe * sqe ,
624
638
const struct rtio_iodev * iodev , int8_t prio ,
625
- void * userdata )
639
+ const void * userdata )
626
640
{
627
641
rtio_sqe_prep_read (sqe , iodev , prio , NULL , 0 , userdata );
628
642
sqe -> flags = RTIO_SQE_MEMPOOL_BUFFER ;
629
643
}
630
644
631
645
static inline void rtio_sqe_prep_read_multishot (struct rtio_sqe * sqe ,
632
646
const struct rtio_iodev * iodev , int8_t prio ,
633
- void * userdata )
647
+ const void * userdata )
634
648
{
635
649
rtio_sqe_prep_read_with_pool (sqe , iodev , prio , userdata );
636
650
sqe -> flags |= RTIO_SQE_MULTISHOT ;
@@ -644,7 +658,7 @@ static inline void rtio_sqe_prep_write(struct rtio_sqe *sqe,
644
658
int8_t prio ,
645
659
const uint8_t * buf ,
646
660
uint32_t len ,
647
- void * userdata )
661
+ const void * userdata )
648
662
{
649
663
memset (sqe , 0 , sizeof (struct rtio_sqe ));
650
664
sqe -> op = RTIO_OP_TX ;
@@ -670,7 +684,7 @@ static inline void rtio_sqe_prep_tiny_write(struct rtio_sqe *sqe,
670
684
int8_t prio ,
671
685
const uint8_t * tiny_write_data ,
672
686
uint8_t tiny_write_len ,
673
- void * userdata )
687
+ const void * userdata )
674
688
{
675
689
__ASSERT_NO_MSG (tiny_write_len <= sizeof (sqe -> tiny_tx .buf ));
676
690
@@ -694,7 +708,7 @@ static inline void rtio_sqe_prep_tiny_write(struct rtio_sqe *sqe,
694
708
static inline void rtio_sqe_prep_callback (struct rtio_sqe * sqe ,
695
709
rtio_callback_t callback ,
696
710
void * arg0 ,
697
- void * userdata )
711
+ const void * userdata )
698
712
{
699
713
memset (sqe , 0 , sizeof (struct rtio_sqe ));
700
714
sqe -> op = RTIO_OP_CALLBACK ;
@@ -718,7 +732,7 @@ static inline void rtio_sqe_prep_callback(struct rtio_sqe *sqe,
718
732
static inline void rtio_sqe_prep_callback_no_cqe (struct rtio_sqe * sqe ,
719
733
rtio_callback_t callback ,
720
734
void * arg0 ,
721
- void * userdata )
735
+ const void * userdata )
722
736
{
723
737
rtio_sqe_prep_callback (sqe , callback , arg0 , userdata );
724
738
sqe -> flags |= RTIO_SQE_NO_RESPONSE ;
@@ -733,7 +747,7 @@ static inline void rtio_sqe_prep_transceive(struct rtio_sqe *sqe,
733
747
const uint8_t * tx_buf ,
734
748
uint8_t * rx_buf ,
735
749
uint32_t buf_len ,
736
- void * userdata )
750
+ const void * userdata )
737
751
{
738
752
memset (sqe , 0 , sizeof (struct rtio_sqe ));
739
753
sqe -> op = RTIO_OP_TXRX ;
@@ -748,7 +762,7 @@ static inline void rtio_sqe_prep_transceive(struct rtio_sqe *sqe,
748
762
static inline void rtio_sqe_prep_await (struct rtio_sqe * sqe ,
749
763
const struct rtio_iodev * iodev ,
750
764
int8_t prio ,
751
- void * userdata )
765
+ const void * userdata )
752
766
{
753
767
memset (sqe , 0 , sizeof (struct rtio_sqe ));
754
768
sqe -> op = RTIO_OP_AWAIT ;
@@ -759,7 +773,7 @@ static inline void rtio_sqe_prep_await(struct rtio_sqe *sqe,
759
773
760
774
static inline void rtio_sqe_prep_delay (struct rtio_sqe * sqe ,
761
775
k_timeout_t timeout ,
762
- void * userdata )
776
+ const void * userdata )
763
777
{
764
778
memset (sqe , 0 , sizeof (struct rtio_sqe ));
765
779
sqe -> op = RTIO_OP_DELAY ;
0 commit comments