From 5251cb9d68ab96da99e284a3b01aa645c3dc7ddb Mon Sep 17 00:00:00 2001 From: Qing Huang Date: Fri, 7 May 2010 03:31:16 +0000 Subject: Move lock to FAT driver binding start to prevent interrupt during hot plug event. (based on FatPkg commit b449ca31443f754ed2e6998ca32f49547dabd615) [jordan.l.justen@intel.com: Use script to relicense to 2-clause BSD] Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jordan Justen Acked-by: Mark Doran Acked-by: Laszlo Ersek --- FatPkg/EnhancedFatDxe/Fat.c | 26 ++++++++++++++++++++++---- FatPkg/EnhancedFatDxe/Init.c | 19 ++----------------- 2 files changed, 24 insertions(+), 21 deletions(-) (limited to 'FatPkg/EnhancedFatDxe') diff --git a/FatPkg/EnhancedFatDxe/Fat.c b/FatPkg/EnhancedFatDxe/Fat.c index 67ee66c..38b7088 100644 --- a/FatPkg/EnhancedFatDxe/Fat.c +++ b/FatPkg/EnhancedFatDxe/Fat.c @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -269,10 +269,21 @@ Returns: EFI_STATUS Status; EFI_BLOCK_IO_PROTOCOL *BlockIo; EFI_DISK_IO_PROTOCOL *DiskIo; + BOOLEAN LockedByMe; + + LockedByMe = FALSE; + // + // Acquire the lock. + // If caller has already acquired the lock, cannot lock it again. + // + Status = FatAcquireLockOrFail (); + if (!EFI_ERROR (Status)) { + LockedByMe = TRUE; + } Status = InitializeUnicodeCollationSupport (This->DriverBindingHandle); if (EFI_ERROR (Status)) { - return Status; + goto Exit; } // // Open our required BlockIo and DiskIo @@ -286,7 +297,7 @@ Returns: EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { - return Status; + goto Exit; } Status = gBS->OpenProtocol ( @@ -298,7 +309,7 @@ Returns: EFI_OPEN_PROTOCOL_BY_DRIVER ); if (EFI_ERROR (Status)) { - return Status; + goto Exit; } // // Allocate Volume structure. In FatAllocateVolume(), Resources @@ -330,6 +341,13 @@ Returns: } } +Exit: + // + // Unlock if locked by myself. + // + if (LockedByMe) { + FatReleaseLock (); + } return Status; } diff --git a/FatPkg/EnhancedFatDxe/Init.c b/FatPkg/EnhancedFatDxe/Init.c index 5d86a83..ee258cd 100644 --- a/FatPkg/EnhancedFatDxe/Init.c +++ b/FatPkg/EnhancedFatDxe/Init.c @@ -51,8 +51,7 @@ Returns: { EFI_STATUS Status; FAT_VOLUME *Volume; - BOOLEAN LockedByMe; - LockedByMe = FALSE; + // // Allocate a volume structure // @@ -60,14 +59,7 @@ Returns: if (Volume == NULL) { return EFI_OUT_OF_RESOURCES; } - // - // Acquire the lock. - // If caller has already acquired the lock, cannot lock it again. - // - Status = FatAcquireLockOrFail (); - if (!EFI_ERROR (Status)) { - LockedByMe = TRUE; - } + // // Initialize the structure // @@ -119,13 +111,6 @@ Returns: Volume->Valid = TRUE; Done: - // - // Unlock if locked by myself. - // - if (LockedByMe) { - FatReleaseLock (); - } - if (EFI_ERROR (Status)) { FatFreeVolume (Volume); } -- cgit v1.1