mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-12 07:37:31 -04:00
usb: gadget: composite: Show warning if function driver's descriptors are incomplete.
In the config_ep_by_speed_and_alt function, select the corresponding descriptor through g->speed. But some legacy or not well designed function drivers may not support the corresponding speed. So, we can directly display warnings instead of causing kernel panic. At the same time, it indicates the reasons in warning message. Change-Id: Ib8c979663d9f04212bcc3ef4e1c0dc5be26c6958 Reviewed-by: Peter Chen <peter.chen@kernel.org> Signed-off-by: Qihang Hu <huqihang@oppo.com> Link: https://lore.kernel.org/r/20211110101129.462357-1-huqihang@oppo.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Mot-CRs-Fixed: (CR) Reviewed-on: https://gerrit.mot.com/2264211 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Igor Kovalenko <igork@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
02b9f89f58
commit
a6f230d5d5
1 changed files with 26 additions and 13 deletions
|
|
@ -161,6 +161,8 @@ int config_ep_by_speed_and_alt(struct usb_gadget *g,
|
|||
int want_comp_desc = 0;
|
||||
|
||||
struct usb_descriptor_header **d_spd; /* cursor for speed desc */
|
||||
struct usb_composite_dev *cdev;
|
||||
bool incomplete_desc = false;
|
||||
|
||||
if (!g || !f || !_ep)
|
||||
return -EIO;
|
||||
|
|
@ -169,28 +171,43 @@ int config_ep_by_speed_and_alt(struct usb_gadget *g,
|
|||
switch (g->speed) {
|
||||
case USB_SPEED_SUPER_PLUS:
|
||||
if (gadget_is_superspeed_plus(g)) {
|
||||
speed_desc = f->ssp_descriptors;
|
||||
want_comp_desc = 1;
|
||||
break;
|
||||
if (f->ssp_descriptors) {
|
||||
speed_desc = f->ssp_descriptors;
|
||||
want_comp_desc = 1;
|
||||
break;
|
||||
}
|
||||
incomplete_desc = true;
|
||||
}
|
||||
/* fall through */
|
||||
case USB_SPEED_SUPER:
|
||||
if (gadget_is_superspeed(g)) {
|
||||
speed_desc = f->ss_descriptors;
|
||||
want_comp_desc = 1;
|
||||
break;
|
||||
if (f->ss_descriptors) {
|
||||
speed_desc = f->ss_descriptors;
|
||||
want_comp_desc = 1;
|
||||
break;
|
||||
}
|
||||
incomplete_desc = true;
|
||||
}
|
||||
/* fall through */
|
||||
case USB_SPEED_HIGH:
|
||||
if (gadget_is_dualspeed(g)) {
|
||||
speed_desc = f->hs_descriptors;
|
||||
break;
|
||||
if (f->hs_descriptors) {
|
||||
speed_desc = f->hs_descriptors;
|
||||
break;
|
||||
}
|
||||
incomplete_desc = true;
|
||||
}
|
||||
/* fall through */
|
||||
default:
|
||||
speed_desc = f->fs_descriptors;
|
||||
}
|
||||
|
||||
cdev = get_gadget_data(g);
|
||||
if (incomplete_desc)
|
||||
WARNING(cdev,
|
||||
"%s doesn't hold the descriptors for current speed\n",
|
||||
f->name);
|
||||
|
||||
/* find correct alternate setting descriptor */
|
||||
for_each_desc(speed_desc, d_spd, USB_DT_INTERFACE) {
|
||||
int_desc = (struct usb_interface_descriptor *)*d_spd;
|
||||
|
|
@ -246,12 +263,8 @@ ep_found:
|
|||
_ep->maxburst = comp_desc->bMaxBurst + 1;
|
||||
break;
|
||||
default:
|
||||
if (comp_desc->bMaxBurst != 0) {
|
||||
struct usb_composite_dev *cdev;
|
||||
|
||||
cdev = get_gadget_data(g);
|
||||
if (comp_desc->bMaxBurst != 0)
|
||||
ERROR(cdev, "ep0 bMaxBurst must be 0\n");
|
||||
}
|
||||
_ep->maxburst = 1;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue