[PATCH] usb: common: Detect USB storage media with "miscellaneous" USB devices

Christian Kohlschütter christian at kohlschutter.com
Sun Sep 25 16:46:10 CEST 2022


When detecting USB storage devices, we currently skip everything that is
not marked as "undefined device class".

Composite devices such as tinyusb's CDC+MSC identify as "miscellaneous"
(class 0xEF).

Introduce a new constant, USB_CLASS_MISC (0xEF), and allow the detection
process to proceed for USB devices with this device class.

Signed-off-by: Christian Kohlschütter <christian at kohlschutter.com>
---
 common/usb_storage.c | 3 ++-
 include/usb_defs.h   | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/usb_storage.c b/common/usb_storage.c
index eaa31374ef..727b364b3d 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -1322,7 +1322,8 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
 	/* let's examine the device now */
 	iface = &dev->config.if_desc[ifnum];
 
-	if (dev->descriptor.bDeviceClass != 0 ||
+	if ((dev->descriptor.bDeviceClass != 0 && dev->descriptor.bDeviceClass
+				!= USB_CLASS_MISC) ||
 			iface->desc.bInterfaceClass != USB_CLASS_MASS_STORAGE ||
 			iface->desc.bInterfaceSubClass < US_SC_MIN ||
 			iface->desc.bInterfaceSubClass > US_SC_MAX) {
diff --git a/include/usb_defs.h b/include/usb_defs.h
index 6dd2c997f9..f8f87d6a8a 100644
--- a/include/usb_defs.h
+++ b/include/usb_defs.h
@@ -19,6 +19,7 @@
 #define USB_CLASS_MASS_STORAGE   8
 #define USB_CLASS_HUB            9
 #define USB_CLASS_DATA           10
+#define USB_CLASS_MISC           0xef
 #define USB_CLASS_VENDOR_SPEC    0xff
 
 /* some HID sub classes */
-- 
2.36.2



More information about the U-Boot mailing list