This will cause the kernel to fall-back to the usb-storage driver for
devices with incomplete uas endpoint descriptors.

The endpoint parsing code used to assume a fixed endpoint config if the
endpoint descriptors were incomplete to get some older (prototype?) devices
to work. This change includes a new quirk for these devices, but it will
break them until quirk entries for them are actually added. This is not
a regression since currently uas is marked as broken.

I believe enforcing proper uas endpoint descriptors, rather then always
falling back to the hardcoded config is for the best because as we start
seeing more uas devices we will likely encounter devices with descriptors
which are broken in a different way.

Signed-off-by: Hans de Goede <hdego...@redhat.com>
---
 drivers/usb/storage/uas-detect.h | 15 ++++++++++++++-
 include/linux/usb_usual.h        |  4 +++-
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/storage/uas-detect.h b/drivers/usb/storage/uas-detect.h
index 3529872..b9ac5e1 100644
--- a/drivers/usb/storage/uas-detect.h
+++ b/drivers/usb/storage/uas-detect.h
@@ -69,7 +69,9 @@ static int uas_find_endpoints(struct usb_host_interface *alt,
 static int uas_use_uas_driver(struct usb_interface *intf,
                              const struct usb_device_id *id)
 {
+       struct usb_host_endpoint *eps[4] = { };
        unsigned long flags = id->driver_info;
+       int r, alt;
 
        if (usb_uas_disabled())
                return 0;
@@ -77,5 +79,16 @@ static int uas_use_uas_driver(struct usb_interface *intf,
        if (flags & US_FL_IGNORE_UAS)
                return 0;
 
-       return uas_find_uas_alt_setting(intf) >= 0;
+       alt = uas_find_uas_alt_setting(intf);
+       if (alt < 0)
+               return 0;
+
+       if (flags & US_FL_UAS_FIXED_EP_CONFIG)
+               return 1;
+
+       r = uas_find_endpoints(&intf->altsetting[alt], eps);
+       if (r < 0)
+               return 0;
+
+       return 1;
 }
diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h
index 1a64b26..82248b5 100644
--- a/include/linux/usb_usual.h
+++ b/include/linux/usb_usual.h
@@ -70,7 +70,9 @@
        US_FLAG(NEEDS_CAP16,    0x00400000)                     \
                /* cannot handle READ_CAPACITY_10 */            \
        US_FLAG(IGNORE_UAS,     0x00800000)                     \
-               /* Device advertises UAS but it is broken */
+               /* Device advertises UAS but it is broken */    \
+       US_FLAG(UAS_FIXED_EP_CONFIG,    0x01000000)             \
+               /* UAS device with hard coded ep config */
 
 #define US_FLAG(name, value)   US_FL_##name = value ,
 enum { US_DO_ALL_FLAGS };
-- 
1.8.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to