From 8fa51bca58949a3c5ee665b3c3ad8cd585e54761 Mon Sep 17 00:00:00 2001 From: Emil Obalski Date: Wed, 6 May 2020 15:39:04 +0200 Subject: [PATCH] usb: Allow Audio Class to handle custom_hander for all interfaces This exception allows USB Audio Class to properly respond to the interface requests. This commit is temporary solution and shall not be considered as valid solution for other classes. Signed-off-by: Emil Obalski --- include/usb/usb_common.h | 1 + subsys/usb/usb_device.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/usb/usb_common.h b/include/usb/usb_common.h index c3c0058e2ef..1e7c7a02525 100644 --- a/include/usb/usb_common.h +++ b/include/usb/usb_common.h @@ -104,6 +104,7 @@ (USB_CONFIGURATION_ATTRIBUTES_REMOTE_WAKEUP), (0)))) /* Classes */ +#define AUDIO_CLASS 0x01 #define COMMUNICATION_DEVICE_CLASS 0x02 #define COMMUNICATION_DEVICE_CLASS_DATA 0x0A #define HID_CLASS 0x03 diff --git a/subsys/usb/usb_device.c b/subsys/usb/usb_device.c index a04962bc2da..d42b2d37c6d 100644 --- a/subsys/usb/usb_device.c +++ b/subsys/usb/usb_device.c @@ -1244,9 +1244,13 @@ static int custom_handler(struct usb_setup_packet *pSetup, continue; } - if ((iface->custom_handler) && + /* An exception for AUDIO_CLASS is temporary and shall not be + * considered as valid solution for other classes. + */ + if (iface->custom_handler && (if_descr->bInterfaceNumber == - sys_le16_to_cpu(pSetup->wIndex))) { + sys_le16_to_cpu(pSetup->wIndex) || + if_descr->bInterfaceClass == AUDIO_CLASS)) { return iface->custom_handler(pSetup, len, data); } }