From patchwork Wed Nov 29 17:28:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 120033 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3331981qgn; Wed, 29 Nov 2017 09:28:37 -0800 (PST) X-Google-Smtp-Source: AGs4zMZbeDv7HDR2R+Rmc/K5pSrG0jbH28ONY69lfblSOXmkzuNxW4hCpdDAZCaquaXI88pqNrWh X-Received: by 10.98.80.208 with SMTP id g77mr3715627pfj.201.1511976516977; Wed, 29 Nov 2017 09:28:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511976516; cv=none; d=google.com; s=arc-20160816; b=ikPLJHCibG94H9EzbReiqfiesn7VXgIHF1V01zK4Xo/rgvsWQjrVB9yOO+f0sBPO+T NVenXXfHlZNlFSq4HprplMriW1bv4VK9RqUUb/cqiTo9VBuMmyK6TlBBMXCAuSF2f2pn RdMh5NdVQxXgXqVHN7eleP/vpQlIRil2iFAAlnfvdZ+XW2omCORmX8Org4obuZi5z3Yi LkFqB/675QO4d3IazmYrj3t0qdFRaX6wYTSWWR/4cJWIUVUJr1L7PEWzlCQ6meL1siUC PoufRlbMe49hCDh/tJQiv1DVZ4GGbNxA3gRghxeGMHAGm+7XKXVlVniI+5LdkM9NwD3s elPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=SigCN4AVHei86kRQZwEntvrSjxCq9H0QhwsZWCUTzi0=; b=BB3oFEdeAjkSo6fZG9v2tsqC9PMcXjYtnFidfX+w6CQNK8cTkVMZrDuNYYr3qf8pqA 8CNzQLgInWxozDjoy74bpws2T90E8u9rcdhoG8CaCDGihyjqkucoaXERVgcc6sfO2Wm4 aXBXVFzFNwU2K9iZQEcDCczjKC/8FPyg0sSgTiAK5Yr3zasW6NP1f8sH+X9ppZatIN+f zd3Ovsj5FSdgicfBvw9fZVbBVaMU1eRyYawEGc+nC8rGDP4o8hiVbG29XvJuJTZablWX ioXwCpynbFNQctR9c4KJx57Q0ouTYshfIn+aEa3WLmPt9UefVGYqrL83FrqszvQ5Y/tW 2Zpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YN9pFwRf; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id k8si1563520pgt.29.2017.11.29.09.28.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Nov 2017 09:28:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YN9pFwRf; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.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 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-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 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 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Laszlo Ersek 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