diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index c045a16ab05d..58a5dd48fdbc 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -71,7 +71,7 @@ struct ffs_function { struct ffs_data *ffs; struct ffs_ep *eps; - u8 eps_revmap[16]; + u8 eps_revmap[32]; short *interfaces_nums; struct usb_function function; @@ -2798,7 +2798,7 @@ static int __ffs_func_bind_do_descs(enum ffs_entity_type type, u8 *valuep, struct ffs_function *func = priv; struct ffs_ep *ffs_ep; unsigned ep_desc_id; - int idx; + int idx, ep_num; static const char *speed_names[] = { "full", "high", "super" }; if (type != FFS_DESCRIPTOR) @@ -2871,8 +2871,9 @@ static int __ffs_func_bind_do_descs(enum ffs_entity_type type, u8 *valuep, ffs_ep->ep = ep; ffs_ep->req = req; - func->eps_revmap[ds->bEndpointAddress & - USB_ENDPOINT_NUMBER_MASK] = idx + 1; + ep_num = ((ds->bEndpointAddress & USB_ENDPOINT_DIR_MASK) >> 3) | + (ds->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); + func->eps_revmap[ep_num] = idx + 1; /* * If we use virtual address mapping, we restore * original bEndpointAddress value. @@ -3409,7 +3410,10 @@ static void ffs_func_resume(struct usb_function *f) static int ffs_func_revmap_ep(struct ffs_function *func, u8 num) { - num = func->eps_revmap[num & USB_ENDPOINT_NUMBER_MASK]; + int ep_num = ((num & USB_ENDPOINT_DIR_MASK) >> 3) | + (num & USB_ENDPOINT_NUMBER_MASK); + + num = func->eps_revmap[ep_num]; return num ? num : -EDOM; }