From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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) 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) 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) From: Julien Grall To: star.zeng@intel.com, eric.dong@intel.com, pankaj.bansal@nxp.com, lersek@redhat.com, leif.lindholm@linaro.org Cc: edk2-devel@lists.01.org, Julien Grall 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: [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: , X-List-Received-Date: Wed, 29 Nov 2017 17:24:08 -0000 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 --- 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/Universal/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. - @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 correctly. **/ EFI_STATUS @@ -264,8 +265,9 @@ SerialReset ( value of DefaultStopBits will use the device's default number of stop bits. - @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 correctly. **/ EFI_STATUS @@ -323,8 +325,10 @@ SerialSetAttributes ( DataBits = OriginalDataBits; StopBits = OriginalStopBits; Status = EFI_SUCCESS; + } else if (Status == EFI_INVALID_PARAMETER || Status == EFI_UNSUPPORTED) { + return EFI_INVALID_PARAMETER; } else { - return Status; + return EFI_DEVICE_ERROR; } } diff --git a/MdePkg/Include/Protocol/SerialIo.h b/MdePkg/Include/Protocol/SerialIo.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. - @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 correctly. **/ typedef -- 2.11.0