drivers: can: mcp2515: 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. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
eb06e6aed0
commit
78d6ba5ce3
2 changed files with 4 additions and 16 deletions
|
@ -524,6 +524,8 @@ static int mcp2515_send(const struct device *dev,
|
|||
uint8_t len;
|
||||
uint8_t tx_frame[MCP2515_FRAME_LEN];
|
||||
|
||||
__ASSERT_NO_MSG(callback != NULL);
|
||||
|
||||
if (frame->dlc > CAN_MAX_DLC) {
|
||||
LOG_ERR("DLC of %d exceeds maximum (%d)",
|
||||
frame->dlc, CAN_MAX_DLC);
|
||||
|
@ -572,10 +574,6 @@ static int mcp2515_send(const struct device *dev,
|
|||
nnn = BIT(tx_idx);
|
||||
mcp2515_cmd_rts(dev, nnn);
|
||||
|
||||
if (callback == NULL) {
|
||||
k_sem_take(&dev_data->tx_cb[tx_idx].sem, K_FOREVER);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -684,11 +682,8 @@ static void mcp2515_tx_done(const struct device *dev, uint8_t tx_idx)
|
|||
{
|
||||
struct mcp2515_data *dev_data = dev->data;
|
||||
|
||||
if (dev_data->tx_cb[tx_idx].cb == NULL) {
|
||||
k_sem_give(&dev_data->tx_cb[tx_idx].sem);
|
||||
} else {
|
||||
dev_data->tx_cb[tx_idx].cb(dev, 0, dev_data->tx_cb[tx_idx].cb_arg);
|
||||
}
|
||||
dev_data->tx_cb[tx_idx].cb = NULL;
|
||||
|
||||
k_mutex_lock(&dev_data->mutex, K_FOREVER);
|
||||
dev_data->tx_busy_map &= ~BIT(tx_idx);
|
||||
|
@ -901,17 +896,11 @@ static int mcp2515_init(const struct device *dev)
|
|||
struct mcp2515_data *dev_data = dev->data;
|
||||
struct can_timing timing;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
k_sem_init(&dev_data->int_sem, 0, 1);
|
||||
k_mutex_init(&dev_data->mutex);
|
||||
k_sem_init(&dev_data->tx_sem, MCP2515_TX_CNT, MCP2515_TX_CNT);
|
||||
|
||||
for (i = 0; i < MCP2515_TX_CNT; i++) {
|
||||
k_sem_init(&dev_data->tx_cb[i].sem, 0, 1);
|
||||
dev_data->tx_cb[i].cb = NULL;
|
||||
}
|
||||
|
||||
if (dev_cfg->phy != NULL) {
|
||||
if (!device_is_ready(dev_cfg->phy)) {
|
||||
LOG_ERR("CAN transceiver not ready");
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define MCP2515_FRAME_LEN 13
|
||||
|
||||
struct mcp2515_tx_cb {
|
||||
struct k_sem sem;
|
||||
can_tx_callback_t cb;
|
||||
void *cb_arg;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue