diff mbox

[edk2,3/3] MdeModulePkg: Some improvements on TerminalDxe

Message ID 1436288191-16773-4-git-send-email-heyi.guo@linaro.org
State New
Headers show

Commit Message

gary guo July 7, 2015, 4:56 p.m. UTC
1. Get default terminal type from PCD rather than using PCANSI
directly in BuildTeminalDevpath;
2. Only terminal type is needed to create an TerminalDev instance, so
remove the useless code of creating and freeing DefaultNode.
3. Some white space refining.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
---
 .../Universal/Console/TerminalDxe/Terminal.c       | 27 ++++------------------
 1 file changed, 4 insertions(+), 23 deletions(-)
diff mbox

Patch

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index 1897196..3f50725 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -250,14 +250,13 @@  BuildTerminalDevpath  (
   EFI_STATUS                        Status;
 
   TerminalDevicePath = NULL;
-  TerminalType = PCANSITYPE;
 
   //
   // Use the RemainingDevicePath to determine the terminal type
   //
   Node = (VENDOR_DEVICE_PATH *) RemainingDevicePath;
   if (Node == NULL) {
-    TerminalType = PCANSITYPE;
+    TerminalType = PcdGet8 (PcdDefaultTerminalType);
 
   } else if (CompareGuid (&Node->Guid, &gEfiPcAnsiGuid)) {
 
@@ -533,7 +532,6 @@  TerminalDriverBindingStart (
   EFI_SERIAL_IO_PROTOCOL              *SerialIo;
   EFI_DEVICE_PATH_PROTOCOL            *ParentDevicePath;
   VENDOR_DEVICE_PATH                  *Node;
-  VENDOR_DEVICE_PATH                  *DefaultNode;
   EFI_SERIAL_IO_MODE                  *Mode;
   UINTN                               SerialInTimeOut;
   TERMINAL_DEV                        *TerminalDevice;
@@ -553,9 +551,8 @@  TerminalDriverBindingStart (
   UINTN                               ModeCount;
 
   TerminalDevice     = NULL;
-  DefaultNode        = NULL;
-  ConInSelected       = FALSE;
-  ConOutSelected      = FALSE;
+  ConInSelected      = FALSE;
+  ConOutSelected     = FALSE;
   NullRemaining      = FALSE;
   SimTxtInInstalled  = FALSE;
   SimTxtOutInstalled = FALSE;
@@ -697,23 +694,14 @@  TerminalDriverBindingStart (
     }
 
     //
-    // If RemainingDevicePath is NULL, then create default device path node
+    // If RemainingDevicePath is NULL, use default terminal type
     //
     if (RemainingDevicePath == NULL) {
-      DefaultNode = AllocateZeroPool (sizeof (VENDOR_DEVICE_PATH));
-      if (DefaultNode == NULL) {
-        Status = EFI_OUT_OF_RESOURCES;
-        goto Error;
-      }
-
       TerminalType = PcdGet8 (PcdDefaultTerminalType);
       //
       // Must be between PCANSITYPE (0) and VTUTF8TYPE (3)
       //
       ASSERT (TerminalType <= VTUTF8TYPE);
-
-      CopyMem (&DefaultNode->Guid, gTerminalType[TerminalType], sizeof (EFI_GUID));
-      RemainingDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DefaultNode;
     } else if (!IsDevicePathEnd (RemainingDevicePath)) {
       //
       // If RemainingDevicePath isn't the End of Device Path Node,
@@ -1151,9 +1139,6 @@  TerminalDriverBindingStart (
       goto Error;
     }
   }
-  if (DefaultNode != NULL) {
-    FreePool (DefaultNode);
-  }
 
   return EFI_SUCCESS;
 
@@ -1222,10 +1207,6 @@  Error:
     }
   }
 
-  if (DefaultNode != NULL) {
-    FreePool (DefaultNode);
-  }
-
   This->Stop (This, Controller, 0, NULL);
 
   return Status;