Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
From: Peter Chen <peter.chen@nxp.com>
To: EJ Hsu <ejh@nvidia.com>
Cc: "balbi@kernel.org" <balbi@kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: [PATCH v2] usb: gadget: fix wrong endpoint desc
Date: Wed, 4 Dec 2019 07:06:49 +0000
Message-ID: <20191204070646.GA25122@b29397-desktop> (raw)
In-Reply-To: <20191204053322.35776-1-ejh@nvidia.com>

On 19-12-03 21:33:22, EJ Hsu wrote:
> 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

Typo

Otherwise:
Reviewed-by: Peter Chen <peter.chen@nxp.com>

> 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>
> ---
> 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(-)
> 
> diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c
> index 6ce044008cf6..460d5d7c984f 100644
> --- a/drivers/usb/gadget/function/f_ecm.c
> +++ b/drivers/usb/gadget/function/f_ecm.c
> @@ -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;
> 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
> 

-- 

Thanks,
Peter Chen

  reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-04  5:33 EJ Hsu
2019-12-04  7:06 ` Peter Chen [this message]
2019-12-06  2:24   ` EJ Hsu
2019-12-06  2:36     ` Peter Chen

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191204070646.GA25122@b29397-desktop \
    --to=peter.chen@nxp.com \
    --cc=balbi@kernel.org \
    --cc=ejh@nvidia.com \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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