usb: gadget: f_fs: Fix enumeration in fullspeed mode
authorBenoit Goby <benoit@android.com>
Thu, 20 Sep 2012 00:03:34 +0000 (17:03 -0700)
committerArve Hjønnevåg <arve@android.com>
Mon, 1 Jul 2013 21:16:07 +0000 (14:16 -0700)
ffs_func_eps_enable always take the highspeed usb_endpoint_descriptor
if it is available. Choose the correct usb_endpoint_descriptor
depending on the gadget speed instead.

Change-Id: I5b8444cfdf1b6fe1eef25525fb7a0a0f617a353e
Signed-off-by: Benoit Goby <benoit@android.com>
drivers/usb/gadget/f_fs.c

index f394f295d63d1b87927fb49fe9ebe3234fe0c635..3d132cb786f012804749895c0f37353dde2cf381 100644 (file)
@@ -1569,7 +1569,12 @@ static int ffs_func_eps_enable(struct ffs_function *func)
        spin_lock_irqsave(&func->ffs->eps_lock, flags);
        do {
                struct usb_endpoint_descriptor *ds;
-               ds = ep->descs[ep->descs[1] ? 1 : 0];
+               int desc_idx = ffs->gadget->speed == USB_SPEED_HIGH ? 1 : 0;
+               ds = ep->descs[desc_idx];
+               if (!ds) {
+                       ret = -EINVAL;
+                       break;
+               }
 
                ep->ep->driver_data = ep;
                ep->ep->desc = ds;