From: Henry Lin <henryl@nvidia.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Henry Lin <henryl@nvidia.com>, Felipe Balbi <balbi@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
Romain Izard <romain.izard.pro@gmail.com>,
<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH] usb: gadget: f_ncm: fix wrong usb_ep
Date: Thu, 21 Nov 2019 12:18:57 +0800 [thread overview]
Message-ID: <20191121041858.15746-1-henryl@nvidia.com> (raw)
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: Henry Lin <henryl@nvidia.com>
---
drivers/usb/gadget/function/f_ncm.c | 28 ++++++++++++----------------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
index 2d6e76e4cffa..420b9c96f2fe 100644
--- a/drivers/usb/gadget/function/f_ncm.c
+++ b/drivers/usb/gadget/function/f_ncm.c
@@ -870,11 +870,10 @@ static int ncm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
DBG(cdev, "reset ncm control %d\n", intf);
usb_ep_disable(ncm->notify);
- if (!(ncm->notify->desc)) {
- DBG(cdev, "init ncm ctrl %d\n", intf);
- if (config_ep_by_speed(cdev->gadget, f, ncm->notify))
- goto fail;
- }
+ DBG(cdev, "init ncm ctrl %d\n", intf);
+ if (config_ep_by_speed(cdev->gadget, f, ncm->notify))
+ goto fail;
+
usb_ep_enable(ncm->notify);
/* Data interface has two altsettings, 0 and 1 */
@@ -897,17 +896,14 @@ static int ncm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
if (alt == 1) {
struct net_device *net;
- if (!ncm->port.in_ep->desc ||
- !ncm->port.out_ep->desc) {
- DBG(cdev, "init ncm\n");
- if (config_ep_by_speed(cdev->gadget, f,
- ncm->port.in_ep) ||
- config_ep_by_speed(cdev->gadget, f,
- ncm->port.out_ep)) {
- ncm->port.in_ep->desc = NULL;
- ncm->port.out_ep->desc = NULL;
- goto fail;
- }
+ DBG(cdev, "init ncm\n");
+ if (config_ep_by_speed(cdev->gadget, f,
+ ncm->port.in_ep) ||
+ config_ep_by_speed(cdev->gadget, f,
+ ncm->port.out_ep)) {
+ ncm->port.in_ep->desc = NULL;
+ ncm->port.out_ep->desc = NULL;
+ goto fail;
}
/* TODO */
--
2.17.1
next reply other threads:[~2019-11-21 4:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-21 4:18 Henry Lin [this message]
2019-11-25 4:20 ` [PATCH] usb: gadget: f_ncm: fix wrong usb_ep Peter Chen
2019-11-26 7:26 ` Henry Lin
2019-11-26 7:55 ` Peter Chen
2019-11-26 10:03 ` Henry Lin
2019-11-27 1:54 ` Peter Chen
2019-11-28 9:21 ` Henry Lin
2019-11-28 9:28 ` Peter Chen
Reply instructions:
You may reply publicly 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=20191121041858.15746-1-henryl@nvidia.com \
--to=henryl@nvidia.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=romain.izard.pro@gmail.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).