ArmPkg: Fix warnings raised by ARMGCC
[mirror_edk2.git] / EmbeddedPkg / Universal / MmcDxe / Mmc.c
index 9c67867aa309686cd1f892e4c63d432ad7b3fb82..468bb1dae6051f9a5801ccdc2233859c242123b6 100644 (file)
@@ -52,7 +52,7 @@ InitializeMmcHostPool (
   VOID\r
   )\r
 {\r
-    InitializeListHead (&mMmcHostPool);\r
+  InitializeListHead (&mMmcHostPool);\r
 }\r
 \r
 /**\r
@@ -63,7 +63,7 @@ InsertMmcHost (
   IN MMC_HOST_INSTANCE      *MmcHostInstance\r
   )\r
 {\r
-    InsertTailList (&mMmcHostPool, &(MmcHostInstance->Link));\r
+  InsertTailList (&mMmcHostPool, &(MmcHostInstance->Link));\r
 }\r
 \r
 /*\r
@@ -74,101 +74,101 @@ RemoveMmcHost (
   IN MMC_HOST_INSTANCE      *MmcHostInstance\r
   )\r
 {\r
-    RemoveEntryList (&(MmcHostInstance->Link));\r
+  RemoveEntryList (&(MmcHostInstance->Link));\r
 }\r
 \r
-MMC_HOST_INSTANCE* CreateMmcHostInstance(\r
+MMC_HOST_INSTANCE* CreateMmcHostInstance (\r
   IN EFI_MMC_HOST_PROTOCOL* MmcHost\r
   )\r
 {\r
-    EFI_STATUS          Status;\r
-    MMC_HOST_INSTANCE*  MmcHostInstance;\r
-    EFI_DEVICE_PATH_PROTOCOL    *NewDevicePathNode;\r
-    EFI_DEVICE_PATH_PROTOCOL    *DevicePath;\r
-\r
-    MmcHostInstance = AllocateZeroPool (sizeof (MMC_HOST_INSTANCE));\r
-    if (MmcHostInstance == NULL) {\r
-        return NULL;\r
-    }\r
+  EFI_STATUS          Status;\r
+  MMC_HOST_INSTANCE*  MmcHostInstance;\r
+  EFI_DEVICE_PATH_PROTOCOL    *NewDevicePathNode;\r
+  EFI_DEVICE_PATH_PROTOCOL    *DevicePath;\r
 \r
-    MmcHostInstance->Signature = MMC_HOST_INSTANCE_SIGNATURE;\r
+  MmcHostInstance = AllocateZeroPool (sizeof (MMC_HOST_INSTANCE));\r
+  if (MmcHostInstance == NULL) {\r
+    return NULL;\r
+  }\r
 \r
-    MmcHostInstance->State = MmcHwInitializationState;\r
-    \r
-    MmcHostInstance->BlockIo.Media = AllocateCopyPool (sizeof(EFI_BLOCK_IO_MEDIA), &mMmcMediaTemplate);\r
-    if (MmcHostInstance->BlockIo.Media == NULL) {\r
-        goto FREE_INSTANCE;\r
-    }\r
+  MmcHostInstance->Signature = MMC_HOST_INSTANCE_SIGNATURE;\r
 \r
-    MmcHostInstance->BlockIo.Revision = EFI_BLOCK_IO_INTERFACE_REVISION;\r
-    MmcHostInstance->BlockIo.Reset = MmcReset;\r
-    MmcHostInstance->BlockIo.ReadBlocks = MmcReadBlocks;\r
-    MmcHostInstance->BlockIo.WriteBlocks = MmcWriteBlocks;\r
-    MmcHostInstance->BlockIo.FlushBlocks = MmcFlushBlocks;\r
+  MmcHostInstance->State = MmcHwInitializationState;\r
 \r
-    MmcHostInstance->MmcHost = MmcHost;\r
+  MmcHostInstance->BlockIo.Media = AllocateCopyPool (sizeof(EFI_BLOCK_IO_MEDIA), &mMmcMediaTemplate);\r
+  if (MmcHostInstance->BlockIo.Media == NULL) {\r
+    goto FREE_INSTANCE;\r
+  }\r
 \r
-    // Create DevicePath for the new MMC Host\r
-    Status = MmcHost->BuildDevicePath(&NewDevicePathNode);\r
-    if (EFI_ERROR (Status)) {\r
-        goto FREE_MEDIA;\r
-    }\r
+  MmcHostInstance->BlockIo.Revision = EFI_BLOCK_IO_INTERFACE_REVISION;\r
+  MmcHostInstance->BlockIo.Reset = MmcReset;\r
+  MmcHostInstance->BlockIo.ReadBlocks = MmcReadBlocks;\r
+  MmcHostInstance->BlockIo.WriteBlocks = MmcWriteBlocks;\r
+  MmcHostInstance->BlockIo.FlushBlocks = MmcFlushBlocks;\r
 \r
-    DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r
-    if (DevicePath == NULL) {\r
-        goto FREE_MEDIA;\r
-    }\r
-    \r
-    SetDevicePathEndNode (DevicePath);\r
-    MmcHostInstance->DevicePath = AppendDevicePathNode (DevicePath, NewDevicePathNode);\r
-\r
-    // Publish BlockIO protocol interface\r
-    Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &MmcHostInstance->MmcHandle,\r
-                  &gEfiBlockIoProtocolGuid,&(MmcHostInstance->BlockIo),\r
-                  &gEfiDevicePathProtocolGuid,MmcHostInstance->DevicePath,\r
-                  NULL\r
-                  );\r
-    if (EFI_ERROR(Status)) {\r
-        goto FREE_DEVICE_PATH;\r
-    }\r
+  MmcHostInstance->MmcHost = MmcHost;\r
+\r
+  // Create DevicePath for the new MMC Host\r
+  Status = MmcHost->BuildDevicePath(&NewDevicePathNode);\r
+  if (EFI_ERROR (Status)) {\r
+    goto FREE_MEDIA;\r
+  }\r
 \r
-    return MmcHostInstance;\r
+  DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r
+  if (DevicePath == NULL) {\r
+    goto FREE_MEDIA;\r
+  }\r
+\r
+  SetDevicePathEndNode (DevicePath);\r
+  MmcHostInstance->DevicePath = AppendDevicePathNode (DevicePath, NewDevicePathNode);\r
+\r
+  // Publish BlockIO protocol interface\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                &MmcHostInstance->MmcHandle,\r
+                &gEfiBlockIoProtocolGuid,&(MmcHostInstance->BlockIo),\r
+                &gEfiDevicePathProtocolGuid,MmcHostInstance->DevicePath,\r
+                NULL\r
+                );\r
+  if (EFI_ERROR(Status)) {\r
+    goto FREE_DEVICE_PATH;\r
+  }\r
+\r
+  return MmcHostInstance;\r
 \r
 FREE_DEVICE_PATH:\r
-    FreePool(DevicePath);\r
+  FreePool(DevicePath);\r
 \r
 FREE_MEDIA:\r
-    FreePool(MmcHostInstance->BlockIo.Media);\r
+  FreePool(MmcHostInstance->BlockIo.Media);\r
 \r
 FREE_INSTANCE:\r
-    FreePool(MmcHostInstance);\r
+  FreePool(MmcHostInstance);\r
 \r
-    return NULL;\r
+  return NULL;\r
 }\r
 \r
-EFI_STATUS DestroyMmcHostInstance(\r
+EFI_STATUS DestroyMmcHostInstance (\r
   IN MMC_HOST_INSTANCE* MmcHostInstance\r
   )\r
 {\r
-    EFI_STATUS Status;\r
+  EFI_STATUS Status;\r
 \r
-    // Uninstall Protocol Interfaces\r
-    Status = gBS->UninstallMultipleProtocolInterfaces(\r
+  // Uninstall Protocol Interfaces\r
+  Status = gBS->UninstallMultipleProtocolInterfaces (\r
         MmcHostInstance->MmcHandle,\r
-            &gEfiBlockIoProtocolGuid,&(MmcHostInstance->BlockIo),\r
+        &gEfiBlockIoProtocolGuid,&(MmcHostInstance->BlockIo),\r
         &gEfiDevicePathProtocolGuid,MmcHostInstance->DevicePath,\r
-            NULL\r
-            );\r
-    ASSERT_EFI_ERROR (Status);\r
-    \r
-    // Free Memory allocated for the instance\r
-    if (MmcHostInstance->BlockIo.Media) {\r
-        FreePool(MmcHostInstance->BlockIo.Media);\r
-    }\r
-    FreePool (MmcHostInstance);\r
+        NULL\r
+        );\r
+  ASSERT_EFI_ERROR (Status);\r
 \r
-    return Status;\r
+  // Free Memory allocated for the instance\r
+  if (MmcHostInstance->BlockIo.Media) {\r
+    FreePool(MmcHostInstance->BlockIo.Media);\r
+  }\r
+  FreePool (MmcHostInstance);\r
+\r
+  return Status;\r
 }\r
 \r
 /**\r
@@ -182,62 +182,62 @@ MmcDriverBindingSupported (
   IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
   )\r
 {\r
-    EFI_STATUS                      Status;\r
-    //EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath;\r
-    EFI_MMC_HOST_PROTOCOL           *MmcHost;\r
-    EFI_DEV_PATH_PTR                Node;\r
-\r
+  EFI_STATUS                      Status;\r
+  //EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath;\r
+  EFI_MMC_HOST_PROTOCOL           *MmcHost;\r
+  EFI_DEV_PATH_PTR                Node;\r
+\r
+  //\r
+  // Check RemainingDevicePath validation\r
+  //\r
+  if (RemainingDevicePath != NULL) {\r
     //\r
-    // Check RemainingDevicePath validation\r
+    // Check if RemainingDevicePath is the End of Device Path Node,\r
+    // if yes, go on checking other conditions\r
     //\r
-    if (RemainingDevicePath != NULL) {\r
-        //\r
-        // Check if RemainingDevicePath is the End of Device Path Node, \r
-        // if yes, go on checking other conditions\r
-        //\r
-        if (!IsDevicePathEnd (RemainingDevicePath)) {\r
-            //\r
-            // If RemainingDevicePath isn't the End of Device Path Node,\r
-            // check its validation\r
-            //\r
-            Node.DevPath = RemainingDevicePath;\r
-            if (Node.DevPath->Type != HARDWARE_DEVICE_PATH ||\r
-              Node.DevPath->SubType != HW_VENDOR_DP      ||\r
-              DevicePathNodeLength(Node.DevPath) != sizeof(VENDOR_DEVICE_PATH)) {\r
-                return EFI_UNSUPPORTED;\r
-            }\r
-        }\r
+    if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+      //\r
+      // If RemainingDevicePath isn't the End of Device Path Node,\r
+      // check its validation\r
+      //\r
+      Node.DevPath = RemainingDevicePath;\r
+      if (Node.DevPath->Type != HARDWARE_DEVICE_PATH ||\r
+        Node.DevPath->SubType != HW_VENDOR_DP      ||\r
+        DevicePathNodeLength(Node.DevPath) != sizeof(VENDOR_DEVICE_PATH)) {\r
+          return EFI_UNSUPPORTED;\r
+      }\r
     }\r
-\r
-    //\r
-    // Check if Mmc Host protocol is installed by platform\r
-    //\r
-    Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiMmcHostProtocolGuid,\r
-                  (VOID **) &MmcHost,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-    if (Status == EFI_ALREADY_STARTED) {\r
-        return EFI_SUCCESS;\r
-    }\r
-    if (EFI_ERROR (Status)) {\r
-        return Status;\r
-    }\r
-\r
-    //\r
-    // Close the Mmc Host used to perform the supported test\r
-    //\r
-    gBS->CloseProtocol (\r
-        Controller,\r
-        &gEfiMmcHostProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Controller\r
-        );\r
-\r
+  }\r
+\r
+  //\r
+  // Check if Mmc Host protocol is installed by platform\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                Controller,\r
+                &gEfiMmcHostProtocolGuid,\r
+                (VOID **) &MmcHost,\r
+                This->DriverBindingHandle,\r
+                Controller,\r
+                EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                );\r
+  if (Status == EFI_ALREADY_STARTED) {\r
     return EFI_SUCCESS;\r
+  }\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Close the Mmc Host used to perform the supported test\r
+  //\r
+  gBS->CloseProtocol (\r
+      Controller,\r
+      &gEfiMmcHostProtocolGuid,\r
+      This->DriverBindingHandle,\r
+      Controller\r
+      );\r
+\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
@@ -251,48 +251,48 @@ MmcDriverBindingStart (
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
   )\r
 {\r
-    EFI_STATUS              Status;\r
-    MMC_HOST_INSTANCE       *MmcHostInstance;\r
-    EFI_MMC_HOST_PROTOCOL   *MmcHost;\r
-\r
+  EFI_STATUS              Status;\r
+  MMC_HOST_INSTANCE       *MmcHostInstance;\r
+  EFI_MMC_HOST_PROTOCOL   *MmcHost;\r
+\r
+  //\r
+  // Check RemainingDevicePath validation\r
+  //\r
+  if (RemainingDevicePath != NULL) {\r
     //\r
-    // Check RemainingDevicePath validation\r
+    // Check if RemainingDevicePath is the End of Device Path Node,\r
+    // if yes, return EFI_SUCCESS\r
     //\r
-    if (RemainingDevicePath != NULL) {\r
-        //\r
-        // Check if RemainingDevicePath is the End of Device Path Node, \r
-        // if yes, return EFI_SUCCESS\r
-        //\r
-        if (IsDevicePathEnd (RemainingDevicePath)) {\r
-            return EFI_SUCCESS;\r
-        }\r
+    if (IsDevicePathEnd (RemainingDevicePath)) {\r
+      return EFI_SUCCESS;\r
     }\r
-\r
-    //\r
-    // Get the Mmc Host protocol\r
-    //\r
-    Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiMmcHostProtocolGuid,\r
-                  (VOID **) &MmcHost,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-    if (EFI_ERROR (Status)) {\r
-        if (Status == EFI_ALREADY_STARTED) {\r
-            return EFI_SUCCESS;\r
-        }\r
-        return Status;\r
+  }\r
+\r
+  //\r
+  // Get the Mmc Host protocol\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                Controller,\r
+                &gEfiMmcHostProtocolGuid,\r
+                (VOID **) &MmcHost,\r
+                This->DriverBindingHandle,\r
+                Controller,\r
+                EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                );\r
+  if (EFI_ERROR (Status)) {\r
+    if (Status == EFI_ALREADY_STARTED) {\r
+      return EFI_SUCCESS;\r
     }\r
+    return Status;\r
+  }\r
 \r
-    MmcHostInstance = CreateMmcHostInstance(MmcHost);\r
-    if (MmcHostInstance != NULL) {\r
-        // Add the handle to the pool\r
-        InsertMmcHost (MmcHostInstance);\r
-    }\r
+  MmcHostInstance = CreateMmcHostInstance(MmcHost);\r
+  if (MmcHostInstance != NULL) {\r
+    // Add the handle to the pool\r
+    InsertMmcHost (MmcHostInstance);\r
+  }\r
 \r
-    return EFI_SUCCESS;\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
@@ -307,33 +307,33 @@ MmcDriverBindingStop (
   IN  EFI_HANDLE                    *ChildHandleBuffer\r
   )\r
 {\r
-    EFI_STATUS          Status = EFI_SUCCESS;\r
-    LIST_ENTRY          *CurrentLink;\r
-    MMC_HOST_INSTANCE   *MmcHostInstance;\r
-\r
-    MMC_TRACE("MmcDriverBindingStop()");\r
-\r
-    // For each MMC instance\r
-    CurrentLink = mMmcHostPool.ForwardLink;\r
-    while (CurrentLink != NULL && CurrentLink != &mMmcHostPool && (Status == EFI_SUCCESS)) {\r
-        MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink);\r
-        ASSERT(MmcHostInstance != NULL);\r
-\r
-        // Close gEfiMmcHostProtocolGuid\r
-        Status = gBS->CloseProtocol (\r
-                    Controller,\r
-                    &gEfiMmcHostProtocolGuid,(VOID **) &MmcHostInstance->MmcHost,\r
-                    This->DriverBindingHandle\r
-                    );\r
-\r
-        // Remove MMC Host Instance from the pool\r
-        RemoveMmcHost (MmcHostInstance);\r
-\r
-        // Destroy MmcHostInstance\r
-        DestroyMmcHostInstance (MmcHostInstance);\r
-    }\r
+  EFI_STATUS          Status = EFI_SUCCESS;\r
+  LIST_ENTRY          *CurrentLink;\r
+  MMC_HOST_INSTANCE   *MmcHostInstance;\r
 \r
-    return Status;\r
+  MMC_TRACE("MmcDriverBindingStop()");\r
+\r
+  // For each MMC instance\r
+  CurrentLink = mMmcHostPool.ForwardLink;\r
+  while (CurrentLink != NULL && CurrentLink != &mMmcHostPool && (Status == EFI_SUCCESS)) {\r
+    MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink);\r
+    ASSERT(MmcHostInstance != NULL);\r
+\r
+    // Close gEfiMmcHostProtocolGuid\r
+    Status = gBS->CloseProtocol (\r
+                Controller,\r
+                &gEfiMmcHostProtocolGuid,(VOID **) &MmcHostInstance->MmcHost,\r
+                This->DriverBindingHandle\r
+                );\r
+\r
+    // Remove MMC Host Instance from the pool\r
+    RemoveMmcHost (MmcHostInstance);\r
+\r
+    // Destroy MmcHostInstance\r
+    DestroyMmcHostInstance (MmcHostInstance);\r
+  }\r
+\r
+  return Status;\r
 }\r
 \r
 EFI_DRIVER_BINDING_PROTOCOL gMmcDriverBinding = {\r
@@ -355,33 +355,33 @@ MmcDxeInitialize (
   IN EFI_SYSTEM_TABLE   *SystemTable\r
   )\r
 {\r
-    EFI_STATUS  Status;\r
-\r
-    //\r
-    // Initializes MMC Host pool\r
-    //\r
-    InitializeMmcHostPool ();\r
-\r
-    //\r
-    // Install driver model protocol(s).\r
-    //\r
-    Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gMmcDriverBinding,\r
-             ImageHandle,\r
-             &gMmcComponentName,\r
-             &gMmcComponentName2\r
-             );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    // Install driver diagnostics\r
-    Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &ImageHandle, \r
-                  &gEfiDriverDiagnostics2ProtocolGuid,&gMmcDriverDiagnostics2,\r
-                  NULL\r
-                  );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    return Status;\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Initializes MMC Host pool\r
+  //\r
+  InitializeMmcHostPool ();\r
+\r
+  //\r
+  // Install driver model protocol(s).\r
+  //\r
+  Status = EfiLibInstallDriverBindingComponentName2 (\r
+           ImageHandle,\r
+           SystemTable,\r
+           &gMmcDriverBinding,\r
+           ImageHandle,\r
+           &gMmcComponentName,\r
+           &gMmcComponentName2\r
+           );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  // Install driver diagnostics\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                &ImageHandle,\r
+                &gEfiDriverDiagnostics2ProtocolGuid,&gMmcDriverDiagnostics2,\r
+                NULL\r
+                );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
 }\r