mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 13:18:50 +08:00
mm/iob: Miscellaneous changes and fixes from code review.
This commit is contained in:
parent
0354702525
commit
1ecc33b7db
8 changed files with 26 additions and 26 deletions
|
@ -200,7 +200,7 @@ FAR struct iob_qentry_s *iob_alloc_qentry(void)
|
|||
{
|
||||
/* Were we called from the interrupt level? */
|
||||
|
||||
if (up_interrupt_context())
|
||||
if (up_interrupt_context() || sched_idletask())
|
||||
{
|
||||
/* Yes, then try to allocate an I/O buffer without waiting */
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/****************************************************************************
|
||||
* mm/iob/iob_copy.c
|
||||
* mm/iob/iob_clone.c
|
||||
*
|
||||
* Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
|
|
|
@ -59,6 +59,11 @@
|
|||
|
||||
void iob_concat(FAR struct iob_s *iob1, FAR struct iob_s *iob2)
|
||||
{
|
||||
/* Combine the total packet size */
|
||||
|
||||
iob1->io_pktlen += iob2->io_pktlen;
|
||||
iob2->io_pktlen = 0;
|
||||
|
||||
/* Find the last buffer in the iob1 buffer chain */
|
||||
|
||||
while (iob1->io_flink)
|
||||
|
@ -69,8 +74,4 @@ void iob_concat(FAR struct iob_s *iob1, FAR struct iob_s *iob2)
|
|||
/* Then connect iob2 buffer chain to the end of the iob1 chain */
|
||||
|
||||
iob1->io_flink = iob2;
|
||||
|
||||
/* Combine the total packet size */
|
||||
|
||||
iob1->io_pktlen += iob2->io_pktlen;
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ int iob_contig(FAR struct iob_s *iob, unsigned int len)
|
|||
/* Get the next I/O buffer in the chain */
|
||||
|
||||
next = iob->io_flink;
|
||||
DEBUGASSERT(next != NULL && next->io_len > 0);
|
||||
DEBUGASSERT(next != NULL);
|
||||
|
||||
/* Copy what we need or what we can from the next buffer */
|
||||
|
||||
|
|
|
@ -115,12 +115,11 @@ FAR struct iob_s *iob_free(FAR struct iob_s *iob)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* This can only happen if the next entry is last entry in the
|
||||
* chain... and if it is empty
|
||||
/* This can only happen if the free entry isn't first entry in the
|
||||
* chain...
|
||||
*/
|
||||
|
||||
next->io_pktlen = 0;
|
||||
DEBUGASSERT(next->io_len == 0 && next->io_flink == NULL);
|
||||
}
|
||||
|
||||
iobinfo("next=%p io_pktlen=%u io_len=%u\n",
|
||||
|
|
|
@ -76,13 +76,13 @@ FAR struct iob_qentry_s *iob_free_qentry(FAR struct iob_qentry_s *iobq)
|
|||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Which list? If there is a task waiting for an IOB, then put
|
||||
* the IOB on either the free list or on the committed list where
|
||||
/* Which list? If there is a task waiting for an IOB chain, then put
|
||||
* the IOB chain on either the free list or on the committed list where
|
||||
* it is reserved for that allocation (and not available to
|
||||
* iob_tryalloc()).
|
||||
* iob_tryalloc_qentry()).
|
||||
*/
|
||||
|
||||
if (g_iob_sem.semcount < 0)
|
||||
if (g_qentry_sem.semcount < 0)
|
||||
{
|
||||
iobq->qe_flink = g_iob_qcommitted;
|
||||
g_iob_qcommitted = iobq;
|
||||
|
|
|
@ -77,12 +77,12 @@ int iob_navail(bool throttled)
|
|||
if (throttled)
|
||||
{
|
||||
ret -= CONFIG_IOB_THROTTLE;
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -112,6 +112,10 @@ int iob_qentry_navail(void)
|
|||
if (ret >= 0)
|
||||
{
|
||||
ret = navail;
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -45,14 +45,6 @@
|
|||
|
||||
#include "iob.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef MIN
|
||||
# define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -79,6 +71,10 @@ FAR struct iob_s *iob_pack(FAR struct iob_s *iob)
|
|||
while (iob->io_len <= 0)
|
||||
{
|
||||
iob = iob_free(iob);
|
||||
if (iob == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now remember the head of the chain (for the return value) */
|
||||
|
|
Loading…
Reference in a new issue