mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-17 01:52:02 +00:00
embed/trezorhal/usb: correct handling of interface messages in usb_class_setup
This commit is contained in:
parent
7b2fd6ae4c
commit
c115faf2cd
@ -373,7 +373,9 @@ static uint8_t usb_class_setup(USBD_HandleTypeDef *dev, USBD_SetupReqTypedef *re
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (req->wIndex >= USBD_MAX_NUM_INTERFACES) {
|
||||
} else
|
||||
if ((req->bmRequest & USB_REQ_RECIPIENT_MASK) == USB_REQ_RECIPIENT_INTERFACE) {
|
||||
if (req->wIndex >= USBD_MAX_NUM_INTERFACES) {
|
||||
USBD_CtlError(dev, req);
|
||||
return USBD_FAIL;
|
||||
}
|
||||
@ -389,6 +391,8 @@ static uint8_t usb_class_setup(USBD_HandleTypeDef *dev, USBD_SetupReqTypedef *re
|
||||
return USBD_FAIL;
|
||||
}
|
||||
}
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
static uint8_t usb_class_data_in(USBD_HandleTypeDef *dev, uint8_t ep_num) {
|
||||
for (int i = 0; i < USBD_MAX_NUM_INTERFACES; i++) {
|
||||
|
@ -217,19 +217,10 @@ static void usb_webusb_class_deinit(USBD_HandleTypeDef *dev, usb_webusb_state_t
|
||||
|
||||
static int usb_webusb_class_setup(USBD_HandleTypeDef *dev, usb_webusb_state_t *state, USBD_SetupReqTypedef *req) {
|
||||
|
||||
switch (req->bmRequest & USB_REQ_TYPE_MASK) {
|
||||
|
||||
// Class request
|
||||
case USB_REQ_TYPE_CLASS:
|
||||
switch (req->bRequest) {
|
||||
default:
|
||||
USBD_CtlError(dev, req);
|
||||
return USBD_FAIL;
|
||||
if ((req->bmRequest & USB_REQ_TYPE_MASK) != USB_REQ_TYPE_STANDARD) {
|
||||
return USBD_OK;
|
||||
}
|
||||
break;
|
||||
|
||||
// Interface & Endpoint request
|
||||
case USB_REQ_TYPE_STANDARD:
|
||||
switch (req->bRequest) {
|
||||
|
||||
case USB_REQ_SET_INTERFACE:
|
||||
@ -240,14 +231,11 @@ static int usb_webusb_class_setup(USBD_HandleTypeDef *dev, usb_webusb_state_t *s
|
||||
case USB_REQ_GET_INTERFACE:
|
||||
USBD_CtlSendData(dev, &state->alt_setting, sizeof(state->alt_setting));
|
||||
return USBD_OK;
|
||||
|
||||
default:
|
||||
USBD_CtlError(dev, req);
|
||||
return USBD_FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
static void usb_webusb_class_data_in(USBD_HandleTypeDef *dev, usb_webusb_state_t *state, uint8_t ep_num) {
|
||||
|
Loading…
Reference in New Issue
Block a user