mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
Replace nxsem API when used as a lock with nxmutex API
Signed-off-by: anjiahao <anjiahao@xiaomi.com> Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
committed by
Masayuki Ishikawa
parent
0dfd1f004d
commit
d1d46335df
+6
-6
@@ -52,7 +52,7 @@ static int file_munmap_(FAR void *start, size_t length, bool kernel)
|
||||
|
||||
/* Find a region containing this start and length in the list of regions */
|
||||
|
||||
ret = nxsem_wait(&g_rammaps.exclsem);
|
||||
ret = nxmutex_lock(&g_rammaps.lock);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
@@ -78,7 +78,7 @@ static int file_munmap_(FAR void *start, size_t length, bool kernel)
|
||||
{
|
||||
ferr("ERROR: Region not found\n");
|
||||
ret = -EINVAL;
|
||||
goto errout_with_semaphore;
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
/* Get the offset from the beginning of the region and the actual number
|
||||
@@ -93,7 +93,7 @@ static int file_munmap_(FAR void *start, size_t length, bool kernel)
|
||||
{
|
||||
ferr("ERROR: Cannot umap without unmapping to the end\n");
|
||||
ret = -ENOSYS;
|
||||
goto errout_with_semaphore;
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
/* Okay.. the region is beging umapped to the end. Make sure the length
|
||||
@@ -151,11 +151,11 @@ static int file_munmap_(FAR void *start, size_t length, bool kernel)
|
||||
curr->length = length;
|
||||
}
|
||||
|
||||
nxsem_post(&g_rammaps.exclsem);
|
||||
nxmutex_unlock(&g_rammaps.lock);
|
||||
return OK;
|
||||
|
||||
errout_with_semaphore:
|
||||
nxsem_post(&g_rammaps.exclsem);
|
||||
errout_with_lock:
|
||||
nxmutex_unlock(&g_rammaps.lock);
|
||||
return ret;
|
||||
#else
|
||||
return OK;
|
||||
|
||||
+3
-3
@@ -48,7 +48,7 @@
|
||||
|
||||
struct fs_allmaps_s g_rammaps =
|
||||
{
|
||||
SEM_INITIALIZER(1)
|
||||
NXMUTEX_INITIALIZER
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -180,7 +180,7 @@ int rammap(FAR struct file *filep, size_t length,
|
||||
|
||||
/* Add the buffer to the list of regions */
|
||||
|
||||
ret = nxsem_wait(&g_rammaps.exclsem);
|
||||
ret = nxmutex_lock(&g_rammaps.lock);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto errout_with_region;
|
||||
@@ -189,7 +189,7 @@ int rammap(FAR struct file *filep, size_t length,
|
||||
map->flink = g_rammaps.head;
|
||||
g_rammaps.head = map;
|
||||
|
||||
nxsem_post(&g_rammaps.exclsem);
|
||||
nxmutex_unlock(&g_rammaps.lock);
|
||||
*mapped = map->addr;
|
||||
return OK;
|
||||
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/mutex.h>
|
||||
|
||||
#ifdef CONFIG_FS_RAMMAP
|
||||
|
||||
@@ -65,7 +65,7 @@ struct fs_rammap_s
|
||||
|
||||
struct fs_allmaps_s
|
||||
{
|
||||
sem_t exclsem; /* Provides exclusive access the list */
|
||||
mutex_t lock; /* Provides exclusive access the list */
|
||||
struct fs_rammap_s *head; /* List of mapped files */
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user