mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-05-30 20:58:46 +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);
|
USBD_CtlError(dev, req);
|
||||||
return USBD_FAIL;
|
return USBD_FAIL;
|
||||||
}
|
}
|
||||||
@ -389,6 +391,8 @@ static uint8_t usb_class_setup(USBD_HandleTypeDef *dev, USBD_SetupReqTypedef *re
|
|||||||
return USBD_FAIL;
|
return USBD_FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return USBD_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static uint8_t usb_class_data_in(USBD_HandleTypeDef *dev, uint8_t ep_num) {
|
static uint8_t usb_class_data_in(USBD_HandleTypeDef *dev, uint8_t ep_num) {
|
||||||
for (int i = 0; i < USBD_MAX_NUM_INTERFACES; i++) {
|
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) {
|
static int usb_webusb_class_setup(USBD_HandleTypeDef *dev, usb_webusb_state_t *state, USBD_SetupReqTypedef *req) {
|
||||||
|
|
||||||
switch (req->bmRequest & USB_REQ_TYPE_MASK) {
|
if ((req->bmRequest & USB_REQ_TYPE_MASK) != USB_REQ_TYPE_STANDARD) {
|
||||||
|
return USBD_OK;
|
||||||
// Class request
|
|
||||||
case USB_REQ_TYPE_CLASS:
|
|
||||||
switch (req->bRequest) {
|
|
||||||
default:
|
|
||||||
USBD_CtlError(dev, req);
|
|
||||||
return USBD_FAIL;
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
// Interface & Endpoint request
|
|
||||||
case USB_REQ_TYPE_STANDARD:
|
|
||||||
switch (req->bRequest) {
|
switch (req->bRequest) {
|
||||||
|
|
||||||
case USB_REQ_SET_INTERFACE:
|
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:
|
case USB_REQ_GET_INTERFACE:
|
||||||
USBD_CtlSendData(dev, &state->alt_setting, sizeof(state->alt_setting));
|
USBD_CtlSendData(dev, &state->alt_setting, sizeof(state->alt_setting));
|
||||||
return USBD_OK;
|
return USBD_OK;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
USBD_CtlError(dev, req);
|
USBD_CtlError(dev, req);
|
||||||
return USBD_FAIL;
|
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) {
|
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