drivers: can: mcan: 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 lpcxpressso55s16 board when running in default configuration. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
d3427d991a
commit
50d77ab854
2 changed files with 3 additions and 15 deletions
|
@ -348,10 +348,6 @@ int can_mcan_init(const struct device *dev)
|
|||
k_mutex_init(&data->tx_mtx);
|
||||
k_sem_init(&data->tx_sem, NUM_TX_BUF_ELEMENTS, NUM_TX_BUF_ELEMENTS);
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(data->tx_fin_sem); ++i) {
|
||||
k_sem_init(&data->tx_fin_sem[i], 0, 1);
|
||||
}
|
||||
|
||||
if (cfg->phy != NULL) {
|
||||
if (!device_is_ready(cfg->phy)) {
|
||||
LOG_ERR("CAN transceiver not ready");
|
||||
|
@ -558,11 +554,7 @@ static void can_mcan_tc_event_handler(const struct device *dev)
|
|||
k_sem_give(&data->tx_sem);
|
||||
|
||||
tx_cb = data->tx_fin_cb[tx_idx];
|
||||
if (tx_cb == NULL) {
|
||||
k_sem_give(&data->tx_fin_sem[tx_idx]);
|
||||
} else {
|
||||
tx_cb(dev, 0, data->tx_fin_cb_arg[tx_idx]);
|
||||
}
|
||||
tx_cb(dev, 0, data->tx_fin_cb_arg[tx_idx]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -814,6 +806,8 @@ int can_mcan_send(const struct device *dev,
|
|||
frame->fd == CAN_DATAFRAME ? "" : "FD frame",
|
||||
frame->brs == CAN_DATAFRAME ? "" : "BRS");
|
||||
|
||||
__ASSERT_NO_MSG(callback != NULL);
|
||||
|
||||
if (data_length > sizeof(frame->data)) {
|
||||
LOG_ERR("data length (%zu) > max frame data length (%zu)",
|
||||
data_length, sizeof(frame->data));
|
||||
|
@ -870,11 +864,6 @@ int can_mcan_send(const struct device *dev,
|
|||
|
||||
k_mutex_unlock(&data->tx_mtx);
|
||||
|
||||
if (callback == NULL) {
|
||||
LOG_DBG("Waiting for TX complete");
|
||||
k_sem_take(&data->tx_fin_sem[put_idx], K_FOREVER);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -170,7 +170,6 @@ struct can_mcan_data {
|
|||
struct k_mutex inst_mutex;
|
||||
struct k_sem tx_sem;
|
||||
struct k_mutex tx_mtx;
|
||||
struct k_sem tx_fin_sem[NUM_TX_BUF_ELEMENTS];
|
||||
can_tx_callback_t tx_fin_cb[NUM_TX_BUF_ELEMENTS];
|
||||
void *tx_fin_cb_arg[NUM_TX_BUF_ELEMENTS];
|
||||
can_rx_callback_t rx_cb_std[NUM_STD_FILTER_DATA];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue