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.100; helo=mga07.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 67A0021A1099A for ; Sun, 26 Nov 2017 17:46:20 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Nov 2017 17:50:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,462,1505804400"; d="scan'208";a="6234895" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by FMSMGA003.fm.intel.com with ESMTP; 26 Nov 2017 17:50:40 -0800 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 26 Nov 2017 17:50:40 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 26 Nov 2017 17:50:40 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.159]) with mapi id 14.03.0319.002; Mon, 27 Nov 2017 09:50:38 +0800 From: "Zeng, Star" To: Julien Grall , "Dong, Eric" , "pankaj.bansal@nxp.com" , "lersek@redhat.com" , "leif.lindholm@linaro.org" CC: "edk2-devel@lists.01.org" , "Zeng, Star" Thread-Topic: [PATCH v2 2/3] MdeModulePkg/SerialDxe: Fix return valued in SerialSetAttributes Thread-Index: AQHTZUAxEjzSm21ca02nNO0MAxfPfqMneaBA Date: Mon, 27 Nov 2017 01:50:37 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9BC191@shsmsx102.ccr.corp.intel.com> References: <20171124162030.31156-1-julien.grall@linaro.org> <20171124162030.31156-3-julien.grall@linaro.org> In-Reply-To: <20171124162030.31156-3-julien.grall@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 v2 2/3] MdeModulePkg/SerialDxe: Fix return valued in SerialSetAttributes X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Nov 2017 01:46:20 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Could you also update the description for EFI_SERIAL_SET_ATTRIBUTES in MdeP= kg/Include/Protocol/SerialIo.h? That could be done in a separated patch. + @retval EFI_INVALID_PARAMETER One or more attributes has an unsupported = value. Thanks, Star -----Original Message----- From: Julien Grall [mailto:julien.grall@linaro.org]=20 Sent: Saturday, November 25, 2017 12:20 AM To: Zeng, Star ; Dong, Eric ; pan= kaj.bansal@nxp.com; lersek@redhat.com; leif.lindholm@linaro.org Cc: edk2-devel@lists.01.org; Julien Grall Subject: [PATCH v2 2/3] MdeModulePkg/SerialDxe: Fix return valued in Serial= SetAttributes SerialSetAttributes is meant to match the behavior of the function EFI_SERIAL_IO_PROTOCOL.SetAttributes() in the UEFI spec (v2.7). This means = the function can only return: - EFI_SUCCESS - EFI_INVALID_PARAMETER - EFI_DEVICE_ERROR However the function SerialPortSetAttributes may also validly return EFI_UN= SUPPORTED. For instance this is the case of the Xen Console driver. EFI_UNSUPPORTED could be also interpreted as "One or more of the attributes= has an unsupported value". So return EFI_INVALID_PARAMETER in that case. Lastly, to prevent another return slipping in the future, all the errors bu= t EFI_INVALID_PARAMETERR and EFI_UNSUPPORTED will return EFI_DEVICE_ERROR. Contributed-under: Tianocore Contribution Agreement 1.1 Signed-off-by: Julien Grall --- MdeModulePkg/Universal/SerialDxe/SerialIo.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Universal/SerialDxe/SerialIo.c b/MdeModulePkg/Uni= versal/SerialDxe/SerialIo.c index 5946a6e2f3..08b95a4a33 100644 --- a/MdeModulePkg/Universal/SerialDxe/SerialIo.c +++ b/MdeModulePkg/Universal/SerialDxe/SerialIo.c @@ -264,8 +264,9 @@ SerialReset ( value of DefaultStopBits will use the device's = default number of stop bits. =20 - @retval EFI_SUCCESS The device was reset. - @retval EFI_DEVICE_ERROR The serial device is not functioning correctly. + @retval EFI_SUCCESS The device was reset. + @retval EFI_INVALID_PARAMETER One or more attributes has an unsupported = value. + @retval EFI_DEVICE_ERROR The serial device is not functioning corre= ctly. =20 **/ EFI_STATUS @@ -323,8 +324,10 @@ SerialSetAttributes ( DataBits =3D OriginalDataBits; StopBits =3D OriginalStopBits; Status =3D EFI_SUCCESS; + } else if (Status =3D=3D EFI_INVALID_PARAMETER || Status =3D=3D EFI_UN= SUPPORTED) { + return EFI_INVALID_PARAMETER; } else { - return Status; + return EFI_DEVICE_ERROR; } } =20 -- 2.11.0