David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 1 | /* |
| 2 | * f_acm.c -- USB CDC serial (ACM) 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 |
Michal Nazarewicz | b97503f | 2009-10-28 16:57:30 +0100 | [diff] [blame] | 7 | * Copyright (C) 2009 by Samsung Electronics |
Duy Truong | e833aca | 2013-02-12 13:35:08 -0800 | [diff] [blame] | 8 | * Copyright (c) 2011 The Linux Foundation. All rights reserved. |
Michal Nazarewicz | 54b8360 | 2012-01-13 15:05:16 +0100 | [diff] [blame] | 9 | * Author: Michal Nazarewicz (mina86@mina86.com) |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 10 | * |
| 11 | * This software is distributed under the terms of the GNU General |
| 12 | * Public License ("GPL") as published by the Free Software Foundation, |
| 13 | * either version 2 of that License or (at your option) any later version. |
| 14 | */ |
| 15 | |
| 16 | /* #define VERBOSE_DEBUG */ |
| 17 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 18 | #include <linux/slab.h> |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 19 | #include <linux/kernel.h> |
| 20 | #include <linux/device.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 21 | #include <linux/usb/android_composite.h> |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 22 | #include <mach/usb_gadget_xport.h> |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 23 | |
| 24 | #include "u_serial.h" |
| 25 | #include "gadget_chips.h" |
| 26 | |
| 27 | |
| 28 | /* |
| 29 | * This CDC ACM function support just wraps control functions and |
| 30 | * notifications around the generic serial-over-usb code. |
| 31 | * |
| 32 | * Because CDC ACM is standardized by the USB-IF, many host operating |
| 33 | * systems have drivers for it. Accordingly, ACM is the preferred |
| 34 | * interop solution for serial-port type connections. The control |
| 35 | * models are often not necessary, and in any case don't do much in |
| 36 | * this bare-bones implementation. |
| 37 | * |
| 38 | * Note that even MS-Windows has some support for ACM. However, that |
| 39 | * support is somewhat broken because when you use ACM in a composite |
| 40 | * device, having multiple interfaces confuses the poor OS. It doesn't |
| 41 | * seem to understand CDC Union descriptors. The new "association" |
| 42 | * descriptors (roughly equivalent to CDC Unions) may sometimes help. |
| 43 | */ |
| 44 | |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 45 | struct f_acm { |
| 46 | struct gserial port; |
| 47 | u8 ctrl_id, data_id; |
| 48 | u8 port_num; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 49 | enum transport_type transport; |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 50 | |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 51 | u8 pending; |
| 52 | |
| 53 | /* lock is mostly for pending and notify_req ... they get accessed |
| 54 | * by callbacks both from tty (open/close/break) under its spinlock, |
| 55 | * and notify_req.complete() which can't use that lock. |
| 56 | */ |
| 57 | spinlock_t lock; |
| 58 | |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 59 | struct usb_ep *notify; |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 60 | struct usb_request *notify_req; |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 61 | |
| 62 | struct usb_cdc_line_coding port_line_coding; /* 8-N-1 etc */ |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 63 | |
| 64 | /* SetControlLineState request -- CDC 1.1 section 6.2.14 (INPUT) */ |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 65 | u16 port_handshake_bits; |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 66 | #define ACM_CTRL_RTS (1 << 1) /* unused with full duplex */ |
| 67 | #define ACM_CTRL_DTR (1 << 0) /* host is ready for data r/w */ |
| 68 | |
| 69 | /* SerialState notification -- CDC 1.1 section 6.3.5 (OUTPUT) */ |
| 70 | u16 serial_state; |
| 71 | #define ACM_CTRL_OVERRUN (1 << 6) |
| 72 | #define ACM_CTRL_PARITY (1 << 5) |
| 73 | #define ACM_CTRL_FRAMING (1 << 4) |
| 74 | #define ACM_CTRL_RI (1 << 3) |
| 75 | #define ACM_CTRL_BRK (1 << 2) |
| 76 | #define ACM_CTRL_DSR (1 << 1) |
| 77 | #define ACM_CTRL_DCD (1 << 0) |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 78 | }; |
| 79 | |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 80 | static unsigned int no_acm_tty_ports; |
| 81 | static unsigned int no_acm_sdio_ports; |
| 82 | static unsigned int no_acm_smd_ports; |
| 83 | static unsigned int nr_acm_ports; |
Devin Kim | 192986b | 2012-06-20 08:37:37 -0700 | [diff] [blame] | 84 | static unsigned int no_acm_hsic_sports; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 85 | |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 86 | static struct acm_port_info { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 87 | enum transport_type transport; |
| 88 | unsigned port_num; |
| 89 | unsigned client_port_num; |
| 90 | } gacm_ports[GSERIAL_NO_PORTS]; |
| 91 | |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 92 | static inline struct f_acm *func_to_acm(struct usb_function *f) |
| 93 | { |
| 94 | return container_of(f, struct f_acm, port.func); |
| 95 | } |
| 96 | |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 97 | static inline struct f_acm *port_to_acm(struct gserial *p) |
| 98 | { |
| 99 | return container_of(p, struct f_acm, port); |
| 100 | } |
| 101 | |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 102 | static int acm_port_setup(struct usb_configuration *c) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 103 | { |
| 104 | int ret = 0; |
Devin Kim | 192986b | 2012-06-20 08:37:37 -0700 | [diff] [blame] | 105 | int port_idx=0; |
| 106 | int i=0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 107 | |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 108 | pr_debug("%s: no_acm_tty_ports:%u no_acm_sdio_ports: %u nr_acm_ports:%u\n", |
| 109 | __func__, no_acm_tty_ports, no_acm_sdio_ports, |
| 110 | nr_acm_ports); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 111 | |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 112 | if (no_acm_tty_ports) |
| 113 | ret = gserial_setup(c->cdev->gadget, no_acm_tty_ports); |
| 114 | if (no_acm_sdio_ports) |
| 115 | ret = gsdio_setup(c->cdev->gadget, no_acm_sdio_ports); |
| 116 | if (no_acm_smd_ports) |
| 117 | ret = gsmd_setup(c->cdev->gadget, no_acm_smd_ports); |
Devin Kim | 192986b | 2012-06-20 08:37:37 -0700 | [diff] [blame] | 118 | if (no_acm_hsic_sports) { |
| 119 | port_idx = ghsic_data_setup(no_acm_hsic_sports, |
| 120 | USB_GADGET_SERIAL); |
| 121 | if (port_idx < 0) |
| 122 | return port_idx; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 123 | |
Devin Kim | 192986b | 2012-06-20 08:37:37 -0700 | [diff] [blame] | 124 | for (i = 0; i < nr_acm_ports; i++) { |
| 125 | if (gacm_ports[i].transport == |
| 126 | USB_GADGET_XPORT_HSIC) { |
| 127 | gacm_ports[i].client_port_num = port_idx; |
| 128 | port_idx++; |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | /*clinet port num is same for data setup and ctrl setup*/ |
| 133 | ret = ghsic_ctrl_setup(no_acm_hsic_sports, USB_GADGET_SERIAL); |
| 134 | if (ret < 0) |
| 135 | return ret; |
| 136 | return 0; |
| 137 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 138 | return ret; |
| 139 | } |
| 140 | |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 141 | static int acm_port_connect(struct f_acm *acm) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 142 | { |
| 143 | unsigned port_num; |
Devin Kim | 192986b | 2012-06-20 08:37:37 -0700 | [diff] [blame] | 144 | int ret=0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 145 | |
| 146 | port_num = gacm_ports[acm->port_num].client_port_num; |
| 147 | |
| 148 | |
| 149 | pr_debug("%s: transport:%s f_acm:%p gserial:%p port_num:%d cl_port_no:%d\n", |
Hemant Kumar | 1b820d5 | 2011-11-03 15:08:28 -0700 | [diff] [blame] | 150 | __func__, xport_to_str(acm->transport), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 151 | acm, &acm->port, acm->port_num, port_num); |
| 152 | |
| 153 | switch (acm->transport) { |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 154 | case USB_GADGET_XPORT_TTY: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 155 | gserial_connect(&acm->port, port_num); |
| 156 | break; |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 157 | case USB_GADGET_XPORT_SDIO: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 158 | gsdio_connect(&acm->port, port_num); |
| 159 | break; |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 160 | case USB_GADGET_XPORT_SMD: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 161 | gsmd_connect(&acm->port, port_num); |
| 162 | break; |
Devin Kim | 192986b | 2012-06-20 08:37:37 -0700 | [diff] [blame] | 163 | case USB_GADGET_XPORT_HSIC: |
| 164 | ret = ghsic_ctrl_connect(&acm->port, port_num); |
| 165 | if (ret) { |
| 166 | pr_err("%s: ghsic_ctrl_connect failed: err:%d\n", |
| 167 | __func__, ret); |
| 168 | return ret; |
| 169 | } |
| 170 | ret = ghsic_data_connect(&acm->port, port_num); |
| 171 | if (ret) { |
| 172 | pr_err("%s: ghsic_data_connect failed: err:%d\n", |
| 173 | __func__, ret); |
| 174 | ghsic_ctrl_disconnect(&acm->port, port_num); |
| 175 | return ret; |
| 176 | } |
| 177 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 178 | default: |
| 179 | pr_err("%s: Un-supported transport: %s\n", __func__, |
Hemant Kumar | 1b820d5 | 2011-11-03 15:08:28 -0700 | [diff] [blame] | 180 | xport_to_str(acm->transport)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 181 | return -ENODEV; |
| 182 | } |
| 183 | |
| 184 | return 0; |
| 185 | } |
| 186 | |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 187 | static int acm_port_disconnect(struct f_acm *acm) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 188 | { |
| 189 | unsigned port_num; |
| 190 | |
| 191 | port_num = gacm_ports[acm->port_num].client_port_num; |
| 192 | |
| 193 | pr_debug("%s: transport:%s f_acm:%p gserial:%p port_num:%d cl_pno:%d\n", |
Hemant Kumar | 1b820d5 | 2011-11-03 15:08:28 -0700 | [diff] [blame] | 194 | __func__, xport_to_str(acm->transport), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 195 | acm, &acm->port, acm->port_num, port_num); |
| 196 | |
| 197 | switch (acm->transport) { |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 198 | case USB_GADGET_XPORT_TTY: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 199 | gserial_disconnect(&acm->port); |
| 200 | break; |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 201 | case USB_GADGET_XPORT_SDIO: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 202 | gsdio_disconnect(&acm->port, port_num); |
| 203 | break; |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 204 | case USB_GADGET_XPORT_SMD: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 205 | gsmd_disconnect(&acm->port, port_num); |
| 206 | break; |
Devin Kim | 192986b | 2012-06-20 08:37:37 -0700 | [diff] [blame] | 207 | case USB_GADGET_XPORT_HSIC: |
| 208 | ghsic_ctrl_disconnect(&acm->port, port_num); |
| 209 | ghsic_data_disconnect(&acm->port, port_num); |
| 210 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 211 | default: |
| 212 | pr_err("%s: Un-supported transport:%s\n", __func__, |
Hemant Kumar | 1b820d5 | 2011-11-03 15:08:28 -0700 | [diff] [blame] | 213 | xport_to_str(acm->transport)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 214 | return -ENODEV; |
| 215 | } |
| 216 | |
| 217 | return 0; |
| 218 | } |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 219 | /*-------------------------------------------------------------------------*/ |
| 220 | |
| 221 | /* notification endpoint uses smallish and infrequent fixed-size messages */ |
| 222 | |
| 223 | #define GS_LOG2_NOTIFY_INTERVAL 5 /* 1 << 5 == 32 msec */ |
Devin Kim | 2bdc71b | 2012-06-20 08:33:44 -0700 | [diff] [blame] | 224 | #define GS_NOTIFY_MAXPACKET 16 |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 225 | |
| 226 | /* interface and class descriptors: */ |
| 227 | |
Michal Nazarewicz | b97503f | 2009-10-28 16:57:30 +0100 | [diff] [blame] | 228 | static struct usb_interface_assoc_descriptor |
| 229 | acm_iad_descriptor = { |
| 230 | .bLength = sizeof acm_iad_descriptor, |
| 231 | .bDescriptorType = USB_DT_INTERFACE_ASSOCIATION, |
| 232 | |
| 233 | /* .bFirstInterface = DYNAMIC, */ |
| 234 | .bInterfaceCount = 2, // control + data |
| 235 | .bFunctionClass = USB_CLASS_COMM, |
| 236 | .bFunctionSubClass = USB_CDC_SUBCLASS_ACM, |
Praveena Nadahally | 5c8db07 | 2010-09-10 23:05:03 +0530 | [diff] [blame] | 237 | .bFunctionProtocol = USB_CDC_ACM_PROTO_AT_V25TER, |
Michal Nazarewicz | b97503f | 2009-10-28 16:57:30 +0100 | [diff] [blame] | 238 | /* .iFunction = DYNAMIC */ |
| 239 | }; |
| 240 | |
| 241 | |
Michal Nazarewicz | 28824b1 | 2010-05-05 12:53:13 +0200 | [diff] [blame] | 242 | static struct usb_interface_descriptor acm_control_interface_desc = { |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 243 | .bLength = USB_DT_INTERFACE_SIZE, |
| 244 | .bDescriptorType = USB_DT_INTERFACE, |
| 245 | /* .bInterfaceNumber = DYNAMIC */ |
| 246 | .bNumEndpoints = 1, |
| 247 | .bInterfaceClass = USB_CLASS_COMM, |
| 248 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ACM, |
| 249 | .bInterfaceProtocol = USB_CDC_ACM_PROTO_AT_V25TER, |
| 250 | /* .iInterface = DYNAMIC */ |
| 251 | }; |
| 252 | |
Michal Nazarewicz | 28824b1 | 2010-05-05 12:53:13 +0200 | [diff] [blame] | 253 | static struct usb_interface_descriptor acm_data_interface_desc = { |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 254 | .bLength = USB_DT_INTERFACE_SIZE, |
| 255 | .bDescriptorType = USB_DT_INTERFACE, |
| 256 | /* .bInterfaceNumber = DYNAMIC */ |
| 257 | .bNumEndpoints = 2, |
| 258 | .bInterfaceClass = USB_CLASS_CDC_DATA, |
| 259 | .bInterfaceSubClass = 0, |
| 260 | .bInterfaceProtocol = 0, |
| 261 | /* .iInterface = DYNAMIC */ |
| 262 | }; |
| 263 | |
Michal Nazarewicz | 28824b1 | 2010-05-05 12:53:13 +0200 | [diff] [blame] | 264 | static struct usb_cdc_header_desc acm_header_desc = { |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 265 | .bLength = sizeof(acm_header_desc), |
| 266 | .bDescriptorType = USB_DT_CS_INTERFACE, |
| 267 | .bDescriptorSubType = USB_CDC_HEADER_TYPE, |
Harvey Harrison | 551509d | 2009-02-11 14:11:36 -0800 | [diff] [blame] | 268 | .bcdCDC = cpu_to_le16(0x0110), |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 269 | }; |
| 270 | |
| 271 | static struct usb_cdc_call_mgmt_descriptor |
Michal Nazarewicz | 28824b1 | 2010-05-05 12:53:13 +0200 | [diff] [blame] | 272 | acm_call_mgmt_descriptor = { |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 273 | .bLength = sizeof(acm_call_mgmt_descriptor), |
| 274 | .bDescriptorType = USB_DT_CS_INTERFACE, |
| 275 | .bDescriptorSubType = USB_CDC_CALL_MANAGEMENT_TYPE, |
| 276 | .bmCapabilities = 0, |
| 277 | /* .bDataInterface = DYNAMIC */ |
| 278 | }; |
| 279 | |
Michal Nazarewicz | 28824b1 | 2010-05-05 12:53:13 +0200 | [diff] [blame] | 280 | static struct usb_cdc_acm_descriptor acm_descriptor = { |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 281 | .bLength = sizeof(acm_descriptor), |
| 282 | .bDescriptorType = USB_DT_CS_INTERFACE, |
| 283 | .bDescriptorSubType = USB_CDC_ACM_TYPE, |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 284 | .bmCapabilities = USB_CDC_CAP_LINE, |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 285 | }; |
| 286 | |
Michal Nazarewicz | 28824b1 | 2010-05-05 12:53:13 +0200 | [diff] [blame] | 287 | static struct usb_cdc_union_desc acm_union_desc = { |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 288 | .bLength = sizeof(acm_union_desc), |
| 289 | .bDescriptorType = USB_DT_CS_INTERFACE, |
| 290 | .bDescriptorSubType = USB_CDC_UNION_TYPE, |
| 291 | /* .bMasterInterface0 = DYNAMIC */ |
| 292 | /* .bSlaveInterface0 = DYNAMIC */ |
| 293 | }; |
| 294 | |
| 295 | /* full speed support: */ |
| 296 | |
Michal Nazarewicz | 28824b1 | 2010-05-05 12:53:13 +0200 | [diff] [blame] | 297 | static struct usb_endpoint_descriptor acm_fs_notify_desc = { |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 298 | .bLength = USB_DT_ENDPOINT_SIZE, |
| 299 | .bDescriptorType = USB_DT_ENDPOINT, |
| 300 | .bEndpointAddress = USB_DIR_IN, |
| 301 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
Harvey Harrison | 551509d | 2009-02-11 14:11:36 -0800 | [diff] [blame] | 302 | .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET), |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 303 | .bInterval = 1 << GS_LOG2_NOTIFY_INTERVAL, |
| 304 | }; |
| 305 | |
Michal Nazarewicz | 28824b1 | 2010-05-05 12:53:13 +0200 | [diff] [blame] | 306 | static struct usb_endpoint_descriptor acm_fs_in_desc = { |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 307 | .bLength = USB_DT_ENDPOINT_SIZE, |
| 308 | .bDescriptorType = USB_DT_ENDPOINT, |
| 309 | .bEndpointAddress = USB_DIR_IN, |
| 310 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
| 311 | }; |
| 312 | |
Michal Nazarewicz | 28824b1 | 2010-05-05 12:53:13 +0200 | [diff] [blame] | 313 | static struct usb_endpoint_descriptor acm_fs_out_desc = { |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 314 | .bLength = USB_DT_ENDPOINT_SIZE, |
| 315 | .bDescriptorType = USB_DT_ENDPOINT, |
| 316 | .bEndpointAddress = USB_DIR_OUT, |
| 317 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
| 318 | }; |
| 319 | |
Michal Nazarewicz | 28824b1 | 2010-05-05 12:53:13 +0200 | [diff] [blame] | 320 | static struct usb_descriptor_header *acm_fs_function[] = { |
Michal Nazarewicz | b97503f | 2009-10-28 16:57:30 +0100 | [diff] [blame] | 321 | (struct usb_descriptor_header *) &acm_iad_descriptor, |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 322 | (struct usb_descriptor_header *) &acm_control_interface_desc, |
| 323 | (struct usb_descriptor_header *) &acm_header_desc, |
| 324 | (struct usb_descriptor_header *) &acm_call_mgmt_descriptor, |
| 325 | (struct usb_descriptor_header *) &acm_descriptor, |
| 326 | (struct usb_descriptor_header *) &acm_union_desc, |
| 327 | (struct usb_descriptor_header *) &acm_fs_notify_desc, |
| 328 | (struct usb_descriptor_header *) &acm_data_interface_desc, |
| 329 | (struct usb_descriptor_header *) &acm_fs_in_desc, |
| 330 | (struct usb_descriptor_header *) &acm_fs_out_desc, |
| 331 | NULL, |
| 332 | }; |
| 333 | |
| 334 | /* high speed support: */ |
| 335 | |
Michal Nazarewicz | 28824b1 | 2010-05-05 12:53:13 +0200 | [diff] [blame] | 336 | static struct usb_endpoint_descriptor acm_hs_notify_desc = { |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 337 | .bLength = USB_DT_ENDPOINT_SIZE, |
| 338 | .bDescriptorType = USB_DT_ENDPOINT, |
| 339 | .bEndpointAddress = USB_DIR_IN, |
| 340 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
Harvey Harrison | 551509d | 2009-02-11 14:11:36 -0800 | [diff] [blame] | 341 | .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET), |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 342 | .bInterval = GS_LOG2_NOTIFY_INTERVAL+4, |
| 343 | }; |
| 344 | |
Michal Nazarewicz | 28824b1 | 2010-05-05 12:53:13 +0200 | [diff] [blame] | 345 | static struct usb_endpoint_descriptor acm_hs_in_desc = { |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 346 | .bLength = USB_DT_ENDPOINT_SIZE, |
| 347 | .bDescriptorType = USB_DT_ENDPOINT, |
| 348 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
Harvey Harrison | 551509d | 2009-02-11 14:11:36 -0800 | [diff] [blame] | 349 | .wMaxPacketSize = cpu_to_le16(512), |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 350 | }; |
| 351 | |
Michal Nazarewicz | 28824b1 | 2010-05-05 12:53:13 +0200 | [diff] [blame] | 352 | static struct usb_endpoint_descriptor acm_hs_out_desc = { |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 353 | .bLength = USB_DT_ENDPOINT_SIZE, |
| 354 | .bDescriptorType = USB_DT_ENDPOINT, |
| 355 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
Harvey Harrison | 551509d | 2009-02-11 14:11:36 -0800 | [diff] [blame] | 356 | .wMaxPacketSize = cpu_to_le16(512), |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 357 | }; |
| 358 | |
Michal Nazarewicz | 28824b1 | 2010-05-05 12:53:13 +0200 | [diff] [blame] | 359 | static struct usb_descriptor_header *acm_hs_function[] = { |
Michal Nazarewicz | b97503f | 2009-10-28 16:57:30 +0100 | [diff] [blame] | 360 | (struct usb_descriptor_header *) &acm_iad_descriptor, |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 361 | (struct usb_descriptor_header *) &acm_control_interface_desc, |
| 362 | (struct usb_descriptor_header *) &acm_header_desc, |
| 363 | (struct usb_descriptor_header *) &acm_call_mgmt_descriptor, |
| 364 | (struct usb_descriptor_header *) &acm_descriptor, |
| 365 | (struct usb_descriptor_header *) &acm_union_desc, |
| 366 | (struct usb_descriptor_header *) &acm_hs_notify_desc, |
| 367 | (struct usb_descriptor_header *) &acm_data_interface_desc, |
| 368 | (struct usb_descriptor_header *) &acm_hs_in_desc, |
| 369 | (struct usb_descriptor_header *) &acm_hs_out_desc, |
| 370 | NULL, |
| 371 | }; |
| 372 | |
Sebastian Andrzej Siewior | 6fecfb0 | 2012-02-06 18:46:36 +0100 | [diff] [blame] | 373 | static struct usb_endpoint_descriptor acm_ss_in_desc = { |
| 374 | .bLength = USB_DT_ENDPOINT_SIZE, |
| 375 | .bDescriptorType = USB_DT_ENDPOINT, |
| 376 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
| 377 | .wMaxPacketSize = cpu_to_le16(1024), |
| 378 | }; |
| 379 | |
| 380 | static struct usb_endpoint_descriptor acm_ss_out_desc = { |
| 381 | .bLength = USB_DT_ENDPOINT_SIZE, |
| 382 | .bDescriptorType = USB_DT_ENDPOINT, |
| 383 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
| 384 | .wMaxPacketSize = cpu_to_le16(1024), |
| 385 | }; |
| 386 | |
| 387 | static struct usb_ss_ep_comp_descriptor acm_ss_bulk_comp_desc = { |
| 388 | .bLength = sizeof acm_ss_bulk_comp_desc, |
| 389 | .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, |
| 390 | }; |
| 391 | |
| 392 | static struct usb_descriptor_header *acm_ss_function[] = { |
| 393 | (struct usb_descriptor_header *) &acm_iad_descriptor, |
| 394 | (struct usb_descriptor_header *) &acm_control_interface_desc, |
| 395 | (struct usb_descriptor_header *) &acm_header_desc, |
| 396 | (struct usb_descriptor_header *) &acm_call_mgmt_descriptor, |
| 397 | (struct usb_descriptor_header *) &acm_descriptor, |
| 398 | (struct usb_descriptor_header *) &acm_union_desc, |
| 399 | (struct usb_descriptor_header *) &acm_hs_notify_desc, |
| 400 | (struct usb_descriptor_header *) &acm_ss_bulk_comp_desc, |
| 401 | (struct usb_descriptor_header *) &acm_data_interface_desc, |
| 402 | (struct usb_descriptor_header *) &acm_ss_in_desc, |
| 403 | (struct usb_descriptor_header *) &acm_ss_bulk_comp_desc, |
| 404 | (struct usb_descriptor_header *) &acm_ss_out_desc, |
| 405 | (struct usb_descriptor_header *) &acm_ss_bulk_comp_desc, |
| 406 | NULL, |
| 407 | }; |
| 408 | |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 409 | /* string descriptors: */ |
| 410 | |
| 411 | #define ACM_CTRL_IDX 0 |
| 412 | #define ACM_DATA_IDX 1 |
Michal Nazarewicz | b97503f | 2009-10-28 16:57:30 +0100 | [diff] [blame] | 413 | #define ACM_IAD_IDX 2 |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 414 | |
| 415 | /* static strings, in UTF-8 */ |
| 416 | static struct usb_string acm_string_defs[] = { |
| 417 | [ACM_CTRL_IDX].s = "CDC Abstract Control Model (ACM)", |
| 418 | [ACM_DATA_IDX].s = "CDC ACM Data", |
Michal Nazarewicz | b97503f | 2009-10-28 16:57:30 +0100 | [diff] [blame] | 419 | [ACM_IAD_IDX ].s = "CDC Serial", |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 420 | { /* ZEROES END LIST */ }, |
| 421 | }; |
| 422 | |
| 423 | static struct usb_gadget_strings acm_string_table = { |
| 424 | .language = 0x0409, /* en-us */ |
| 425 | .strings = acm_string_defs, |
| 426 | }; |
| 427 | |
| 428 | static struct usb_gadget_strings *acm_strings[] = { |
| 429 | &acm_string_table, |
| 430 | NULL, |
| 431 | }; |
| 432 | |
| 433 | /*-------------------------------------------------------------------------*/ |
| 434 | |
| 435 | /* ACM control ... data handling is delegated to tty library code. |
| 436 | * The main task of this function is to activate and deactivate |
| 437 | * that code based on device state; track parameters like line |
| 438 | * speed, handshake state, and so on; and issue notifications. |
| 439 | */ |
| 440 | |
| 441 | static void acm_complete_set_line_coding(struct usb_ep *ep, |
| 442 | struct usb_request *req) |
| 443 | { |
| 444 | struct f_acm *acm = ep->driver_data; |
| 445 | struct usb_composite_dev *cdev = acm->port.func.config->cdev; |
| 446 | |
| 447 | if (req->status != 0) { |
| 448 | DBG(cdev, "acm ttyGS%d completion, err %d\n", |
| 449 | acm->port_num, req->status); |
| 450 | return; |
| 451 | } |
| 452 | |
| 453 | /* normal completion */ |
| 454 | if (req->actual != sizeof(acm->port_line_coding)) { |
| 455 | DBG(cdev, "acm ttyGS%d short resp, len %d\n", |
| 456 | acm->port_num, req->actual); |
| 457 | usb_ep_set_halt(ep); |
| 458 | } else { |
| 459 | struct usb_cdc_line_coding *value = req->buf; |
| 460 | |
| 461 | /* REVISIT: we currently just remember this data. |
| 462 | * If we change that, (a) validate it first, then |
| 463 | * (b) update whatever hardware needs updating, |
| 464 | * (c) worry about locking. This is information on |
| 465 | * the order of 9600-8-N-1 ... most of which means |
| 466 | * nothing unless we control a real RS232 line. |
| 467 | */ |
| 468 | acm->port_line_coding = *value; |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | static int acm_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) |
| 473 | { |
| 474 | struct f_acm *acm = func_to_acm(f); |
| 475 | struct usb_composite_dev *cdev = f->config->cdev; |
| 476 | struct usb_request *req = cdev->req; |
| 477 | int value = -EOPNOTSUPP; |
| 478 | u16 w_index = le16_to_cpu(ctrl->wIndex); |
| 479 | u16 w_value = le16_to_cpu(ctrl->wValue); |
| 480 | u16 w_length = le16_to_cpu(ctrl->wLength); |
| 481 | |
| 482 | /* composite driver infrastructure handles everything except |
| 483 | * CDC class messages; interface activation uses set_alt(). |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 484 | * |
| 485 | * Note CDC spec table 4 lists the ACM request profile. It requires |
| 486 | * encapsulated command support ... we don't handle any, and respond |
| 487 | * to them by stalling. Options include get/set/clear comm features |
| 488 | * (not that useful) and SEND_BREAK. |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 489 | */ |
| 490 | switch ((ctrl->bRequestType << 8) | ctrl->bRequest) { |
| 491 | |
| 492 | /* SET_LINE_CODING ... just read and save what the host sends */ |
| 493 | case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8) |
| 494 | | USB_CDC_REQ_SET_LINE_CODING: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 495 | if (w_length != sizeof(struct usb_cdc_line_coding)) |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 496 | goto invalid; |
| 497 | |
| 498 | value = w_length; |
| 499 | cdev->gadget->ep0->driver_data = acm; |
| 500 | req->complete = acm_complete_set_line_coding; |
| 501 | break; |
| 502 | |
| 503 | /* GET_LINE_CODING ... return what host sent, or initial value */ |
| 504 | case ((USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8) |
| 505 | | USB_CDC_REQ_GET_LINE_CODING: |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 506 | |
| 507 | value = min_t(unsigned, w_length, |
| 508 | sizeof(struct usb_cdc_line_coding)); |
| 509 | memcpy(req->buf, &acm->port_line_coding, value); |
| 510 | break; |
| 511 | |
| 512 | /* SET_CONTROL_LINE_STATE ... save what the host sent */ |
| 513 | case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8) |
| 514 | | USB_CDC_REQ_SET_CONTROL_LINE_STATE: |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 515 | value = 0; |
| 516 | |
| 517 | /* FIXME we should not allow data to flow until the |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 518 | * host sets the ACM_CTRL_DTR bit; and when it clears |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 519 | * that bit, we should return to that no-flow state. |
| 520 | */ |
| 521 | acm->port_handshake_bits = w_value; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 522 | if (acm->port.notify_modem) { |
| 523 | unsigned port_num = |
| 524 | gacm_ports[acm->port_num].client_port_num; |
| 525 | |
| 526 | acm->port.notify_modem(&acm->port, port_num, w_value); |
| 527 | } |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 528 | break; |
| 529 | |
| 530 | default: |
| 531 | invalid: |
| 532 | VDBG(cdev, "invalid control req%02x.%02x v%04x i%04x l%d\n", |
| 533 | ctrl->bRequestType, ctrl->bRequest, |
| 534 | w_value, w_index, w_length); |
| 535 | } |
| 536 | |
| 537 | /* respond with data transfer or status phase? */ |
| 538 | if (value >= 0) { |
| 539 | DBG(cdev, "acm ttyGS%d req%02x.%02x v%04x i%04x l%d\n", |
| 540 | acm->port_num, ctrl->bRequestType, ctrl->bRequest, |
| 541 | w_value, w_index, w_length); |
| 542 | req->zero = 0; |
| 543 | req->length = value; |
| 544 | value = usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC); |
| 545 | if (value < 0) |
| 546 | ERROR(cdev, "acm response on ttyGS%d, err %d\n", |
| 547 | acm->port_num, value); |
| 548 | } |
| 549 | |
| 550 | /* device either stalls (value < 0) or reports success */ |
| 551 | return value; |
| 552 | } |
| 553 | |
| 554 | static int acm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) |
| 555 | { |
| 556 | struct f_acm *acm = func_to_acm(f); |
| 557 | struct usb_composite_dev *cdev = f->config->cdev; |
| 558 | |
| 559 | /* we know alt == 0, so this is an activation or a reset */ |
| 560 | |
| 561 | if (intf == acm->ctrl_id) { |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 562 | if (acm->notify->driver_data) { |
| 563 | VDBG(cdev, "reset acm control interface %d\n", intf); |
| 564 | usb_ep_disable(acm->notify); |
| 565 | } else { |
| 566 | VDBG(cdev, "init acm ctrl interface %d\n", intf); |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 567 | } |
Tatyana Brokhman | 31ac352 | 2011-06-28 15:33:50 +0200 | [diff] [blame] | 568 | if (config_ep_by_speed(cdev->gadget, f, acm->notify)) |
| 569 | return -EINVAL; |
| 570 | |
Tatyana Brokhman | 72c973d | 2011-06-28 16:33:48 +0300 | [diff] [blame] | 571 | usb_ep_enable(acm->notify); |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 572 | acm->notify->driver_data = acm; |
| 573 | |
| 574 | } else if (intf == acm->data_id) { |
| 575 | if (acm->port.in->driver_data) { |
| 576 | DBG(cdev, "reset acm ttyGS%d\n", acm->port_num); |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 577 | acm_port_disconnect(acm); |
Tatyana Brokhman | ea2a1df7 | 2011-06-28 16:33:50 +0300 | [diff] [blame] | 578 | } |
| 579 | if (!acm->port.in->desc || !acm->port.out->desc) { |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 580 | DBG(cdev, "activate acm ttyGS%d\n", acm->port_num); |
Tatyana Brokhman | ea2a1df7 | 2011-06-28 16:33:50 +0300 | [diff] [blame] | 581 | if (config_ep_by_speed(cdev->gadget, f, |
| 582 | acm->port.in) || |
| 583 | config_ep_by_speed(cdev->gadget, f, |
| 584 | acm->port.out)) { |
| 585 | acm->port.in->desc = NULL; |
| 586 | acm->port.out->desc = NULL; |
| 587 | return -EINVAL; |
| 588 | } |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 589 | } |
Tatyana Brokhman | 31ac352 | 2011-06-28 15:33:50 +0200 | [diff] [blame] | 590 | if (config_ep_by_speed(cdev->gadget, f, |
| 591 | acm->port.in) || |
| 592 | config_ep_by_speed(cdev->gadget, f, |
| 593 | acm->port.out)) { |
| 594 | acm->port.in->desc = NULL; |
| 595 | acm->port.out->desc = NULL; |
| 596 | return -EINVAL; |
| 597 | } |
| 598 | |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 599 | acm_port_connect(acm); |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 600 | |
| 601 | } else |
| 602 | return -EINVAL; |
| 603 | |
| 604 | return 0; |
| 605 | } |
| 606 | |
| 607 | static void acm_disable(struct usb_function *f) |
| 608 | { |
| 609 | struct f_acm *acm = func_to_acm(f); |
| 610 | struct usb_composite_dev *cdev = f->config->cdev; |
| 611 | |
| 612 | DBG(cdev, "acm ttyGS%d deactivated\n", acm->port_num); |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 613 | acm_port_disconnect(acm); |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 614 | usb_ep_disable(acm->notify); |
| 615 | acm->notify->driver_data = NULL; |
| 616 | } |
| 617 | |
| 618 | /*-------------------------------------------------------------------------*/ |
| 619 | |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 620 | /** |
| 621 | * acm_cdc_notify - issue CDC notification to host |
| 622 | * @acm: wraps host to be notified |
| 623 | * @type: notification type |
| 624 | * @value: Refer to cdc specs, wValue field. |
| 625 | * @data: data to be sent |
| 626 | * @length: size of data |
| 627 | * Context: irqs blocked, acm->lock held, acm_notify_req non-null |
| 628 | * |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 629 | * Returns zero on success or a negative errno. |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 630 | * |
| 631 | * See section 6.3.5 of the CDC 1.1 specification for information |
| 632 | * about the only notification we issue: SerialState change. |
| 633 | */ |
| 634 | static int acm_cdc_notify(struct f_acm *acm, u8 type, u16 value, |
| 635 | void *data, unsigned length) |
| 636 | { |
| 637 | struct usb_ep *ep = acm->notify; |
| 638 | struct usb_request *req; |
| 639 | struct usb_cdc_notification *notify; |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 640 | void *buf; |
| 641 | int status; |
Devin Kim | 192986b | 2012-06-20 08:37:37 -0700 | [diff] [blame] | 642 | unsigned char noti_buf[GS_NOTIFY_MAXPACKET]; |
| 643 | |
| 644 | memset(noti_buf, 0, GS_NOTIFY_MAXPACKET); |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 645 | |
| 646 | req = acm->notify_req; |
| 647 | acm->notify_req = NULL; |
| 648 | acm->pending = false; |
| 649 | |
Devin Kim | 192986b | 2012-06-20 08:37:37 -0700 | [diff] [blame] | 650 | req->length = GS_NOTIFY_MAXPACKET; |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 651 | notify = req->buf; |
| 652 | buf = notify + 1; |
| 653 | |
| 654 | notify->bmRequestType = USB_DIR_IN | USB_TYPE_CLASS |
| 655 | | USB_RECIP_INTERFACE; |
| 656 | notify->bNotificationType = type; |
| 657 | notify->wValue = cpu_to_le16(value); |
| 658 | notify->wIndex = cpu_to_le16(acm->ctrl_id); |
| 659 | notify->wLength = cpu_to_le16(length); |
Devin Kim | 192986b | 2012-06-20 08:37:37 -0700 | [diff] [blame] | 660 | memcpy(noti_buf, data, length); |
| 661 | memcpy(buf, noti_buf, GS_NOTIFY_MAXPACKET); |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 662 | memcpy(buf, data, length); |
| 663 | |
David Brownell | e50ae57 | 2008-11-12 11:35:13 -0800 | [diff] [blame] | 664 | /* ep_queue() can complete immediately if it fills the fifo... */ |
| 665 | spin_unlock(&acm->lock); |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 666 | status = usb_ep_queue(ep, req, GFP_ATOMIC); |
David Brownell | e50ae57 | 2008-11-12 11:35:13 -0800 | [diff] [blame] | 667 | spin_lock(&acm->lock); |
| 668 | |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 669 | if (status < 0) { |
| 670 | ERROR(acm->port.func.config->cdev, |
| 671 | "acm ttyGS%d can't notify serial state, %d\n", |
| 672 | acm->port_num, status); |
| 673 | acm->notify_req = req; |
| 674 | } |
| 675 | |
| 676 | return status; |
| 677 | } |
| 678 | |
| 679 | static int acm_notify_serial_state(struct f_acm *acm) |
| 680 | { |
| 681 | struct usb_composite_dev *cdev = acm->port.func.config->cdev; |
| 682 | int status; |
| 683 | |
| 684 | spin_lock(&acm->lock); |
| 685 | if (acm->notify_req) { |
| 686 | DBG(cdev, "acm ttyGS%d serial state %04x\n", |
| 687 | acm->port_num, acm->serial_state); |
| 688 | status = acm_cdc_notify(acm, USB_CDC_NOTIFY_SERIAL_STATE, |
| 689 | 0, &acm->serial_state, sizeof(acm->serial_state)); |
| 690 | } else { |
| 691 | acm->pending = true; |
| 692 | status = 0; |
| 693 | } |
| 694 | spin_unlock(&acm->lock); |
| 695 | return status; |
| 696 | } |
| 697 | |
| 698 | static void acm_cdc_notify_complete(struct usb_ep *ep, struct usb_request *req) |
| 699 | { |
| 700 | struct f_acm *acm = req->context; |
| 701 | u8 doit = false; |
| 702 | |
| 703 | /* on this call path we do NOT hold the port spinlock, |
| 704 | * which is why ACM needs its own spinlock |
| 705 | */ |
| 706 | spin_lock(&acm->lock); |
| 707 | if (req->status != -ESHUTDOWN) |
| 708 | doit = acm->pending; |
| 709 | acm->notify_req = req; |
| 710 | spin_unlock(&acm->lock); |
| 711 | |
| 712 | if (doit) |
| 713 | acm_notify_serial_state(acm); |
| 714 | } |
| 715 | |
| 716 | /* connect == the TTY link is open */ |
| 717 | |
| 718 | static void acm_connect(struct gserial *port) |
| 719 | { |
| 720 | struct f_acm *acm = port_to_acm(port); |
| 721 | |
| 722 | acm->serial_state |= ACM_CTRL_DSR | ACM_CTRL_DCD; |
| 723 | acm_notify_serial_state(acm); |
| 724 | } |
| 725 | |
| 726 | static void acm_disconnect(struct gserial *port) |
| 727 | { |
| 728 | struct f_acm *acm = port_to_acm(port); |
| 729 | |
| 730 | acm->serial_state &= ~(ACM_CTRL_DSR | ACM_CTRL_DCD); |
| 731 | acm_notify_serial_state(acm); |
| 732 | } |
| 733 | |
| 734 | static int acm_send_break(struct gserial *port, int duration) |
| 735 | { |
| 736 | struct f_acm *acm = port_to_acm(port); |
| 737 | u16 state; |
| 738 | |
| 739 | state = acm->serial_state; |
| 740 | state &= ~ACM_CTRL_BRK; |
| 741 | if (duration) |
| 742 | state |= ACM_CTRL_BRK; |
| 743 | |
| 744 | acm->serial_state = state; |
| 745 | return acm_notify_serial_state(acm); |
| 746 | } |
| 747 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 748 | static int acm_send_modem_ctrl_bits(struct gserial *port, int ctrl_bits) |
| 749 | { |
| 750 | struct f_acm *acm = port_to_acm(port); |
| 751 | |
| 752 | acm->serial_state = ctrl_bits; |
| 753 | |
| 754 | return acm_notify_serial_state(acm); |
| 755 | } |
| 756 | |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 757 | /*-------------------------------------------------------------------------*/ |
| 758 | |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 759 | /* ACM function driver setup/binding */ |
Michal Nazarewicz | 28824b1 | 2010-05-05 12:53:13 +0200 | [diff] [blame] | 760 | static int |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 761 | acm_bind(struct usb_configuration *c, struct usb_function *f) |
| 762 | { |
| 763 | struct usb_composite_dev *cdev = c->cdev; |
| 764 | struct f_acm *acm = func_to_acm(f); |
| 765 | int status; |
| 766 | struct usb_ep *ep; |
| 767 | |
| 768 | /* allocate instance-specific interface IDs, and patch descriptors */ |
| 769 | status = usb_interface_id(c, f); |
| 770 | if (status < 0) |
| 771 | goto fail; |
| 772 | acm->ctrl_id = status; |
Michal Nazarewicz | b97503f | 2009-10-28 16:57:30 +0100 | [diff] [blame] | 773 | acm_iad_descriptor.bFirstInterface = status; |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 774 | |
| 775 | acm_control_interface_desc.bInterfaceNumber = status; |
| 776 | acm_union_desc .bMasterInterface0 = status; |
| 777 | |
| 778 | status = usb_interface_id(c, f); |
| 779 | if (status < 0) |
| 780 | goto fail; |
| 781 | acm->data_id = status; |
| 782 | |
| 783 | acm_data_interface_desc.bInterfaceNumber = status; |
| 784 | acm_union_desc.bSlaveInterface0 = status; |
| 785 | acm_call_mgmt_descriptor.bDataInterface = status; |
| 786 | |
| 787 | status = -ENODEV; |
| 788 | |
| 789 | /* allocate instance-specific endpoints */ |
| 790 | ep = usb_ep_autoconfig(cdev->gadget, &acm_fs_in_desc); |
| 791 | if (!ep) |
| 792 | goto fail; |
| 793 | acm->port.in = ep; |
| 794 | ep->driver_data = cdev; /* claim */ |
| 795 | |
| 796 | ep = usb_ep_autoconfig(cdev->gadget, &acm_fs_out_desc); |
| 797 | if (!ep) |
| 798 | goto fail; |
| 799 | acm->port.out = ep; |
| 800 | ep->driver_data = cdev; /* claim */ |
| 801 | |
| 802 | ep = usb_ep_autoconfig(cdev->gadget, &acm_fs_notify_desc); |
| 803 | if (!ep) |
| 804 | goto fail; |
| 805 | acm->notify = ep; |
| 806 | ep->driver_data = cdev; /* claim */ |
| 807 | |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 808 | /* allocate notification */ |
| 809 | acm->notify_req = gs_alloc_req(ep, |
| 810 | sizeof(struct usb_cdc_notification) + 2, |
| 811 | GFP_KERNEL); |
| 812 | if (!acm->notify_req) |
| 813 | goto fail; |
| 814 | |
| 815 | acm->notify_req->complete = acm_cdc_notify_complete; |
| 816 | acm->notify_req->context = acm; |
| 817 | |
Tatyana Brokhman | ea2a1df7 | 2011-06-28 16:33:50 +0300 | [diff] [blame] | 818 | /* copy descriptors */ |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 819 | f->descriptors = usb_copy_descriptors(acm_fs_function); |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 820 | if (!f->descriptors) |
| 821 | goto fail; |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 822 | |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 823 | /* support all relevant hardware speeds... we expect that when |
| 824 | * hardware is dual speed, all bulk-capable endpoints work at |
| 825 | * both speeds |
| 826 | */ |
| 827 | if (gadget_is_dualspeed(c->cdev->gadget)) { |
| 828 | acm_hs_in_desc.bEndpointAddress = |
| 829 | acm_fs_in_desc.bEndpointAddress; |
| 830 | acm_hs_out_desc.bEndpointAddress = |
| 831 | acm_fs_out_desc.bEndpointAddress; |
| 832 | acm_hs_notify_desc.bEndpointAddress = |
| 833 | acm_fs_notify_desc.bEndpointAddress; |
| 834 | |
Tatyana Brokhman | ea2a1df7 | 2011-06-28 16:33:50 +0300 | [diff] [blame] | 835 | /* copy descriptors */ |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 836 | f->hs_descriptors = usb_copy_descriptors(acm_hs_function); |
Rajkumar Raghupathy | c636cb4 | 2012-01-25 16:15:04 +0530 | [diff] [blame] | 837 | if (!f->hs_descriptors) |
| 838 | goto fail; |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 839 | } |
Sebastian Andrzej Siewior | 6fecfb0 | 2012-02-06 18:46:36 +0100 | [diff] [blame] | 840 | if (gadget_is_superspeed(c->cdev->gadget)) { |
| 841 | acm_ss_in_desc.bEndpointAddress = |
| 842 | acm_fs_in_desc.bEndpointAddress; |
| 843 | acm_ss_out_desc.bEndpointAddress = |
| 844 | acm_fs_out_desc.bEndpointAddress; |
| 845 | |
| 846 | /* copy descriptors, and track endpoint copies */ |
| 847 | f->ss_descriptors = usb_copy_descriptors(acm_ss_function); |
| 848 | if (!f->ss_descriptors) |
| 849 | goto fail; |
| 850 | } |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 851 | |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 852 | DBG(cdev, "acm ttyGS%d: %s speed IN/%s OUT/%s NOTIFY/%s\n", |
| 853 | acm->port_num, |
Sebastian Andrzej Siewior | 6fecfb0 | 2012-02-06 18:46:36 +0100 | [diff] [blame] | 854 | gadget_is_superspeed(c->cdev->gadget) ? "super" : |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 855 | gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", |
| 856 | acm->port.in->name, acm->port.out->name, |
| 857 | acm->notify->name); |
| 858 | return 0; |
| 859 | |
| 860 | fail: |
Rajkumar Raghupathy | c636cb4 | 2012-01-25 16:15:04 +0530 | [diff] [blame] | 861 | if (f->hs_descriptors) |
| 862 | usb_free_descriptors(f->hs_descriptors); |
| 863 | if (f->descriptors) |
| 864 | usb_free_descriptors(f->descriptors); |
| 865 | |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 866 | if (acm->notify_req) |
| 867 | gs_free_req(acm->notify, acm->notify_req); |
| 868 | |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 869 | /* we might as well release our claims on endpoints */ |
| 870 | if (acm->notify) |
| 871 | acm->notify->driver_data = NULL; |
| 872 | if (acm->port.out) |
| 873 | acm->port.out->driver_data = NULL; |
| 874 | if (acm->port.in) |
| 875 | acm->port.in->driver_data = NULL; |
| 876 | |
| 877 | ERROR(cdev, "%s/%p: can't bind, err %d\n", f->name, f, status); |
| 878 | |
| 879 | return status; |
| 880 | } |
| 881 | |
| 882 | static void |
| 883 | acm_unbind(struct usb_configuration *c, struct usb_function *f) |
| 884 | { |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 885 | struct f_acm *acm = func_to_acm(f); |
| 886 | |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 887 | if (gadget_is_dualspeed(c->cdev->gadget)) |
| 888 | usb_free_descriptors(f->hs_descriptors); |
Sebastian Andrzej Siewior | 6fecfb0 | 2012-02-06 18:46:36 +0100 | [diff] [blame] | 889 | if (gadget_is_superspeed(c->cdev->gadget)) |
| 890 | usb_free_descriptors(f->ss_descriptors); |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 891 | usb_free_descriptors(f->descriptors); |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 892 | gs_free_req(acm->notify, acm->notify_req); |
John Michelau | 677ba87 | 2010-11-08 18:05:37 -0600 | [diff] [blame] | 893 | kfree(acm->port.func.name); |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 894 | kfree(acm); |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 895 | } |
| 896 | |
| 897 | /* Some controllers can't support CDC ACM ... */ |
| 898 | static inline bool can_support_cdc(struct usb_configuration *c) |
| 899 | { |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 900 | /* everything else is *probably* fine ... */ |
| 901 | return true; |
| 902 | } |
| 903 | |
| 904 | /** |
| 905 | * acm_bind_config - add a CDC ACM function to a configuration |
| 906 | * @c: the configuration to support the CDC ACM instance |
| 907 | * @port_num: /dev/ttyGS* port this interface will use |
| 908 | * Context: single threaded during gadget setup |
| 909 | * |
| 910 | * Returns zero on success, else negative errno. |
| 911 | * |
| 912 | * Caller must have called @gserial_setup() with enough ports to |
| 913 | * handle all the ones it binds. Caller is also responsible |
| 914 | * for calling @gserial_cleanup() before module unload. |
| 915 | */ |
Michal Nazarewicz | 28824b1 | 2010-05-05 12:53:13 +0200 | [diff] [blame] | 916 | int acm_bind_config(struct usb_configuration *c, u8 port_num) |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 917 | { |
| 918 | struct f_acm *acm; |
| 919 | int status; |
| 920 | |
| 921 | if (!can_support_cdc(c)) |
| 922 | return -EINVAL; |
| 923 | |
| 924 | /* REVISIT might want instance-specific strings to help |
| 925 | * distinguish instances ... |
| 926 | */ |
| 927 | |
| 928 | /* maybe allocate device-global string IDs, and patch descriptors */ |
| 929 | if (acm_string_defs[ACM_CTRL_IDX].id == 0) { |
| 930 | status = usb_string_id(c->cdev); |
| 931 | if (status < 0) |
| 932 | return status; |
| 933 | acm_string_defs[ACM_CTRL_IDX].id = status; |
| 934 | |
| 935 | acm_control_interface_desc.iInterface = status; |
| 936 | |
| 937 | status = usb_string_id(c->cdev); |
| 938 | if (status < 0) |
| 939 | return status; |
| 940 | acm_string_defs[ACM_DATA_IDX].id = status; |
| 941 | |
| 942 | acm_data_interface_desc.iInterface = status; |
Michal Nazarewicz | b97503f | 2009-10-28 16:57:30 +0100 | [diff] [blame] | 943 | |
| 944 | status = usb_string_id(c->cdev); |
| 945 | if (status < 0) |
| 946 | return status; |
| 947 | acm_string_defs[ACM_IAD_IDX].id = status; |
| 948 | |
| 949 | acm_iad_descriptor.iFunction = status; |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 950 | } |
| 951 | |
| 952 | /* allocate and initialize one new instance */ |
| 953 | acm = kzalloc(sizeof *acm, GFP_KERNEL); |
| 954 | if (!acm) |
| 955 | return -ENOMEM; |
| 956 | |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 957 | spin_lock_init(&acm->lock); |
| 958 | |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 959 | acm->port_num = port_num; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 960 | acm->transport = gacm_ports[port_num].transport; |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 961 | |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 962 | acm->port.connect = acm_connect; |
| 963 | acm->port.disconnect = acm_disconnect; |
| 964 | acm->port.send_break = acm_send_break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 965 | acm->port.send_modem_ctrl_bits = acm_send_modem_ctrl_bits; |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 966 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 967 | acm->port.func.name = kasprintf(GFP_KERNEL, "acm%u", port_num + 1); |
John Michelau | 677ba87 | 2010-11-08 18:05:37 -0600 | [diff] [blame] | 968 | if (!acm->port.func.name) { |
| 969 | kfree(acm); |
| 970 | return -ENOMEM; |
| 971 | } |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 972 | acm->port.func.strings = acm_strings; |
| 973 | /* descriptors are per-instance copies */ |
| 974 | acm->port.func.bind = acm_bind; |
| 975 | acm->port.func.unbind = acm_unbind; |
| 976 | acm->port.func.set_alt = acm_set_alt; |
| 977 | acm->port.func.setup = acm_setup; |
| 978 | acm->port.func.disable = acm_disable; |
| 979 | |
| 980 | status = usb_add_function(c, &acm->port.func); |
| 981 | if (status) |
| 982 | kfree(acm); |
| 983 | return status; |
| 984 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 985 | |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 986 | /** |
| 987 | * acm_init_port - bind a acm_port to its transport |
| 988 | */ |
Pavankumar Kondeti | d0f3d43 | 2013-04-25 10:35:54 +0530 | [diff] [blame] | 989 | static int acm_init_port(int port_num, const char *name, const char *port_name) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 990 | { |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 991 | enum transport_type transport; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 992 | |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 993 | if (port_num >= GSERIAL_NO_PORTS) |
| 994 | return -ENODEV; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 995 | |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 996 | transport = str_to_xport(name); |
| 997 | pr_debug("%s, port:%d, transport:%s\n", __func__, |
| 998 | port_num, xport_to_str(transport)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 999 | |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 1000 | gacm_ports[port_num].transport = transport; |
| 1001 | gacm_ports[port_num].port_num = port_num; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1002 | |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 1003 | switch (transport) { |
| 1004 | case USB_GADGET_XPORT_TTY: |
| 1005 | gacm_ports[port_num].client_port_num = no_acm_tty_ports; |
| 1006 | no_acm_tty_ports++; |
| 1007 | break; |
| 1008 | case USB_GADGET_XPORT_SDIO: |
| 1009 | gacm_ports[port_num].client_port_num = no_acm_sdio_ports; |
| 1010 | no_acm_sdio_ports++; |
| 1011 | break; |
| 1012 | case USB_GADGET_XPORT_SMD: |
| 1013 | gacm_ports[port_num].client_port_num = no_acm_smd_ports; |
| 1014 | no_acm_smd_ports++; |
| 1015 | break; |
Devin Kim | 192986b | 2012-06-20 08:37:37 -0700 | [diff] [blame] | 1016 | case USB_GADGET_XPORT_HSIC: |
Pavankumar Kondeti | d0f3d43 | 2013-04-25 10:35:54 +0530 | [diff] [blame] | 1017 | ghsic_ctrl_set_port_name(port_name, name); |
| 1018 | ghsic_data_set_port_name(port_name, name); |
| 1019 | |
Devin Kim | 192986b | 2012-06-20 08:37:37 -0700 | [diff] [blame] | 1020 | /*client port number will be updated in acm_port_setup*/ |
| 1021 | no_acm_hsic_sports++; |
| 1022 | break; |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 1023 | default: |
| 1024 | pr_err("%s: Un-supported transport transport: %u\n", |
| 1025 | __func__, gacm_ports[port_num].transport); |
| 1026 | return -ENODEV; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1027 | } |
| 1028 | |
Anji jonnala | 92be1b4 | 2011-12-19 09:44:41 +0530 | [diff] [blame] | 1029 | nr_acm_ports++; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1030 | |
| 1031 | return 0; |
| 1032 | } |