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 <julien.grall@linaro.org>
---
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
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Could you also update the description for EFI_SERIAL_SET_ATTRIBUTES in MdePkg/Include/Protocol/SerialIo.h? That could be done in a separated patch.
+ @retval EFI_INVALID_PARAMETER One or more attributes has an unsupported value.
Thanks,
Star
-----Original Message-----
From: Julien Grall [mailto:julien.grall@linaro.org]
Sent: Saturday, November 25, 2017 12:20 AM
To: Zeng, Star <star.zeng@intel.com>; Dong, Eric <eric.dong@intel.com>; pankaj.bansal@nxp.com; lersek@redhat.com; leif.lindholm@linaro.org
Cc: edk2-devel@lists.01.org; Julien Grall <julien.grall@linaro.org>
Subject: [PATCH v2 2/3] MdeModulePkg/SerialDxe: Fix return valued in SerialSetAttributes
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 <julien.grall@linaro.org>
---
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
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
© 2016 - 2026 Red Hat, Inc.