Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] usb: gadget: fix wrong endpoint desc
@ 2019-12-03 10:46 EJ Hsu
  2019-12-03 12:31 ` Felipe Balbi
  0 siblings, 1 reply; 4+ messages in thread
From: EJ Hsu @ 2019-12-03 10:46 UTC (permalink / raw)
  To: linux-usb; +Cc: EJ Hsu

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.

Signed-off-by: EJ Hsu <ejh@nvidia.com>
---
 drivers/usb/gadget/function/f_ecm.c   | 4 ++++
 drivers/usb/gadget/function/f_rndis.c | 1 +
 2 files changed, 5 insertions(+)

diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c
index 6ce044008cf6..494fe4e38a65 100644
--- a/drivers/usb/gadget/function/f_ecm.c
+++ b/drivers/usb/gadget/function/f_ecm.c
@@ -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;
diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c
index d48df36622b7..0d8e4a364ca6 100644
--- a/drivers/usb/gadget/function/f_rndis.c
+++ b/drivers/usb/gadget/function/f_rndis.c
@@ -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;
 }
 
 /*-------------------------------------------------------------------------*/
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: gadget: fix wrong endpoint desc
  2019-12-03 10:46 [PATCH] usb: gadget: fix wrong endpoint desc EJ Hsu
@ 2019-12-03 12:31 ` Felipe Balbi
  2019-12-04  2:58   ` EJ Hsu
  0 siblings, 1 reply; 4+ messages in thread
From: Felipe Balbi @ 2019-12-03 12:31 UTC (permalink / raw)
  To: EJ Hsu, linux-usb; +Cc: EJ Hsu

[-- Attachment #1: Type: text/plain, Size: 978 bytes --]


Hi,

EJ Hsu <ejh@nvidia.com> writes:
> 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.

your commit log doesn't match the patch body. What gives?

> Signed-off-by: EJ Hsu <ejh@nvidia.com>
> ---
>  drivers/usb/gadget/function/f_ecm.c   | 4 ++++
>  drivers/usb/gadget/function/f_rndis.c | 1 +
>  2 files changed, 5 insertions(+)
>
> diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c
> index 6ce044008cf6..494fe4e38a65 100644
> --- a/drivers/usb/gadget/function/f_ecm.c
> +++ b/drivers/usb/gadget/function/f_ecm.c
> @@ -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 {} ;-)

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] usb: gadget: fix wrong endpoint desc
  2019-12-03 12:31 ` Felipe Balbi
@ 2019-12-04  2:58   ` EJ Hsu
  2019-12-04 12:15     ` Felipe Balbi
  0 siblings, 1 reply; 4+ messages in thread
From: EJ Hsu @ 2019-12-04  2:58 UTC (permalink / raw)
  To: Felipe Balbi, linux-usb

Hi,

Felipe Balb writes:
>EJ Hsu <ejh@nvidia.com> writes:
>> 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.
>
>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.

>> Signed-off-by: EJ Hsu <ejh@nvidia.com>
>> ---
>>  drivers/usb/gadget/function/f_ecm.c   | 4 ++++
>>  drivers/usb/gadget/function/f_rndis.c | 1 +
>>  2 files changed, 5 insertions(+)
>>
>> diff --git a/drivers/usb/gadget/function/f_ecm.c 
>> b/drivers/usb/gadget/function/f_ecm.c
>> index 6ce044008cf6..494fe4e38a65 100644
>> --- a/drivers/usb/gadget/function/f_ecm.c
>> +++ b/drivers/usb/gadget/function/f_ecm.c
>> @@ -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 {} ;-)

Thanks. Will correct it.

EJ
--nvpublic

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] usb: gadget: fix wrong endpoint desc
  2019-12-04  2:58   ` EJ Hsu
@ 2019-12-04 12:15     ` Felipe Balbi
  0 siblings, 0 replies; 4+ messages in thread
From: Felipe Balbi @ 2019-12-04 12:15 UTC (permalink / raw)
  To: EJ Hsu, linux-usb\

[-- Attachment #1: Type: text/plain, Size: 778 bytes --]


Hi,

EJ Hsu <ejh@nvidia.com> writes:
> Felipe Balb writes:
>>EJ Hsu <ejh@nvidia.com> writes:
>>> 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.
>>
>>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.

this would be a commit log that matches the implementation ;-)

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-03 10:46 [PATCH] usb: gadget: fix wrong endpoint desc EJ Hsu
2019-12-03 12:31 ` Felipe Balbi
2019-12-04  2:58   ` EJ Hsu
2019-12-04 12:15     ` Felipe Balbi

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git