drivers: can: mcux: flexcan: abort transfers before entering freeze mode
Abort any pending transmissions before entering freeze mode and notify the senders. Fixes: #50545 Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
94d4638ccc
commit
b8eb11de3b
1 changed files with 19 additions and 2 deletions
|
@ -220,12 +220,31 @@ static int mcux_flexcan_stop(const struct device *dev)
|
|||
{
|
||||
const struct mcux_flexcan_config *config = dev->config;
|
||||
struct mcux_flexcan_data *data = dev->data;
|
||||
can_tx_callback_t function;
|
||||
void *arg;
|
||||
int alloc;
|
||||
int err;
|
||||
|
||||
if (!data->started) {
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
data->started = false;
|
||||
|
||||
/* Abort any pending TX frames before entering freeze mode */
|
||||
for (alloc = 0; alloc < MCUX_FLEXCAN_MAX_TX; alloc++) {
|
||||
function = data->tx_cbs[alloc].function;
|
||||
arg = data->tx_cbs[alloc].arg;
|
||||
|
||||
if (atomic_test_and_clear_bit(data->tx_allocs, alloc)) {
|
||||
FLEXCAN_TransferAbortSend(config->base, &data->handle,
|
||||
ALLOC_IDX_TO_TXMB_IDX(alloc));
|
||||
|
||||
function(dev, -ENETDOWN, arg);
|
||||
k_sem_give(&data->tx_allocs_sem);
|
||||
}
|
||||
}
|
||||
|
||||
FLEXCAN_EnterFreezeMode(config->base);
|
||||
|
||||
if (config->phy != NULL) {
|
||||
|
@ -236,8 +255,6 @@ static int mcux_flexcan_stop(const struct device *dev)
|
|||
}
|
||||
}
|
||||
|
||||
data->started = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue