forked from nuttx/nuttx-update
mm/iob: add an interface to support dequeue an iob from the queue
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
e73883aba5
commit
2c51c29768
4 changed files with 115 additions and 1 deletions
|
@ -164,6 +164,7 @@ Public Function Prototypes
|
|||
- :c:func:`iob_remove_queue()`
|
||||
- :c:func:`iob_peek_queue()`
|
||||
- :c:func:`iob_free_queue()`
|
||||
- :c:func:`iob_free_queue_qentry()`
|
||||
- :c:func:`iob_copyin()`
|
||||
- :c:func:`iob_trycopyin()`
|
||||
- :c:func:`iob_copyout()`
|
||||
|
@ -238,6 +239,11 @@ Public Function Prototypes
|
|||
|
||||
Free an entire queue of I/O buffer chains.
|
||||
|
||||
.. c:function:: void iob_free_queue_qentry(FAR struct iob_s *iob, \
|
||||
FAR struct iob_queue_s *iobq);
|
||||
|
||||
Free an iob entire queue of I/O buffer chains.
|
||||
|
||||
.. c:function:: int iob_copyin(FAR struct iob_s *iob, FAR const uint8_t *src, \
|
||||
unsigned int len, unsigned int offset, bool throttled);
|
||||
|
||||
|
|
|
@ -425,6 +425,20 @@ void iob_free_queue(FAR struct iob_queue_s *qhead,
|
|||
enum iob_user_e producerid);
|
||||
#endif /* CONFIG_IOB_NCHAINS > 0 */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iob_free_queue_qentry
|
||||
*
|
||||
* Description:
|
||||
* Free an iob entire queue of I/O buffer chains.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_IOB_NCHAINS > 0
|
||||
void iob_free_queue_qentry(FAR struct iob_s *iob,
|
||||
FAR struct iob_queue_s *iobq,
|
||||
enum iob_user_e producerid);
|
||||
#endif /* CONFIG_IOB_NCHAINS > 0 */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iob_copyin
|
||||
*
|
||||
|
|
|
@ -27,7 +27,7 @@ CSRCS += iob_concat.c iob_copyin.c iob_copyout.c iob_contig.c iob_free.c
|
|||
CSRCS += iob_free_chain.c iob_free_qentry.c iob_free_queue.c
|
||||
CSRCS += iob_initialize.c iob_pack.c iob_peek_queue.c iob_remove_queue.c
|
||||
CSRCS += iob_statistics.c iob_trimhead.c iob_trimhead_queue.c iob_trimtail.c
|
||||
CSRCS += iob_navail.c
|
||||
CSRCS += iob_navail.c iob_free_queue_qentry.c
|
||||
|
||||
ifeq ($(CONFIG_IOB_NOTIFIER),y)
|
||||
CSRCS += iob_notifier.c
|
||||
|
|
94
mm/iob/iob_free_queue_qentry.c
Normal file
94
mm/iob/iob_free_queue_qentry.c
Normal file
|
@ -0,0 +1,94 @@
|
|||
/****************************************************************************
|
||||
* mm/iob/iob_free_queue_qentry.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <assert.h>
|
||||
#include <nuttx/mm/iob.h>
|
||||
|
||||
#include "iob.h"
|
||||
|
||||
#if CONFIG_IOB_NCHAINS > 0
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL ((FAR void *)0)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iob_free_queue_qentry
|
||||
*
|
||||
* Description:
|
||||
* Free an iob entire queue of I/O buffer chains.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void iob_free_queue_qentry(FAR struct iob_s *iob,
|
||||
FAR struct iob_queue_s *iobq,
|
||||
enum iob_user_e producerid)
|
||||
{
|
||||
FAR struct iob_qentry_s *prev = NULL;
|
||||
FAR struct iob_qentry_s *qentry;
|
||||
|
||||
for (qentry = iobq->qh_head; qentry != NULL;
|
||||
prev = qentry, qentry = qentry->qe_flink)
|
||||
{
|
||||
/* Find head of the I/O buffer chain */
|
||||
|
||||
if (qentry->qe_head == iob)
|
||||
{
|
||||
if (prev == NULL)
|
||||
{
|
||||
iobq->qh_head = qentry->qe_flink;
|
||||
}
|
||||
else
|
||||
{
|
||||
prev->qe_flink = qentry->qe_flink;
|
||||
}
|
||||
|
||||
if (iobq->qh_tail == qentry)
|
||||
{
|
||||
iobq->qh_tail = prev;
|
||||
}
|
||||
|
||||
/* Remove the queue container */
|
||||
|
||||
iob_free_qentry(qentry);
|
||||
|
||||
/* Free the I/O chain */
|
||||
|
||||
iob_free_chain(iob, producerid);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_IOB_NCHAINS > 0 */
|
Loading…
Reference in a new issue