diff options
Diffstat (limited to 'drivers/usb/gadget/cdc2.c')
-rw-r--r-- | drivers/usb/gadget/cdc2.c | 56 |
1 files changed, 11 insertions, 45 deletions
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c index 725550f06fab..1e4bb77f00bb 100644 --- a/drivers/usb/gadget/cdc2.c +++ b/drivers/usb/gadget/cdc2.c | |||
@@ -11,7 +11,6 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/utsname.h> | ||
15 | #include <linux/module.h> | 14 | #include <linux/module.h> |
16 | 15 | ||
17 | #include "u_ether.h" | 16 | #include "u_ether.h" |
@@ -34,6 +33,7 @@ | |||
34 | #define CDC_PRODUCT_NUM 0xa4aa /* CDC Composite: ECM + ACM */ | 33 | #define CDC_PRODUCT_NUM 0xa4aa /* CDC Composite: ECM + ACM */ |
35 | 34 | ||
36 | /*-------------------------------------------------------------------------*/ | 35 | /*-------------------------------------------------------------------------*/ |
36 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
37 | 37 | ||
38 | /* | 38 | /* |
39 | * Kbuild is not very cooperative with respect to linking separately | 39 | * Kbuild is not very cooperative with respect to linking separately |
@@ -43,10 +43,6 @@ | |||
43 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | 43 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
44 | */ | 44 | */ |
45 | 45 | ||
46 | #include "composite.c" | ||
47 | #include "usbstring.c" | ||
48 | #include "config.c" | ||
49 | #include "epautoconf.c" | ||
50 | #include "u_serial.c" | 46 | #include "u_serial.c" |
51 | #include "f_acm.c" | 47 | #include "f_acm.c" |
52 | #include "f_ecm.c" | 48 | #include "f_ecm.c" |
@@ -92,15 +88,10 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
92 | 88 | ||
93 | 89 | ||
94 | /* string IDs are assigned dynamically */ | 90 | /* string IDs are assigned dynamically */ |
95 | |||
96 | #define STRING_MANUFACTURER_IDX 0 | ||
97 | #define STRING_PRODUCT_IDX 1 | ||
98 | |||
99 | static char manufacturer[50]; | ||
100 | |||
101 | static struct usb_string strings_dev[] = { | 91 | static struct usb_string strings_dev[] = { |
102 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 92 | [USB_GADGET_MANUFACTURER_IDX].s = "", |
103 | [STRING_PRODUCT_IDX].s = DRIVER_DESC, | 93 | [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC, |
94 | [USB_GADGET_SERIAL_IDX].s = "", | ||
104 | { } /* end of list */ | 95 | { } /* end of list */ |
105 | }; | 96 | }; |
106 | 97 | ||
@@ -152,7 +143,6 @@ static struct usb_configuration cdc_config_driver = { | |||
152 | 143 | ||
153 | static int __init cdc_bind(struct usb_composite_dev *cdev) | 144 | static int __init cdc_bind(struct usb_composite_dev *cdev) |
154 | { | 145 | { |
155 | int gcnum; | ||
156 | struct usb_gadget *gadget = cdev->gadget; | 146 | struct usb_gadget *gadget = cdev->gadget; |
157 | int status; | 147 | int status; |
158 | 148 | ||
@@ -172,47 +162,22 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) | |||
172 | if (status < 0) | 162 | if (status < 0) |
173 | goto fail0; | 163 | goto fail0; |
174 | 164 | ||
175 | gcnum = usb_gadget_controller_number(gadget); | ||
176 | if (gcnum >= 0) | ||
177 | device_desc.bcdDevice = cpu_to_le16(0x0300 | gcnum); | ||
178 | else { | ||
179 | /* We assume that can_support_ecm() tells the truth; | ||
180 | * but if the controller isn't recognized at all then | ||
181 | * that assumption is a bit more likely to be wrong. | ||
182 | */ | ||
183 | WARNING(cdev, "controller '%s' not recognized; trying %s\n", | ||
184 | gadget->name, | ||
185 | cdc_config_driver.label); | ||
186 | device_desc.bcdDevice = | ||
187 | cpu_to_le16(0x0300 | 0x0099); | ||
188 | } | ||
189 | |||
190 | |||
191 | /* Allocate string descriptor numbers ... note that string | 165 | /* Allocate string descriptor numbers ... note that string |
192 | * contents can be overridden by the composite_dev glue. | 166 | * contents can be overridden by the composite_dev glue. |
193 | */ | 167 | */ |
194 | 168 | ||
195 | /* device descriptor strings: manufacturer, product */ | 169 | status = usb_string_ids_tab(cdev, strings_dev); |
196 | snprintf(manufacturer, sizeof manufacturer, "%s %s with %s", | ||
197 | init_utsname()->sysname, init_utsname()->release, | ||
198 | gadget->name); | ||
199 | status = usb_string_id(cdev); | ||
200 | if (status < 0) | ||
201 | goto fail1; | ||
202 | strings_dev[STRING_MANUFACTURER_IDX].id = status; | ||
203 | device_desc.iManufacturer = status; | ||
204 | |||
205 | status = usb_string_id(cdev); | ||
206 | if (status < 0) | 170 | if (status < 0) |
207 | goto fail1; | 171 | goto fail1; |
208 | strings_dev[STRING_PRODUCT_IDX].id = status; | 172 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
209 | device_desc.iProduct = status; | 173 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
210 | 174 | ||
211 | /* register our configuration */ | 175 | /* register our configuration */ |
212 | status = usb_add_config(cdev, &cdc_config_driver, cdc_do_config); | 176 | status = usb_add_config(cdev, &cdc_config_driver, cdc_do_config); |
213 | if (status < 0) | 177 | if (status < 0) |
214 | goto fail1; | 178 | goto fail1; |
215 | 179 | ||
180 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
216 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", | 181 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", |
217 | DRIVER_DESC); | 182 | DRIVER_DESC); |
218 | 183 | ||
@@ -232,11 +197,12 @@ static int __exit cdc_unbind(struct usb_composite_dev *cdev) | |||
232 | return 0; | 197 | return 0; |
233 | } | 198 | } |
234 | 199 | ||
235 | static struct usb_composite_driver cdc_driver = { | 200 | static __refdata struct usb_composite_driver cdc_driver = { |
236 | .name = "g_cdc", | 201 | .name = "g_cdc", |
237 | .dev = &device_desc, | 202 | .dev = &device_desc, |
238 | .strings = dev_strings, | 203 | .strings = dev_strings, |
239 | .max_speed = USB_SPEED_HIGH, | 204 | .max_speed = USB_SPEED_HIGH, |
205 | .bind = cdc_bind, | ||
240 | .unbind = __exit_p(cdc_unbind), | 206 | .unbind = __exit_p(cdc_unbind), |
241 | }; | 207 | }; |
242 | 208 | ||
@@ -246,7 +212,7 @@ MODULE_LICENSE("GPL"); | |||
246 | 212 | ||
247 | static int __init init(void) | 213 | static int __init init(void) |
248 | { | 214 | { |
249 | return usb_composite_probe(&cdc_driver, cdc_bind); | 215 | return usb_composite_probe(&cdc_driver); |
250 | } | 216 | } |
251 | module_init(init); | 217 | module_init(init); |
252 | 218 | ||