usb: gadget: use config_ep_by_speed() instead of ep_choose()
Remove obsolete functions:
1. ep_choose()
2. usb_find_endpoint()
Signed-off-by: Tatyana Brokhman <tlinder@codeaurora.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
[idos@codeaurora.org: Changed also the following files to
comply with this commit: f_accessory.c,f_adb.c,f_diag.c,f_mtp.c,
f_rmnet.c,f_rmnet_sdio,f_rmnet_smd,f_rmnet_smd_sdio,f_serial.f_ccid.c.
Also merged a patch in f_serial.c for checking return value of
config_ep_by_speed, see "usb: gadget: fix g_serial regression".
Also fix a bug in ci13xxx_udc. Since f_serial is now checking if the endpoint
descriptors are null in the set_alt function, need to set them to null on
ep_disable in case of cable disconnect. Since the ep descriptor was inserted to
struct usb_ep in "usb: gadget: add usb_endpoint_descriptor to struct usb_ep",
also set mEp->ep.desc to NULL. I have upstream this to the community, please
see "usb: gadget: Clear usb_endpoint_descriptor inside the struct usb_ep" in
the latest linux kernel.]
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
diff --git a/drivers/usb/gadget/f_serial.c b/drivers/usb/gadget/f_serial.c
index cc972ff..8d9f090 100644
--- a/drivers/usb/gadget/f_serial.c
+++ b/drivers/usb/gadget/f_serial.c
@@ -29,21 +29,12 @@
*/
#define GSERIAL_NO_PORTS 2
-struct gser_descs {
- struct usb_endpoint_descriptor *in;
- struct usb_endpoint_descriptor *out;
-#ifdef CONFIG_MODEM_SUPPORT
- struct usb_endpoint_descriptor *notify;
-#endif
-};
struct f_gser {
struct gserial port;
u8 data_id;
u8 port_num;
- struct gser_descs fs;
- struct gser_descs hs;
u8 online;
enum transport_type transport;
@@ -477,10 +468,15 @@
DBG(cdev, "reset generic ctl ttyGS%d\n", gser->port_num);
usb_ep_disable(gser->notify);
}
- gser->notify->desc = ep_choose(cdev->gadget,
- gser->hs.notify,
- gser->fs.notify);
+
+ if (!gser->notify->desc) {
+ if (config_ep_by_speed(cdev->gadget, f, gser->notify)) {
+ gser->notify->desc = NULL;
+ return -EINVAL;
+ }
+ }
rc = usb_ep_enable(gser->notify);
+
if (rc) {
ERROR(cdev, "can't enable %s, result %d\n",
gser->notify->name, rc);
@@ -492,13 +488,16 @@
if (gser->port.in->driver_data) {
DBG(cdev, "reset generic data ttyGS%d\n", gser->port_num);
gport_disconnect(gser);
- } else {
- DBG(cdev, "activate generic data ttyGS%d\n", gser->port_num);
}
- gser->port.in->desc = ep_choose(cdev->gadget,
- gser->hs.in, gser->fs.in);
- gser->port.out->desc = ep_choose(cdev->gadget,
- gser->hs.out, gser->fs.out);
+ if (!gser->port.in->desc || !gser->port.out->desc) {
+ DBG(cdev, "activate generic ttyGS%d\n", gser->port_num);
+ if (config_ep_by_speed(cdev->gadget, f, gser->port.in) ||
+ config_ep_by_speed(cdev->gadget, f, gser->port.out)) {
+ gser->port.in->desc = NULL;
+ gser->port.out->desc = NULL;
+ return -EINVAL;
+ }
+ }
gport_connect(gser);
@@ -743,16 +742,6 @@
if (!f->descriptors)
goto fail;
- gser->fs.in = usb_find_endpoint(gser_fs_function,
- f->descriptors, &gser_fs_in_desc);
- gser->fs.out = usb_find_endpoint(gser_fs_function,
- f->descriptors, &gser_fs_out_desc);
-#ifdef CONFIG_MODEM_SUPPORT
- gser->fs.notify = usb_find_endpoint(gser_fs_function,
- f->descriptors, &gser_fs_notify_desc);
-#endif
-
-
/* support all relevant hardware speeds... we expect that when
* hardware is dual speed, all bulk-capable endpoints work at
* both speeds
@@ -773,14 +762,6 @@
if (!f->hs_descriptors)
goto fail;
- gser->hs.in = usb_find_endpoint(gser_hs_function,
- f->hs_descriptors, &gser_hs_in_desc);
- gser->hs.out = usb_find_endpoint(gser_hs_function,
- f->hs_descriptors, &gser_hs_out_desc);
-#ifdef CONFIG_MODEM_SUPPORT
- gser->hs.notify = usb_find_endpoint(gser_hs_function,
- f->hs_descriptors, &gser_hs_notify_desc);
-#endif
}
DBG(cdev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n",