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:
parent
28d9b5428b
commit
f499559434
18 changed files with 162 additions and 152 deletions
|
@ -34,7 +34,7 @@ static int can_exit_sleep_mode(struct can_mcan_reg *can)
|
|||
if (k_cycle_get_32() - start_time >
|
||||
k_ms_to_cyc_ceil32(CAN_INIT_TIMEOUT)) {
|
||||
can->cccr |= CAN_MCAN_CCCR_CSR;
|
||||
return CAN_TIMEOUT;
|
||||
return -EAGAIN;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ static int can_enter_init_mode(struct can_mcan_reg *can, k_timeout_t timeout)
|
|||
while ((can->cccr & CAN_MCAN_CCCR_INIT) == 0U) {
|
||||
if (k_uptime_ticks() - start_time > timeout.ticks) {
|
||||
can->cccr &= ~CAN_MCAN_CCCR_INIT;
|
||||
return CAN_TIMEOUT;
|
||||
return -EAGAIN;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ static int can_leave_init_mode(struct can_mcan_reg *can, k_timeout_t timeout)
|
|||
|
||||
while ((can->cccr & CAN_MCAN_CCCR_INIT) != 0U) {
|
||||
if (k_uptime_ticks() - start_time > timeout.ticks) {
|
||||
return CAN_TIMEOUT;
|
||||
return -EAGAIN;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -431,7 +431,7 @@ static void can_mcan_tc_event_handler(struct can_mcan_reg *can,
|
|||
if (tx_cb == NULL) {
|
||||
k_sem_give(&data->tx_fin_sem[tx_idx]);
|
||||
} else {
|
||||
tx_cb(CAN_TX_OK, data->tx_fin_cb_arg[tx_idx]);
|
||||
tx_cb(0, data->tx_fin_cb_arg[tx_idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -658,21 +658,21 @@ int can_mcan_send(const struct can_mcan_config *cfg,
|
|||
if (data_length > sizeof(frame->data)) {
|
||||
LOG_ERR("data length (%zu) > max frame data length (%zu)",
|
||||
data_length, sizeof(frame->data));
|
||||
return CAN_TX_EINVAL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (frame->fd != 1 && frame->dlc > MCAN_MAX_DLC) {
|
||||
LOG_ERR("DLC of %d without fd flag set.", frame->dlc);
|
||||
return CAN_TX_EINVAL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (can->psr & CAN_MCAN_PSR_BO) {
|
||||
return CAN_TX_BUS_OFF;
|
||||
return -ENETDOWN;
|
||||
}
|
||||
|
||||
ret = k_sem_take(&data->tx_sem, timeout);
|
||||
if (ret != 0) {
|
||||
return CAN_TIMEOUT;
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
__ASSERT_NO_MSG((can->txfqs & CAN_MCAN_TXFQS_TFQF) !=
|
||||
|
@ -715,7 +715,7 @@ int can_mcan_send(const struct can_mcan_config *cfg,
|
|||
k_sem_take(&data->tx_fin_sem[put_idx], K_FOREVER);
|
||||
}
|
||||
|
||||
return CAN_TX_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int can_mcan_get_free_std(volatile struct can_mcan_std_filter *filters)
|
||||
|
@ -726,7 +726,7 @@ static int can_mcan_get_free_std(volatile struct can_mcan_std_filter *filters)
|
|||
}
|
||||
}
|
||||
|
||||
return CAN_NO_FREE_FILTER;
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
/* Use masked configuration only for simplicity. If someone needs more than
|
||||
|
@ -749,9 +749,9 @@ int can_mcan_attach_std(struct can_mcan_data *data,
|
|||
k_mutex_lock(&data->inst_mutex, K_FOREVER);
|
||||
filter_nr = can_mcan_get_free_std(msg_ram->std_filt);
|
||||
|
||||
if (filter_nr == CAN_NO_FREE_FILTER) {
|
||||
if (filter_nr == -ENOSPC) {
|
||||
LOG_INF("No free standard id filter left");
|
||||
return CAN_NO_FREE_FILTER;
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
/* TODO propper fifo balancing */
|
||||
|
@ -790,7 +790,7 @@ static int can_mcan_get_free_ext(volatile struct can_mcan_ext_filter *filters)
|
|||
}
|
||||
}
|
||||
|
||||
return CAN_NO_FREE_FILTER;
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
static int can_mcan_attach_ext(struct can_mcan_data *data,
|
||||
|
@ -808,9 +808,9 @@ static int can_mcan_attach_ext(struct can_mcan_data *data,
|
|||
k_mutex_lock(&data->inst_mutex, K_FOREVER);
|
||||
filter_nr = can_mcan_get_free_ext(msg_ram->ext_filt);
|
||||
|
||||
if (filter_nr == CAN_NO_FREE_FILTER) {
|
||||
if (filter_nr == -ENOSPC) {
|
||||
LOG_INF("No free extender id filter left");
|
||||
return CAN_NO_FREE_FILTER;
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
/* TODO propper fifo balancing */
|
||||
|
@ -861,7 +861,7 @@ int can_mcan_attach_isr(struct can_mcan_data *data,
|
|||
filter_nr += NUM_STD_FILTER_DATA;
|
||||
}
|
||||
|
||||
if (filter_nr == CAN_NO_FREE_FILTER) {
|
||||
if (filter_nr == -ENOSPC) {
|
||||
LOG_INF("No free filter left");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue