2014-06-03 20:41:34 +02:00
|
|
|
/****************************************************************************
|
2017-05-09 15:34:59 +02:00
|
|
|
* mm/iob/iob_remove_queue.c
|
2014-06-03 20:41:34 +02:00
|
|
|
*
|
2024-09-12 16:44:55 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2021-02-08 13:50:10 +01: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-03 20:41:34 +02:00
|
|
|
*
|
2021-02-08 13:50:10 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-06-03 20:41:34 +02:00
|
|
|
*
|
2021-02-08 13:50:10 +01: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-03 20:41:34 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2014-06-06 17:35:31 +02:00
|
|
|
#include <debug.h>
|
2014-06-03 20:41:34 +02:00
|
|
|
|
2021-11-10 14:23:30 +01:00
|
|
|
#include <nuttx/irq.h>
|
|
|
|
#include <nuttx/arch.h>
|
2017-05-09 15:34:59 +02:00
|
|
|
#include <nuttx/mm/iob.h>
|
2014-06-03 20:41:34 +02:00
|
|
|
|
|
|
|
#include "iob.h"
|
|
|
|
|
2014-06-22 19:27:57 +02:00
|
|
|
#if CONFIG_IOB_NCHAINS > 0
|
|
|
|
|
2014-06-03 20:41:34 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2014-06-24 23:38:00 +02:00
|
|
|
* Name: iob_remove_queue
|
2014-06-03 20:41:34 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2014-06-24 23:38:00 +02: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-03 20:41:34 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-06-06 17:35:31 +02:00
|
|
|
FAR struct iob_s *iob_remove_queue(FAR struct iob_queue_s *iobq)
|
2014-06-03 20:41:34 +02:00
|
|
|
{
|
2014-06-06 17:35:31 +02:00
|
|
|
FAR struct iob_qentry_s *qentry;
|
|
|
|
FAR struct iob_s *iob = NULL;
|
2014-06-03 20:41:34 +02:00
|
|
|
|
2014-06-06 17:35:31 +02:00
|
|
|
/* Remove the I/O buffer chain from the head of the queue */
|
|
|
|
|
2023-10-21 11:20:29 +02:00
|
|
|
irqstate_t flags = spin_lock_irqsave(&g_iob_lock);
|
2014-06-06 17:35:31 +02:00
|
|
|
qentry = iobq->qh_head;
|
|
|
|
if (qentry)
|
2014-06-03 20:41:34 +02:00
|
|
|
{
|
2014-06-06 17:35:31 +02:00
|
|
|
iobq->qh_head = qentry->qe_flink;
|
|
|
|
if (!iobq->qh_head)
|
|
|
|
{
|
|
|
|
iobq->qh_tail = NULL;
|
|
|
|
}
|
|
|
|
|
2023-10-21 11:20:29 +02:00
|
|
|
spin_unlock_irqrestore(&g_iob_lock, flags);
|
|
|
|
|
2014-06-06 17:35:31 +02:00
|
|
|
/* Extract the I/O buffer chain from the container and free the
|
|
|
|
* container.
|
|
|
|
*/
|
|
|
|
|
|
|
|
iob = qentry->qe_head;
|
|
|
|
iob_free_qentry(qentry);
|
2014-06-03 20:41:34 +02:00
|
|
|
}
|
2023-10-21 11:20:29 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
spin_unlock_irqrestore(&g_iob_lock, flags);
|
|
|
|
}
|
2014-06-03 20:41:34 +02:00
|
|
|
|
2014-06-06 17:35:31 +02:00
|
|
|
return iob;
|
2014-06-03 20:41:34 +02:00
|
|
|
}
|
2014-06-06 17:35:31 +02:00
|
|
|
|
2014-06-22 19:27:57 +02:00
|
|
|
#endif /* CONFIG_IOB_NCHAINS > 0 */
|