mm/iob: add iob_get_queue_size() helper

Change-Id: I117530f364cbef1e011638ff6d14087b7447bde7
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an
2021-04-13 20:50:38 +08:00
parent f0ba04eb2b
commit 2fd5872449
3 changed files with 73 additions and 1 deletions
+12
View File
@@ -457,6 +457,18 @@ void iob_destroy_queue(FAR struct iob_queue_s *qhead,
int iob_get_queue_count(FAR struct iob_queue_s *queue);
#endif /* CONFIG_IOB_NCHAINS > 0 */
/****************************************************************************
* Name: iob_get_queue_size
*
* Description:
* Queue helper for get the iob entry size.
*
****************************************************************************/
#if CONFIG_IOB_NCHAINS > 0
size_t iob_get_queue_size(FAR struct iob_queue_s *queue);
#endif /* CONFIG_IOB_NCHAINS > 0 */
/****************************************************************************
* Name: iob_copyin
*
+1 -1
View File
@@ -25,7 +25,7 @@ ifeq ($(CONFIG_MM_IOB),y)
CSRCS += iob_add_queue.c iob_alloc.c iob_alloc_qentry.c iob_clone.c
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_destroy_queue.c
CSRCS += iob_free_queue.c iob_get_queue_count.c
CSRCS += iob_free_queue.c iob_get_queue_count.c iob_get_queue_size.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
+60
View File
@@ -0,0 +1,60 @@
/****************************************************************************
* mm/iob/iob_get_queue_size.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 <nuttx/mm/iob.h>
#include "iob.h"
#if CONFIG_IOB_NCHAINS > 0
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: iob_get_queue_size
*
* Description:
* Queue helper for get the iob entry count.
*
****************************************************************************/
size_t iob_get_queue_size(FAR struct iob_queue_s *queue)
{
FAR struct iob_qentry_s *iobq;
FAR struct iob_s *iob;
size_t total = 0;
for (iobq = queue->qh_head; iobq != NULL; iobq = iobq->qe_flink)
{
for (iob = iobq->qe_head; iob; iob = iob->io_flink)
{
total += iob->io_len;
}
}
return total;
}
#endif /* CONFIG_IOB_NCHAINS > 0 */