From patchwork Tue Jul 7 16:56:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary guo X-Patchwork-Id: 50847 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C6B10229FC for ; Tue, 7 Jul 2015 16:57:22 +0000 (UTC) Received: by wizo10 with SMTP id o10sf11926847wiz.0 for ; Tue, 07 Jul 2015 09:57:22 -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:reply-to: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=He1kqSMGdBaXD9gQXmyqvAH77wSU6Oe+TB5TGTl7yHc=; b=ZaGvFzsVxMwf0Hc4n/GGTjaf5DD34EbJNalhZqSfAURFlSvkxOZpde0H+5HVaIKpL5 xHx23hMwMtdtfvtZjCnsz5PUAD3GxN8kBHoTJLLQE2KHTWutw/ZgmrAf4I5uT5ZN5iQ0 gwFqSinqw0wrvSUM9avao6rvnlNS3QeqVqm6DYd4By1Qak6N/ZgUSgv6ez345TZxJAqP wOjNJc6/OKvihV2+bZSPSF2gdWQ3wzMfU73CqB3N/ppIYzxhkvk9ZyJQh/i8NPg7kuze 2V8VucybDXc8UOm0rdWokTAPeok39i3H843R2YGo7tlvWyWumKy0Wgtbm/roN5/nklu8 Q5eA== X-Gm-Message-State: ALoCoQkI7NNdtneZYcrEXyr6ooBdPqLHq1TKig/+8UMI15Qb3/gvBVhLEXndHz+s5iNTEl6mzfhR X-Received: by 10.180.97.9 with SMTP id dw9mr18435629wib.2.1436288242139; Tue, 07 Jul 2015 09:57:22 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.179.39 with SMTP id dd7ls844693lac.60.gmail; Tue, 07 Jul 2015 09:57:21 -0700 (PDT) X-Received: by 10.152.22.99 with SMTP id c3mr5062424laf.32.1436288241839; Tue, 07 Jul 2015 09:57:21 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id p1si18555115laj.140.2015.07.07.09.57.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2015 09:57:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by laar3 with SMTP id r3so204115291laa.0 for ; Tue, 07 Jul 2015 09:57:21 -0700 (PDT) X-Received: by 10.112.126.101 with SMTP id mx5mr4982883lbb.35.1436288241590; Tue, 07 Jul 2015 09:57:21 -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 hn6csp2519126lbb; Tue, 7 Jul 2015 09:57:20 -0700 (PDT) X-Received: by 10.107.133.78 with SMTP id h75mr7496465iod.36.1436288240112; Tue, 07 Jul 2015 09:57:20 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id mz5si21057060icc.63.2015.07.07.09.57.19 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 07 Jul 2015 09:57:20 -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-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZCWBC-0005w3-F5; Tue, 07 Jul 2015 16:57:10 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZCWBB-0005vn-5p for edk2-devel@lists.sourceforge.net; Tue, 07 Jul 2015 16:57:09 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.220.48 as permitted sender) client-ip=209.85.220.48; envelope-from=heyi.guo@linaro.org; helo=mail-pa0-f48.google.com; Received: from mail-pa0-f48.google.com ([209.85.220.48]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1ZCWB9-0003Yt-Be for edk2-devel@lists.sourceforge.net; Tue, 07 Jul 2015 16:57:09 +0000 Received: by pabvl15 with SMTP id vl15so116049149pab.1 for ; Tue, 07 Jul 2015 09:57:01 -0700 (PDT) X-Received: by 10.70.42.134 with SMTP id o6mr10841570pdl.11.1436288221793; Tue, 07 Jul 2015 09:57:01 -0700 (PDT) Received: from localhost.localdomain ([180.150.157.4]) by mx.google.com with ESMTPSA id i4sm22505073pdk.74.2015.07.07.09.56.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Jul 2015 09:57:00 -0700 (PDT) From: Heyi Guo To: edk2-devel@lists.sourceforge.net Date: Wed, 8 Jul 2015 00:56:31 +0800 Message-Id: <1436288191-16773-4-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1436288191-16773-1-git-send-email-heyi.guo@linaro.org> References: <1436288191-16773-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: 1ZCWB9-0003Yt-Be Subject: [edk2] [PATCH 3/3] MdeModulePkg: Some improvements on TerminalDxe X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net 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.215.50 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 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;