blob: 7b6acc622e5ac8b49924e5f73a146358fd2bb38a [file] [log] [blame]
David Brownell61d8bae2008-06-19 18:18:50 -07001/*
2 * f_serial.c - generic USB serial function driver
3 *
4 * Copyright (C) 2003 Al Borchers (alborchers@steinerpoint.com)
5 * Copyright (C) 2008 by David Brownell
6 * Copyright (C) 2008 by Nokia Corporation
7 *
8 * This software is distributed under the terms of the GNU General
9 * Public License ("GPL") as published by the Free Software Foundation,
10 * either version 2 of that License or (at your option) any later version.
11 */
12
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090013#include <linux/slab.h>
David Brownell61d8bae2008-06-19 18:18:50 -070014#include <linux/kernel.h>
15#include <linux/device.h>
Hemant Kumarbffd4142011-11-03 13:20:40 -070016#include <mach/usb_gadget_xport.h>
David Brownell61d8bae2008-06-19 18:18:50 -070017
18#include "u_serial.h"
19#include "gadget_chips.h"
20
21
22/*
23 * This function packages a simple "generic serial" port with no real
24 * control mechanisms, just raw data transfer over two bulk endpoints.
25 *
26 * Because it's not standardized, this isn't as interoperable as the
27 * CDC ACM driver. However, for many purposes it's just as functional
28 * if you can arrange appropriate host side drivers.
29 */
Vijayavardhan Vennapusaeb8d2392012-04-03 18:58:49 +053030#define GSERIAL_NO_PORTS 3
David Brownell61d8bae2008-06-19 18:18:50 -070031
David Brownell61d8bae2008-06-19 18:18:50 -070032struct f_gser {
33 struct gserial port;
34 u8 data_id;
35 u8 port_num;
36
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070037 u8 online;
38 enum transport_type transport;
39
40#ifdef CONFIG_MODEM_SUPPORT
41 u8 pending;
42 spinlock_t lock;
43 struct usb_ep *notify;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070044 struct usb_request *notify_req;
45
46 struct usb_cdc_line_coding port_line_coding;
47
48 /* SetControlLineState request */
49 u16 port_handshake_bits;
50#define ACM_CTRL_RTS (1 << 1) /* unused with full duplex */
51#define ACM_CTRL_DTR (1 << 0) /* host is ready for data r/w */
52
53 /* SerialState notification */
54 u16 serial_state;
55#define ACM_CTRL_OVERRUN (1 << 6)
56#define ACM_CTRL_PARITY (1 << 5)
57#define ACM_CTRL_FRAMING (1 << 4)
58#define ACM_CTRL_RI (1 << 3)
59#define ACM_CTRL_BRK (1 << 2)
60#define ACM_CTRL_DSR (1 << 1)
61#define ACM_CTRL_DCD (1 << 0)
62#endif
David Brownell61d8bae2008-06-19 18:18:50 -070063};
64
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070065static unsigned int no_tty_ports;
66static unsigned int no_sdio_ports;
67static unsigned int no_smd_ports;
Jack Pham427f6922011-11-23 19:42:00 -080068static unsigned int no_hsic_sports;
Vijayavardhan Vennapusaeb8d2392012-04-03 18:58:49 +053069static unsigned int no_hsuart_sports;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070070static unsigned int nr_ports;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070071
72static struct port_info {
73 enum transport_type transport;
74 unsigned port_num;
75 unsigned client_port_num;
76} gserial_ports[GSERIAL_NO_PORTS];
77
78static inline bool is_transport_sdio(enum transport_type t)
79{
Hemant Kumarbffd4142011-11-03 13:20:40 -070080 if (t == USB_GADGET_XPORT_SDIO)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070081 return 1;
82 return 0;
83}
84
David Brownell61d8bae2008-06-19 18:18:50 -070085static inline struct f_gser *func_to_gser(struct usb_function *f)
86{
87 return container_of(f, struct f_gser, port.func);
88}
89
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070090#ifdef CONFIG_MODEM_SUPPORT
91static inline struct f_gser *port_to_gser(struct gserial *p)
92{
93 return container_of(p, struct f_gser, port);
94}
95#define GS_LOG2_NOTIFY_INTERVAL 5 /* 1 << 5 == 32 msec */
96#define GS_NOTIFY_MAXPACKET 10 /* notification + 2 bytes */
97#endif
David Brownell61d8bae2008-06-19 18:18:50 -070098/*-------------------------------------------------------------------------*/
99
100/* interface descriptor: */
101
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700102static struct usb_interface_descriptor gser_interface_desc = {
David Brownell61d8bae2008-06-19 18:18:50 -0700103 .bLength = USB_DT_INTERFACE_SIZE,
104 .bDescriptorType = USB_DT_INTERFACE,
105 /* .bInterfaceNumber = DYNAMIC */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700106#ifdef CONFIG_MODEM_SUPPORT
107 .bNumEndpoints = 3,
108#else
David Brownell61d8bae2008-06-19 18:18:50 -0700109 .bNumEndpoints = 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700110#endif
David Brownell61d8bae2008-06-19 18:18:50 -0700111 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
112 .bInterfaceSubClass = 0,
113 .bInterfaceProtocol = 0,
114 /* .iInterface = DYNAMIC */
115};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700116#ifdef CONFIG_MODEM_SUPPORT
117static struct usb_cdc_header_desc gser_header_desc = {
118 .bLength = sizeof(gser_header_desc),
119 .bDescriptorType = USB_DT_CS_INTERFACE,
120 .bDescriptorSubType = USB_CDC_HEADER_TYPE,
121 .bcdCDC = __constant_cpu_to_le16(0x0110),
122};
David Brownell61d8bae2008-06-19 18:18:50 -0700123
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700124static struct usb_cdc_call_mgmt_descriptor
125gser_call_mgmt_descriptor = {
126 .bLength = sizeof(gser_call_mgmt_descriptor),
127 .bDescriptorType = USB_DT_CS_INTERFACE,
128 .bDescriptorSubType = USB_CDC_CALL_MANAGEMENT_TYPE,
129 .bmCapabilities = 0,
130 /* .bDataInterface = DYNAMIC */
131};
132
133static struct usb_cdc_acm_descriptor gser_descriptor = {
134 .bLength = sizeof(gser_descriptor),
135 .bDescriptorType = USB_DT_CS_INTERFACE,
136 .bDescriptorSubType = USB_CDC_ACM_TYPE,
137 .bmCapabilities = USB_CDC_CAP_LINE,
138};
139
140static struct usb_cdc_union_desc gser_union_desc = {
141 .bLength = sizeof(gser_union_desc),
142 .bDescriptorType = USB_DT_CS_INTERFACE,
143 .bDescriptorSubType = USB_CDC_UNION_TYPE,
144 /* .bMasterInterface0 = DYNAMIC */
145 /* .bSlaveInterface0 = DYNAMIC */
146};
147#endif
David Brownell61d8bae2008-06-19 18:18:50 -0700148/* full speed support: */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700149#ifdef CONFIG_MODEM_SUPPORT
150static struct usb_endpoint_descriptor gser_fs_notify_desc = {
151 .bLength = USB_DT_ENDPOINT_SIZE,
152 .bDescriptorType = USB_DT_ENDPOINT,
153 .bEndpointAddress = USB_DIR_IN,
154 .bmAttributes = USB_ENDPOINT_XFER_INT,
155 .wMaxPacketSize = __constant_cpu_to_le16(GS_NOTIFY_MAXPACKET),
156 .bInterval = 1 << GS_LOG2_NOTIFY_INTERVAL,
157};
158#endif
David Brownell61d8bae2008-06-19 18:18:50 -0700159
Manu Gautama4d993f2011-08-30 18:25:55 +0530160static struct usb_endpoint_descriptor gser_fs_in_desc = {
David Brownell61d8bae2008-06-19 18:18:50 -0700161 .bLength = USB_DT_ENDPOINT_SIZE,
162 .bDescriptorType = USB_DT_ENDPOINT,
163 .bEndpointAddress = USB_DIR_IN,
164 .bmAttributes = USB_ENDPOINT_XFER_BULK,
165};
166
Manu Gautama4d993f2011-08-30 18:25:55 +0530167static struct usb_endpoint_descriptor gser_fs_out_desc = {
David Brownell61d8bae2008-06-19 18:18:50 -0700168 .bLength = USB_DT_ENDPOINT_SIZE,
169 .bDescriptorType = USB_DT_ENDPOINT,
170 .bEndpointAddress = USB_DIR_OUT,
171 .bmAttributes = USB_ENDPOINT_XFER_BULK,
172};
173
Manu Gautama4d993f2011-08-30 18:25:55 +0530174static struct usb_descriptor_header *gser_fs_function[] = {
David Brownell61d8bae2008-06-19 18:18:50 -0700175 (struct usb_descriptor_header *) &gser_interface_desc,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700176#ifdef CONFIG_MODEM_SUPPORT
177 (struct usb_descriptor_header *) &gser_header_desc,
178 (struct usb_descriptor_header *) &gser_call_mgmt_descriptor,
179 (struct usb_descriptor_header *) &gser_descriptor,
180 (struct usb_descriptor_header *) &gser_union_desc,
181 (struct usb_descriptor_header *) &gser_fs_notify_desc,
182#endif
David Brownell61d8bae2008-06-19 18:18:50 -0700183 (struct usb_descriptor_header *) &gser_fs_in_desc,
184 (struct usb_descriptor_header *) &gser_fs_out_desc,
185 NULL,
186};
187
188/* high speed support: */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700189#ifdef CONFIG_MODEM_SUPPORT
190static struct usb_endpoint_descriptor gser_hs_notify_desc = {
191 .bLength = USB_DT_ENDPOINT_SIZE,
192 .bDescriptorType = USB_DT_ENDPOINT,
193 .bEndpointAddress = USB_DIR_IN,
194 .bmAttributes = USB_ENDPOINT_XFER_INT,
195 .wMaxPacketSize = __constant_cpu_to_le16(GS_NOTIFY_MAXPACKET),
196 .bInterval = GS_LOG2_NOTIFY_INTERVAL+4,
197};
198#endif
David Brownell61d8bae2008-06-19 18:18:50 -0700199
Manu Gautama4d993f2011-08-30 18:25:55 +0530200static struct usb_endpoint_descriptor gser_hs_in_desc = {
David Brownell61d8bae2008-06-19 18:18:50 -0700201 .bLength = USB_DT_ENDPOINT_SIZE,
202 .bDescriptorType = USB_DT_ENDPOINT,
203 .bmAttributes = USB_ENDPOINT_XFER_BULK,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700204 .wMaxPacketSize = __constant_cpu_to_le16(512),
David Brownell61d8bae2008-06-19 18:18:50 -0700205};
206
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700207static struct usb_endpoint_descriptor gser_hs_out_desc = {
David Brownell61d8bae2008-06-19 18:18:50 -0700208 .bLength = USB_DT_ENDPOINT_SIZE,
209 .bDescriptorType = USB_DT_ENDPOINT,
210 .bmAttributes = USB_ENDPOINT_XFER_BULK,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700211 .wMaxPacketSize = __constant_cpu_to_le16(512),
David Brownell61d8bae2008-06-19 18:18:50 -0700212};
213
Manu Gautama4d993f2011-08-30 18:25:55 +0530214static struct usb_descriptor_header *gser_hs_function[] = {
David Brownell61d8bae2008-06-19 18:18:50 -0700215 (struct usb_descriptor_header *) &gser_interface_desc,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700216#ifdef CONFIG_MODEM_SUPPORT
217 (struct usb_descriptor_header *) &gser_header_desc,
218 (struct usb_descriptor_header *) &gser_call_mgmt_descriptor,
219 (struct usb_descriptor_header *) &gser_descriptor,
220 (struct usb_descriptor_header *) &gser_union_desc,
221 (struct usb_descriptor_header *) &gser_hs_notify_desc,
222#endif
David Brownell61d8bae2008-06-19 18:18:50 -0700223 (struct usb_descriptor_header *) &gser_hs_in_desc,
224 (struct usb_descriptor_header *) &gser_hs_out_desc,
225 NULL,
226};
227
Sebastian Andrzej Siewior6fecfb02012-02-06 18:46:36 +0100228static struct usb_endpoint_descriptor gser_ss_in_desc __initdata = {
229 .bLength = USB_DT_ENDPOINT_SIZE,
230 .bDescriptorType = USB_DT_ENDPOINT,
231 .bmAttributes = USB_ENDPOINT_XFER_BULK,
232 .wMaxPacketSize = cpu_to_le16(1024),
233};
234
235static struct usb_endpoint_descriptor gser_ss_out_desc __initdata = {
236 .bLength = USB_DT_ENDPOINT_SIZE,
237 .bDescriptorType = USB_DT_ENDPOINT,
238 .bmAttributes = USB_ENDPOINT_XFER_BULK,
239 .wMaxPacketSize = cpu_to_le16(1024),
240};
241
242static struct usb_ss_ep_comp_descriptor gser_ss_bulk_comp_desc __initdata = {
243 .bLength = sizeof gser_ss_bulk_comp_desc,
244 .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
245};
246
247static struct usb_descriptor_header *gser_ss_function[] __initdata = {
248 (struct usb_descriptor_header *) &gser_interface_desc,
249 (struct usb_descriptor_header *) &gser_ss_in_desc,
250 (struct usb_descriptor_header *) &gser_ss_bulk_comp_desc,
251 (struct usb_descriptor_header *) &gser_ss_out_desc,
252 (struct usb_descriptor_header *) &gser_ss_bulk_comp_desc,
253 NULL,
254};
255
David Brownell61d8bae2008-06-19 18:18:50 -0700256/* string descriptors: */
257
258static struct usb_string gser_string_defs[] = {
259 [0].s = "Generic Serial",
260 { } /* end of list */
261};
262
263static struct usb_gadget_strings gser_string_table = {
264 .language = 0x0409, /* en-us */
265 .strings = gser_string_defs,
266};
267
268static struct usb_gadget_strings *gser_strings[] = {
269 &gser_string_table,
270 NULL,
271};
272
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700273static int gport_setup(struct usb_configuration *c)
274{
275 int ret = 0;
Jack Pham427f6922011-11-23 19:42:00 -0800276 int port_idx;
277 int i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700278
Jack Pham427f6922011-11-23 19:42:00 -0800279 pr_debug("%s: no_tty_ports: %u no_sdio_ports: %u"
Vijayavardhan Vennapusaeb8d2392012-04-03 18:58:49 +0530280 " no_smd_ports: %u no_hsic_sports: %u no_hsuart_ports: %u nr_ports: %u\n",
Jack Pham427f6922011-11-23 19:42:00 -0800281 __func__, no_tty_ports, no_sdio_ports, no_smd_ports,
Vijayavardhan Vennapusaeb8d2392012-04-03 18:58:49 +0530282 no_hsic_sports, no_hsuart_sports, nr_ports);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700283
284 if (no_tty_ports)
285 ret = gserial_setup(c->cdev->gadget, no_tty_ports);
286 if (no_sdio_ports)
287 ret = gsdio_setup(c->cdev->gadget, no_sdio_ports);
288 if (no_smd_ports)
289 ret = gsmd_setup(c->cdev->gadget, no_smd_ports);
Jack Pham427f6922011-11-23 19:42:00 -0800290 if (no_hsic_sports) {
291 port_idx = ghsic_data_setup(no_hsic_sports, USB_GADGET_SERIAL);
292 if (port_idx < 0)
293 return port_idx;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700294
Jack Pham427f6922011-11-23 19:42:00 -0800295 for (i = 0; i < nr_ports; i++) {
296 if (gserial_ports[i].transport ==
297 USB_GADGET_XPORT_HSIC) {
298 gserial_ports[i].client_port_num = port_idx;
299 port_idx++;
300 }
301 }
302
303 /*clinet port num is same for data setup and ctrl setup*/
304 ret = ghsic_ctrl_setup(no_hsic_sports, USB_GADGET_SERIAL);
305 if (ret < 0)
306 return ret;
307 return 0;
308 }
Vijayavardhan Vennapusaeb8d2392012-04-03 18:58:49 +0530309 if (no_hsuart_sports) {
310 port_idx = ghsuart_data_setup(no_hsuart_sports,
311 USB_GADGET_SERIAL);
312 if (port_idx < 0)
313 return port_idx;
314
315 for (i = 0; i < nr_ports; i++) {
316 if (gserial_ports[i].transport ==
317 USB_GADGET_XPORT_HSUART) {
318 gserial_ports[i].client_port_num = port_idx;
319 port_idx++;
320 }
321 }
322
323 return 0;
324 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700325 return ret;
326}
Manu Gautama4d993f2011-08-30 18:25:55 +0530327
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700328static int gport_connect(struct f_gser *gser)
329{
Jack Pham427f6922011-11-23 19:42:00 -0800330 unsigned port_num;
331 int ret;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700332
Jack Pham427f6922011-11-23 19:42:00 -0800333 pr_debug("%s: transport: %s f_gser: %p gserial: %p port_num: %d\n",
Hemant Kumar1b820d52011-11-03 15:08:28 -0700334 __func__, xport_to_str(gser->transport),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700335 gser, &gser->port, gser->port_num);
336
337 port_num = gserial_ports[gser->port_num].client_port_num;
338
339 switch (gser->transport) {
Hemant Kumarbffd4142011-11-03 13:20:40 -0700340 case USB_GADGET_XPORT_TTY:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700341 gserial_connect(&gser->port, port_num);
342 break;
Hemant Kumarbffd4142011-11-03 13:20:40 -0700343 case USB_GADGET_XPORT_SDIO:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700344 gsdio_connect(&gser->port, port_num);
345 break;
Hemant Kumarbffd4142011-11-03 13:20:40 -0700346 case USB_GADGET_XPORT_SMD:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700347 gsmd_connect(&gser->port, port_num);
348 break;
Jack Pham427f6922011-11-23 19:42:00 -0800349 case USB_GADGET_XPORT_HSIC:
350 ret = ghsic_ctrl_connect(&gser->port, port_num);
351 if (ret) {
352 pr_err("%s: ghsic_ctrl_connect failed: err:%d\n",
353 __func__, ret);
354 return ret;
355 }
356 ret = ghsic_data_connect(&gser->port, port_num);
357 if (ret) {
358 pr_err("%s: ghsic_data_connect failed: err:%d\n",
359 __func__, ret);
360 ghsic_ctrl_disconnect(&gser->port, port_num);
361 return ret;
362 }
363 break;
Vijayavardhan Vennapusaeb8d2392012-04-03 18:58:49 +0530364 case USB_GADGET_XPORT_HSUART:
365 ret = ghsuart_data_connect(&gser->port, port_num);
366 if (ret) {
367 pr_err("%s: ghsuart_data_connect failed: err:%d\n",
368 __func__, ret);
369 return ret;
370 }
371 break;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700372 default:
373 pr_err("%s: Un-supported transport: %s\n", __func__,
Hemant Kumar1b820d52011-11-03 15:08:28 -0700374 xport_to_str(gser->transport));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700375 return -ENODEV;
376 }
377
378 return 0;
379}
380
381static int gport_disconnect(struct f_gser *gser)
382{
383 unsigned port_num;
384
Jack Pham427f6922011-11-23 19:42:00 -0800385 pr_debug("%s: transport: %s f_gser: %p gserial: %p port_num: %d\n",
Hemant Kumar1b820d52011-11-03 15:08:28 -0700386 __func__, xport_to_str(gser->transport),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700387 gser, &gser->port, gser->port_num);
388
389 port_num = gserial_ports[gser->port_num].client_port_num;
390
391 switch (gser->transport) {
Hemant Kumarbffd4142011-11-03 13:20:40 -0700392 case USB_GADGET_XPORT_TTY:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700393 gserial_disconnect(&gser->port);
394 break;
Hemant Kumarbffd4142011-11-03 13:20:40 -0700395 case USB_GADGET_XPORT_SDIO:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700396 gsdio_disconnect(&gser->port, port_num);
397 break;
Hemant Kumarbffd4142011-11-03 13:20:40 -0700398 case USB_GADGET_XPORT_SMD:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700399 gsmd_disconnect(&gser->port, port_num);
400 break;
Jack Pham427f6922011-11-23 19:42:00 -0800401 case USB_GADGET_XPORT_HSIC:
402 ghsic_ctrl_disconnect(&gser->port, port_num);
403 ghsic_data_disconnect(&gser->port, port_num);
404 break;
Vijayavardhan Vennapusaeb8d2392012-04-03 18:58:49 +0530405 case USB_GADGET_XPORT_HSUART:
406 ghsuart_data_disconnect(&gser->port, port_num);
407 break;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700408 default:
409 pr_err("%s: Un-supported transport:%s\n", __func__,
Hemant Kumar1b820d52011-11-03 15:08:28 -0700410 xport_to_str(gser->transport));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700411 return -ENODEV;
412 }
413
414 return 0;
415}
416
417#ifdef CONFIG_MODEM_SUPPORT
418static void gser_complete_set_line_coding(struct usb_ep *ep,
419 struct usb_request *req)
420{
421 struct f_gser *gser = ep->driver_data;
422 struct usb_composite_dev *cdev = gser->port.func.config->cdev;
423
424 if (req->status != 0) {
425 DBG(cdev, "gser ttyGS%d completion, err %d\n",
426 gser->port_num, req->status);
427 return;
428 }
429
430 /* normal completion */
431 if (req->actual != sizeof(gser->port_line_coding)) {
432 DBG(cdev, "gser ttyGS%d short resp, len %d\n",
433 gser->port_num, req->actual);
434 usb_ep_set_halt(ep);
435 } else {
436 struct usb_cdc_line_coding *value = req->buf;
437 gser->port_line_coding = *value;
438 }
439}
David Brownell61d8bae2008-06-19 18:18:50 -0700440/*-------------------------------------------------------------------------*/
441
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700442static int
443gser_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
444{
445 struct f_gser *gser = func_to_gser(f);
446 struct usb_composite_dev *cdev = f->config->cdev;
447 struct usb_request *req = cdev->req;
448 int value = -EOPNOTSUPP;
449 u16 w_index = le16_to_cpu(ctrl->wIndex);
450 u16 w_value = le16_to_cpu(ctrl->wValue);
451 u16 w_length = le16_to_cpu(ctrl->wLength);
452
453 switch ((ctrl->bRequestType << 8) | ctrl->bRequest) {
454
455 /* SET_LINE_CODING ... just read and save what the host sends */
456 case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8)
457 | USB_CDC_REQ_SET_LINE_CODING:
458 if (w_length != sizeof(struct usb_cdc_line_coding))
459 goto invalid;
460
461 value = w_length;
462 cdev->gadget->ep0->driver_data = gser;
463 req->complete = gser_complete_set_line_coding;
464 break;
465
466 /* GET_LINE_CODING ... return what host sent, or initial value */
467 case ((USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8)
468 | USB_CDC_REQ_GET_LINE_CODING:
469 value = min_t(unsigned, w_length,
470 sizeof(struct usb_cdc_line_coding));
471 memcpy(req->buf, &gser->port_line_coding, value);
472 break;
473
474 /* SET_CONTROL_LINE_STATE ... save what the host sent */
475 case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8)
476 | USB_CDC_REQ_SET_CONTROL_LINE_STATE:
477
478 value = 0;
479 gser->port_handshake_bits = w_value;
480 if (gser->port.notify_modem) {
481 unsigned port_num =
482 gserial_ports[gser->port_num].client_port_num;
483
484 gser->port.notify_modem(&gser->port,
485 port_num, w_value);
486 }
487 break;
488
489 default:
490invalid:
491 DBG(cdev, "invalid control req%02x.%02x v%04x i%04x l%d\n",
492 ctrl->bRequestType, ctrl->bRequest,
493 w_value, w_index, w_length);
494 }
495
496 /* respond with data transfer or status phase? */
497 if (value >= 0) {
498 DBG(cdev, "gser ttyGS%d req%02x.%02x v%04x i%04x l%d\n",
499 gser->port_num, ctrl->bRequestType, ctrl->bRequest,
500 w_value, w_index, w_length);
501 req->zero = 0;
502 req->length = value;
503 value = usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC);
504 if (value < 0)
505 ERROR(cdev, "gser response on ttyGS%d, err %d\n",
506 gser->port_num, value);
507 }
508
509 /* device either stalls (value < 0) or reports success */
510 return value;
511}
512#endif
David Brownell61d8bae2008-06-19 18:18:50 -0700513static int gser_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
514{
515 struct f_gser *gser = func_to_gser(f);
516 struct usb_composite_dev *cdev = f->config->cdev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700517 int rc = 0;
David Brownell61d8bae2008-06-19 18:18:50 -0700518
519 /* we know alt == 0, so this is an activation or a reset */
520
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700521#ifdef CONFIG_MODEM_SUPPORT
522 if (gser->notify->driver_data) {
523 DBG(cdev, "reset generic ctl ttyGS%d\n", gser->port_num);
524 usb_ep_disable(gser->notify);
David Brownell61d8bae2008-06-19 18:18:50 -0700525 }
Tatyana Brokhman31ac3522011-06-28 15:33:50 +0200526
527 if (!gser->notify->desc) {
528 if (config_ep_by_speed(cdev->gadget, f, gser->notify)) {
529 gser->notify->desc = NULL;
530 return -EINVAL;
531 }
532 }
Tatyana Brokhmancf709c12011-06-28 16:33:48 +0300533 rc = usb_ep_enable(gser->notify);
Tatyana Brokhman31ac3522011-06-28 15:33:50 +0200534
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700535 if (rc) {
536 ERROR(cdev, "can't enable %s, result %d\n",
537 gser->notify->name, rc);
538 return rc;
539 }
540 gser->notify->driver_data = gser;
541#endif
542
David Brownell61d8bae2008-06-19 18:18:50 -0700543 if (gser->port.in->driver_data) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700544 DBG(cdev, "reset generic data ttyGS%d\n", gser->port_num);
545 gport_disconnect(gser);
Tatyana Brokhmanea2a1df72011-06-28 16:33:50 +0300546 }
547 if (!gser->port.in->desc || !gser->port.out->desc) {
David Brownell61d8bae2008-06-19 18:18:50 -0700548 DBG(cdev, "activate generic ttyGS%d\n", gser->port_num);
Robert Jarzmikfef69642011-11-18 20:16:27 +0100549 if (config_ep_by_speed(cdev->gadget, f, gser->port.in) ||
550 config_ep_by_speed(cdev->gadget, f, gser->port.out)) {
Tatyana Brokhmanea2a1df72011-06-28 16:33:50 +0300551 gser->port.in->desc = NULL;
552 gser->port.out->desc = NULL;
553 return -EINVAL;
554 }
David Brownell61d8bae2008-06-19 18:18:50 -0700555 }
David Brownac5d1542012-02-06 10:37:22 -0800556
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700557 gport_connect(gser);
558
559 gser->online = 1;
560 return rc;
David Brownell61d8bae2008-06-19 18:18:50 -0700561}
562
563static void gser_disable(struct usb_function *f)
564{
565 struct f_gser *gser = func_to_gser(f);
566 struct usb_composite_dev *cdev = f->config->cdev;
567
568 DBG(cdev, "generic ttyGS%d deactivated\n", gser->port_num);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700569
570 gport_disconnect(gser);
571
572#ifdef CONFIG_MODEM_SUPPORT
573 usb_ep_fifo_flush(gser->notify);
574 usb_ep_disable(gser->notify);
575#endif
576 gser->online = 0;
577}
578#ifdef CONFIG_MODEM_SUPPORT
579static int gser_notify(struct f_gser *gser, u8 type, u16 value,
580 void *data, unsigned length)
581{
582 struct usb_ep *ep = gser->notify;
583 struct usb_request *req;
584 struct usb_cdc_notification *notify;
585 const unsigned len = sizeof(*notify) + length;
586 void *buf;
587 int status;
588 struct usb_composite_dev *cdev = gser->port.func.config->cdev;
589
590 req = gser->notify_req;
591 gser->notify_req = NULL;
592 gser->pending = false;
593
594 req->length = len;
595 notify = req->buf;
596 buf = notify + 1;
597
598 notify->bmRequestType = USB_DIR_IN | USB_TYPE_CLASS
599 | USB_RECIP_INTERFACE;
600 notify->bNotificationType = type;
601 notify->wValue = cpu_to_le16(value);
602 notify->wIndex = cpu_to_le16(gser->data_id);
603 notify->wLength = cpu_to_le16(length);
604 memcpy(buf, data, length);
605
606 status = usb_ep_queue(ep, req, GFP_ATOMIC);
607 if (status < 0) {
608 ERROR(cdev, "gser ttyGS%d can't notify serial state, %d\n",
609 gser->port_num, status);
610 gser->notify_req = req;
611 }
612
613 return status;
David Brownell61d8bae2008-06-19 18:18:50 -0700614}
615
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700616static int gser_notify_serial_state(struct f_gser *gser)
617{
618 int status;
619 unsigned long flags;
620 struct usb_composite_dev *cdev = gser->port.func.config->cdev;
621
622 spin_lock_irqsave(&gser->lock, flags);
623 if (gser->notify_req) {
624 DBG(cdev, "gser ttyGS%d serial state %04x\n",
625 gser->port_num, gser->serial_state);
626 status = gser_notify(gser, USB_CDC_NOTIFY_SERIAL_STATE,
627 0, &gser->serial_state,
628 sizeof(gser->serial_state));
629 } else {
630 gser->pending = true;
631 status = 0;
632 }
633 spin_unlock_irqrestore(&gser->lock, flags);
634 return status;
635}
636
637static void gser_notify_complete(struct usb_ep *ep, struct usb_request *req)
638{
639 struct f_gser *gser = req->context;
640 u8 doit = false;
641 unsigned long flags;
642
643 /* on this call path we do NOT hold the port spinlock,
644 * which is why ACM needs its own spinlock
645 */
646 spin_lock_irqsave(&gser->lock, flags);
647 if (req->status != -ESHUTDOWN)
648 doit = gser->pending;
649 gser->notify_req = req;
650 spin_unlock_irqrestore(&gser->lock, flags);
651
652 if (doit && gser->online)
653 gser_notify_serial_state(gser);
654}
655static void gser_connect(struct gserial *port)
656{
657 struct f_gser *gser = port_to_gser(port);
658
659 gser->serial_state |= ACM_CTRL_DSR | ACM_CTRL_DCD;
660 gser_notify_serial_state(gser);
661}
662
663unsigned int gser_get_dtr(struct gserial *port)
664{
665 struct f_gser *gser = port_to_gser(port);
666
667 if (gser->port_handshake_bits & ACM_CTRL_DTR)
668 return 1;
669 else
670 return 0;
671}
672
673unsigned int gser_get_rts(struct gserial *port)
674{
675 struct f_gser *gser = port_to_gser(port);
676
677 if (gser->port_handshake_bits & ACM_CTRL_RTS)
678 return 1;
679 else
680 return 0;
681}
682
683unsigned int gser_send_carrier_detect(struct gserial *port, unsigned int yes)
684{
685 struct f_gser *gser = port_to_gser(port);
686 u16 state;
687
688 state = gser->serial_state;
689 state &= ~ACM_CTRL_DCD;
690 if (yes)
691 state |= ACM_CTRL_DCD;
692
693 gser->serial_state = state;
694 return gser_notify_serial_state(gser);
695
696}
697
698unsigned int gser_send_ring_indicator(struct gserial *port, unsigned int yes)
699{
700 struct f_gser *gser = port_to_gser(port);
701 u16 state;
702
703 state = gser->serial_state;
704 state &= ~ACM_CTRL_RI;
705 if (yes)
706 state |= ACM_CTRL_RI;
707
708 gser->serial_state = state;
709 return gser_notify_serial_state(gser);
710
711}
712static void gser_disconnect(struct gserial *port)
713{
714 struct f_gser *gser = port_to_gser(port);
715
716 gser->serial_state &= ~(ACM_CTRL_DSR | ACM_CTRL_DCD);
717 gser_notify_serial_state(gser);
718}
719
720static int gser_send_break(struct gserial *port, int duration)
721{
722 struct f_gser *gser = port_to_gser(port);
723 u16 state;
724
725 state = gser->serial_state;
726 state &= ~ACM_CTRL_BRK;
727 if (duration)
728 state |= ACM_CTRL_BRK;
729
730 gser->serial_state = state;
731 return gser_notify_serial_state(gser);
732}
733
734static int gser_send_modem_ctrl_bits(struct gserial *port, int ctrl_bits)
735{
736 struct f_gser *gser = port_to_gser(port);
737
738 gser->serial_state = ctrl_bits;
739
740 return gser_notify_serial_state(gser);
741}
742#endif
David Brownell61d8bae2008-06-19 18:18:50 -0700743/*-------------------------------------------------------------------------*/
744
745/* serial function driver setup/binding */
746
Manu Gautama4d993f2011-08-30 18:25:55 +0530747static int
David Brownell61d8bae2008-06-19 18:18:50 -0700748gser_bind(struct usb_configuration *c, struct usb_function *f)
749{
750 struct usb_composite_dev *cdev = c->cdev;
751 struct f_gser *gser = func_to_gser(f);
752 int status;
753 struct usb_ep *ep;
754
755 /* allocate instance-specific interface IDs */
756 status = usb_interface_id(c, f);
757 if (status < 0)
758 goto fail;
759 gser->data_id = status;
760 gser_interface_desc.bInterfaceNumber = status;
761
762 status = -ENODEV;
763
764 /* allocate instance-specific endpoints */
765 ep = usb_ep_autoconfig(cdev->gadget, &gser_fs_in_desc);
766 if (!ep)
767 goto fail;
768 gser->port.in = ep;
769 ep->driver_data = cdev; /* claim */
770
771 ep = usb_ep_autoconfig(cdev->gadget, &gser_fs_out_desc);
772 if (!ep)
773 goto fail;
774 gser->port.out = ep;
775 ep->driver_data = cdev; /* claim */
776
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700777#ifdef CONFIG_MODEM_SUPPORT
778 ep = usb_ep_autoconfig(cdev->gadget, &gser_fs_notify_desc);
779 if (!ep)
780 goto fail;
781 gser->notify = ep;
782 ep->driver_data = cdev; /* claim */
783 /* allocate notification */
784 gser->notify_req = gs_alloc_req(ep,
785 sizeof(struct usb_cdc_notification) + 2,
786 GFP_KERNEL);
787 if (!gser->notify_req)
788 goto fail;
789
790 gser->notify_req->complete = gser_notify_complete;
791 gser->notify_req->context = gser;
792#endif
793
David Brownell61d8bae2008-06-19 18:18:50 -0700794 /* copy descriptors, and track endpoint copies */
795 f->descriptors = usb_copy_descriptors(gser_fs_function);
796
Pavankumar Kondetif0f95d82011-09-23 11:38:57 +0530797 if (!f->descriptors)
798 goto fail;
799
David Brownell61d8bae2008-06-19 18:18:50 -0700800 /* support all relevant hardware speeds... we expect that when
801 * hardware is dual speed, all bulk-capable endpoints work at
802 * both speeds
803 */
804 if (gadget_is_dualspeed(c->cdev->gadget)) {
805 gser_hs_in_desc.bEndpointAddress =
806 gser_fs_in_desc.bEndpointAddress;
807 gser_hs_out_desc.bEndpointAddress =
808 gser_fs_out_desc.bEndpointAddress;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700809#ifdef CONFIG_MODEM_SUPPORT
810 gser_hs_notify_desc.bEndpointAddress =
811 gser_fs_notify_desc.bEndpointAddress;
812#endif
David Brownell61d8bae2008-06-19 18:18:50 -0700813
814 /* copy descriptors, and track endpoint copies */
815 f->hs_descriptors = usb_copy_descriptors(gser_hs_function);
816
Pavankumar Kondetif0f95d82011-09-23 11:38:57 +0530817 if (!f->hs_descriptors)
818 goto fail;
819
David Brownell61d8bae2008-06-19 18:18:50 -0700820 }
Sebastian Andrzej Siewior6fecfb02012-02-06 18:46:36 +0100821 if (gadget_is_superspeed(c->cdev->gadget)) {
822 gser_ss_in_desc.bEndpointAddress =
823 gser_fs_in_desc.bEndpointAddress;
824 gser_ss_out_desc.bEndpointAddress =
825 gser_fs_out_desc.bEndpointAddress;
826
827 /* copy descriptors, and track endpoint copies */
828 f->ss_descriptors = usb_copy_descriptors(gser_ss_function);
829 if (!f->ss_descriptors)
830 goto fail;
831 }
David Brownell61d8bae2008-06-19 18:18:50 -0700832
833 DBG(cdev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n",
834 gser->port_num,
Sebastian Andrzej Siewior6fecfb02012-02-06 18:46:36 +0100835 gadget_is_superspeed(c->cdev->gadget) ? "super" :
David Brownell61d8bae2008-06-19 18:18:50 -0700836 gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full",
837 gser->port.in->name, gser->port.out->name);
838 return 0;
839
840fail:
Pavankumar Kondetif0f95d82011-09-23 11:38:57 +0530841 if (f->descriptors)
842 usb_free_descriptors(f->descriptors);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700843#ifdef CONFIG_MODEM_SUPPORT
844 if (gser->notify_req)
845 gs_free_req(gser->notify, gser->notify_req);
846
847 /* we might as well release our claims on endpoints */
848 if (gser->notify)
849 gser->notify->driver_data = NULL;
850#endif
David Brownell61d8bae2008-06-19 18:18:50 -0700851 /* we might as well release our claims on endpoints */
852 if (gser->port.out)
853 gser->port.out->driver_data = NULL;
854 if (gser->port.in)
855 gser->port.in->driver_data = NULL;
856
857 ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
858
859 return status;
860}
861
862static void
863gser_unbind(struct usb_configuration *c, struct usb_function *f)
864{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700865#ifdef CONFIG_MODEM_SUPPORT
866 struct f_gser *gser = func_to_gser(f);
867#endif
David Brownell61d8bae2008-06-19 18:18:50 -0700868 if (gadget_is_dualspeed(c->cdev->gadget))
869 usb_free_descriptors(f->hs_descriptors);
Sebastian Andrzej Siewior6fecfb02012-02-06 18:46:36 +0100870 if (gadget_is_superspeed(c->cdev->gadget))
871 usb_free_descriptors(f->ss_descriptors);
David Brownell61d8bae2008-06-19 18:18:50 -0700872 usb_free_descriptors(f->descriptors);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700873#ifdef CONFIG_MODEM_SUPPORT
874 gs_free_req(gser->notify, gser->notify_req);
875#endif
David Brownell61d8bae2008-06-19 18:18:50 -0700876 kfree(func_to_gser(f));
877}
878
879/**
880 * gser_bind_config - add a generic serial function to a configuration
881 * @c: the configuration to support the serial instance
882 * @port_num: /dev/ttyGS* port this interface will use
883 * Context: single threaded during gadget setup
884 *
885 * Returns zero on success, else negative errno.
886 *
887 * Caller must have called @gserial_setup() with enough ports to
888 * handle all the ones it binds. Caller is also responsible
889 * for calling @gserial_cleanup() before module unload.
890 */
Manu Gautama4d993f2011-08-30 18:25:55 +0530891int gser_bind_config(struct usb_configuration *c, u8 port_num)
David Brownell61d8bae2008-06-19 18:18:50 -0700892{
893 struct f_gser *gser;
894 int status;
895
896 /* REVISIT might want instance-specific strings to help
897 * distinguish instances ...
898 */
899
900 /* maybe allocate device-global string ID */
901 if (gser_string_defs[0].id == 0) {
902 status = usb_string_id(c->cdev);
903 if (status < 0)
904 return status;
905 gser_string_defs[0].id = status;
906 }
907
908 /* allocate and initialize one new instance */
909 gser = kzalloc(sizeof *gser, GFP_KERNEL);
910 if (!gser)
911 return -ENOMEM;
912
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700913#ifdef CONFIG_MODEM_SUPPORT
914 spin_lock_init(&gser->lock);
915#endif
David Brownell61d8bae2008-06-19 18:18:50 -0700916 gser->port_num = port_num;
917
918 gser->port.func.name = "gser";
919 gser->port.func.strings = gser_strings;
920 gser->port.func.bind = gser_bind;
921 gser->port.func.unbind = gser_unbind;
922 gser->port.func.set_alt = gser_set_alt;
923 gser->port.func.disable = gser_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700924 gser->transport = gserial_ports[port_num].transport;
925#ifdef CONFIG_MODEM_SUPPORT
Vijayavardhan Vennapusaeb8d2392012-04-03 18:58:49 +0530926 /* We support only three ports for now */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700927 if (port_num == 0)
928 gser->port.func.name = "modem";
Vijayavardhan Vennapusaeb8d2392012-04-03 18:58:49 +0530929 else if (port_num == 1)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700930 gser->port.func.name = "nmea";
Vijayavardhan Vennapusaeb8d2392012-04-03 18:58:49 +0530931 else
932 gser->port.func.name = "modem2";
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700933 gser->port.func.setup = gser_setup;
934 gser->port.connect = gser_connect;
935 gser->port.get_dtr = gser_get_dtr;
936 gser->port.get_rts = gser_get_rts;
937 gser->port.send_carrier_detect = gser_send_carrier_detect;
938 gser->port.send_ring_indicator = gser_send_ring_indicator;
939 gser->port.send_modem_ctrl_bits = gser_send_modem_ctrl_bits;
940 gser->port.disconnect = gser_disconnect;
941 gser->port.send_break = gser_send_break;
942#endif
David Brownell61d8bae2008-06-19 18:18:50 -0700943
944 status = usb_add_function(c, &gser->port.func);
945 if (status)
946 kfree(gser);
947 return status;
948}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700949
Manu Gautama4d993f2011-08-30 18:25:55 +0530950/**
951 * gserial_init_port - bind a gserial_port to its transport
952 */
953static int gserial_init_port(int port_num, const char *name)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700954{
Manu Gautama4d993f2011-08-30 18:25:55 +0530955 enum transport_type transport;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700956
Manu Gautama4d993f2011-08-30 18:25:55 +0530957 if (port_num >= GSERIAL_NO_PORTS)
958 return -ENODEV;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700959
Hemant Kumar1b820d52011-11-03 15:08:28 -0700960 transport = str_to_xport(name);
Manu Gautama4d993f2011-08-30 18:25:55 +0530961 pr_debug("%s, port:%d, transport:%s\n", __func__,
Jack Pham427f6922011-11-23 19:42:00 -0800962 port_num, xport_to_str(transport));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700963
Manu Gautama4d993f2011-08-30 18:25:55 +0530964 gserial_ports[port_num].transport = transport;
965 gserial_ports[port_num].port_num = port_num;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700966
Manu Gautama4d993f2011-08-30 18:25:55 +0530967 switch (transport) {
Hemant Kumarbffd4142011-11-03 13:20:40 -0700968 case USB_GADGET_XPORT_TTY:
Manu Gautama4d993f2011-08-30 18:25:55 +0530969 gserial_ports[port_num].client_port_num = no_tty_ports;
970 no_tty_ports++;
971 break;
Hemant Kumarbffd4142011-11-03 13:20:40 -0700972 case USB_GADGET_XPORT_SDIO:
Manu Gautama4d993f2011-08-30 18:25:55 +0530973 gserial_ports[port_num].client_port_num = no_sdio_ports;
974 no_sdio_ports++;
975 break;
Hemant Kumarbffd4142011-11-03 13:20:40 -0700976 case USB_GADGET_XPORT_SMD:
Manu Gautama4d993f2011-08-30 18:25:55 +0530977 gserial_ports[port_num].client_port_num = no_smd_ports;
978 no_smd_ports++;
979 break;
Jack Pham427f6922011-11-23 19:42:00 -0800980 case USB_GADGET_XPORT_HSIC:
981 /*client port number will be updated in gport_setup*/
982 no_hsic_sports++;
983 break;
Vijayavardhan Vennapusaeb8d2392012-04-03 18:58:49 +0530984 case USB_GADGET_XPORT_HSUART:
985 /*client port number will be updated in gport_setup*/
986 no_hsuart_sports++;
987 break;
Manu Gautama4d993f2011-08-30 18:25:55 +0530988 default:
989 pr_err("%s: Un-supported transport transport: %u\n",
990 __func__, gserial_ports[port_num].transport);
991 return -ENODEV;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700992 }
993
Manu Gautama4d993f2011-08-30 18:25:55 +0530994 nr_ports++;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700995
996 return 0;
997}