@@ -185,7 +185,6 @@ struct can_rcar_cfg {
185185};
186186
187187struct can_rcar_tx_cb {
188- struct k_sem sem ;
189188 can_tx_callback_t cb ;
190189 void * cb_arg ;
191190};
@@ -231,11 +230,7 @@ static void can_rcar_tx_done(const struct device *dev)
231230 }
232231
233232 data -> tx_unsent -- ;
234- if (tx_cb -> cb != NULL ) {
235- tx_cb -> cb (dev , 0 , tx_cb -> cb_arg );
236- } else {
237- k_sem_give (& tx_cb -> sem );
238- }
233+ tx_cb -> cb (dev , 0 , tx_cb -> cb_arg );
239234 k_sem_give (& data -> tx_sem );
240235}
241236
@@ -864,6 +859,7 @@ static int can_rcar_send(const struct device *dev, const struct can_frame *frame
864859 "standard" : "extended"
865860 , frame -> rtr == CAN_DATAFRAME ? "no" : "yes" );
866861
862+ __ASSERT_NO_MSG (callback != NULL );
867863 __ASSERT (frame -> dlc == 0U || frame -> data != NULL , "Dataptr is null" );
868864
869865 if (frame -> dlc > CAN_MAX_DLC ) {
@@ -886,8 +882,6 @@ static int can_rcar_send(const struct device *dev, const struct can_frame *frame
886882 tx_cb -> cb = callback ;
887883 tx_cb -> cb_arg = user_data ;
888884
889- k_sem_reset (& tx_cb -> sem );
890-
891885 data -> tx_head ++ ;
892886 if (data -> tx_head >= RCAR_CAN_FIFO_DEPTH ) {
893887 data -> tx_head = 0 ;
@@ -921,9 +915,6 @@ static int can_rcar_send(const struct device *dev, const struct can_frame *frame
921915 sys_write8 (0xff , config -> reg_addr + RCAR_CAN_TFPCR );
922916
923917 k_mutex_unlock (& data -> inst_mutex );
924- if (callback == NULL ) {
925- k_sem_take (& tx_cb -> sem , K_FOREVER );
926- }
927918
928919 return 0 ;
929920}
@@ -986,14 +977,10 @@ static int can_rcar_init(const struct device *dev)
986977 struct can_timing timing ;
987978 int ret ;
988979 uint16_t ctlr ;
989- uint8_t idx ;
990980
991981 k_mutex_init (& data -> inst_mutex );
992982 k_mutex_init (& data -> rx_mutex );
993983 k_sem_init (& data -> tx_sem , RCAR_CAN_FIFO_DEPTH , RCAR_CAN_FIFO_DEPTH );
994- for (idx = 0 ; idx < RCAR_CAN_FIFO_DEPTH ; idx ++ ) {
995- k_sem_init (& data -> tx_cb [idx ].sem , 0 , 1 );
996- }
997984
998985 data -> tx_head = 0 ;
999986 data -> tx_tail = 0 ;
0 commit comments