Fix IOB functions

The operations of struct iob_queue_s in qh_head & qh_tail are performed with interrupts disabled.

change iflags to flags

add header file ref
update for check
This commit is contained in:
Chery Dan 2021-11-10 21:23:30 +08:00 committed by Xiang Xiao
parent 87c47b8758
commit 8d799f2148
3 changed files with 16 additions and 0 deletions

View File

@ -28,6 +28,8 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/mm/iob.h>
#include "iob.h"
@ -66,6 +68,8 @@ static int iob_add_queue_internal(FAR struct iob_s *iob,
/* Add the container to the end of the queue */
qentry->qe_flink = NULL;
irqstate_t flags = enter_critical_section();
if (!iobq->qh_head)
{
iobq->qh_head = qentry;
@ -78,6 +82,8 @@ static int iob_add_queue_internal(FAR struct iob_s *iob,
iobq->qh_tail = qentry;
}
leave_critical_section(flags);
return 0;
}

View File

@ -24,6 +24,9 @@
#include <nuttx/config.h>
#include <assert.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/mm/iob.h>
#include "iob.h"
@ -57,6 +60,7 @@ void iob_free_queue_qentry(FAR struct iob_s *iob,
FAR struct iob_qentry_s *prev = NULL;
FAR struct iob_qentry_s *qentry;
irqstate_t flags = enter_critical_section();
for (qentry = iobq->qh_head; qentry != NULL;
prev = qentry, qentry = qentry->qe_flink)
{
@ -89,6 +93,8 @@ void iob_free_queue_qentry(FAR struct iob_s *iob,
break;
}
}
leave_critical_section(flags);
}
#endif /* CONFIG_IOB_NCHAINS > 0 */

View File

@ -26,6 +26,8 @@
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/mm/iob.h>
#include "iob.h"
@ -62,6 +64,7 @@ FAR struct iob_s *iob_remove_queue(FAR struct iob_queue_s *iobq)
/* Remove the I/O buffer chain from the head of the queue */
irqstate_t flags = enter_critical_section();
qentry = iobq->qh_head;
if (qentry)
{
@ -79,6 +82,7 @@ FAR struct iob_s *iob_remove_queue(FAR struct iob_queue_s *iobq)
iob_free_qentry(qentry);
}
leave_critical_section(flags);
return iob;
}