mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
mm/iob: Remove initialized static variable inside iob_initialize
since it's impossible to call iob_initialize twice Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
committed by
Gustavo Henrique Nihei
parent
b0786606fc
commit
d9a442a859
+10
-24
@@ -73,12 +73,19 @@ FAR struct iob_qentry_s *g_iob_qcommitted;
|
|||||||
|
|
||||||
/* Counting semaphores that tracks the number of free IOBs/qentries */
|
/* Counting semaphores that tracks the number of free IOBs/qentries */
|
||||||
|
|
||||||
sem_t g_iob_sem; /* Counts free I/O buffers */
|
sem_t g_iob_sem = SEM_INITIALIZER(CONFIG_IOB_NBUFFERS);
|
||||||
|
|
||||||
#if CONFIG_IOB_THROTTLE > 0
|
#if CONFIG_IOB_THROTTLE > 0
|
||||||
sem_t g_throttle_sem; /* Counts available I/O buffers when throttled */
|
/* Counts available I/O buffers when throttled */
|
||||||
|
|
||||||
|
sem_t g_throttle_sem = SEM_INITIALIZER(CONFIG_IOB_NBUFFERS -
|
||||||
|
CONFIG_IOB_THROTTLE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_IOB_NCHAINS > 0
|
#if CONFIG_IOB_NCHAINS > 0
|
||||||
sem_t g_qentry_sem; /* Counts free I/O buffer queue containers */
|
/* Counts free I/O buffer queue containers */
|
||||||
|
|
||||||
|
sem_t g_qentry_sem = SEM_INITIALIZER(CONFIG_IOB_NCHAINS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -95,13 +102,8 @@ sem_t g_qentry_sem; /* Counts free I/O buffer queue containers */
|
|||||||
|
|
||||||
void iob_initialize(void)
|
void iob_initialize(void)
|
||||||
{
|
{
|
||||||
static bool initialized = false;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Perform one-time initialization */
|
|
||||||
|
|
||||||
if (!initialized)
|
|
||||||
{
|
|
||||||
/* Add each I/O buffer to the free list */
|
/* Add each I/O buffer to the free list */
|
||||||
|
|
||||||
for (i = 0; i < CONFIG_IOB_NBUFFERS; i++)
|
for (i = 0; i < CONFIG_IOB_NBUFFERS; i++)
|
||||||
@@ -114,15 +116,6 @@ void iob_initialize(void)
|
|||||||
g_iob_freelist = iob;
|
g_iob_freelist = iob;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_iob_committed = NULL;
|
|
||||||
|
|
||||||
nxsem_init(&g_iob_sem, 0, CONFIG_IOB_NBUFFERS);
|
|
||||||
#if CONFIG_IOB_THROTTLE > 0
|
|
||||||
nxsem_init(&g_throttle_sem,
|
|
||||||
0,
|
|
||||||
CONFIG_IOB_NBUFFERS - CONFIG_IOB_THROTTLE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_IOB_NCHAINS > 0
|
#if CONFIG_IOB_NCHAINS > 0
|
||||||
/* Add each I/O buffer chain queue container to the free list */
|
/* Add each I/O buffer chain queue container to the free list */
|
||||||
|
|
||||||
@@ -137,12 +130,5 @@ void iob_initialize(void)
|
|||||||
iobq->qe_flink = g_iob_freeqlist;
|
iobq->qe_flink = g_iob_freeqlist;
|
||||||
g_iob_freeqlist = iobq;
|
g_iob_freeqlist = iobq;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_iob_qcommitted = NULL;
|
|
||||||
|
|
||||||
nxsem_init(&g_qentry_sem, 0, CONFIG_IOB_NCHAINS);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user