usb: gadget: fix wrong endpoint desc
PATCH v2 1/1 usb: gadget: fix wrong endpoint desc
Gadget driver should always use config_ep_by_speed() to initialize usb_ep struct according to usb device's operating speed. Otherwise, usb_ep struct may be wrong if usb devcie's operating speed is changed.
The key point in this patch is that we want to make sure the descpointer in usb_ep struct will be set to NULL when gadget is disconnected. This will force it to call config_ep_by_speed() to correctly initialize usb_ep struct based on the new operating speed when gadget is re-connected later.
---
v2: fix the coding style
--- drivers/usb/gadget/function/f_ecm.c | 6 +++++- drivers/usb/gadget/function/f_rndis.c | 1 + 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/usb/gadget/function/f_ecm.c +5 -1
@@ -621,8 +621,12 @@ static void ecm_disable(struct usb_function *f)DBG (cdev,"ecm deactivated\n" ); -if (ecm->port.in_ep->enabled) +if (ecm->port.in_ep->enabled) {gether_disconnect (&ecm->port); + }else { + ecm->port.in_ep->desc =NULL ; + ecm->port.out_ep->desc =NULL ; + }usb_ep_disable (ecm->notify); ecm->notify->desc =NULL ;
drivers/usb/gadget/function/f_rndis.c +1 -0
@@ -618,6 +618,7 @@ static void rndis_disable(struct usb_function *f)gether_disconnect (&rndis->port);usb_ep_disable (rndis->notify); + rndis->notify->desc =NULL ; }/*-------------------------------------------------------------------------*/
Signature · 1 line
2.17.1
Quoted 5 lines · EJ Hsu
Gadget driver should always use
config_ep_by_speed()to initializeusb_epstruct according to usb device's operating speed. Otherwise,usb_epstruct may be wrong if usb devcie's operating speed is changed.The key point in this patch is that we want to make sure the descpointer
Typo
Otherwise:
Quoted 46 lines
in
usb_epstruct will be set to NULL when gadget is disconnected. This will force it to callconfig_ep_by_speed()to correctly initializeusb_epstruct based on the new operating speed when gadget is re-connected later.Signed-off-by EJ Hsu <[email protected]>---
v2: fix the coding style--- drivers/usb/gadget/function/f_ecm.c | 6 +++++- drivers/usb/gadget/function/f_rndis.c | 1 + 2 files changed, 6 insertions(+), 1 deletion(-)drivers/usb/gadget/function/f_ecm.c +5
-1@@ -621,8 +621,12 @@ static void ecm_disable(struct usb_function *f)DBG (cdev,"ecm deactivated\n" ); -if (ecm->port.in_ep->enabled) +if (ecm->port.in_ep->enabled) {gether_disconnect (&ecm->port); + }else { + ecm->port.in_ep->desc =NULL ; + ecm->port.out_ep->desc =NULL ; + }usb_ep_disable (ecm->notify); ecm->notify->desc =NULL ;drivers/usb/gadget/function/f_rndis.c +1
-0@@ -618,6 +618,7 @@ static void rndis_disable(struct usb_function *f)gether_disconnect (&rndis->port);usb_ep_disable (rndis->notify); + rndis->notify->desc =NULL ; }/*-------------------------------------------------------------------------*/ Signature · 1 line
2.17.1
Signature · 2 lines
Thanks, Peter Chen
Hi Peter,
Quoted 5 lines · Peter Chen
Quoted 4 lines · EJ Hsu
Gadget driver should always use
config_ep_by_speed()to initializeusb_epstruct according to usb device's operating speed. Otherwise,usb_epstruct may be wrong if usb devcie's operating speed is changed.
Quoted 8 lines
Quoted 2 lines
The key point in this patch is that we want to make sure the descpointer
Typo
Otherwise:
Reviewed-by Peter Chen <[email protected]>
I have uploaded a new patch following your feedback. Could you please help to review it again?
Thanks,
EJ
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
Quoted 11 lines
Quoted 8 lines · Peter Chen
Quoted 6 lines · EJ Hsu
Gadget driver should always use
config_ep_by_speed()to initializeusb_epstruct according to usb device's operating speed. Otherwise,usb_epstruct may be wrong if usb devcie's operating speed is changed.The key point in this patch is that we want to make sure the descpointer
Quoted 9 lines
Quoted 5 lines
Typo
Otherwise:
Reviewed-by Peter Chen <[email protected]>I have uploaded a new patch following your feedback. Could you please help to review it again?
Feel free to add my Reviewed-by for your v3 since you only change the typo I pointed.
Peter