]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/SerialDxe: Fix return valued in SerialSetAttributes
authorJulien Grall <julien.grall@linaro.org>
Wed, 29 Nov 2017 17:28:22 +0000 (01:28 +0800)
committerStar Zeng <star.zeng@intel.com>
Thu, 30 Nov 2017 01:11:49 +0000 (09:11 +0800)
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_PARAMETER and EFI_UNSUPPORTED will return
EFI_DEVICE_ERROR.

Contributed-under: Tianocore Contribution Agreement 1.1
Signed-off-by: Julien Grall <julien.grall@linaro.org>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
MdeModulePkg/Universal/SerialDxe/SerialIo.c
MdePkg/Include/Protocol/SerialIo.h

index 19fc889c25aff4999d975c1b9d0a4f34ca5c1b08..ee10ec7e05eadcb1a5ffc2fc3bd8d0a8d678851e 100644 (file)
@@ -66,8 +66,9 @@ SerialReset (
                            value of DefaultStopBits will use the device's default number of\r
                            stop bits.\r
 \r
                            value of DefaultStopBits will use the device's default number of\r
                            stop bits.\r
 \r
-  @retval EFI_SUCCESS      The device was reset.\r
-  @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.\r
+  @retval EFI_SUCCESS           The device was reset.\r
+  @retval EFI_INVALID_PARAMETER One or more attributes has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The serial device is not functioning correctly.\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -264,8 +265,9 @@ SerialReset (
                            value of DefaultStopBits will use the device's default number of\r
                            stop bits.\r
 \r
                            value of DefaultStopBits will use the device's default number of\r
                            stop bits.\r
 \r
-  @retval EFI_SUCCESS      The device was reset.\r
-  @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.\r
+  @retval EFI_SUCCESS           The device was reset.\r
+  @retval EFI_INVALID_PARAMETER One or more attributes has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The serial device is not functioning correctly.\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -323,8 +325,10 @@ SerialSetAttributes (
       DataBits = OriginalDataBits;\r
       StopBits = OriginalStopBits;\r
       Status = EFI_SUCCESS;\r
       DataBits = OriginalDataBits;\r
       StopBits = OriginalStopBits;\r
       Status = EFI_SUCCESS;\r
+    } else if (Status == EFI_INVALID_PARAMETER || Status == EFI_UNSUPPORTED) {\r
+      return EFI_INVALID_PARAMETER;\r
     } else {\r
     } else {\r
-      return Status;\r
+      return EFI_DEVICE_ERROR;\r
     }\r
   }\r
 \r
     }\r
   }\r
 \r
index 84cb34364d9ee1199fb956d1863cf1b648fddca5..1263dc4fe9731b285fab0a60683742290f2491ff 100644 (file)
@@ -125,8 +125,9 @@ EFI_STATUS
                            value of DefaultStopBits will use the device's default number of\r
                            stop bits.\r
 \r
                            value of DefaultStopBits will use the device's default number of\r
                            stop bits.\r
 \r
-  @retval EFI_SUCCESS      The device was reset.\r
-  @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.\r
+  @retval EFI_SUCCESS           The device was reset.\r
+  @retval EFI_INVALID_PARAMETER One or more attributes has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The serial device is not functioning correctly.\r
 \r
 **/\r
 typedef\r
 \r
 **/\r
 typedef\r