]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/NorFlashDxe: Clean the driver
authorOlivier Martin <olivier.martin@arm.com>
Tue, 26 Aug 2014 10:20:47 +0000 (10:20 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 26 Aug 2014 10:20:47 +0000 (10:20 +0000)
- 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

ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h

index a5933792acf86eae21e747be26d2b4e42be7382f..5673d0bf29f85aeb4b020e34ead82bbc5d484bf2 100644 (file)
@@ -182,7 +182,7 @@ NorFlashReadStatusRegister (
   return MmioRead32 (Instance->DeviceBaseAddress);\r
 }\r
 \r
   return MmioRead32 (Instance->DeviceBaseAddress);\r
 }\r
 \r
-\r
+STATIC\r
 BOOLEAN\r
 NorFlashBlockIsLocked (\r
   IN NOR_FLASH_INSTANCE     *Instance,\r
 BOOLEAN\r
 NorFlashBlockIsLocked (\r
   IN NOR_FLASH_INSTANCE     *Instance,\r
@@ -190,9 +190,6 @@ NorFlashBlockIsLocked (
   )\r
 {\r
   UINT32                LockStatus;\r
   )\r
 {\r
   UINT32                LockStatus;\r
-  BOOLEAN               BlockIsLocked;\r
-\r
-  BlockIsLocked = TRUE;\r
 \r
   // Send command for reading device id\r
   SEND_NOR_COMMAND (BlockAddress, 2, P30_CMD_READ_DEVICE_ID);\r
 \r
   // Send command for reading device id\r
   SEND_NOR_COMMAND (BlockAddress, 2, P30_CMD_READ_DEVICE_ID);\r
@@ -207,23 +204,16 @@ NorFlashBlockIsLocked (
     DEBUG((EFI_D_ERROR, "NorFlashBlockIsLocked: WARNING: Block LOCKED DOWN\n"));\r
   }\r
 \r
     DEBUG((EFI_D_ERROR, "NorFlashBlockIsLocked: WARNING: Block LOCKED DOWN\n"));\r
   }\r
 \r
-  if ((LockStatus & 0x1) == 0) {\r
-    // This means the block is unlocked\r
-    DEBUG((DEBUG_BLKIO, "UnlockSingleBlock: Block 0x%08x unlocked\n", BlockAddress));\r
-    BlockIsLocked = FALSE;\r
-  }\r
-\r
-  return BlockIsLocked;\r
+  return ((LockStatus & 0x1) != 0);\r
 }\r
 \r
 }\r
 \r
-\r
+STATIC\r
 EFI_STATUS\r
 NorFlashUnlockSingleBlock (\r
   IN NOR_FLASH_INSTANCE     *Instance,\r
   IN UINTN                  BlockAddress\r
   )\r
 {\r
 EFI_STATUS\r
 NorFlashUnlockSingleBlock (\r
   IN NOR_FLASH_INSTANCE     *Instance,\r
   IN UINTN                  BlockAddress\r
   )\r
 {\r
-  EFI_STATUS            Status = EFI_SUCCESS;\r
   UINT32                LockStatus;\r
 \r
   // Raise the Task Priority Level to TPL_NOTIFY to serialise all its operations\r
   UINT32                LockStatus;\r
 \r
   // Raise the Task Priority Level to TPL_NOTIFY to serialise all its operations\r
@@ -262,19 +252,21 @@ NorFlashUnlockSingleBlock (
   // Put device back into Read Array mode\r
   SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_READ_ARRAY);\r
 \r
   // Put device back into Read Array mode\r
   SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_READ_ARRAY);\r
 \r
-  DEBUG((DEBUG_BLKIO, "UnlockSingleBlock: BlockAddress=0x%08x, Exit Status = \"%r\".\n", BlockAddress, Status));\r
+  DEBUG((DEBUG_BLKIO, "UnlockSingleBlock: BlockAddress=0x%08x\n", BlockAddress));\r
 \r
 \r
-  return Status;\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 }\r
 \r
