usb: gadget: fix wrong endpoint desc
PATCH 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.
--- drivers/usb/gadget/function/f_ecm.c | 4 ++++ drivers/usb/gadget/function/f_rndis.c | 1 + 2 files changed, 5 insertions(+)
drivers/usb/gadget/function/f_ecm.c +4 -0
@@ -623,6 +623,10 @@ static void ecm_disable(struct usb_function *f)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
Hi,
Quoted 3 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.
your commit log doesn't match the patch body. What gives?
Quoted 11 lines
Signed-off-by EJ Hsu <[email protected]>--- drivers/usb/gadget/function/f_ecm.c | 4 ++++ drivers/usb/gadget/function/f_rndis.c | 1 + 2 files changed, 5 insertions(+)drivers/usb/gadget/function/f_ecm.c +0
-0
drivers/usb/gadget/function/f_ecm.c static void ecm_disable(struct usb_function *f) · line 626
Quoted 4 lines
drivers/usb/gadget/function/f_ecm.c +1
-0@@ -623,6 +623,10 @@ static void ecm_disable(struct usb_function *f)if (ecm->port.in_ep->enabled)gether_disconnect (&ecm->port); +else {
coding style. If one branch has {}, both branches should have {} ;-)
Signature · 1 line
balbi
Hi,
Quoted 6 lines · Felipe Balb
Quoted 3 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.your commit log doesn't match the patch body. What gives?
The key point in this patch is that we want to make sure the desc pointer 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.
Quoted 13 lines
Quoted 13 lines
Signed-off-by EJ Hsu <[email protected]>--- drivers/usb/gadget/function/f_ecm.c | 4 ++++ drivers/usb/gadget/function/f_rndis.c | 1 + 2 files changed, 5 insertions(+)drivers/usb/gadget/function/f_ecm.c +0
-0@@ -623,6 +623,10 @@ static void ecm_disable(struct usb_function *f)
Quoted 5 lines
drivers/usb/gadget/function/f_ecm.c static void ecm_disable(struct usb_function *f) · line 626
Quoted 3 lines
drivers/usb/gadget/function/f_ecm.c +1
-0if (ecm->port.in_ep->enabled)gether_disconnect (&ecm->port); +else {coding style. If one branch has {}, both branches should have {} ;-)
Thanks. Will correct it.
EJ
--nvpublic
Hi,
Quoted 6 lines · EJ Hsu
Quoted 5 lines · Felipe Balb
Quoted 3 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 6 lines
Quoted 1 line
your commit log doesn't match the patch body. What gives?
The key point in this patch is that we want to make sure the desc pointer 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.
this would be a commit log that matches the implementation ;-)
Signature · 1 line
balbi