From patchwork Mon Jul 13 03:24:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary guo X-Patchwork-Id: 51058 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E276722916 for ; Mon, 13 Jul 2015 03:25:30 +0000 (UTC) Received: by wgfk9 with SMTP id k9sf99980795wgf.1 for ; Sun, 12 Jul 2015 20:25:30 -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=YpsDBkKrZ3I/SrywQRBoEAVOdVU4brU2ze8o9YRsqMI=; b=BtLVUOzdv0Aa7C12pTBr2Aq1+dzQV+17UpNUhOQj8uStTdKgkSTYDQKMjmc5Lv9eAn /10bSplcRbd0Oen6qpr5/0iYneimKBk7qsEwoivGlNn98nCAw6dfISrruU0tNtLc9BvJ /ybHQlHKEjnVd+ZRB7k+0V746jUzTUPwgFDw0aXqJ3kc+t+5GHehuhRkzA280FTxE2Yn qyGzqusJoErne+xXlk20lKV+4byLqHyjX/DNB/BCaFUb2I2ZIJilSA0S2PBJ2f7XCoIM SaFx09PVqzg8+JhsSXsA/yR8yXwDbKk1wsX1CKrfmwOMACjoaESkdotnn7MvPv2iYcx3 QEWw== X-Gm-Message-State: ALoCoQkhH/M9KyYkjchk2zWV8Hw8Kt2IwNQk82Z14i/9JQi1eUF2QN/HFPe2FK0l8QF/q92uE2IB X-Received: by 10.112.85.69 with SMTP id f5mr17611776lbz.23.1436757930037; Sun, 12 Jul 2015 20:25:30 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.116 with SMTP id v20ls134374lal.22.gmail; Sun, 12 Jul 2015 20:25:29 -0700 (PDT) X-Received: by 10.112.123.179 with SMTP id mb19mr8029884lbb.55.1436757929888; Sun, 12 Jul 2015 20:25:29 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id ur9si13764947lac.98.2015.07.12.20.25.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Jul 2015 20:25:29 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lblf12 with SMTP id f12so47639114lbl.2 for ; Sun, 12 Jul 2015 20:25:29 -0700 (PDT) X-Received: by 10.112.128.169 with SMTP id np9mr30452473lbb.73.1436757929717; Sun, 12 Jul 2015 20:25:29 -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 hn6csp1458830lbb; Sun, 12 Jul 2015 20:25:28 -0700 (PDT) X-Received: by 10.50.1.115 with SMTP id 19mr9257991igl.67.1436757928205; Sun, 12 Jul 2015 20:25:28 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id z16si4558603igp.40.2015.07.12.20.25.27 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 12 Jul 2015 20:25:28 -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 1ZEUMm-0007I4-Ja; Mon, 13 Jul 2015 03:25:16 +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 1ZEUMl-0007HJ-Lm for edk2-devel@lists.sourceforge.net; Mon, 13 Jul 2015 03:25:15 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.192.173 as permitted sender) client-ip=209.85.192.173; envelope-from=heyi.guo@linaro.org; helo=mail-pd0-f173.google.com; Received: from mail-pd0-f173.google.com ([209.85.192.173]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1ZEUMj-0005mt-U8 for edk2-devel@lists.sourceforge.net; Mon, 13 Jul 2015 03:25:15 +0000 Received: by pdjr16 with SMTP id r16so54799738pdj.3 for ; Sun, 12 Jul 2015 20:25:08 -0700 (PDT) X-Received: by 10.69.19.129 with SMTP id gu1mr65687390pbd.162.1436757908349; Sun, 12 Jul 2015 20:25:08 -0700 (PDT) Received: from localhost.localdomain ([180.150.148.224]) by smtp.gmail.com with ESMTPSA id d7sm16586315pbu.41.2015.07.12.20.25.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 12 Jul 2015 20:25:07 -0700 (PDT) From: Heyi Guo To: edk2-devel@lists.sourceforge.net Date: Mon, 13 Jul 2015 11:24:36 +0800 Message-Id: <1436757876-29691-4-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1436757876-29691-1-git-send-email-heyi.guo@linaro.org> References: <1436757876-29691-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 X-Headers-End: 1ZEUMj-0005mt-U8 Subject: [edk2] [PATCH V2 3/3] 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.178 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. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Heyi Guo --- .../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;