Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
David Brownell | a7707ad | 2008-06-19 17:52:07 -0700 | [diff] [blame] | 2 | * serial.c -- USB gadget serial driver |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
David Brownell | a7707ad | 2008-06-19 17:52:07 -0700 | [diff] [blame] | 4 | * Copyright (C) 2003 Al Borchers (alborchers@steinerpoint.com) |
| 5 | * Copyright (C) 2008 by David Brownell |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 6 | * Copyright (C) 2008 by Nokia Corporation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | */ |
| 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/device.h> |
Andrzej Pietrasiewicz | d141279 | 2013-03-21 09:22:30 +0100 | [diff] [blame] | 15 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/tty.h> |
| 17 | #include <linux/tty_flip.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
David Brownell | a7707ad | 2008-06-19 17:52:07 -0700 | [diff] [blame] | 19 | #include "u_serial.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include "gadget_chips.h" |
| 21 | |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | /* Defines */ |
| 24 | |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 25 | #define GS_VERSION_STR "v2.4" |
| 26 | #define GS_VERSION_NUM 0x2400 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
| 28 | #define GS_LONG_NAME "Gadget Serial" |
David Brownell | a7707ad | 2008-06-19 17:52:07 -0700 | [diff] [blame] | 29 | #define GS_VERSION_NAME GS_LONG_NAME " " GS_VERSION_STR |
| 30 | |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 31 | /*-------------------------------------------------------------------------*/ |
Sebastian Andrzej Siewior | 7d16e8d | 2012-09-10 15:01:53 +0200 | [diff] [blame] | 32 | USB_GADGET_COMPOSITE_OPTIONS(); |
David Brownell | 4e9ba51 | 2008-08-18 17:41:02 -0700 | [diff] [blame] | 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | /* Thanks to NetChip Technologies for donating this product ID. |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 35 | * |
| 36 | * DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! |
| 37 | * Instead: allocate your own, using normal USB-IF procedures. |
| 38 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #define GS_VENDOR_ID 0x0525 /* NetChip */ |
| 40 | #define GS_PRODUCT_ID 0xa4a6 /* Linux-USB Serial Gadget */ |
| 41 | #define GS_CDC_PRODUCT_ID 0xa4a7 /* ... as CDC-ACM */ |
Felipe Balbi | 3086775 | 2008-08-18 17:39:30 -0700 | [diff] [blame] | 42 | #define GS_CDC_OBEX_PRODUCT_ID 0xa4a9 /* ... as CDC-OBEX */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 44 | /* string IDs are assigned dynamically */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
Sebastian Andrzej Siewior | 276e2e4 | 2012-09-06 20:11:21 +0200 | [diff] [blame] | 46 | #define STRING_DESCRIPTION_IDX USB_GADGET_FIRST_AVAIL_IDX |
David Brownell | a7707ad | 2008-06-19 17:52:07 -0700 | [diff] [blame] | 47 | |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 48 | static struct usb_string strings_dev[] = { |
Sebastian Andrzej Siewior | cc2683c | 2012-09-10 15:01:58 +0200 | [diff] [blame] | 49 | [USB_GADGET_MANUFACTURER_IDX].s = "", |
Sebastian Andrzej Siewior | 276e2e4 | 2012-09-06 20:11:21 +0200 | [diff] [blame] | 50 | [USB_GADGET_PRODUCT_IDX].s = GS_VERSION_NAME, |
| 51 | [USB_GADGET_SERIAL_IDX].s = "", |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 52 | [STRING_DESCRIPTION_IDX].s = NULL /* updated; f(use_acm) */, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | { } /* end of list */ |
| 54 | }; |
| 55 | |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 56 | static struct usb_gadget_strings stringtab_dev = { |
| 57 | .language = 0x0409, /* en-us */ |
| 58 | .strings = strings_dev, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | }; |
| 60 | |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 61 | static struct usb_gadget_strings *dev_strings[] = { |
| 62 | &stringtab_dev, |
| 63 | NULL, |
| 64 | }; |
| 65 | |
| 66 | static struct usb_device_descriptor device_desc = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | .bLength = USB_DT_DEVICE_SIZE, |
| 68 | .bDescriptorType = USB_DT_DEVICE, |
Harvey Harrison | 551509d | 2009-02-11 14:11:36 -0800 | [diff] [blame] | 69 | .bcdUSB = cpu_to_le16(0x0200), |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 70 | /* .bDeviceClass = f(use_acm) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | .bDeviceSubClass = 0, |
| 72 | .bDeviceProtocol = 0, |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 73 | /* .bMaxPacketSize0 = f(hardware) */ |
Harvey Harrison | 551509d | 2009-02-11 14:11:36 -0800 | [diff] [blame] | 74 | .idVendor = cpu_to_le16(GS_VENDOR_ID), |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 75 | /* .idProduct = f(use_acm) */ |
Sebastian Andrzej Siewior | 5c4d46e | 2012-09-10 19:06:44 +0200 | [diff] [blame] | 76 | .bcdDevice = cpu_to_le16(GS_VERSION_NUM), |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 77 | /* .iManufacturer = DYNAMIC */ |
| 78 | /* .iProduct = DYNAMIC */ |
| 79 | .bNumConfigurations = 1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 82 | static struct usb_otg_descriptor otg_descriptor = { |
| 83 | .bLength = sizeof otg_descriptor, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | .bDescriptorType = USB_DT_OTG, |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 85 | |
| 86 | /* REVISIT SRP-only hardware is possible, although |
| 87 | * it would not be called "OTG" ... |
| 88 | */ |
| 89 | .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | }; |
| 91 | |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 92 | static const struct usb_descriptor_header *otg_desc[] = { |
| 93 | (struct usb_descriptor_header *) &otg_descriptor, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | NULL, |
| 95 | }; |
| 96 | |
David Brownell | 9079e91 | 2008-05-07 16:00:36 -0700 | [diff] [blame] | 97 | /*-------------------------------------------------------------------------*/ |
| 98 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | /* Module */ |
David Brownell | a7707ad | 2008-06-19 17:52:07 -0700 | [diff] [blame] | 100 | MODULE_DESCRIPTION(GS_VERSION_NAME); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | MODULE_AUTHOR("Al Borchers"); |
David Brownell | a7707ad | 2008-06-19 17:52:07 -0700 | [diff] [blame] | 102 | MODULE_AUTHOR("David Brownell"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | MODULE_LICENSE("GPL"); |
| 104 | |
Rusty Russell | 90ab5ee | 2012-01-13 09:32:20 +1030 | [diff] [blame] | 105 | static bool use_acm = true; |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 106 | module_param(use_acm, bool, 0); |
| 107 | MODULE_PARM_DESC(use_acm, "Use CDC ACM, default=yes"); |
| 108 | |
Rusty Russell | 90ab5ee | 2012-01-13 09:32:20 +1030 | [diff] [blame] | 109 | static bool use_obex = false; |
Felipe Balbi | 3086775 | 2008-08-18 17:39:30 -0700 | [diff] [blame] | 110 | module_param(use_obex, bool, 0); |
| 111 | MODULE_PARM_DESC(use_obex, "Use CDC OBEX, default=no"); |
| 112 | |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 113 | static unsigned n_ports = 1; |
| 114 | module_param(n_ports, uint, 0); |
| 115 | MODULE_PARM_DESC(n_ports, "number of ports to create, default=1"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
David Brownell | 9079e91 | 2008-05-07 16:00:36 -0700 | [diff] [blame] | 117 | /*-------------------------------------------------------------------------*/ |
Sebastian Andrzej Siewior | 48177cd | 2012-12-23 21:10:03 +0100 | [diff] [blame] | 118 | |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 119 | static struct usb_configuration serial_config_driver = { |
| 120 | /* .label = f(use_acm) */ |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 121 | /* .bConfigurationValue = f(use_acm) */ |
| 122 | /* .iConfiguration = DYNAMIC */ |
| 123 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
David Brownell | 9079e91 | 2008-05-07 16:00:36 -0700 | [diff] [blame] | 124 | }; |
| 125 | |
Sebastian Andrzej Siewior | ff47f59 | 2012-12-23 21:10:07 +0100 | [diff] [blame] | 126 | static struct usb_function_instance *fi_serial[MAX_U_SERIAL_PORTS]; |
| 127 | static struct usb_function *f_serial[MAX_U_SERIAL_PORTS]; |
| 128 | |
| 129 | static int serial_register_ports(struct usb_composite_dev *cdev, |
| 130 | struct usb_configuration *c, const char *f_name) |
Sebastian Andrzej Siewior | 19b10a8 | 2012-12-23 21:10:06 +0100 | [diff] [blame] | 131 | { |
| 132 | int i; |
Sebastian Andrzej Siewior | ff47f59 | 2012-12-23 21:10:07 +0100 | [diff] [blame] | 133 | int ret; |
Sebastian Andrzej Siewior | 19b10a8 | 2012-12-23 21:10:06 +0100 | [diff] [blame] | 134 | |
Sebastian Andrzej Siewior | ff47f59 | 2012-12-23 21:10:07 +0100 | [diff] [blame] | 135 | ret = usb_add_config_only(cdev, c); |
| 136 | if (ret) |
| 137 | goto out; |
| 138 | |
| 139 | for (i = 0; i < n_ports; i++) { |
Sebastian Andrzej Siewior | ff47f59 | 2012-12-23 21:10:07 +0100 | [diff] [blame] | 140 | |
| 141 | fi_serial[i] = usb_get_function_instance(f_name); |
| 142 | if (IS_ERR(fi_serial[i])) { |
| 143 | ret = PTR_ERR(fi_serial[i]); |
| 144 | goto fail; |
| 145 | } |
Sebastian Andrzej Siewior | ff47f59 | 2012-12-23 21:10:07 +0100 | [diff] [blame] | 146 | |
| 147 | f_serial[i] = usb_get_function(fi_serial[i]); |
| 148 | if (IS_ERR(f_serial[i])) { |
| 149 | ret = PTR_ERR(f_serial[i]); |
| 150 | goto err_get_func; |
| 151 | } |
| 152 | |
| 153 | ret = usb_add_function(c, f_serial[i]); |
| 154 | if (ret) |
| 155 | goto err_add_func; |
| 156 | } |
| 157 | |
Sebastian Andrzej Siewior | 19b10a8 | 2012-12-23 21:10:06 +0100 | [diff] [blame] | 158 | return 0; |
Sebastian Andrzej Siewior | ff47f59 | 2012-12-23 21:10:07 +0100 | [diff] [blame] | 159 | |
| 160 | err_add_func: |
| 161 | usb_put_function(f_serial[i]); |
| 162 | err_get_func: |
| 163 | usb_put_function_instance(fi_serial[i]); |
| 164 | |
| 165 | fail: |
| 166 | i--; |
| 167 | while (i >= 0) { |
| 168 | usb_remove_function(c, f_serial[i]); |
| 169 | usb_put_function(f_serial[i]); |
| 170 | usb_put_function_instance(fi_serial[i]); |
| 171 | i--; |
| 172 | } |
| 173 | out: |
| 174 | return ret; |
Sebastian Andrzej Siewior | 19b10a8 | 2012-12-23 21:10:06 +0100 | [diff] [blame] | 175 | } |
| 176 | |
Michal Nazarewicz | e12995e | 2010-08-12 17:43:52 +0200 | [diff] [blame] | 177 | static int __init gs_bind(struct usb_composite_dev *cdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | { |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 179 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 181 | /* Allocate string descriptor numbers ... note that string |
| 182 | * contents can be overridden by the composite_dev glue. |
David Brownell | f371e75 | 2008-04-18 17:37:49 -0700 | [diff] [blame] | 183 | */ |
| 184 | |
Sebastian Andrzej Siewior | e1f15cc | 2012-09-06 20:11:16 +0200 | [diff] [blame] | 185 | status = usb_string_ids_tab(cdev, strings_dev); |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 186 | if (status < 0) |
| 187 | goto fail; |
Sebastian Andrzej Siewior | 276e2e4 | 2012-09-06 20:11:21 +0200 | [diff] [blame] | 188 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
| 189 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
Sebastian Andrzej Siewior | e1f15cc | 2012-09-06 20:11:16 +0200 | [diff] [blame] | 190 | status = strings_dev[STRING_DESCRIPTION_IDX].id; |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 191 | serial_config_driver.iConfiguration = status; |
| 192 | |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 193 | if (gadget_is_otg(cdev->gadget)) { |
| 194 | serial_config_driver.descriptors = otg_desc; |
| 195 | serial_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; |
| 196 | } |
| 197 | |
| 198 | /* register our configuration */ |
Sebastian Andrzej Siewior | ff47f59 | 2012-12-23 21:10:07 +0100 | [diff] [blame] | 199 | if (use_acm) { |
| 200 | status = serial_register_ports(cdev, &serial_config_driver, |
| 201 | "acm"); |
| 202 | usb_ep_autoconfig_reset(cdev->gadget); |
| 203 | } else if (use_obex) |
Andrzej Pietrasiewicz | d141279 | 2013-03-21 09:22:30 +0100 | [diff] [blame] | 204 | status = serial_register_ports(cdev, &serial_config_driver, |
| 205 | "obex"); |
Andrzej Pietrasiewicz | 70cc3c0 | 2013-03-14 16:02:12 +0100 | [diff] [blame] | 206 | else { |
| 207 | status = serial_register_ports(cdev, &serial_config_driver, |
| 208 | "gser"); |
| 209 | } |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 210 | if (status < 0) |
| 211 | goto fail; |
| 212 | |
Sebastian Andrzej Siewior | 7d16e8d | 2012-09-10 15:01:53 +0200 | [diff] [blame] | 213 | usb_composite_overwrite_options(cdev, &coverwrite); |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 214 | INFO(cdev, "%s\n", GS_VERSION_NAME); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | |
| 216 | return 0; |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 217 | |
| 218 | fail: |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 219 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | } |
| 221 | |
Sebastian Andrzej Siewior | ff47f59 | 2012-12-23 21:10:07 +0100 | [diff] [blame] | 222 | static int gs_unbind(struct usb_composite_dev *cdev) |
| 223 | { |
| 224 | int i; |
| 225 | |
| 226 | for (i = 0; i < n_ports; i++) { |
| 227 | usb_put_function(f_serial[i]); |
| 228 | usb_put_function_instance(fi_serial[i]); |
Sebastian Andrzej Siewior | ff47f59 | 2012-12-23 21:10:07 +0100 | [diff] [blame] | 229 | } |
| 230 | return 0; |
| 231 | } |
| 232 | |
Sebastian Andrzej Siewior | c2ec75c | 2012-09-06 20:11:03 +0200 | [diff] [blame] | 233 | static __refdata struct usb_composite_driver gserial_driver = { |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 234 | .name = "g_serial", |
| 235 | .dev = &device_desc, |
| 236 | .strings = dev_strings, |
Sebastian Andrzej Siewior | 6fecfb0 | 2012-02-06 18:46:36 +0100 | [diff] [blame] | 237 | .max_speed = USB_SPEED_SUPER, |
Sebastian Andrzej Siewior | 03e42bd | 2012-09-06 20:11:04 +0200 | [diff] [blame] | 238 | .bind = gs_bind, |
Sebastian Andrzej Siewior | 19b10a8 | 2012-12-23 21:10:06 +0100 | [diff] [blame] | 239 | .unbind = gs_unbind, |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 240 | }; |
| 241 | |
| 242 | static int __init init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | { |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 244 | /* We *could* export two configs; that'd be much cleaner... |
| 245 | * but neither of these product IDs was defined that way. |
| 246 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | if (use_acm) { |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 248 | serial_config_driver.label = "CDC ACM config"; |
| 249 | serial_config_driver.bConfigurationValue = 2; |
| 250 | device_desc.bDeviceClass = USB_CLASS_COMM; |
| 251 | device_desc.idProduct = |
Harvey Harrison | 551509d | 2009-02-11 14:11:36 -0800 | [diff] [blame] | 252 | cpu_to_le16(GS_CDC_PRODUCT_ID); |
Felipe Balbi | 3086775 | 2008-08-18 17:39:30 -0700 | [diff] [blame] | 253 | } else if (use_obex) { |
| 254 | serial_config_driver.label = "CDC OBEX config"; |
| 255 | serial_config_driver.bConfigurationValue = 3; |
| 256 | device_desc.bDeviceClass = USB_CLASS_COMM; |
| 257 | device_desc.idProduct = |
Harvey Harrison | 551509d | 2009-02-11 14:11:36 -0800 | [diff] [blame] | 258 | cpu_to_le16(GS_CDC_OBEX_PRODUCT_ID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | } else { |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 260 | serial_config_driver.label = "Generic Serial config"; |
| 261 | serial_config_driver.bConfigurationValue = 1; |
| 262 | device_desc.bDeviceClass = USB_CLASS_VENDOR_SPEC; |
| 263 | device_desc.idProduct = |
Harvey Harrison | 551509d | 2009-02-11 14:11:36 -0800 | [diff] [blame] | 264 | cpu_to_le16(GS_PRODUCT_ID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | } |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 266 | strings_dev[STRING_DESCRIPTION_IDX].s = serial_config_driver.label; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | |
Sebastian Andrzej Siewior | 03e42bd | 2012-09-06 20:11:04 +0200 | [diff] [blame] | 268 | return usb_composite_probe(&gserial_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | } |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 270 | module_init(init); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 272 | static void __exit cleanup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | { |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 274 | usb_composite_unregister(&gserial_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | } |
David Brownell | 7bb5ea5 | 2008-06-19 18:19:03 -0700 | [diff] [blame] | 276 | module_exit(cleanup); |