@@ -185,7 +185,6 @@ struct can_rcar_cfg {
185
185
};
186
186
187
187
struct can_rcar_tx_cb {
188
- struct k_sem sem ;
189
188
can_tx_callback_t cb ;
190
189
void * cb_arg ;
191
190
};
@@ -231,11 +230,7 @@ static void can_rcar_tx_done(const struct device *dev)
231
230
}
232
231
233
232
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 );
239
234
k_sem_give (& data -> tx_sem );
240
235
}
241
236
@@ -864,6 +859,7 @@ static int can_rcar_send(const struct device *dev, const struct can_frame *frame
864
859
"standard" : "extended"
865
860
, frame -> rtr == CAN_DATAFRAME ? "no" : "yes" );
866
861
862
+ __ASSERT_NO_MSG (callback != NULL );
867
863
__ASSERT (frame -> dlc == 0U || frame -> data != NULL , "Dataptr is null" );
868
864
869
865
if (frame -> dlc > CAN_MAX_DLC ) {
@@ -886,8 +882,6 @@ static int can_rcar_send(const struct device *dev, const struct can_frame *frame
886
882
tx_cb -> cb = callback ;
887
883
tx_cb -> cb_arg = user_data ;
888
884
889
- k_sem_reset (& tx_cb -> sem );
890
-
891
885
data -> tx_head ++ ;
892
886
if (data -> tx_head >= RCAR_CAN_FIFO_DEPTH ) {
893
887
data -> tx_head = 0 ;
@@ -921,9 +915,6 @@ static int can_rcar_send(const struct device *dev, const struct can_frame *frame
921
915
sys_write8 (0xff , config -> reg_addr + RCAR_CAN_TFPCR );
922
916
923
917
k_mutex_unlock (& data -> inst_mutex );
924
- if (callback == NULL ) {
925
- k_sem_take (& tx_cb -> sem , K_FOREVER );
926
- }
927
918
928
919
return 0 ;
929
920
}
@@ -986,14 +977,10 @@ static int can_rcar_init(const struct device *dev)
986
977
struct can_timing timing ;
987
978
int ret ;
988
979
uint16_t ctlr ;
989
- uint8_t idx ;
990
980
991
981
k_mutex_init (& data -> inst_mutex );
992
982
k_mutex_init (& data -> rx_mutex );
993
983
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
- }
997
984
998
985
data -> tx_head = 0 ;
999
986
data -> tx_tail = 0 ;
0 commit comments