From patchwork Thu Jul 16 02:09:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary guo X-Patchwork-Id: 51136 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 3A67320300 for ; Thu, 16 Jul 2015 02:11:01 +0000 (UTC) Received: by widic2 with SMTP id ic2sf952137wid.1 for ; Wed, 15 Jul 2015 19:11:00 -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=KAweoWGrQWd2ItInRVhHiL8JMQEV/bv5UBqInAG1KC81jhMzjWKR8OKc9aVFTvrbSN zczP+KzKZT0egXcttVNNPoRO+VCQ1q+TzdHD8mI/dU1Q4726c6w8dhuD2pB6nskJ7Xmm p0UGi01jNm48W5jmwEDqkplYKFXViC6g4RwyfFhZI1cGEi6WZ2REJs2XI/HZm2e8pI8t ZWCQaaSsRMS195b3yR1iCu1049aHuvtBjilaV+g3Qg9S9jJfBFXESyGdmYmPbqsfYpVY O/LWCgPEPsWeX0nNU3Bn3Cn3czN01/Tw6gI9xU8mY1dcEa2VDZZ9+XOfqBXizRtbEyH8 tU5Q== X-Gm-Message-State: ALoCoQkI+osG/Cy29RIupf9q2bpxm/kM69vzYhY/ohMBafPLc7p0eZaCPZI25g6qiqKy5eyHOtIj X-Received: by 10.112.99.37 with SMTP id en5mr3556846lbb.7.1437012660546; Wed, 15 Jul 2015 19:11:00 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.73 with SMTP id j9ls296143lag.73.gmail; Wed, 15 Jul 2015 19:11:00 -0700 (PDT) X-Received: by 10.152.87.165 with SMTP id az5mr7028560lab.8.1437012660295; Wed, 15 Jul 2015 19:11:00 -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 l2si5638600lag.12.2015.07.15.19.10.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jul 2015 19:10:59 -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 lagx9 with SMTP id x9so35138290lag.1 for ; Wed, 15 Jul 2015 19:10:59 -0700 (PDT) X-Received: by 10.152.4.163 with SMTP id l3mr7191333lal.35.1437012659796; Wed, 15 Jul 2015 19:10:59 -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 hn6csp3451492lbb; Wed, 15 Jul 2015 19:10:58 -0700 (PDT) X-Received: by 10.50.178.133 with SMTP id cy5mr261272igc.5.1437012658241; Wed, 15 Jul 2015 19:10:58 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id h22si5165263ioi.41.2015.07.15.19.10.57 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 15 Jul 2015 19:10:58 -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-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZFYdN-0001W4-AN; Thu, 16 Jul 2015 02:10:49 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZFYdL-0001Vu-EB for edk2-devel@lists.sourceforge.net; Thu, 16 Jul 2015 02:10:47 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.192.179 as permitted sender) client-ip=209.85.192.179; envelope-from=heyi.guo@linaro.org; helo=mail-pd0-f179.google.com; Received: from mail-pd0-f179.google.com ([209.85.192.179]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1ZFYdK-0004Nq-HH for edk2-devel@lists.sourceforge.net; Thu, 16 Jul 2015 02:10:47 +0000 Received: by pdbep18 with SMTP id ep18so36266639pdb.1 for ; Wed, 15 Jul 2015 19:10:40 -0700 (PDT) X-Received: by 10.66.165.67 with SMTP id yw3mr13663386pab.95.1437012640878; Wed, 15 Jul 2015 19:10:40 -0700 (PDT) Received: from localhost.localdomain ([180.150.157.4]) by smtp.gmail.com with ESMTPSA id ym6sm6023953pac.32.2015.07.15.19.10.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Jul 2015 19:10:40 -0700 (PDT) From: Heyi Guo To: edk2-devel@lists.sourceforge.net Date: Thu, 16 Jul 2015 10:09:48 +0800 Message-Id: <1437012588-24390-5-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1437012588-24390-1-git-send-email-heyi.guo@linaro.org> References: <1437012588-24390-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: 1ZFYdK-0004Nq-HH Subject: [edk2] [PATCH V3 4/4] 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.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 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;