Skip to content
Permalink
Browse files

usb: usb_device: fix handlers call for secondary descriptor

Fix handlers call for secondary descriptor.
USB class like DFU has two sets of descriptors. In the handler
look up function, wind the pointer forward to the range
of the current descriptor.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
  • Loading branch information...
jfischer-phytec-iot authored and nashif committed May 23, 2019
1 parent 4d2b7f6 commit 28f2dc6c690fed7b253f0a39db7fd155f96cdedb
Showing with 16 additions and 0 deletions.
  1. +16 −0 subsys/usb/usb_device.c
@@ -1384,6 +1384,14 @@ static int class_handler(struct usb_setup_packet *pSetup,
for (size_t i = 0; i < size; i++) {
iface = &(__usb_data_start[i].interface);
if_descr = __usb_data_start[i].interface_descriptor;
/*
* Wind forward until it is within the range
* of the current descriptor.
*/
if ((u8_t *)if_descr < usb_dev.descriptors) {
continue;
}

if ((iface->class_handler) &&
(if_descr->bInterfaceNumber ==
sys_le16_to_cpu(pSetup->wIndex))) {
@@ -1407,6 +1415,14 @@ static int custom_handler(struct usb_setup_packet *pSetup,
for (size_t i = 0; i < size; i++) {
iface = &(__usb_data_start[i].interface);
if_descr = __usb_data_start[i].interface_descriptor;
/*
* Wind forward until it is within the range
* of the current descriptor.
*/
if ((u8_t *)if_descr < usb_dev.descriptors) {
continue;
}

if ((iface->custom_handler) &&
(if_descr->bInterfaceNumber ==
sys_le16_to_cpu(pSetup->wIndex))) {

0 comments on commit 28f2dc6

Please sign in to comment.
You can’t perform that action at this time.