@@ -328,7 +328,7 @@ static int mcux_flexcan_send(const struct device *dev,
328328
329329 if (frame -> dlc > CAN_MAX_DLC ) {
330330 LOG_ERR ("DLC of %d exceeds maximum (%d)" , frame -> dlc , CAN_MAX_DLC );
331- return CAN_TX_EINVAL ;
331+ return - EINVAL ;
332332 }
333333
334334 while (true) {
@@ -342,7 +342,7 @@ static int mcux_flexcan_send(const struct device *dev,
342342 }
343343
344344 if (k_sem_take (& data -> tx_allocs_sem , timeout ) != 0 ) {
345- return CAN_TIMEOUT ;
345+ return - EAGAIN ;
346346 }
347347 }
348348
@@ -355,15 +355,15 @@ static int mcux_flexcan_send(const struct device *dev,
355355 status = FLEXCAN_TransferSendNonBlocking (config -> base , & data -> handle ,
356356 & xfer );
357357 if (status != kStatus_Success ) {
358- return CAN_TX_ERR ;
358+ return - EIO ;
359359 }
360360
361361 if (callback == NULL ) {
362362 k_sem_take (& data -> tx_cbs [alloc ].done , K_FOREVER );
363363 return data -> tx_cbs [alloc ].status ;
364364 }
365365
366- return CAN_TX_OK ;
366+ return 0 ;
367367}
368368
369369static int mcux_flexcan_attach_isr (const struct device * dev ,
@@ -376,7 +376,7 @@ static int mcux_flexcan_attach_isr(const struct device *dev,
376376 flexcan_mb_transfer_t xfer ;
377377 status_t status ;
378378 uint32_t mask ;
379- int alloc = CAN_NO_FREE_FILTER ;
379+ int alloc = - ENOSPC ;
380380 int i ;
381381
382382 __ASSERT_NO_MSG (isr );
@@ -391,7 +391,7 @@ static int mcux_flexcan_attach_isr(const struct device *dev,
391391 }
392392 }
393393
394- if (alloc == CAN_NO_FREE_FILTER ) {
394+ if (alloc == - ENOSPC ) {
395395 return alloc ;
396396 }
397397
@@ -414,7 +414,7 @@ static int mcux_flexcan_attach_isr(const struct device *dev,
414414 if (status != kStatus_Success ) {
415415 LOG_ERR ("Failed to start rx for filter id %d (err = %d)" ,
416416 alloc , status );
417- alloc = CAN_NO_FREE_FILTER ;
417+ alloc = - ENOSPC ;
418418 }
419419
420420 k_mutex_unlock (& data -> rx_mutex );
@@ -473,7 +473,7 @@ int mcux_flexcan_recover(const struct device *dev, k_timeout_t timeout)
473473 while (mcux_flexcan_get_state (dev , NULL ) == CAN_BUS_OFF ) {
474474 if (!K_TIMEOUT_EQ (timeout , K_FOREVER ) &&
475475 k_uptime_ticks () - start_time >= timeout .ticks ) {
476- ret = CAN_TIMEOUT ;
476+ ret = - EAGAIN ;
477477 }
478478 }
479479 }
@@ -518,22 +518,22 @@ static inline void mcux_flexcan_transfer_error_status(const struct device *dev,
518518 const struct mcux_flexcan_config * config = dev -> config ;
519519 struct mcux_flexcan_data * data = dev -> data ;
520520 can_tx_callback_t function ;
521- int status = CAN_TX_OK ;
521+ int status = 0 ;
522522 void * arg ;
523523 int alloc ;
524524 enum can_state state ;
525525 struct can_bus_err_cnt err_cnt ;
526526
527527 if (error & CAN_ESR1_FLTCONF (2 )) {
528528 LOG_DBG ("Tx bus off (error 0x%08llx)" , error );
529- status = CAN_TX_BUS_OFF ;
529+ status = - ENETDOWN ;
530530 } else if ((error & kFLEXCAN_Bit0Error ) ||
531531 (error & kFLEXCAN_Bit1Error )) {
532532 LOG_DBG ("TX arbitration lost (error 0x%08llx)" , error );
533- status = CAN_TX_ARB_LOST ;
533+ status = - EBUSY ;
534534 } else if (error & kFLEXCAN_AckError ) {
535535 LOG_DBG ("TX no ACK received (error 0x%08llx)" , error );
536- status = CAN_TX_ERR ;
536+ status = - EIO ;
537537 } else if (error & kFLEXCAN_StuffingError ) {
538538 LOG_DBG ("RX stuffing error (error 0x%08llx)" , error );
539539 } else if (error & kFLEXCAN_FormError ) {
@@ -552,7 +552,7 @@ static inline void mcux_flexcan_transfer_error_status(const struct device *dev,
552552 }
553553 }
554554
555- if (status == CAN_TX_OK ) {
555+ if (status == 0 ) {
556556 /*
557557 * Error/status is not TX related. No further action
558558 * required.
@@ -605,9 +605,9 @@ static inline void mcux_flexcan_transfer_tx_idle(const struct device *dev,
605605
606606 if (atomic_test_and_clear_bit (data -> tx_allocs , alloc )) {
607607 if (function != NULL ) {
608- function (CAN_TX_OK , arg );
608+ function (0 , arg );
609609 } else {
610- data -> tx_cbs [alloc ].status = CAN_TX_OK ;
610+ data -> tx_cbs [alloc ].status = 0 ;
611611 k_sem_give (& data -> tx_cbs [alloc ].done );
612612 }
613613 k_sem_give (& data -> tx_allocs_sem );
0 commit comments