summaryrefslogtreecommitdiff
path: root/ArmPlatformPkg
diff options
context:
space:
mode:
authorOlivier Martin <olivier.martin@arm.com>2014-08-26 10:20:47 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2014-08-26 10:20:47 +0000
commit22044caa2cf9a484a01c6290fa5bcee5f157c8b4 (patch)
tree8dc06f3f69f6ca4e40846f43c86162e27647b796 /ArmPlatformPkg
parentbcb53c42d057b13a198781bdeca3c2cf55b13164 (diff)
downloadedk2-platforms-22044caa2cf9a484a01c6290fa5bcee5f157c8b4.tar.xz
ArmPlatformPkg/NorFlashDxe: Clean the driver
- Marked some functions as STATIC - Simplified some conditions Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15907 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg')
-rw-r--r--ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c34
-rw-r--r--ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h6
2 files changed, 14 insertions, 26 deletions
diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
index a5933792ac..5673d0bf29 100644
--- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
+++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
@@ -182,7 +182,7 @@ NorFlashReadStatusRegister (
return MmioRead32 (Instance->DeviceBaseAddress);
}
-
+STATIC
BOOLEAN
NorFlashBlockIsLocked (
IN NOR_FLASH_INSTANCE *Instance,
@@ -190,9 +190,6 @@ NorFlashBlockIsLocked (
)
{
UINT32 LockStatus;
- BOOLEAN BlockIsLocked;
-
- BlockIsLocked = TRUE;
// Send command for reading device id
SEND_NOR_COMMAND (BlockAddress, 2, P30_CMD_READ_DEVICE_ID);
@@ -207,23 +204,16 @@ NorFlashBlockIsLocked (
DEBUG((EFI_D_ERROR, "NorFlashBlockIsLocked: WARNING: Block LOCKED DOWN\n"));
}
- if ((LockStatus & 0x1) == 0) {
- // This means the block is unlocked
- DEBUG((DEBUG_BLKIO, "UnlockSingleBlock: Block 0x%08x unlocked\n", BlockAddress));
- BlockIsLocked = FALSE;
- }
-
- return BlockIsLocked;
+ return ((LockStatus & 0x1) != 0);
}
-
+STATIC
EFI_STATUS
NorFlashUnlockSingleBlock (
IN NOR_FLASH_INSTANCE *Instance,
IN UINTN BlockAddress
)
{
- EFI_STATUS Status = EFI_SUCCESS;
UINT32 LockStatus;
// Raise the Task Priority Level to TPL_NOTIFY to serialise all its operations
@@ -262,19 +252,21 @@ NorFlashUnlockSingleBlock (
// Put device back into Read Array mode
SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_READ_ARRAY);
- DEBUG((DEBUG_BLKIO, "UnlockSingleBlock: BlockAddress=0x%08x, Exit Status = \"%r\".\n", BlockAddress, Status));
+ DEBUG((DEBUG_BLKIO, "UnlockSingleBlock: BlockAddress=0x%08x\n", BlockAddress));
- return Status;
+ return EFI_SUCCESS;
}
-
+STATIC
EFI_STATUS
NorFlashUnlockSingleBlockIfNecessary (
IN NOR_FLASH_INSTANCE *Instance,
IN UINTN BlockAddress
)
{
- EFI_STATUS Status = EFI_SUCCESS;
+ EFI_STATUS Status;
+
+ Status = EFI_SUCCESS;
if (NorFlashBlockIsLocked (Instance, BlockAddress) == TRUE) {
Status = NorFlashUnlockSingleBlock (Instance, BlockAddress);
@@ -287,6 +279,7 @@ NorFlashUnlockSingleBlockIfNecessary (
/**
* The following function presumes that the block has already been unlocked.
**/
+STATIC
EFI_STATUS
NorFlashEraseSingleBlock (
IN NOR_FLASH_INSTANCE *Instance,
@@ -340,7 +333,7 @@ NorFlashEraseSingleBlock (
}
/**
- * The following function presumes that the block has already been unlocked.
+ * This function unlock and erase an entire NOR Flash block.
**/
EFI_STATUS
NorFlashUnlockAndEraseSingleBlock (
@@ -366,9 +359,10 @@ NorFlashUnlockAndEraseSingleBlock (
do {
// Unlock the block if we have to
Status = NorFlashUnlockSingleBlockIfNecessary (Instance, BlockAddress);
- if (!EFI_ERROR(Status)) {
- Status = NorFlashEraseSingleBlock (Instance, BlockAddress);
+ if (EFI_ERROR (Status)) {
+ break;
}
+ Status = NorFlashEraseSingleBlock (Instance, BlockAddress);
Index++;
} while ((Index < NOR_FLASH_ERASE_RETRY) && (Status == EFI_WRITE_PROTECTED));
diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h
index 801e6c46f6..c24680098f 100644
--- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h
+++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h
@@ -364,10 +364,4 @@ NorFlashReset (
IN NOR_FLASH_INSTANCE *Instance
);
-EFI_STATUS
-NorFlashUnlockSingleBlockIfNecessary (
- IN NOR_FLASH_INSTANCE *Instance,
- IN UINTN BlockAddress
- );
-
#endif /* __NOR_FLASH_DXE_H__ */