diff options
-rw-r--r-- | drivers/usb/gadget/acm_ms.c | 2 | ||||
-rw-r--r-- | drivers/usb/gadget/audio.c | 3 | ||||
-rw-r--r-- | drivers/usb/gadget/cdc2.c | 2 | ||||
-rw-r--r-- | drivers/usb/gadget/composite.c | 63 | ||||
-rw-r--r-- | drivers/usb/gadget/ether.c | 2 | ||||
-rw-r--r-- | drivers/usb/gadget/g_ffs.c | 4 | ||||
-rw-r--r-- | drivers/usb/gadget/gmidi.c | 4 | ||||
-rw-r--r-- | drivers/usb/gadget/hid.c | 2 | ||||
-rw-r--r-- | drivers/usb/gadget/mass_storage.c | 3 | ||||
-rw-r--r-- | drivers/usb/gadget/multi.c | 3 | ||||
-rw-r--r-- | drivers/usb/gadget/ncm.c | 2 | ||||
-rw-r--r-- | drivers/usb/gadget/nokia.c | 2 | ||||
-rw-r--r-- | drivers/usb/gadget/printer.c | 4 | ||||
-rw-r--r-- | drivers/usb/gadget/serial.c | 2 | ||||
-rw-r--r-- | drivers/usb/gadget/tcm_usb_gadget.c | 5 | ||||
-rw-r--r-- | drivers/usb/gadget/webcam.c | 2 | ||||
-rw-r--r-- | drivers/usb/gadget/zero.c | 2 | ||||
-rw-r--r-- | include/linux/usb/composite.h | 24 |
18 files changed, 103 insertions, 28 deletions
diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c index ea349bab7f15..7bd6b71af5d3 100644 --- a/drivers/usb/gadget/acm_ms.c +++ b/drivers/usb/gadget/acm_ms.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include "f_mass_storage.c" | 47 | #include "f_mass_storage.c" |
48 | 48 | ||
49 | /*-------------------------------------------------------------------------*/ | 49 | /*-------------------------------------------------------------------------*/ |
50 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
50 | 51 | ||
51 | static struct usb_device_descriptor device_desc = { | 52 | static struct usb_device_descriptor device_desc = { |
52 | .bLength = sizeof device_desc, | 53 | .bLength = sizeof device_desc, |
@@ -203,6 +204,7 @@ static int __init acm_ms_bind(struct usb_composite_dev *cdev) | |||
203 | if (status < 0) | 204 | if (status < 0) |
204 | goto fail1; | 205 | goto fail1; |
205 | 206 | ||
207 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
206 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", | 208 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", |
207 | DRIVER_DESC); | 209 | DRIVER_DESC); |
208 | fsg_common_put(&fsg_common); | 210 | fsg_common_put(&fsg_common); |
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c index 5702ce3777fb..55b593c5a9c8 100644 --- a/drivers/usb/gadget/audio.c +++ b/drivers/usb/gadget/audio.c | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/utsname.h> | 15 | #include <linux/utsname.h> |
16 | #include <linux/usb/composite.h> | ||
16 | 17 | ||
17 | #include "gadget_chips.h" | 18 | #include "gadget_chips.h" |
18 | #define DRIVER_DESC "Linux USB Audio Gadget" | 19 | #define DRIVER_DESC "Linux USB Audio Gadget" |
@@ -28,6 +29,7 @@ | |||
28 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | 29 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
29 | */ | 30 | */ |
30 | #include "composite.c" | 31 | #include "composite.c" |
32 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
31 | 33 | ||
32 | /* string IDs are assigned dynamically */ | 34 | /* string IDs are assigned dynamically */ |
33 | 35 | ||
@@ -174,6 +176,7 @@ static int __init audio_bind(struct usb_composite_dev *cdev) | |||
174 | status = usb_add_config(cdev, &audio_config_driver, audio_do_config); | 176 | status = usb_add_config(cdev, &audio_config_driver, audio_do_config); |
175 | if (status < 0) | 177 | if (status < 0) |
176 | goto fail; | 178 | goto fail; |
179 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
177 | 180 | ||
178 | INFO(cdev, "%s, version: %s\n", DRIVER_DESC, DRIVER_VERSION); | 181 | INFO(cdev, "%s, version: %s\n", DRIVER_DESC, DRIVER_VERSION); |
179 | return 0; | 182 | return 0; |
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c index 3b89fe2bd0b8..93a75809b4de 100644 --- a/drivers/usb/gadget/cdc2.c +++ b/drivers/usb/gadget/cdc2.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #define CDC_PRODUCT_NUM 0xa4aa /* CDC Composite: ECM + ACM */ | 34 | #define CDC_PRODUCT_NUM 0xa4aa /* CDC Composite: ECM + ACM */ |
35 | 35 | ||
36 | /*-------------------------------------------------------------------------*/ | 36 | /*-------------------------------------------------------------------------*/ |
37 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
37 | 38 | ||
38 | /* | 39 | /* |
39 | * Kbuild is not very cooperative with respect to linking separately | 40 | * Kbuild is not very cooperative with respect to linking separately |
@@ -204,6 +205,7 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) | |||
204 | if (status < 0) | 205 | if (status < 0) |
205 | goto fail1; | 206 | goto fail1; |
206 | 207 | ||
208 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
207 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", | 209 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", |
208 | DRIVER_DESC); | 210 | DRIVER_DESC); |
209 | 211 | ||
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 8d81a5ccfa03..317a5ece3bd2 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
@@ -32,19 +32,6 @@ | |||
32 | * published in the device descriptor, either numbers or strings or both. | 32 | * published in the device descriptor, either numbers or strings or both. |
33 | * String parameters are in UTF-8 (superset of ASCII's 7 bit characters). | 33 | * String parameters are in UTF-8 (superset of ASCII's 7 bit characters). |
34 | */ | 34 | */ |
35 | |||
36 | static ushort idVendor; | ||
37 | module_param(idVendor, ushort, S_IRUGO); | ||
38 | MODULE_PARM_DESC(idVendor, "USB Vendor ID"); | ||
39 | |||
40 | static ushort idProduct; | ||
41 | module_param(idProduct, ushort, S_IRUGO); | ||
42 | MODULE_PARM_DESC(idProduct, "USB Product ID"); | ||
43 | |||
44 | static ushort bcdDevice; | ||
45 | module_param(bcdDevice, ushort, S_IRUGO); | ||
46 | MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)"); | ||
47 | |||
48 | static char *iManufacturer; | 35 | static char *iManufacturer; |
49 | module_param(iManufacturer, charp, S_IRUGO); | 36 | module_param(iManufacturer, charp, S_IRUGO); |
50 | MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string"); | 37 | MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string"); |
@@ -1418,6 +1405,30 @@ static u8 override_id(struct usb_composite_dev *cdev, u8 *desc) | |||
1418 | return *desc; | 1405 | return *desc; |
1419 | } | 1406 | } |
1420 | 1407 | ||
1408 | static void update_unchanged_dev_desc(struct usb_device_descriptor *new, | ||
1409 | const struct usb_device_descriptor *old) | ||
1410 | { | ||
1411 | __le16 idVendor; | ||
1412 | __le16 idProduct; | ||
1413 | __le16 bcdDevice; | ||
1414 | |||
1415 | /* | ||
1416 | * these variables may have been set in | ||
1417 | * usb_composite_overwrite_options() | ||
1418 | */ | ||
1419 | idVendor = new->idVendor; | ||
1420 | idProduct = new->idProduct; | ||
1421 | bcdDevice = new->bcdDevice; | ||
1422 | |||
1423 | *new = *old; | ||
1424 | if (idVendor) | ||
1425 | new->idVendor = idVendor; | ||
1426 | if (idProduct) | ||
1427 | new->idProduct = idProduct; | ||
1428 | if (bcdDevice) | ||
1429 | new->bcdDevice = bcdDevice; | ||
1430 | } | ||
1431 | |||
1421 | static struct usb_composite_driver *to_cdriver(struct usb_gadget_driver *gdrv) | 1432 | static struct usb_composite_driver *to_cdriver(struct usb_gadget_driver *gdrv) |
1422 | { | 1433 | { |
1423 | return container_of(gdrv, struct usb_composite_driver, gadget_driver); | 1434 | return container_of(gdrv, struct usb_composite_driver, gadget_driver); |
@@ -1473,17 +1484,7 @@ static int composite_bind(struct usb_gadget *gadget, | |||
1473 | if (status < 0) | 1484 | if (status < 0) |
1474 | goto fail; | 1485 | goto fail; |
1475 | 1486 | ||
1476 | cdev->desc = *composite->dev; | 1487 | update_unchanged_dev_desc(&cdev->desc, composite->dev); |
1477 | |||
1478 | /* standardized runtime overrides for device ID data */ | ||
1479 | if (idVendor) | ||
1480 | cdev->desc.idVendor = cpu_to_le16(idVendor); | ||
1481 | |||
1482 | if (idProduct) | ||
1483 | cdev->desc.idProduct = cpu_to_le16(idProduct); | ||
1484 | |||
1485 | if (bcdDevice) | ||
1486 | cdev->desc.bcdDevice = cpu_to_le16(bcdDevice); | ||
1487 | 1488 | ||
1488 | /* string overrides */ | 1489 | /* string overrides */ |
1489 | if (iManufacturer || !cdev->desc.iManufacturer) { | 1490 | if (iManufacturer || !cdev->desc.iManufacturer) { |
@@ -1686,3 +1687,17 @@ void usb_composite_setup_continue(struct usb_composite_dev *cdev) | |||
1686 | spin_unlock_irqrestore(&cdev->lock, flags); | 1687 | spin_unlock_irqrestore(&cdev->lock, flags); |
1687 | } | 1688 | } |
1688 | 1689 | ||
1690 | void usb_composite_overwrite_options(struct usb_composite_dev *cdev, | ||
1691 | struct usb_composite_overwrite *covr) | ||
1692 | { | ||
1693 | struct usb_device_descriptor *desc = &cdev->desc; | ||
1694 | |||
1695 | if (covr->idVendor) | ||
1696 | desc->idVendor = cpu_to_le16(covr->idVendor); | ||
1697 | |||
1698 | if (covr->idProduct) | ||
1699 | desc->idProduct = cpu_to_le16(covr->idProduct); | ||
1700 | |||
1701 | if (covr->bcdDevice) | ||
1702 | desc->bcdDevice = cpu_to_le16(covr->bcdDevice); | ||
1703 | } | ||
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 004c6ed79e3b..709ef2265596 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -114,6 +114,7 @@ static inline bool has_rndis(void) | |||
114 | #include "u_ether.c" | 114 | #include "u_ether.c" |
115 | 115 | ||
116 | /*-------------------------------------------------------------------------*/ | 116 | /*-------------------------------------------------------------------------*/ |
117 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
117 | 118 | ||
118 | /* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! | 119 | /* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! |
119 | * Instead: allocate your own, using normal USB-IF procedures. | 120 | * Instead: allocate your own, using normal USB-IF procedures. |
@@ -363,6 +364,7 @@ static int __init eth_bind(struct usb_composite_dev *cdev) | |||
363 | if (status < 0) | 364 | if (status < 0) |
364 | goto fail; | 365 | goto fail; |
365 | 366 | ||
367 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
366 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", | 368 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", |
367 | DRIVER_DESC); | 369 | DRIVER_DESC); |
368 | 370 | ||
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c index c3a583ea9938..a44ed661c16b 100644 --- a/drivers/usb/gadget/g_ffs.c +++ b/drivers/usb/gadget/g_ffs.c | |||
@@ -73,6 +73,8 @@ struct gfs_ffs_obj { | |||
73 | struct ffs_data *ffs_data; | 73 | struct ffs_data *ffs_data; |
74 | }; | 74 | }; |
75 | 75 | ||
76 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
77 | |||
76 | static struct usb_device_descriptor gfs_dev_desc = { | 78 | static struct usb_device_descriptor gfs_dev_desc = { |
77 | .bLength = sizeof gfs_dev_desc, | 79 | .bLength = sizeof gfs_dev_desc, |
78 | .bDescriptorType = USB_DT_DEVICE, | 80 | .bDescriptorType = USB_DT_DEVICE, |
@@ -377,7 +379,7 @@ static int gfs_bind(struct usb_composite_dev *cdev) | |||
377 | if (unlikely(ret < 0)) | 379 | if (unlikely(ret < 0)) |
378 | goto error_unbind; | 380 | goto error_unbind; |
379 | } | 381 | } |
380 | 382 | usb_composite_overwrite_options(cdev, &coverwrite); | |
381 | return 0; | 383 | return 0; |
382 | 384 | ||
383 | error_unbind: | 385 | error_unbind: |
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index 68f8c032ba6b..01b31e2d03af 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c | |||
@@ -48,6 +48,8 @@ MODULE_LICENSE("GPL v2"); | |||
48 | static const char shortname[] = "g_midi"; | 48 | static const char shortname[] = "g_midi"; |
49 | static const char longname[] = "MIDI Gadget"; | 49 | static const char longname[] = "MIDI Gadget"; |
50 | 50 | ||
51 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
52 | |||
51 | static int index = SNDRV_DEFAULT_IDX1; | 53 | static int index = SNDRV_DEFAULT_IDX1; |
52 | module_param(index, int, S_IRUGO); | 54 | module_param(index, int, S_IRUGO); |
53 | MODULE_PARM_DESC(index, "Index value for the USB MIDI Gadget adapter."); | 55 | MODULE_PARM_DESC(index, "Index value for the USB MIDI Gadget adapter."); |
@@ -163,7 +165,7 @@ static int __init midi_bind(struct usb_composite_dev *cdev) | |||
163 | status = usb_add_config(cdev, &midi_config, midi_bind_config); | 165 | status = usb_add_config(cdev, &midi_config, midi_bind_config); |
164 | if (status < 0) | 166 | if (status < 0) |
165 | return status; | 167 | return status; |
166 | 168 | usb_composite_overwrite_options(cdev, &coverwrite); | |
167 | pr_info("%s\n", longname); | 169 | pr_info("%s\n", longname); |
168 | return 0; | 170 | return 0; |
169 | } | 171 | } |
diff --git a/drivers/usb/gadget/hid.c b/drivers/usb/gadget/hid.c index 1e3f03be94df..59fe7eef00da 100644 --- a/drivers/usb/gadget/hid.c +++ b/drivers/usb/gadget/hid.c | |||
@@ -48,6 +48,7 @@ struct hidg_func_node { | |||
48 | static LIST_HEAD(hidg_func_list); | 48 | static LIST_HEAD(hidg_func_list); |
49 | 49 | ||
50 | /*-------------------------------------------------------------------------*/ | 50 | /*-------------------------------------------------------------------------*/ |
51 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
51 | 52 | ||
52 | static struct usb_device_descriptor device_desc = { | 53 | static struct usb_device_descriptor device_desc = { |
53 | .bLength = sizeof device_desc, | 54 | .bLength = sizeof device_desc, |
@@ -188,6 +189,7 @@ static int __init hid_bind(struct usb_composite_dev *cdev) | |||
188 | if (status < 0) | 189 | if (status < 0) |
189 | return status; | 190 | return status; |
190 | 191 | ||
192 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
191 | dev_info(&gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); | 193 | dev_info(&gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); |
192 | 194 | ||
193 | return 0; | 195 | return 0; |
diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index 0b0f008427ed..8ffbade383f2 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c | |||
@@ -52,6 +52,7 @@ | |||
52 | #include "f_mass_storage.c" | 52 | #include "f_mass_storage.c" |
53 | 53 | ||
54 | /*-------------------------------------------------------------------------*/ | 54 | /*-------------------------------------------------------------------------*/ |
55 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
55 | 56 | ||
56 | static struct usb_device_descriptor msg_device_desc = { | 57 | static struct usb_device_descriptor msg_device_desc = { |
57 | .bLength = sizeof msg_device_desc, | 58 | .bLength = sizeof msg_device_desc, |
@@ -143,7 +144,7 @@ static int __init msg_bind(struct usb_composite_dev *cdev) | |||
143 | status = usb_add_config(cdev, &msg_config_driver, msg_do_config); | 144 | status = usb_add_config(cdev, &msg_config_driver, msg_do_config); |
144 | if (status < 0) | 145 | if (status < 0) |
145 | return status; | 146 | return status; |
146 | 147 | usb_composite_overwrite_options(cdev, &coverwrite); | |
147 | dev_info(&cdev->gadget->dev, | 148 | dev_info(&cdev->gadget->dev, |
148 | DRIVER_DESC ", version: " DRIVER_VERSION "\n"); | 149 | DRIVER_DESC ", version: " DRIVER_VERSION "\n"); |
149 | set_bit(0, &msg_registered); | 150 | set_bit(0, &msg_registered); |
diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index 72fb30141ff4..60168877330a 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c | |||
@@ -58,7 +58,7 @@ MODULE_LICENSE("GPL"); | |||
58 | #endif | 58 | #endif |
59 | #include "u_ether.c" | 59 | #include "u_ether.c" |
60 | 60 | ||
61 | 61 | USB_GADGET_COMPOSITE_OPTIONS(); | |
62 | 62 | ||
63 | /***************************** Device Descriptor ****************************/ | 63 | /***************************** Device Descriptor ****************************/ |
64 | 64 | ||
@@ -307,6 +307,7 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) | |||
307 | status = cdc_config_register(cdev); | 307 | status = cdc_config_register(cdev); |
308 | if (unlikely(status < 0)) | 308 | if (unlikely(status < 0)) |
309 | goto fail2; | 309 | goto fail2; |
310 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
310 | 311 | ||
311 | /* we're done */ | 312 | /* we're done */ |
312 | dev_info(&gadget->dev, DRIVER_DESC "\n"); | 313 | dev_info(&gadget->dev, DRIVER_DESC "\n"); |
diff --git a/drivers/usb/gadget/ncm.c b/drivers/usb/gadget/ncm.c index 6c7e15984535..8537cd9c6aff 100644 --- a/drivers/usb/gadget/ncm.c +++ b/drivers/usb/gadget/ncm.c | |||
@@ -54,6 +54,7 @@ | |||
54 | #define CDC_PRODUCT_NUM 0xa4a1 /* Linux-USB Ethernet Gadget */ | 54 | #define CDC_PRODUCT_NUM 0xa4a1 /* Linux-USB Ethernet Gadget */ |
55 | 55 | ||
56 | /*-------------------------------------------------------------------------*/ | 56 | /*-------------------------------------------------------------------------*/ |
57 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
57 | 58 | ||
58 | static struct usb_device_descriptor device_desc = { | 59 | static struct usb_device_descriptor device_desc = { |
59 | .bLength = sizeof device_desc, | 60 | .bLength = sizeof device_desc, |
@@ -191,6 +192,7 @@ static int __init gncm_bind(struct usb_composite_dev *cdev) | |||
191 | if (status < 0) | 192 | if (status < 0) |
192 | goto fail; | 193 | goto fail; |
193 | 194 | ||
195 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
194 | dev_info(&gadget->dev, "%s\n", DRIVER_DESC); | 196 | dev_info(&gadget->dev, "%s\n", DRIVER_DESC); |
195 | 197 | ||
196 | return 0; | 198 | return 0; |
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c index b0893136a05d..5ed927b16c0e 100644 --- a/drivers/usb/gadget/nokia.c +++ b/drivers/usb/gadget/nokia.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include "u_ether.c" | 49 | #include "u_ether.c" |
50 | 50 | ||
51 | /*-------------------------------------------------------------------------*/ | 51 | /*-------------------------------------------------------------------------*/ |
52 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
52 | 53 | ||
53 | #define NOKIA_VENDOR_ID 0x0421 /* Nokia */ | 54 | #define NOKIA_VENDOR_ID 0x0421 /* Nokia */ |
54 | #define NOKIA_PRODUCT_ID 0x01c8 /* Nokia Gadget */ | 55 | #define NOKIA_PRODUCT_ID 0x01c8 /* Nokia Gadget */ |
@@ -197,6 +198,7 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) | |||
197 | if (status < 0) | 198 | if (status < 0) |
198 | goto err_usb; | 199 | goto err_usb; |
199 | 200 | ||
201 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
200 | dev_info(&gadget->dev, "%s\n", NOKIA_LONG_NAME); | 202 | dev_info(&gadget->dev, "%s\n", NOKIA_LONG_NAME); |
201 | 203 | ||
202 | return 0; | 204 | return 0; |
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index 51b6e7bf413e..3fa4d80629cc 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c | |||
@@ -54,6 +54,7 @@ | |||
54 | #include "composite.c" | 54 | #include "composite.c" |
55 | 55 | ||
56 | /*-------------------------------------------------------------------------*/ | 56 | /*-------------------------------------------------------------------------*/ |
57 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
57 | 58 | ||
58 | #define DRIVER_DESC "Printer Gadget" | 59 | #define DRIVER_DESC "Printer Gadget" |
59 | #define DRIVER_VERSION "2007 OCT 06" | 60 | #define DRIVER_VERSION "2007 OCT 06" |
@@ -1265,6 +1266,9 @@ static int __init printer_bind(struct usb_composite_dev *cdev) | |||
1265 | device_desc.iSerialNumber = strings[STRING_SERIALNUM].id; | 1266 | device_desc.iSerialNumber = strings[STRING_SERIALNUM].id; |
1266 | 1267 | ||
1267 | ret = usb_add_config(cdev, &printer_cfg_driver, printer_bind_config); | 1268 | ret = usb_add_config(cdev, &printer_cfg_driver, printer_bind_config); |
1269 | if (ret) | ||
1270 | return ret; | ||
1271 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
1268 | return ret; | 1272 | return ret; |
1269 | } | 1273 | } |
1270 | 1274 | ||
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 9962504e14f1..27b5ce939bdb 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include "u_serial.c" | 45 | #include "u_serial.c" |
46 | 46 | ||
47 | /*-------------------------------------------------------------------------*/ | 47 | /*-------------------------------------------------------------------------*/ |
48 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
48 | 49 | ||
49 | /* Thanks to NetChip Technologies for donating this product ID. | 50 | /* Thanks to NetChip Technologies for donating this product ID. |
50 | * | 51 | * |
@@ -212,6 +213,7 @@ static int __init gs_bind(struct usb_composite_dev *cdev) | |||
212 | if (status < 0) | 213 | if (status < 0) |
213 | goto fail; | 214 | goto fail; |
214 | 215 | ||
216 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
215 | INFO(cdev, "%s\n", GS_VERSION_NAME); | 217 | INFO(cdev, "%s\n", GS_VERSION_NAME); |
216 | 218 | ||
217 | return 0; | 219 | return 0; |
diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c index 2f4980881a80..fa3137ef228b 100644 --- a/drivers/usb/gadget/tcm_usb_gadget.c +++ b/drivers/usb/gadget/tcm_usb_gadget.c | |||
@@ -29,6 +29,8 @@ | |||
29 | 29 | ||
30 | #include "tcm_usb_gadget.h" | 30 | #include "tcm_usb_gadget.h" |
31 | 31 | ||
32 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
33 | |||
32 | static struct target_fabric_configfs *usbg_fabric_configfs; | 34 | static struct target_fabric_configfs *usbg_fabric_configfs; |
33 | 35 | ||
34 | static inline struct f_uas *to_f_uas(struct usb_function *f) | 36 | static inline struct f_uas *to_f_uas(struct usb_function *f) |
@@ -2437,6 +2439,9 @@ static int usb_target_bind(struct usb_composite_dev *cdev) | |||
2437 | 2439 | ||
2438 | ret = usb_add_config(cdev, &usbg_config_driver, | 2440 | ret = usb_add_config(cdev, &usbg_config_driver, |
2439 | usbg_cfg_bind); | 2441 | usbg_cfg_bind); |
2442 | if (ret) | ||
2443 | return ret; | ||
2444 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
2440 | return 0; | 2445 | return 0; |
2441 | } | 2446 | } |
2442 | 2447 | ||
diff --git a/drivers/usb/gadget/webcam.c b/drivers/usb/gadget/webcam.c index d44a4510a65a..306006419f38 100644 --- a/drivers/usb/gadget/webcam.c +++ b/drivers/usb/gadget/webcam.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "uvc_v4l2.c" | 30 | #include "uvc_v4l2.c" |
31 | #include "f_uvc.c" | 31 | #include "f_uvc.c" |
32 | 32 | ||
33 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
33 | /* -------------------------------------------------------------------------- | 34 | /* -------------------------------------------------------------------------- |
34 | * Device descriptor | 35 | * Device descriptor |
35 | */ | 36 | */ |
@@ -370,6 +371,7 @@ webcam_bind(struct usb_composite_dev *cdev) | |||
370 | webcam_config_bind)) < 0) | 371 | webcam_config_bind)) < 0) |
371 | goto error; | 372 | goto error; |
372 | 373 | ||
374 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
373 | INFO(cdev, "Webcam Video Gadget\n"); | 375 | INFO(cdev, "Webcam Video Gadget\n"); |
374 | return 0; | 376 | return 0; |
375 | 377 | ||
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index dbc336e3ba98..2b31a4ae26b9 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c | |||
@@ -64,6 +64,7 @@ | |||
64 | #include "f_loopback.c" | 64 | #include "f_loopback.c" |
65 | 65 | ||
66 | /*-------------------------------------------------------------------------*/ | 66 | /*-------------------------------------------------------------------------*/ |
67 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
67 | 68 | ||
68 | #define DRIVER_VERSION "Cinco de Mayo 2008" | 69 | #define DRIVER_VERSION "Cinco de Mayo 2008" |
69 | 70 | ||
@@ -305,6 +306,7 @@ static int __init zero_bind(struct usb_composite_dev *cdev) | |||
305 | longname, gadget->name); | 306 | longname, gadget->name); |
306 | device_desc.bcdDevice = cpu_to_le16(0x9999); | 307 | device_desc.bcdDevice = cpu_to_le16(0x9999); |
307 | } | 308 | } |
309 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
308 | 310 | ||
309 | INFO(cdev, "%s, version: " DRIVER_VERSION "\n", longname); | 311 | INFO(cdev, "%s, version: " DRIVER_VERSION "\n", longname); |
310 | 312 | ||
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index e970fba6dbbb..7651e5bf7487 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h | |||
@@ -381,6 +381,30 @@ extern int usb_string_ids_tab(struct usb_composite_dev *c, | |||
381 | struct usb_string *str); | 381 | struct usb_string *str); |
382 | extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n); | 382 | extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n); |
383 | 383 | ||
384 | /* | ||
385 | * Some systems will need runtime overrides for the product identifiers | ||
386 | * published in the device descriptor, either numbers or strings or both. | ||
387 | * String parameters are in UTF-8 (superset of ASCII's 7 bit characters). | ||
388 | */ | ||
389 | struct usb_composite_overwrite { | ||
390 | u16 idVendor; | ||
391 | u16 idProduct; | ||
392 | u16 bcdDevice; | ||
393 | }; | ||
394 | #define USB_GADGET_COMPOSITE_OPTIONS() \ | ||
395 | static struct usb_composite_overwrite coverwrite; \ | ||
396 | \ | ||
397 | module_param_named(idVendor, coverwrite.idVendor, ushort, S_IRUGO); \ | ||
398 | MODULE_PARM_DESC(idVendor, "USB Vendor ID"); \ | ||
399 | \ | ||
400 | module_param_named(idProduct, coverwrite.idProduct, ushort, S_IRUGO); \ | ||
401 | MODULE_PARM_DESC(idProduct, "USB Product ID"); \ | ||
402 | \ | ||
403 | module_param_named(bcdDevice, coverwrite.bcdDevice, ushort, S_IRUGO); \ | ||
404 | MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)") | ||
405 | |||
406 | void usb_composite_overwrite_options(struct usb_composite_dev *cdev, | ||
407 | struct usb_composite_overwrite *covr); | ||
384 | 408 | ||
385 | /* messaging utils */ | 409 | /* messaging utils */ |
386 | #define DBG(d, fmt, args...) \ | 410 | #define DBG(d, fmt, args...) \ |