[rtems commit] drvmgr: Use API mutex usage

Sebastian Huber sebh at rtems.org
Tue Apr 24 13:24:49 UTC 2018


Module:    rtems
Branch:    master
Commit:    905d7fa3a283d75969373783feeeff331157304e
Changeset: http://git.rtems.org/rtems/commit/?id=905d7fa3a283d75969373783feeeff331157304e

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Apr 24 15:23:39 2018 +0200

drvmgr: Use API mutex usage

The driver manager lock may be used before the executing thread is
initialized.

---

 cpukit/libdrvmgr/drvmgr_lock.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/cpukit/libdrvmgr/drvmgr_lock.c b/cpukit/libdrvmgr/drvmgr_lock.c
index c7a1104..23cdb13 100644
--- a/cpukit/libdrvmgr/drvmgr_lock.c
+++ b/cpukit/libdrvmgr/drvmgr_lock.c
@@ -7,16 +7,20 @@
  * http://www.rtems.org/license/LICENSE.
  */
 
-#include <rtems.h>
 #include <drvmgr/drvmgr.h>
 #include "drvmgr_internal.h"
+#include <rtems/score/sysstate.h>
 
-void _DRV_Manager_Lock(void)
+void _DRV_Manager_Lock( void )
 {
-	_API_Mutex_Lock(&drvmgr.lock);
+  if ( !_System_state_Is_before_multitasking( _System_state_Get() ) ) {
+    _API_Mutex_Lock( &drvmgr.lock );
+  }
 }
 
 void _DRV_Manager_Unlock(void)
 {
-	_API_Mutex_Unlock(&drvmgr.lock);
+  if ( !_System_state_Is_before_multitasking( _System_state_Get() ) ) {
+    _API_Mutex_Unlock( &drvmgr.lock );
+  }
 }




More information about the vc mailing list