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_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>
This commit is contained in:
Julien Grall 2017-11-30 01:28:22 +08:00 committed by Star Zeng
parent b462f25a21
commit 13d378fc82
2 changed files with 12 additions and 7 deletions

View File

@ -67,6 +67,7 @@ SerialReset (
stop bits.
@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.
**/
@ -265,6 +266,7 @@ SerialReset (
stop bits.
@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.
**/
@ -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;
}
}

View File

@ -126,6 +126,7 @@ EFI_STATUS
stop bits.
@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.
**/