aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/f_serial.c')
-rw-r--r--drivers/usb/gadget/f_serial.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/drivers/usb/gadget/f_serial.c b/drivers/usb/gadget/f_serial.c
index a9ce6261d15..91fdf790ed2 100644
--- a/drivers/usb/gadget/f_serial.c
+++ b/drivers/usb/gadget/f_serial.c
@@ -27,18 +27,10 @@
27 * if you can arrange appropriate host side drivers. 27 * if you can arrange appropriate host side drivers.
28 */ 28 */
29 29
30struct gser_descs {
31 struct usb_endpoint_descriptor *in;
32 struct usb_endpoint_descriptor *out;
33};
34
35struct f_gser { 30struct f_gser {
36 struct gserial port; 31 struct gserial port;
37 u8 data_id; 32 u8 data_id;
38 u8 port_num; 33 u8 port_num;
39
40 struct gser_descs fs;
41 struct gser_descs hs;
42}; 34};
43 35
44static inline struct f_gser *func_to_gser(struct usb_function *f) 36static inline struct f_gser *func_to_gser(struct usb_function *f)
@@ -136,12 +128,15 @@ static int gser_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
136 if (gser->port.in->driver_data) { 128 if (gser->port.in->driver_data) {
137 DBG(cdev, "reset generic ttyGS%d\n", gser->port_num); 129 DBG(cdev, "reset generic ttyGS%d\n", gser->port_num);
138 gserial_disconnect(&gser->port); 130 gserial_disconnect(&gser->port);
139 } else { 131 }
132 if (!gser->port.in->desc || !gser->port.out->desc) {
140 DBG(cdev, "activate generic ttyGS%d\n", gser->port_num); 133 DBG(cdev, "activate generic ttyGS%d\n", gser->port_num);
141 gser->port.in->desc = ep_choose(cdev->gadget, 134 if (!config_ep_by_speed(cdev->gadget, f, gser->port.in) ||
142 gser->hs.in, gser->fs.in); 135 !config_ep_by_speed(cdev->gadget, f, gser->port.out)) {
143 gser->port.out->desc = ep_choose(cdev->gadget, 136 gser->port.in->desc = NULL;
144 gser->hs.out, gser->fs.out); 137 gser->port.out->desc = NULL;
138 return -EINVAL;
139 }
145 } 140 }
146 gserial_connect(&gser->port, gser->port_num); 141 gserial_connect(&gser->port, gser->port_num);
147 return 0; 142 return 0;
@@ -193,12 +188,6 @@ gser_bind(struct usb_configuration *c, struct usb_function *f)
193 /* copy descriptors, and track endpoint copies */ 188 /* copy descriptors, and track endpoint copies */
194 f->descriptors = usb_copy_descriptors(gser_fs_function); 189 f->descriptors = usb_copy_descriptors(gser_fs_function);
195 190
196 gser->fs.in = usb_find_endpoint(gser_fs_function,
197 f->descriptors, &gser_fs_in_desc);
198 gser->fs.out = usb_find_endpoint(gser_fs_function,
199 f->descriptors, &gser_fs_out_desc);
200
201
202 /* support all relevant hardware speeds... we expect that when 191 /* support all relevant hardware speeds... we expect that when
203 * hardware is dual speed, all bulk-capable endpoints work at 192 * hardware is dual speed, all bulk-capable endpoints work at
204 * both speeds 193 * both speeds
@@ -211,11 +200,6 @@ gser_bind(struct usb_configuration *c, struct usb_function *f)
211 200
212 /* copy descriptors, and track endpoint copies */ 201 /* copy descriptors, and track endpoint copies */
213 f->hs_descriptors = usb_copy_descriptors(gser_hs_function); 202 f->hs_descriptors = usb_copy_descriptors(gser_hs_function);
214
215 gser->hs.in = usb_find_endpoint(gser_hs_function,
216 f->hs_descriptors, &gser_hs_in_desc);
217 gser->hs.out = usb_find_endpoint(gser_hs_function,
218 f->hs_descriptors, &gser_hs_out_desc);
219 } 203 }
220 204
221 DBG(cdev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n", 205 DBG(cdev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n",