2014-06-04 02:41:34 +08:00
|
|
|
/****************************************************************************
|
2017-05-09 21:34:59 +08:00
|
|
|
* mm/iob/iob_remove_queue.c
|
2014-06-04 02:41:34 +08:00
|
|
|
*
|
2021-02-08 20:50:10 +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
|
|
|
*
|
2021-02-08 20:50:10 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-06-04 02:41:34 +08:00
|
|
|
*
|
2021-02-08 20:50:10 +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>
|
|
|
|
|
2014-06-06 23:35:31 +08:00
|
|
|
#include <debug.h>
|
2014-06-04 02:41:34 +08:00
|
|
|
|
2021-11-10 21:23:30 +08:00
|
|
|
#include <nuttx/irq.h>
|
|
|
|
#include <nuttx/arch.h>
|
2017-05-09 21:34:59 +08:00
|
|
|
#include <nuttx/mm/iob.h>
|
2014-06-04 02:41:34 +08:00
|
|
|
|
|
|
|
#include "iob.h"
|
|
|
|
|
2014-06-23 01:27:57 +08:00
|
|
|
#if CONFIG_IOB_NCHAINS > 0
|
|
|
|
|
2014-06-04 02:41:34 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2014-06-25 05:38:00 +08:00
|
|
|
* Name: iob_remove_queue
|
2014-06-04 02:41:34 +08:00
|
|
|
*
|
|
|
|
* Description:
|
2014-06-25 05:38:00 +08:00
|
|
|
* 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
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-06-06 23:35:31 +08:00
|
|
|
FAR struct iob_s *iob_remove_queue(FAR struct iob_queue_s *iobq)
|
2014-06-04 02:41:34 +08:00
|
|
|
{
|
2014-06-06 23:35:31 +08:00
|
|
|
FAR struct iob_qentry_s *qentry;
|
|
|
|
FAR struct iob_s *iob = NULL;
|
2014-06-04 02:41:34 +08:00
|
|
|
|
2014-06-06 23:35:31 +08:00
|
|
|
/* Remove the I/O buffer chain from the head of the queue */
|
|
|
|
|
2021-11-10 21:23:30 +08:00
|
|
|
irqstate_t flags = enter_critical_section();
|
2014-06-06 23:35:31 +08:00
|
|
|
qentry = iobq->qh_head;
|
|
|
|
if (qentry)
|
2014-06-04 02:41:34 +08:00
|
|
|
{
|
2014-06-06 23:35:31 +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
|
|
|
}
|
|
|
|
|
2021-11-10 21:23:30 +08:00
|
|
|
leave_critical_section(flags);
|
2014-06-06 23:35:31 +08:00
|
|
|
return iob;
|
2014-06-04 02:41:34 +08:00
|
|
|
}
|
2014-06-06 23:35:31 +08:00
|
|
|
|
2014-06-23 01:27:57 +08:00
|
|
|
#endif /* CONFIG_IOB_NCHAINS > 0 */
|