-\r
+STATIC\r
 EFI_STATUS\r
 NorFlashUnlockSingleBlockIfNecessary (\r
   IN NOR_FLASH_INSTANCE     *Instance,\r
   IN UINTN                  BlockAddress\r
   )\r
 {\r
 EFI_STATUS\r
 NorFlashUnlockSingleBlockIfNecessary (\r
   IN NOR_FLASH_INSTANCE     *Instance,\r
   IN UINTN                  BlockAddress\r
   )\r
 {\r
-  EFI_STATUS Status = EFI_SUCCESS;\r
+  EFI_STATUS Status;\r
+\r
+  Status = EFI_SUCCESS;\r
 \r
   if (NorFlashBlockIsLocked (Instance, BlockAddress) == TRUE) {\r
     Status = NorFlashUnlockSingleBlock (Instance, BlockAddress);\r
 \r
   if (NorFlashBlockIsLocked (Instance, BlockAddress) == TRUE) {\r
     Status = NorFlashUnlockSingleBlock (Instance, BlockAddress);\r
@@ -287,6 +279,7 @@ NorFlashUnlockSingleBlockIfNecessary (
 /**\r
  * The following function presumes that the block has already been unlocked.\r
  **/\r
 /**\r
  * The following function presumes that the block has already been unlocked.\r
  **/\r
+STATIC\r
 EFI_STATUS\r
 NorFlashEraseSingleBlock (\r
   IN NOR_FLASH_INSTANCE     *Instance,\r
 EFI_STATUS\r
 NorFlashEraseSingleBlock (\r
   IN NOR_FLASH_INSTANCE     *Instance,\r
@@ -340,7 +333,7 @@ NorFlashEraseSingleBlock (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
- * The following function presumes that the block has already been unlocked.\r
+ * This function unlock and erase an entire NOR Flash block.\r
  **/\r
 EFI_STATUS\r
 NorFlashUnlockAndEraseSingleBlock (\r
  **/\r
 EFI_STATUS\r
 NorFlashUnlockAndEraseSingleBlock (\r
@@ -366,9 +359,10 @@ NorFlashUnlockAndEraseSingleBlock (
   do {\r
     // Unlock the block if we have to\r
     Status = NorFlashUnlockSingleBlockIfNecessary (Instance, BlockAddress);\r
   do {\r
     // Unlock the block if we have to\r
     Status = NorFlashUnlockSingleBlockIfNecessary (Instance, BlockAddress);\r
-    if (!EFI_ERROR(Status)) {\r
-      Status = NorFlashEraseSingleBlock (Instance, BlockAddress);\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
     }\r
     }\r
+    Status = NorFlashEraseSingleBlock (Instance, BlockAddress);\r
     Index++;\r
   } while ((Index < NOR_FLASH_ERASE_RETRY) && (Status == EFI_WRITE_PROTECTED));\r
 \r
     Index++;\r
   } while ((Index < NOR_FLASH_ERASE_RETRY) && (Status == EFI_WRITE_PROTECTED));\r
 \r
index 801e6c46f677a13b8fffc82d15ea3c55947d4f3f..c24680098f629541fe823a7356c778e7819f7907 100644 (file)
@@ -364,10 +364,4 @@ NorFlashReset (
   IN  NOR_FLASH_INSTANCE *Instance\r
   );\r
 \r
   IN  NOR_FLASH_INSTANCE *Instance\r
   );\r
 \r
-EFI_STATUS\r
-NorFlashUnlockSingleBlockIfNecessary (\r
-  IN NOR_FLASH_INSTANCE     *Instance,\r
-  IN UINTN                  BlockAddress\r
-  );\r
-\r
 #endif /* __NOR_FLASH_DXE_H__ */\r
 #endif /* __NOR_FLASH_DXE_H__ */\r