drivers: can: loopback: 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
4165186d13
commit
10cd28a61a
1 changed files with 3 additions and 17 deletions
|
@ -22,7 +22,6 @@ struct can_loopback_frame {
|
|||
struct can_frame frame;
|
||||
can_tx_callback_t cb;
|
||||
void *cb_arg;
|
||||
struct k_sem *tx_compl;
|
||||
};
|
||||
|
||||
struct can_loopback_filter {
|
||||
|
@ -82,13 +81,8 @@ static void tx_thread(void *arg1, void *arg2, void *arg3)
|
|||
}
|
||||
|
||||
k_mutex_unlock(&data->mtx);
|
||||
|
||||
if (!frame.cb) {
|
||||
k_sem_give(frame.tx_compl);
|
||||
} else {
|
||||
frame.cb(dev, 0, frame.cb_arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int can_loopback_send(const struct device *dev,
|
||||
|
@ -99,9 +93,10 @@ static int can_loopback_send(const struct device *dev,
|
|||
struct can_loopback_data *data = dev->data;
|
||||
struct can_loopback_frame loopback_frame;
|
||||
uint8_t max_dlc = CAN_MAX_DLC;
|
||||
struct k_sem tx_sem;
|
||||
int ret;
|
||||
|
||||
__ASSERT_NO_MSG(callback != NULL);
|
||||
|
||||
LOG_DBG("Sending %d bytes on %s. Id: 0x%x, ID type: %s %s",
|
||||
frame->dlc, dev->name, frame->id,
|
||||
frame->id_type == CAN_STANDARD_IDENTIFIER ?
|
||||
|
@ -130,18 +125,9 @@ static int can_loopback_send(const struct device *dev,
|
|||
loopback_frame.frame = *frame;
|
||||
loopback_frame.cb = callback;
|
||||
loopback_frame.cb_arg = user_data;
|
||||
loopback_frame.tx_compl = &tx_sem;
|
||||
|
||||
if (!callback) {
|
||||
k_sem_init(&tx_sem, 0, 1);
|
||||
}
|
||||
|
||||
ret = k_msgq_put(&data->tx_msgq, &loopback_frame, timeout);
|
||||
|
||||
if (!callback) {
|
||||
k_sem_take(&tx_sem, K_FOREVER);
|
||||
}
|
||||
|
||||
return ret ? -EAGAIN : 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue