From patchwork Thu Jul 16 08:22:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary guo X-Patchwork-Id: 51143 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D175422A8A for ; Thu, 16 Jul 2015 08:24:46 +0000 (UTC) Received: by wipp2 with SMTP id p2sf2710268wip.2 for ; Thu, 16 Jul 2015 01:24:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=JcSjitESYcRVmeUP7RqXwqDL1lEBLevcIK9+Q2lVLYY=; b=e74mk9o4Z6tdXK/Icvclf+RWFDzSQEdAB32wFVun8Bg6jVW55+vXX6q9QVYBxAk9Hb SZsUq0eQmRVIjGm9x+Zltx4m4tZfOFi07GorwIWp9yFd4rWvkp2+pWWCsSLO7NgyIM8n 4aG+sJ4+GozC5oEMX33dJAyAgZxnRS7GVrtzpYEy9zfcUhhfyd0RXUXEHHmzGPtZYWw3 SecKRXtRj/0UebezrQB0Wz6hJs/ciiO6nFdXpigm/Pe7bnFOq3a83oDcWBClrIBMJ1au Qf8LbmletvuimGM64FLPn1FwI5ld6sQbDRcqUlH8O7v0bNKUjOsOGs8GrymgdJFJ9lia v9Mg== X-Gm-Message-State: ALoCoQkDYt+TDPzzidTRff6oXAnW41ukkLB83BsJ/Se240CgKzwniRRTxPNUq+OKCVGtwpBlmI4v X-Received: by 10.180.182.110 with SMTP id ed14mr1277383wic.5.1437035086192; Thu, 16 Jul 2015 01:24:46 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.102 with SMTP id lb6ls364196lab.49.gmail; Thu, 16 Jul 2015 01:24:45 -0700 (PDT) X-Received: by 10.112.91.196 with SMTP id cg4mr8241953lbb.10.1437035085895; Thu, 16 Jul 2015 01:24:45 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id l7si1149206lbb.19.2015.07.16.01.24.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 01:24:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbbzr7 with SMTP id zr7so39280931lbb.1 for ; Thu, 16 Jul 2015 01:24:45 -0700 (PDT) X-Received: by 10.112.125.34 with SMTP id mn2mr7557657lbb.76.1437035085778; Thu, 16 Jul 2015 01:24:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp94172lbb; Thu, 16 Jul 2015 01:24:44 -0700 (PDT) X-Received: by 10.107.18.28 with SMTP id a28mr11168192ioj.106.1437035084067; Thu, 16 Jul 2015 01:24:44 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id p17si1099259igx.1.2015.07.16.01.24.43 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 16 Jul 2015 01:24:44 -0700 (PDT) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZFeT4-0007BL-M8; Thu, 16 Jul 2015 08:24:34 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZFeT3-0007B1-PB for edk2-devel@lists.sourceforge.net; Thu, 16 Jul 2015 08:24:33 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.192.181 as permitted sender) client-ip=209.85.192.181; envelope-from=heyi.guo@linaro.org; helo=mail-pd0-f181.google.com; Received: from mail-pd0-f181.google.com ([209.85.192.181]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1ZFeT2-0005fz-Su for edk2-devel@lists.sourceforge.net; Thu, 16 Jul 2015 08:24:33 +0000 Received: by pdbqm3 with SMTP id qm3so40481638pdb.0 for ; Thu, 16 Jul 2015 01:24:27 -0700 (PDT) X-Received: by 10.70.63.1 with SMTP id c1mr16263786pds.88.1437035067308; Thu, 16 Jul 2015 01:24:27 -0700 (PDT) Received: from localhost.localdomain ([180.150.157.4]) by smtp.gmail.com with ESMTPSA id pc5sm7063946pbc.15.2015.07.16.01.24.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jul 2015 01:24:26 -0700 (PDT) From: Heyi Guo To: edk2-devel@lists.sourceforge.net Date: Thu, 16 Jul 2015 16:22:02 +0800 Message-Id: <1437034922-18361-6-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1437034922-18361-1-git-send-email-heyi.guo@linaro.org> References: <1437034922-18361-1-git-send-email-heyi.guo@linaro.org> X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1ZFeT2-0005fz-Su Subject: [edk2] [PATCH V4 5/5] MdeModulePkg/TerminalDxe: Some improvements X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: heyi.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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. Cc: Feng Tian Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Heyi Guo Reviewed-by: Ruiyu Ni Reviewed-by: Feng Tian --- .../Universal/Console/TerminalDxe/Terminal.c | 27 ++++------------------ 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c index 75bfdec..6fde3b2 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c @@ -258,14 +258,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)) { @@ -545,7 +544,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; @@ -565,9 +563,8 @@ TerminalDriverBindingStart ( UINTN ModeCount; TerminalDevice = NULL; - DefaultNode = NULL; - ConInSelected = FALSE; - ConOutSelected = FALSE; + ConInSelected = FALSE; + ConOutSelected = FALSE; NullRemaining = FALSE; SimTxtInInstalled = FALSE; SimTxtOutInstalled = FALSE; @@ -709,23 +706,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 TTYTERMTYPE (4) // ASSERT (TerminalType <= TTYTERMTYPE); - - 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, @@ -1183,9 +1171,6 @@ TerminalDriverBindingStart ( goto Error; } } - if (DefaultNode != NULL) { - FreePool (DefaultNode); - } return EFI_SUCCESS; @@ -1254,10 +1239,6 @@ Error: } } - if (DefaultNode != NULL) { - FreePool (DefaultNode); - } - This->Stop (This, Controller, 0, NULL); return Status;