summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-12-13 16:23:34 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-02-02 15:01:22 +0100
commit0940648f6fd85df7fe64a61c4eb3a041fe53f5a1 (patch)
tree9c6b9d4a047609a387266061e8b5d5074a29a086
parent3b77417ba7a6ad6cb6bbfaeccc4cfd0cd7198489 (diff)
RFS: Use self-contained recursive mutex
Update #2843.
-rwxr-xr-xcpukit/include/rtems/confdefs.h9
-rw-r--r--cpukit/include/rtems/rfs/rtems-rfs-mutex.h25
-rw-r--r--cpukit/libfs/src/rfs/rtems-rfs-mutex.c31
3 files changed, 7 insertions, 58 deletions
diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h
index f988ea9592..212b46cd42 100755
--- a/cpukit/include/rtems/confdefs.h
+++ b/cpukit/include/rtems/confdefs.h
@@ -427,14 +427,8 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
#if !defined(CONFIGURE_FILESYSTEM_ENTRY_RFS) && \
defined(CONFIGURE_FILESYSTEM_RFS)
#include <rtems/rtems-rfs.h>
- #if !defined(CONFIGURE_MAXIMUM_RFS_MOUNTS)
- #define CONFIGURE_MAXIMUM_RFS_MOUNTS 1
- #endif
#define CONFIGURE_FILESYSTEM_ENTRY_RFS \
{ RTEMS_FILESYSTEM_TYPE_RFS, rtems_rfs_rtems_initialise }
- #define _CONFIGURE_SEMAPHORES_FOR_RFS CONFIGURE_MAXIMUM_RFS_MOUNTS
-#else
- #define _CONFIGURE_SEMAPHORES_FOR_RFS 0
#endif
/**
@@ -453,8 +447,7 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
*/
#define _CONFIGURE_SEMAPHORES_FOR_FILE_SYSTEMS \
(_CONFIGURE_SEMAPHORES_FOR_FIFOS + \
- _CONFIGURE_SEMAPHORES_FOR_NFS + \
- _CONFIGURE_SEMAPHORES_FOR_RFS)
+ _CONFIGURE_SEMAPHORES_FOR_NFS)
#ifdef CONFIGURE_INIT
diff --git a/cpukit/include/rtems/rfs/rtems-rfs-mutex.h b/cpukit/include/rtems/rfs/rtems-rfs-mutex.h
index 606fd53233..57b58e507e 100644
--- a/cpukit/include/rtems/rfs/rtems-rfs-mutex.h
+++ b/cpukit/include/rtems/rfs/rtems-rfs-mutex.h
@@ -29,13 +29,14 @@
#if __rtems__
#include <rtems.h>
#include <rtems/error.h>
+#include <rtems/thread.h>
#endif
/**
* RFS Mutex type.
*/
#if __rtems__
-typedef rtems_id rtems_rfs_mutex;
+typedef rtems_recursive_mutex rtems_rfs_mutex;
#else
typedef uint32_t rtems_rfs_mutex; /* place holder */
#endif
@@ -73,16 +74,7 @@ static inline int
rtems_rfs_mutex_lock (rtems_rfs_mutex* mutex)
{
#if __rtems__
- rtems_status_code sc = rtems_semaphore_obtain (*mutex, RTEMS_WAIT, 0);
- if (sc != RTEMS_SUCCESSFUL)
- {
-#if RTEMS_RFS_TRACE
- if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
- printf ("rtems-rfs: mutex: obtain failed: %s\n",
- rtems_status_text (sc));
-#endif
- return EIO;
- }
+ rtems_recursive_mutex_lock(mutex);
#endif
return 0;
}
@@ -99,16 +91,7 @@ static inline int
rtems_rfs_mutex_unlock (rtems_rfs_mutex* mutex)
{
#if __rtems__
- rtems_status_code sc = rtems_semaphore_release (*mutex);
- if (sc != RTEMS_SUCCESSFUL)
- {
-#if RTEMS_RFS_TRACE
- if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
- printf ("rtems-rfs: mutex: release failed: %s\n",
- rtems_status_text (sc));
-#endif
- return EIO;
- }
+ rtems_recursive_mutex_unlock(mutex);
#endif
return 0;
}
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-mutex.c b/cpukit/libfs/src/rfs/rtems-rfs-mutex.c
index a320d8093c..9c97c829ed 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-mutex.c
+++ b/cpukit/libfs/src/rfs/rtems-rfs-mutex.c
@@ -18,30 +18,11 @@
#include <rtems/rfs/rtems-rfs-mutex.h>
-#if __rtems__
-/**
- * RTEMS_RFS Mutex Attributes
- */
-#define RTEMS_RFS_MUTEX_ATTRIBS \
- (RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | \
- RTEMS_INHERIT_PRIORITY | RTEMS_NO_PRIORITY_CEILING | RTEMS_LOCAL)
-#endif
-
int
rtems_rfs_mutex_create (rtems_rfs_mutex* mutex)
{
#if __rtems__
- rtems_status_code sc;
- sc = rtems_semaphore_create (rtems_build_name ('R', 'F', 'S', 'm'),
- 1, RTEMS_RFS_MUTEX_ATTRIBS, 0,
- mutex);
- if (sc != RTEMS_SUCCESSFUL)
- {
- if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
- printf ("rtems-rfs: mutex: open failed: %s\n",
- rtems_status_text (sc));
- return EIO;
- }
+ rtems_recursive_mutex_init(mutex, "RFS");
#endif
return 0;
}
@@ -50,15 +31,7 @@ int
rtems_rfs_mutex_destroy (rtems_rfs_mutex* mutex)
{
#if __rtems__
- rtems_status_code sc;
- sc = rtems_semaphore_delete (*mutex);
- if (sc != RTEMS_SUCCESSFUL)
- {
- if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
- printf ("rtems-rfs: mutex: close failed: %s\n",
- rtems_status_text (sc));
- return EIO;
- }
+ rtems_recursive_mutex_destroy(mutex);
#endif
return 0;
}