usb: gadget: f_fs: fix ep req_match error for composite device

This patch add direction index for eps_revmap, which can avoid matching
to the requests for other functions.

For example, if we config ep1in for uac and ep1out for adb, the requests
for ep1in will be matching to ffs without this patch.

Change-Id: Ic7a52fca35503656bbc306c9f0014dfdea61392b
Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
This commit is contained in:
Ren Jianing
2021-01-06 17:30:53 +08:00
committed by Tao Huang
parent bcf7606d61
commit 7e08fbf2c8

View File

@@ -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;
}