mm/iob: add a helper function to get iob count in chain
Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
parent
eb884c00e8
commit
6e380c0978
@ -177,6 +177,7 @@ Public Function Prototypes
|
|||||||
- :c:func:`iob_trimtail()`
|
- :c:func:`iob_trimtail()`
|
||||||
- :c:func:`iob_pack()`
|
- :c:func:`iob_pack()`
|
||||||
- :c:func:`iob_contig()`
|
- :c:func:`iob_contig()`
|
||||||
|
- :c:func:`iob_count()`
|
||||||
- :c:func:`iob_dump()`
|
- :c:func:`iob_dump()`
|
||||||
|
|
||||||
.. c:function:: void iob_initialize(void);
|
.. c:function:: void iob_initialize(void);
|
||||||
@ -324,6 +325,10 @@ Public Function Prototypes
|
|||||||
space at the beginning of the I/O buffer chain starting at
|
space at the beginning of the I/O buffer chain starting at
|
||||||
``iob``.
|
``iob``.
|
||||||
|
|
||||||
|
.. c:function:: int iob_count(FAR struct iob_s *iob);
|
||||||
|
|
||||||
|
Get ``iob`` entries count in chain.
|
||||||
|
|
||||||
.. c:function:: void iob_dump(FAR const char *msg, FAR struct iob_s *iob, unsigned int len, \
|
.. c:function:: void iob_dump(FAR const char *msg, FAR struct iob_s *iob, unsigned int len, \
|
||||||
unsigned int offset);
|
unsigned int offset);
|
||||||
|
|
||||||
|
@ -593,6 +593,16 @@ void iob_reserve(FAR struct iob_s *iob, unsigned int reserved);
|
|||||||
|
|
||||||
void iob_update_pktlen(FAR struct iob_s *iob, unsigned int pktlen);
|
void iob_update_pktlen(FAR struct iob_s *iob, unsigned int pktlen);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: iob_count
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Get iob entries count in chain.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int iob_count(FAR struct iob_s *iob);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: iob_dump
|
* Name: iob_dump
|
||||||
*
|
*
|
||||||
|
@ -29,6 +29,7 @@ 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_statistics.c iob_trimhead.c iob_trimhead_queue.c iob_trimtail.c
|
||||||
CSRCS += iob_navail.c iob_free_queue_qentry.c iob_tailroom.c
|
CSRCS += iob_navail.c iob_free_queue_qentry.c iob_tailroom.c
|
||||||
CSRCS += iob_get_queue_size.c iob_reserve.c iob_update_pktlen.c
|
CSRCS += iob_get_queue_size.c iob_reserve.c iob_update_pktlen.c
|
||||||
|
CSRCS += iob_count.c
|
||||||
|
|
||||||
ifeq ($(CONFIG_IOB_NOTIFIER),y)
|
ifeq ($(CONFIG_IOB_NOTIFIER),y)
|
||||||
CSRCS += iob_notifier.c
|
CSRCS += iob_notifier.c
|
||||||
|
49
mm/iob/iob_count.c
Normal file
49
mm/iob/iob_count.c
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* mm/iob/iob_count.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"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: iob_count
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Get iob entries count in chain.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int iob_count(FAR struct iob_s *iob)
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
|
||||||
|
for (count = 0; iob != NULL;
|
||||||
|
iob = iob->io_flink, count++);
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user