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::241; helo=mail-wr0-x241.google.com; envelope-from=julien.grall@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) (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 E7032220F3C43 for ; Fri, 24 Nov 2017 08:16:19 -0800 (PST) Received: by mail-wr0-x241.google.com with SMTP id u40so20787262wrf.10 for ; Fri, 24 Nov 2017 08:20:38 -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=mMuGFrfwfga4dxcOTjsK8Qf5KAouUEBFIbpC8e+wrKA=; b=F1nzBkvKkCrWmx6JUJV8mAUylIMZG8dRyQSZkh2g810ZPofZpQVInBvsI//9eS842R Ah7dcBC3JKfNkHQ9bOrgP405etKzsfVwjrH+wM00OYx0uf90Tjy8LUQpf0Ur+v8nKrgL srgj5mS+0Cny3xTa8fkW58/tE+8Z2xf/fBwhI= 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=mMuGFrfwfga4dxcOTjsK8Qf5KAouUEBFIbpC8e+wrKA=; b=hzjsKk4Q0Mi0cFbJ8I3WLmrLl+04FDyJugL4uWap2oEr0m/xdmeBjxWWCPGdZNesnP 5tKZu/bUx758cwpMbFmohadNY1QGhxgobCRVCCbX5yR4c4UzO7YZZ6GGNnxI0/olTt6f pbRHxJx1gVL3hphzAVrBStz3PKjplZ2dr6Uv+IW+CtZeJIclp/iICaYcgWONl80XIbxr bMpjB9C9zEKvE1yjSMgX5FtppaVt9taTpxkitBea7x8bs+vzBN0epjUI+WjW/uxj4EgW 9gv1y16Un+awmD+sANpO89R+x3YO5SHeblcdKZrVTKLrFabdPsvrKhmWVmxnt8D9mEZ0 WOBw== X-Gm-Message-State: AJaThX6nyudVFP+jDhLzPCloRofFgdYBV7eXr+ZW9tjRn/vr+oAKLnkb bi/6nZlm2lLlcVNIq2aCuA/IKA== X-Google-Smtp-Source: AGs4zMaWzqdIK8POuV0c2j/MtWyKfSr7qOx19nqyOJJBrIyb2UE6iWPA/ic++3hfYMpXEbAbd4dq4g== X-Received: by 10.223.181.132 with SMTP id c4mr1142490wre.42.1511540436925; Fri, 24 Nov 2017 08:20:36 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id k30sm38803840wrf.63.2017.11.24.08.20.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Nov 2017 08:20:36 -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: Fri, 24 Nov 2017 16:20:29 +0000 Message-Id: <20171124162030.31156-3-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171124162030.31156-1-julien.grall@linaro.org> References: <20171124162030.31156-1-julien.grall@linaro.org> Subject: [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: Fri, 24 Nov 2017 16:16:20 -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 --- MdeModulePkg/Universal/SerialDxe/SerialIo.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Universal/SerialDxe/SerialIo.c b/MdeModulePkg/Universal/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. - @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 +324,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; } } -- 2.11.0