summaryrefslogtreecommitdiff
path: root/components/drivers
diff options
context:
space:
mode:
authorzms123456 <[email protected]>2024-04-16 11:17:06 +0800
committerGitHub <[email protected]>2024-04-15 23:17:06 -0400
commitbe699795f8a5076e671091fb904823c21adf7df4 (patch)
tree51bd87ba0aadf8666cd5ac9d5c47acbb1d48e098 /components/drivers
parent6ad0b2bd093d26771bc1348d9bcda7eac7e1dc52 (diff)
[components][drivers]close can irq before release fifo
原来的CAN close中先释放fifo后关闭CAN中断,可能导致释放fifo后且关闭CAN中断前来CAN中断,此时rt_hw_can_isr可能在RT_ASSERT(tx/rx_fifo != RT_NULL)断言失败
Diffstat (limited to 'components/drivers')
-rw-r--r--components/drivers/can/can.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/components/drivers/can/can.c b/components/drivers/can/can.c
index 11521608df..2ebab4afbc 100644
--- a/components/drivers/can/can.c
+++ b/components/drivers/can/can.c
@@ -407,20 +407,24 @@ static rt_err_t rt_can_close(struct rt_device *dev)
{
struct rt_can_rx_fifo *rx_fifo;
+ /* clear can rx interrupt */
+ can->ops->control(can, RT_DEVICE_CTRL_CLR_INT, (void *)RT_DEVICE_FLAG_INT_RX);
+
rx_fifo = (struct rt_can_rx_fifo *)can->can_rx;
RT_ASSERT(rx_fifo != RT_NULL);
rt_free(rx_fifo);
dev->open_flag &= ~RT_DEVICE_FLAG_INT_RX;
can->can_rx = RT_NULL;
- /* clear can rx interrupt */
- can->ops->control(can, RT_DEVICE_CTRL_CLR_INT, (void *)RT_DEVICE_FLAG_INT_RX);
}
if (dev->open_flag & RT_DEVICE_FLAG_INT_TX)
{
struct rt_can_tx_fifo *tx_fifo;
+ /* clear can tx interrupt */
+ can->ops->control(can, RT_DEVICE_CTRL_CLR_INT, (void *)RT_DEVICE_FLAG_INT_TX);
+
tx_fifo = (struct rt_can_tx_fifo *)can->can_tx;
RT_ASSERT(tx_fifo != RT_NULL);
@@ -428,8 +432,6 @@ static rt_err_t rt_can_close(struct rt_device *dev)
rt_free(tx_fifo);
dev->open_flag &= ~RT_DEVICE_FLAG_INT_TX;
can->can_tx = RT_NULL;
- /* clear can tx interrupt */
- can->ops->control(can, RT_DEVICE_CTRL_CLR_INT, (void *)RT_DEVICE_FLAG_INT_TX);
}
can->ops->control(can, RT_DEVICE_CTRL_CLR_INT, (void *)RT_DEVICE_CAN_INT_ERR);