fs: Initialize fs_allmaps_s::exclsem in declaration directly
and then remove rammap_initialize and caller Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Change-Id: Ife9f04d409b3a14a3be4bbb61c23da6e7a9f8a3d
This commit is contained in:
parent
4ba1bafe55
commit
ec30d6ef6b
|
@ -103,7 +103,6 @@ int munmap(FAR void *start, size_t length)
|
|||
|
||||
/* Find a region containing this start and length in the list of regions */
|
||||
|
||||
rammap_initialize();
|
||||
ret = nxsem_wait(&g_rammaps.exclsem);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
|
|
@ -46,35 +46,15 @@
|
|||
|
||||
/* This is the list of all mapped files */
|
||||
|
||||
struct fs_allmaps_s g_rammaps;
|
||||
struct fs_allmaps_s g_rammaps =
|
||||
{
|
||||
SEM_INITIALIZER(1)
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: rammap_initialize
|
||||
*
|
||||
* Description:
|
||||
* Verified that this capability has been initialized.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void rammap_initialize(void)
|
||||
{
|
||||
if (!g_rammaps.initialized)
|
||||
{
|
||||
nxsem_init(&g_rammaps.exclsem, 0, 1);
|
||||
g_rammaps.initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: rammmap
|
||||
*
|
||||
|
@ -197,7 +177,6 @@ FAR void *rammap(int fd, size_t length, off_t offset)
|
|||
|
||||
/* Add the buffer to the list of regions */
|
||||
|
||||
rammap_initialize();
|
||||
ret = nxsem_wait(&g_rammaps.exclsem);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
|
|
@ -65,7 +65,6 @@ struct fs_rammap_s
|
|||
|
||||
struct fs_allmaps_s
|
||||
{
|
||||
bool initialized; /* True: This structure has been initialized */
|
||||
sem_t exclsem; /* Provides exclusive access the list */
|
||||
struct fs_rammap_s *head; /* List of mapped files */
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue