From f1d5f1091d7306b6217ad7600266bf53ccc8e907 Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Tue, 17 Dec 2019 22:54:22 -0600 Subject: [PATCH] MdeModulePkg/Usb/Keyboard.c: don't request protocol before setting No need to check the interface protocol then conditionally setting, just set it to BOOT_PROTOCOL and check for error. Signed-off-by: Matt DeVillier --- MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c | 28 ++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c index b1de8ffcd9..beee42ab19 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c @@ -807,7 +807,6 @@ InitUSBKeyboard ( IN OUT USB_KB_DEV *UsbKeyboardDevice ) { - UINT8 Protocol; EFI_STATUS Status; REPORT_STATUS_CODE_WITH_DEVICE_PATH ( @@ -820,21 +819,28 @@ InitUSBKeyboard ( InitQueue (&UsbKeyboardDevice->EfiKeyQueue, sizeof (EFI_KEY_DATA)); InitQueue (&UsbKeyboardDevice->EfiKeyQueueForNotify, sizeof (EFI_KEY_DATA)); - UsbGetProtocolRequest ( - UsbKeyboardDevice->UsbIo, - UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber, - &Protocol - ); // // Set boot protocol for the USB Keyboard. // This driver only supports boot protocol. // - if (Protocol != BOOT_PROTOCOL) { - UsbSetProtocolRequest ( - UsbKeyboardDevice->UsbIo, - UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber, - BOOT_PROTOCOL + Status = UsbSetProtocolRequest ( + UsbKeyboardDevice->UsbIo, + UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber, + BOOT_PROTOCOL + ); + if (EFI_ERROR (Status)) { + // + // If protocol could not be set here, it means + // the keyboard interface has some errors and could + // not be initialized + // + REPORT_STATUS_CODE_WITH_DEVICE_PATH ( + EFI_ERROR_CODE | EFI_ERROR_MINOR, + (EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_INTERFACE_ERROR), + UsbKeyboardDevice->DevicePath ); + + return EFI_DEVICE_ERROR; } UsbKeyboardDevice->CtrlOn = FALSE;