forked from xt-sys/exectos
Simplify device map locking using RAII
This commit is contained in:
@@ -28,8 +28,9 @@ OB::DeviceMap::GetGlobalDevicesDirectory(IN POBJECT_DIRECTORY Directory)
|
|||||||
/* Assume no mapping exists */
|
/* Assume no mapping exists */
|
||||||
GlobalDevicesDirectory = NULLPTR;
|
GlobalDevicesDirectory = NULLPTR;
|
||||||
|
|
||||||
/* Acquire the device map lock */
|
/* Enter guarded region and acquire the device map lock */
|
||||||
KE::PushLock::AcquireExclusivePushLock(&DeviceMapLock);
|
KE::GuardedRegionGuard GuardedRegion;
|
||||||
|
KE::PushLockExclusiveGuard PushLock(&DeviceMapLock);
|
||||||
|
|
||||||
/* Check if the directory has an associated device map */
|
/* Check if the directory has an associated device map */
|
||||||
if(Directory->DeviceMap)
|
if(Directory->DeviceMap)
|
||||||
@@ -38,9 +39,6 @@ OB::DeviceMap::GetGlobalDevicesDirectory(IN POBJECT_DIRECTORY Directory)
|
|||||||
GlobalDevicesDirectory = Directory->DeviceMap->GlobalDevicesDirectory;
|
GlobalDevicesDirectory = Directory->DeviceMap->GlobalDevicesDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release the device map lock */
|
|
||||||
KE::PushLock::ReleaseExclusivePushLock(&DeviceMapLock);
|
|
||||||
|
|
||||||
/* Return the resolved directory */
|
/* Return the resolved directory */
|
||||||
return GlobalDevicesDirectory;
|
return GlobalDevicesDirectory;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user