From nobody Wed Dec 25 01:28:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 151197651749026.749359929730872; Wed, 29 Nov 2017 09:28:37 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 652B420359E97; Wed, 29 Nov 2017 09:24:11 -0800 (PST) Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id ED60921B00DC4 for ; Wed, 29 Nov 2017 09:24:07 -0800 (PST) Received: by mail-wr0-x243.google.com with SMTP id s66so4097960wrc.9 for ; Wed, 29 Nov 2017 09:28:32 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id o80sm1782687wmg.6.2017.11.29.09.28.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Nov 2017 09:28:29 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::243; helo=mail-wr0-x243.google.com; envelope-from=julien.grall@linaro.org; receiver=edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=h+b2F4UV2VsmFJz4c9ZSVNNffh8DIILIqBdYZl9rSvY=; b=YN9pFwRfjQ2RNk6lji7kgtTARILFQN8lQccIfz9l3K5n7jl6cfX47rgzz4e2OsKVYV 8CFcHOXNxdDlcoS/BFiQeXcmuoHdKXRsmKj/4gQ4P80YCcE0j71ZxUb3SB3+HmqquU9I 0YiKivB08kpFpYfNglzBuGfAVm8W7xblYgmyI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=h+b2F4UV2VsmFJz4c9ZSVNNffh8DIILIqBdYZl9rSvY=; b=MZb+FhNtuGdN38tVl4FonyRPV2VWXb1JE5gFXrV7QkWa7Jmb3Se8/1ohjb3RhGpnBt K2+cTAGPufRdr98xjKMBfzP2Ti0r1wtlWrDSLq1KeRSCFnMaOLQbAIfHzOZ65CAIuDbx Hm/IPX9EgfjEVBGQ8ln0/aaYT88dKFj3zkNt5TEzAUpLAFNSRF5QhXg2v1HXBiDBReWK aqtT1Y2ABZA3ginellwv8B4CIZkXX72WtYVWr3WxNvF5A+fB9KDT8Unl/SzHbgZBcTL1 SR1ppuOy6IIPba8be492WcjkiOhToYjibaYQ3tUwLJesLblF761UAIMIc4EsL/VqGmu7 UBCg== X-Gm-Message-State: AJaThX5c4Vbex8KnTsHM7lpYevySkS+1KiLyTNAxqH43ZKXaJwhFdjsK CeiGJiH5aWiB4piez+ooTEP2wQ== X-Google-Smtp-Source: AGs4zMZ05vybtNNfMU/E3kmtVtmeF4y6US/asjR5cjpJDvwEPT/VNxnUD1KpSoBwVSsgEQ49NSkGTg== X-Received: by 10.223.171.85 with SMTP id r21mr2901084wrc.182.1511976510427; Wed, 29 Nov 2017 09:28:30 -0800 (PST) From: Julien Grall To: star.zeng@intel.com, eric.dong@intel.com, pankaj.bansal@nxp.com, lersek@redhat.com, leif.lindholm@linaro.org Date: Wed, 29 Nov 2017 17:28:22 +0000 Message-Id: <20171129172823.2906-3-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171129172823.2906-1-julien.grall@linaro.org> References: <20171129172823.2906-1-julien.grall@linaro.org> Subject: [edk2] [PATCH v3 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: , Cc: edk2-devel@lists.01.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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_UNSUPPORTED. 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 but EFI_INVALID_PARAMETERR and EFI_UNSUPPORTED will return EFI_DEVICE_ERROR. Contributed-under: Tianocore Contribution Agreement 1.1 Signed-off-by: Julien Grall Reviewed-by: Star Zeng Reviewed-by: Laszlo Ersek --- Star, I found a prototype for SetAttributes in SerialIo.c as well and updated the description there. I decided to keep the Reviewed-by even with that change. Let me know whether it is fine for you. Changes in v3: - Add description of EFI_INVALID_PARAMETER above the prototypes for SetAttributes as well. - Add Star reviewed-by --- MdeModulePkg/Universal/SerialDxe/SerialIo.c | 14 +++++++++----- MdePkg/Include/Protocol/SerialIo.h | 5 +++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/MdeModulePkg/Universal/SerialDxe/SerialIo.c b/MdeModulePkg/Uni= versal/SerialDxe/SerialIo.c index 19fc889c25..ee10ec7e05 100644 --- a/MdeModulePkg/Universal/SerialDxe/SerialIo.c +++ b/MdeModulePkg/Universal/SerialDxe/SerialIo.c @@ -66,8 +66,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 @@ -264,8 +265,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 +325,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 diff --git a/MdePkg/Include/Protocol/SerialIo.h b/MdePkg/Include/Protocol/S= erialIo.h index 84cb34364d..1263dc4fe9 100644 --- a/MdePkg/Include/Protocol/SerialIo.h +++ b/MdePkg/Include/Protocol/SerialIo.h @@ -125,8 +125,9 @@ EFI_STATUS 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 **/ typedef --=20 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel