drivers: can: deprecate the use of CAN-specific error return values

Deprecate the use of CAN-specific error return values and replace them
with standard errno values.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
Henrik Brix Andersen 2021-12-08 00:01:57 +01:00 committed by Anas Nashif
commit f499559434
18 changed files with 162 additions and 152 deletions

View file

@ -328,7 +328,7 @@ static int mcux_flexcan_send(const struct device *dev,
if (frame->dlc > CAN_MAX_DLC) {
LOG_ERR("DLC of %d exceeds maximum (%d)", frame->dlc, CAN_MAX_DLC);
return CAN_TX_EINVAL;
return -EINVAL;
}
while (true) {
@ -342,7 +342,7 @@ static int mcux_flexcan_send(const struct device *dev,
}
if (k_sem_take(&data->tx_allocs_sem, timeout) != 0) {
return CAN_TIMEOUT;
return -EAGAIN;
}
}
@ -355,7 +355,7 @@ static int mcux_flexcan_send(const struct device *dev,
status = FLEXCAN_TransferSendNonBlocking(config->base, &data->handle,
&xfer);
if (status != kStatus_Success) {
return CAN_TX_ERR;
return -EIO;
}
if (callback == NULL) {
@ -363,7 +363,7 @@ static int mcux_flexcan_send(const struct device *dev,
return data->tx_cbs[alloc].status;
}
return CAN_TX_OK;
return 0;
}
static int mcux_flexcan_attach_isr(const struct device *dev,
@ -376,7 +376,7 @@ static int mcux_flexcan_attach_isr(const struct device *dev,
flexcan_mb_transfer_t xfer;
status_t status;
uint32_t mask;
int alloc = CAN_NO_FREE_FILTER;
int alloc = -ENOSPC;
int i;
__ASSERT_NO_MSG(isr);
@ -391,7 +391,7 @@ static int mcux_flexcan_attach_isr(const struct device *dev,
}
}
if (alloc == CAN_NO_FREE_FILTER) {
if (alloc == -ENOSPC) {
return alloc;
}
@ -414,7 +414,7 @@ static int mcux_flexcan_attach_isr(const struct device *dev,
if (status != kStatus_Success) {
LOG_ERR("Failed to start rx for filter id %d (err = %d)",
alloc, status);
alloc = CAN_NO_FREE_FILTER;
alloc = -ENOSPC;
}
k_mutex_unlock(&data->rx_mutex);
@ -473,7 +473,7 @@ int mcux_flexcan_recover(const struct device *dev, k_timeout_t timeout)
while (mcux_flexcan_get_state(dev, NULL) == CAN_BUS_OFF) {
if (!K_TIMEOUT_EQ(timeout, K_FOREVER) &&
k_uptime_ticks() - start_time >= timeout.ticks) {
ret = CAN_TIMEOUT;
ret = -EAGAIN;
}
}
}
@ -518,7 +518,7 @@ static inline void mcux_flexcan_transfer_error_status(const struct device *dev,
const struct mcux_flexcan_config *config = dev->config;
struct mcux_flexcan_data *data = dev->data;
can_tx_callback_t function;
int status = CAN_TX_OK;
int status = 0;
void *arg;
int alloc;
enum can_state state;
@ -526,14 +526,14 @@ static inline void mcux_flexcan_transfer_error_status(const struct device *dev,
if (error & CAN_ESR1_FLTCONF(2)) {
LOG_DBG("Tx bus off (error 0x%08llx)", error);
status = CAN_TX_BUS_OFF;
status = -ENETDOWN;
} else if ((error & kFLEXCAN_Bit0Error) ||
(error & kFLEXCAN_Bit1Error)) {
LOG_DBG("TX arbitration lost (error 0x%08llx)", error);
status = CAN_TX_ARB_LOST;
status = -EBUSY;
} else if (error & kFLEXCAN_AckError) {
LOG_DBG("TX no ACK received (error 0x%08llx)", error);
status = CAN_TX_ERR;
status = -EIO;
} else if (error & kFLEXCAN_StuffingError) {
LOG_DBG("RX stuffing error (error 0x%08llx)", error);
} else if (error & kFLEXCAN_FormError) {
@ -552,7 +552,7 @@ static inline void mcux_flexcan_transfer_error_status(const struct device *dev,
}
}
if (status == CAN_TX_OK) {
if (status == 0) {
/*
* Error/status is not TX related. No further action
* required.
@ -605,9 +605,9 @@ static inline void mcux_flexcan_transfer_tx_idle(const struct device *dev,
if (atomic_test_and_clear_bit(data->tx_allocs, alloc)) {
if (function != NULL) {
function(CAN_TX_OK, arg);
function(0, arg);
} else {
data->tx_cbs[alloc].status = CAN_TX_OK;
data->tx_cbs[alloc].status = 0;
k_sem_give(&data->tx_cbs[alloc].done);
}
k_sem_give(&data->tx_allocs_sem);