incubator-nuttx/mm/iob/iob_remove_queue.c

82 lines
2.5 KiB
C
Raw Normal View History

2014-06-04 02:41:34 +08:00
/****************************************************************************
* mm/iob/iob_remove_queue.c
2014-06-04 02:41:34 +08:00
*
* 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
2014-06-04 02:41:34 +08:00
*
* http://www.apache.org/licenses/LICENSE-2.0
2014-06-04 02:41:34 +08:00
*
* 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.
2014-06-04 02:41:34 +08:00
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
2014-06-04 02:41:34 +08:00
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/mm/iob.h>
2014-06-04 02:41:34 +08:00
#include "iob.h"
#if CONFIG_IOB_NCHAINS > 0
2014-06-04 02:41:34 +08:00
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: iob_remove_queue
2014-06-04 02:41:34 +08:00
*
* Description:
* Remove and return one I/O buffer chain from the head of a queue.
*
* Returned Value:
* Returns a reference to the I/O buffer chain at the head of the queue.
2014-06-04 02:41:34 +08:00
*
****************************************************************************/
FAR struct iob_s *iob_remove_queue(FAR struct iob_queue_s *iobq)
2014-06-04 02:41:34 +08:00
{
FAR struct iob_qentry_s *qentry;
FAR struct iob_s *iob = NULL;
2014-06-04 02:41:34 +08:00
/* Remove the I/O buffer chain from the head of the queue */
irqstate_t flags = enter_critical_section();
qentry = iobq->qh_head;
if (qentry)
2014-06-04 02:41:34 +08:00
{
iobq->qh_head = qentry->qe_flink;
if (!iobq->qh_head)
{
iobq->qh_tail = NULL;
}
/* Extract the I/O buffer chain from the container and free the
* container.
*/
iob = qentry->qe_head;
iob_free_qentry(qentry);
2014-06-04 02:41:34 +08:00
}
leave_critical_section(flags);
return iob;
2014-06-04 02:41:34 +08:00
}
#endif /* CONFIG_IOB_NCHAINS > 0 */