drivers: can: mcux: flexcan: assume can_send() always provides callback

Given the recent change to the CAN controller can_send() API wrapper,
assume that a callback is always provided at the driver level.

This saves approximately 500 bytes of SRAM on the frdm_k64f board, while on
the mimxrt1024_evk board the saving is approximately 2.5 kbytes of SRAM,
both when running in default configuration.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
Henrik Brix Andersen 2022-09-19 22:53:03 +02:00 committed by Fabio Baltieri
commit fcf7c6e6d1

View file

@ -104,8 +104,6 @@ struct mcux_flexcan_rx_callback {
};
struct mcux_flexcan_tx_callback {
struct k_sem done;
int status;
flexcan_frame_t frame;
can_tx_callback_t function;
void *arg;
@ -408,6 +406,8 @@ static int mcux_flexcan_send(const struct device *dev,
status_t status;
int alloc;
__ASSERT_NO_MSG(callback != NULL);
if (frame->dlc > CAN_MAX_DLC) {
LOG_ERR("DLC of %d exceeds maximum (%d)", frame->dlc, CAN_MAX_DLC);
return -EINVAL;
@ -445,11 +445,6 @@ static int mcux_flexcan_send(const struct device *dev,
return -EIO;
}
if (callback == NULL) {
k_sem_take(&data->tx_cbs[alloc].done, K_FOREVER);
return data->tx_cbs[alloc].status;
}
return 0;
}
@ -647,13 +642,8 @@ static inline void mcux_flexcan_transfer_error_status(const struct device *dev,
if (atomic_test_and_clear_bit(data->tx_allocs, alloc)) {
FLEXCAN_TransferAbortSend(config->base, &data->handle,
ALLOC_IDX_TO_TXMB_IDX(alloc));
if (function != NULL) {
function(dev, -ENETUNREACH, arg);
} else {
data->tx_cbs[alloc].status = -ENETUNREACH;
k_sem_give(&data->tx_cbs[alloc].done);
}
function(dev, -ENETUNREACH, arg);
k_sem_give(&data->tx_allocs_sem);
}
}
@ -675,12 +665,7 @@ static inline void mcux_flexcan_transfer_tx_idle(const struct device *dev,
arg = data->tx_cbs[alloc].arg;
if (atomic_test_and_clear_bit(data->tx_allocs, alloc)) {
if (function != NULL) {
function(dev, 0, arg);
} else {
data->tx_cbs[alloc].status = 0;
k_sem_give(&data->tx_cbs[alloc].done);
}
k_sem_give(&data->tx_allocs_sem);
}
}
@ -774,7 +759,6 @@ static int mcux_flexcan_init(const struct device *dev)
flexcan_config_t flexcan_config;
uint32_t clock_freq;
int err;
int i;
if (config->phy != NULL) {
if (!device_is_ready(config->phy)) {
@ -792,10 +776,6 @@ static int mcux_flexcan_init(const struct device *dev)
k_sem_init(&data->tx_allocs_sem, MCUX_FLEXCAN_MAX_TX,
MCUX_FLEXCAN_MAX_TX);
for (i = 0; i < ARRAY_SIZE(data->tx_cbs); i++) {
k_sem_init(&data->tx_cbs[i].done, 0, 1);
}
data->timing.sjw = config->sjw;
if (config->sample_point && USE_SP_ALGO) {
err = can_calc_timing(dev, &data->timing, config->bitrate,