From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.126; helo=mga18.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AF7A0211A3CA6 for ; Wed, 13 Jun 2018 17:54:26 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jun 2018 17:54:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,220,1526367600"; d="scan'208";a="62992064" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga004.fm.intel.com with ESMTP; 13 Jun 2018 17:54:26 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 13 Jun 2018 17:54:26 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 13 Jun 2018 17:54:25 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.223]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.70]) with mapi id 14.03.0319.002; Thu, 14 Jun 2018 08:54:24 +0800 From: "Zeng, Star" To: Ard Biesheuvel , "edk2-devel@lists.01.org" CC: "leif.lindholm@linaro.org" , "Yao, Jiewen" , "Kinney, Michael D" , "Zeng, Star" Thread-Topic: [PATCH v4 2/4] MdeModulePkg/DxeCapsuleLibFmp: pass progress callback only if it works Thread-Index: AQHUAu3g0PIIMbITJU+Y4fv5H1QhO6Re7oew Date: Thu, 14 Jun 2018 00:54:23 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BB57B53@shsmsx102.ccr.corp.intel.com> References: <20180613080901.7156-1-ard.biesheuvel@linaro.org> <20180613080901.7156-3-ard.biesheuvel@linaro.org> In-Reply-To: <20180613080901.7156-3-ard.biesheuvel@linaro.org> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v4 2/4] MdeModulePkg/DxeCapsuleLibFmp: pass progress callback only if it works X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 00:54:26 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng -----Original Message----- From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]=20 Sent: Wednesday, June 13, 2018 4:09 PM To: edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org; Zeng, Star ; Yao, Jiewen= ; Kinney, Michael D ; Ar= d Biesheuvel Subject: [PATCH v4 2/4] MdeModulePkg/DxeCapsuleLibFmp: pass progress callba= ck only if it works If the first call to UpdateImageProgress() fails, there is no point in pass= ing a pointer to it to Fmp->SetImage(), since it is highly unlikely to succ= eed on any subsequent calls. This permits the FMP implementation to fall back to an alternate means of p= roviding feedback to the user, e.g., via the console. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeMod= ulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c index f0226eafa576..ab41df0eb0a4 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c @@ -841,6 +841,7 @@ SetFmpImageData ( UINT8 *Image; VOID *VendorCode; CHAR16 *AbortReason; + EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS ProgressCallback; =20 Status =3D gBS->HandleProtocol( Handle, @@ -892,7 +893,11 @@ SetFmpImageData ( // // Before calling SetImage(), reset the progress bar to 0% // - UpdateImageProgress (0); + ProgressCallback =3D UpdateImageProgress; Status =3D UpdateImageProgres= s=20 + (0); if (EFI_ERROR (Status)) { + ProgressCallback =3D NULL; + } =20 Status =3D Fmp->SetImage( Fmp, @@ -900,13 +905,15 @@ SetFmpImageData ( Image, // Image ImageHeader->UpdateImageSize, // ImageSize VendorCode, // VendorCode - UpdateImageProgress, // Progress + ProgressCallback, // Progress &AbortReason // AbortReason ); // // Set the progress bar to 100% after returning from SetImage() // - UpdateImageProgress (100); + if (ProgressCallback !=3D NULL) { + UpdateImageProgress (100); + } =20 DEBUG((DEBUG_INFO, "Fmp->SetImage - %r\n", Status)); if (AbortReason !=3D NULL) { -- 2.17.1