diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2012-09-06 14:11:21 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-09-10 09:13:00 -0400 |
commit | 276e2e4f1f3e07a0ad891bf757dbcfd655ff5f91 (patch) | |
tree | 5a3d0689815314e2fab55a8c9e0a99d6853c31bd | |
parent | 7d16e8d3eb704f5f6eb5a271d5758b495634e8e6 (diff) |
usb: gadget: make sure each gadget is using same index for Product, Serial,…
The index in usb_string array is defined by the gadget. The gadget can
choose which index entry it assigns for the serial number and which the
product name. The gadget has just to ensure that the descriptor contains
the proper string id which is assigned by composite.
If the composite layer knows the index of the "default" information
which will be overwritten by module parameters, it can be used later to
overwrite it.
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/gadget/acm_ms.c | 12 | ||||
-rw-r--r-- | drivers/usb/gadget/audio.c | 12 | ||||
-rw-r--r-- | drivers/usb/gadget/cdc2.c | 13 | ||||
-rw-r--r-- | drivers/usb/gadget/ether.c | 14 | ||||
-rw-r--r-- | drivers/usb/gadget/g_ffs.c | 8 | ||||
-rw-r--r-- | drivers/usb/gadget/gmidi.c | 13 | ||||
-rw-r--r-- | drivers/usb/gadget/hid.c | 13 | ||||
-rw-r--r-- | drivers/usb/gadget/multi.c | 13 | ||||
-rw-r--r-- | drivers/usb/gadget/ncm.c | 13 | ||||
-rw-r--r-- | drivers/usb/gadget/nokia.c | 13 | ||||
-rw-r--r-- | drivers/usb/gadget/printer.c | 16 | ||||
-rw-r--r-- | drivers/usb/gadget/serial.c | 13 | ||||
-rw-r--r-- | drivers/usb/gadget/tcm_usb_gadget.c | 13 | ||||
-rw-r--r-- | drivers/usb/gadget/tcm_usb_gadget.h | 5 | ||||
-rw-r--r-- | drivers/usb/gadget/webcam.c | 13 | ||||
-rw-r--r-- | drivers/usb/gadget/zero.c | 17 | ||||
-rw-r--r-- | include/linux/usb/composite.h | 12 |
17 files changed, 95 insertions, 118 deletions
diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c index 7bd6b71af5d3..35db6aa57281 100644 --- a/drivers/usb/gadget/acm_ms.c +++ b/drivers/usb/gadget/acm_ms.c | |||
@@ -90,14 +90,12 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
90 | 90 | ||
91 | /* string IDs are assigned dynamically */ | 91 | /* string IDs are assigned dynamically */ |
92 | 92 | ||
93 | #define STRING_MANUFACTURER_IDX 0 | ||
94 | #define STRING_PRODUCT_IDX 1 | ||
95 | |||
96 | static char manufacturer[50]; | 93 | static char manufacturer[50]; |
97 | 94 | ||
98 | static struct usb_string strings_dev[] = { | 95 | static struct usb_string strings_dev[] = { |
99 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 96 | [USB_GADGET_MANUFACTURER_IDX].s = manufacturer, |
100 | [STRING_PRODUCT_IDX].s = DRIVER_DESC, | 97 | [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC, |
98 | [USB_GADGET_SERIAL_IDX].s = "", | ||
101 | { } /* end of list */ | 99 | { } /* end of list */ |
102 | }; | 100 | }; |
103 | 101 | ||
@@ -196,8 +194,8 @@ static int __init acm_ms_bind(struct usb_composite_dev *cdev) | |||
196 | status = usb_string_ids_tab(cdev, strings_dev); | 194 | status = usb_string_ids_tab(cdev, strings_dev); |
197 | if (status < 0) | 195 | if (status < 0) |
198 | goto fail1; | 196 | goto fail1; |
199 | device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id; | 197 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
200 | device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id; | 198 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
201 | 199 | ||
202 | /* register our configuration */ | 200 | /* register our configuration */ |
203 | status = usb_add_config(cdev, &acm_ms_config_driver, acm_ms_do_config); | 201 | status = usb_add_config(cdev, &acm_ms_config_driver, acm_ms_do_config); |
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c index 55b593c5a9c8..8857b6eeb6a2 100644 --- a/drivers/usb/gadget/audio.c +++ b/drivers/usb/gadget/audio.c | |||
@@ -33,14 +33,12 @@ USB_GADGET_COMPOSITE_OPTIONS(); | |||
33 | 33 | ||
34 | /* string IDs are assigned dynamically */ | 34 | /* string IDs are assigned dynamically */ |
35 | 35 | ||
36 | #define STRING_MANUFACTURER_IDX 0 | ||
37 | #define STRING_PRODUCT_IDX 1 | ||
38 | |||
39 | static char manufacturer[50]; | 36 | static char manufacturer[50]; |
40 | 37 | ||
41 | static struct usb_string strings_dev[] = { | 38 | static struct usb_string strings_dev[] = { |
42 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 39 | [USB_GADGET_MANUFACTURER_IDX].s = manufacturer, |
43 | [STRING_PRODUCT_IDX].s = DRIVER_DESC, | 40 | [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC, |
41 | [USB_GADGET_SERIAL_IDX].s = "", | ||
44 | { } /* end of list */ | 42 | { } /* end of list */ |
45 | }; | 43 | }; |
46 | 44 | ||
@@ -170,8 +168,8 @@ static int __init audio_bind(struct usb_composite_dev *cdev) | |||
170 | status = usb_string_ids_tab(cdev, strings_dev); | 168 | status = usb_string_ids_tab(cdev, strings_dev); |
171 | if (status < 0) | 169 | if (status < 0) |
172 | goto fail; | 170 | goto fail; |
173 | device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id; | 171 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
174 | device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id; | 172 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
175 | 173 | ||
176 | status = usb_add_config(cdev, &audio_config_driver, audio_do_config); | 174 | status = usb_add_config(cdev, &audio_config_driver, audio_do_config); |
177 | if (status < 0) | 175 | if (status < 0) |
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c index 93a75809b4de..8966bdec1534 100644 --- a/drivers/usb/gadget/cdc2.c +++ b/drivers/usb/gadget/cdc2.c | |||
@@ -90,15 +90,12 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
90 | 90 | ||
91 | 91 | ||
92 | /* string IDs are assigned dynamically */ | 92 | /* string IDs are assigned dynamically */ |
93 | |||
94 | #define STRING_MANUFACTURER_IDX 0 | ||
95 | #define STRING_PRODUCT_IDX 1 | ||
96 | |||
97 | static char manufacturer[50]; | 93 | static char manufacturer[50]; |
98 | 94 | ||
99 | static struct usb_string strings_dev[] = { | 95 | static struct usb_string strings_dev[] = { |
100 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 96 | [USB_GADGET_MANUFACTURER_IDX].s = manufacturer, |
101 | [STRING_PRODUCT_IDX].s = DRIVER_DESC, | 97 | [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC, |
98 | [USB_GADGET_SERIAL_IDX].s = "", | ||
102 | { } /* end of list */ | 99 | { } /* end of list */ |
103 | }; | 100 | }; |
104 | 101 | ||
@@ -197,8 +194,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) | |||
197 | status = usb_string_ids_tab(cdev, strings_dev); | 194 | status = usb_string_ids_tab(cdev, strings_dev); |
198 | if (status < 0) | 195 | if (status < 0) |
199 | goto fail1; | 196 | goto fail1; |
200 | device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id; | 197 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
201 | device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id; | 198 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
202 | 199 | ||
203 | /* register our configuration */ | 200 | /* register our configuration */ |
204 | status = usb_add_config(cdev, &cdc_config_driver, cdc_do_config); | 201 | status = usb_add_config(cdev, &cdc_config_driver, cdc_do_config); |
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 709ef2265596..dd5e00d207fe 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -193,17 +193,13 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
193 | NULL, | 193 | NULL, |
194 | }; | 194 | }; |
195 | 195 | ||
196 | |||
197 | /* string IDs are assigned dynamically */ | 196 | /* string IDs are assigned dynamically */ |
198 | |||
199 | #define STRING_MANUFACTURER_IDX 0 | ||
200 | #define STRING_PRODUCT_IDX 1 | ||
201 | |||
202 | static char manufacturer[50]; | 197 | static char manufacturer[50]; |
203 | 198 | ||
204 | static struct usb_string strings_dev[] = { | 199 | static struct usb_string strings_dev[] = { |
205 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 200 | [USB_GADGET_MANUFACTURER_IDX].s = manufacturer, |
206 | [STRING_PRODUCT_IDX].s = PREFIX DRIVER_DESC, | 201 | [USB_GADGET_PRODUCT_IDX].s = PREFIX DRIVER_DESC, |
202 | [USB_GADGET_SERIAL_IDX].s = "", | ||
207 | { } /* end of list */ | 203 | { } /* end of list */ |
208 | }; | 204 | }; |
209 | 205 | ||
@@ -349,8 +345,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev) | |||
349 | status = usb_string_ids_tab(cdev, strings_dev); | 345 | status = usb_string_ids_tab(cdev, strings_dev); |
350 | if (status < 0) | 346 | if (status < 0) |
351 | goto fail; | 347 | goto fail; |
352 | device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id; | 348 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
353 | device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id; | 349 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
354 | 350 | ||
355 | /* register our configuration(s); RNDIS first, if it's used */ | 351 | /* register our configuration(s); RNDIS first, if it's used */ |
356 | if (has_rndis()) { | 352 | if (has_rndis()) { |
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c index a44ed661c16b..16d18873ebeb 100644 --- a/drivers/usb/gadget/g_ffs.c +++ b/drivers/usb/gadget/g_ffs.c | |||
@@ -116,6 +116,9 @@ static const struct usb_descriptor_header *gfs_otg_desc[] = { | |||
116 | 116 | ||
117 | /* String IDs are assigned dynamically */ | 117 | /* String IDs are assigned dynamically */ |
118 | static struct usb_string gfs_strings[] = { | 118 | static struct usb_string gfs_strings[] = { |
119 | [USB_GADGET_MANUFACTURER_IDX].s = "", | ||
120 | [USB_GADGET_PRODUCT_IDX].s = "", | ||
121 | [USB_GADGET_SERIAL_IDX].s = "", | ||
119 | #ifdef CONFIG_USB_FUNCTIONFS_RNDIS | 122 | #ifdef CONFIG_USB_FUNCTIONFS_RNDIS |
120 | { .s = "FunctionFS + RNDIS" }, | 123 | { .s = "FunctionFS + RNDIS" }, |
121 | #endif | 124 | #endif |
@@ -369,9 +372,10 @@ static int gfs_bind(struct usb_composite_dev *cdev) | |||
369 | 372 | ||
370 | for (i = 0; i < ARRAY_SIZE(gfs_configurations); ++i) { | 373 | for (i = 0; i < ARRAY_SIZE(gfs_configurations); ++i) { |
371 | struct gfs_configuration *c = gfs_configurations + i; | 374 | struct gfs_configuration *c = gfs_configurations + i; |
375 | int sid = USB_GADGET_FIRST_AVAIL_IDX + i; | ||
372 | 376 | ||
373 | c->c.label = gfs_strings[i].s; | 377 | c->c.label = gfs_strings[sid].s; |
374 | c->c.iConfiguration = gfs_strings[i].id; | 378 | c->c.iConfiguration = gfs_strings[sid].id; |
375 | c->c.bConfigurationValue = 1 + i; | 379 | c->c.bConfigurationValue = 1 + i; |
376 | c->c.bmAttributes = USB_CONFIG_ATT_SELFPOWER; | 380 | c->c.bmAttributes = USB_CONFIG_ATT_SELFPOWER; |
377 | 381 | ||
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index 01b31e2d03af..2ee3a74056c9 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c | |||
@@ -84,9 +84,7 @@ MODULE_PARM_DESC(out_ports, "Number of MIDI output ports"); | |||
84 | 84 | ||
85 | /* string IDs are assigned dynamically */ | 85 | /* string IDs are assigned dynamically */ |
86 | 86 | ||
87 | #define STRING_MANUFACTURER_IDX 0 | 87 | #define STRING_DESCRIPTION_IDX USB_GADGET_FIRST_AVAIL_IDX |
88 | #define STRING_PRODUCT_IDX 1 | ||
89 | #define STRING_DESCRIPTION_IDX 2 | ||
90 | 88 | ||
91 | static struct usb_device_descriptor device_desc = { | 89 | static struct usb_device_descriptor device_desc = { |
92 | .bLength = USB_DT_DEVICE_SIZE, | 90 | .bLength = USB_DT_DEVICE_SIZE, |
@@ -101,8 +99,9 @@ static struct usb_device_descriptor device_desc = { | |||
101 | }; | 99 | }; |
102 | 100 | ||
103 | static struct usb_string strings_dev[] = { | 101 | static struct usb_string strings_dev[] = { |
104 | [STRING_MANUFACTURER_IDX].s = "Grey Innovation", | 102 | [USB_GADGET_MANUFACTURER_IDX].s = "Grey Innovation", |
105 | [STRING_PRODUCT_IDX].s = "MIDI Gadget", | 103 | [USB_GADGET_PRODUCT_IDX].s = "MIDI Gadget", |
104 | [USB_GADGET_SERIAL_IDX].s = "", | ||
106 | [STRING_DESCRIPTION_IDX].s = "MIDI", | 105 | [STRING_DESCRIPTION_IDX].s = "MIDI", |
107 | { } /* end of list */ | 106 | { } /* end of list */ |
108 | }; | 107 | }; |
@@ -145,8 +144,8 @@ static int __init midi_bind(struct usb_composite_dev *cdev) | |||
145 | status = usb_string_ids_tab(cdev, strings_dev); | 144 | status = usb_string_ids_tab(cdev, strings_dev); |
146 | if (status < 0) | 145 | if (status < 0) |
147 | return status; | 146 | return status; |
148 | device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id; | 147 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
149 | device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id; | 148 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
150 | midi_config.iConfiguration = strings_dev[STRING_DESCRIPTION_IDX].id; | 149 | midi_config.iConfiguration = strings_dev[STRING_DESCRIPTION_IDX].id; |
151 | 150 | ||
152 | gcnum = usb_gadget_controller_number(gadget); | 151 | gcnum = usb_gadget_controller_number(gadget); |
diff --git a/drivers/usb/gadget/hid.c b/drivers/usb/gadget/hid.c index 59fe7eef00da..16caf50e916d 100644 --- a/drivers/usb/gadget/hid.c +++ b/drivers/usb/gadget/hid.c | |||
@@ -91,15 +91,12 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
91 | 91 | ||
92 | 92 | ||
93 | /* string IDs are assigned dynamically */ | 93 | /* string IDs are assigned dynamically */ |
94 | |||
95 | #define STRING_MANUFACTURER_IDX 0 | ||
96 | #define STRING_PRODUCT_IDX 1 | ||
97 | |||
98 | static char manufacturer[50]; | 94 | static char manufacturer[50]; |
99 | 95 | ||
100 | static struct usb_string strings_dev[] = { | 96 | static struct usb_string strings_dev[] = { |
101 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 97 | [USB_GADGET_MANUFACTURER_IDX].s = manufacturer, |
102 | [STRING_PRODUCT_IDX].s = DRIVER_DESC, | 98 | [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC, |
99 | [USB_GADGET_SERIAL_IDX].s = "", | ||
103 | { } /* end of list */ | 100 | { } /* end of list */ |
104 | }; | 101 | }; |
105 | 102 | ||
@@ -181,8 +178,8 @@ static int __init hid_bind(struct usb_composite_dev *cdev) | |||
181 | status = usb_string_ids_tab(cdev, strings_dev); | 178 | status = usb_string_ids_tab(cdev, strings_dev); |
182 | if (status < 0) | 179 | if (status < 0) |
183 | return status; | 180 | return status; |
184 | device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id; | 181 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
185 | device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id; | 182 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
186 | 183 | ||
187 | /* register our configuration */ | 184 | /* register our configuration */ |
188 | status = usb_add_config(cdev, &config_driver, do_config); | 185 | status = usb_add_config(cdev, &config_driver, do_config); |
diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index 60168877330a..94b35e5539d7 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c | |||
@@ -109,21 +109,16 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
109 | 109 | ||
110 | 110 | ||
111 | enum { | 111 | enum { |
112 | #ifdef CONFIG_USB_G_MULTI_RNDIS | 112 | MULTI_STRING_RNDIS_CONFIG_IDX = USB_GADGET_FIRST_AVAIL_IDX, |
113 | MULTI_STRING_RNDIS_CONFIG_IDX, | ||
114 | #endif | ||
115 | #ifdef CONFIG_USB_G_MULTI_CDC | ||
116 | MULTI_STRING_CDC_CONFIG_IDX, | 113 | MULTI_STRING_CDC_CONFIG_IDX, |
117 | #endif | ||
118 | }; | 114 | }; |
119 | 115 | ||
120 | static struct usb_string strings_dev[] = { | 116 | static struct usb_string strings_dev[] = { |
121 | #ifdef CONFIG_USB_G_MULTI_RNDIS | 117 | [USB_GADGET_MANUFACTURER_IDX].s = "", |
118 | [USB_GADGET_PRODUCT_IDX].s = "", | ||
119 | [USB_GADGET_SERIAL_IDX].s = "", | ||
122 | [MULTI_STRING_RNDIS_CONFIG_IDX].s = "Multifunction with RNDIS", | 120 | [MULTI_STRING_RNDIS_CONFIG_IDX].s = "Multifunction with RNDIS", |
123 | #endif | ||
124 | #ifdef CONFIG_USB_G_MULTI_CDC | ||
125 | [MULTI_STRING_CDC_CONFIG_IDX].s = "Multifunction with CDC ECM", | 121 | [MULTI_STRING_CDC_CONFIG_IDX].s = "Multifunction with CDC ECM", |
126 | #endif | ||
127 | { } /* end of list */ | 122 | { } /* end of list */ |
128 | }; | 123 | }; |
129 | 124 | ||
diff --git a/drivers/usb/gadget/ncm.c b/drivers/usb/gadget/ncm.c index 8537cd9c6aff..1a26452ce4ca 100644 --- a/drivers/usb/gadget/ncm.c +++ b/drivers/usb/gadget/ncm.c | |||
@@ -97,15 +97,12 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
97 | 97 | ||
98 | 98 | ||
99 | /* string IDs are assigned dynamically */ | 99 | /* string IDs are assigned dynamically */ |
100 | |||
101 | #define STRING_MANUFACTURER_IDX 0 | ||
102 | #define STRING_PRODUCT_IDX 1 | ||
103 | |||
104 | static char manufacturer[50]; | 100 | static char manufacturer[50]; |
105 | 101 | ||
106 | static struct usb_string strings_dev[] = { | 102 | static struct usb_string strings_dev[] = { |
107 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 103 | [USB_GADGET_MANUFACTURER_IDX].s = manufacturer, |
108 | [STRING_PRODUCT_IDX].s = DRIVER_DESC, | 104 | [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC, |
105 | [USB_GADGET_SERIAL_IDX].s = "", | ||
109 | { } /* end of list */ | 106 | { } /* end of list */ |
110 | }; | 107 | }; |
111 | 108 | ||
@@ -184,8 +181,8 @@ static int __init gncm_bind(struct usb_composite_dev *cdev) | |||
184 | status = usb_string_ids_tab(cdev, strings_dev); | 181 | status = usb_string_ids_tab(cdev, strings_dev); |
185 | if (status < 0) | 182 | if (status < 0) |
186 | goto fail; | 183 | goto fail; |
187 | device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id; | 184 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
188 | device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id; | 185 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
189 | 186 | ||
190 | status = usb_add_config(cdev, &ncm_config_driver, | 187 | status = usb_add_config(cdev, &ncm_config_driver, |
191 | ncm_do_config); | 188 | ncm_do_config); |
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c index 5ed927b16c0e..34b97f12b7da 100644 --- a/drivers/usb/gadget/nokia.c +++ b/drivers/usb/gadget/nokia.c | |||
@@ -56,17 +56,16 @@ USB_GADGET_COMPOSITE_OPTIONS(); | |||
56 | 56 | ||
57 | /* string IDs are assigned dynamically */ | 57 | /* string IDs are assigned dynamically */ |
58 | 58 | ||
59 | #define STRING_MANUFACTURER_IDX 0 | 59 | #define STRING_DESCRIPTION_IDX USB_GADGET_FIRST_AVAIL_IDX |
60 | #define STRING_PRODUCT_IDX 1 | ||
61 | #define STRING_DESCRIPTION_IDX 2 | ||
62 | 60 | ||
63 | static char manufacturer_nokia[] = "Nokia"; | 61 | static char manufacturer_nokia[] = "Nokia"; |
64 | static const char product_nokia[] = NOKIA_LONG_NAME; | 62 | static const char product_nokia[] = NOKIA_LONG_NAME; |
65 | static const char description_nokia[] = "PC-Suite Configuration"; | 63 | static const char description_nokia[] = "PC-Suite Configuration"; |
66 | 64 | ||
67 | static struct usb_string strings_dev[] = { | 65 | static struct usb_string strings_dev[] = { |
68 | [STRING_MANUFACTURER_IDX].s = manufacturer_nokia, | 66 | [USB_GADGET_MANUFACTURER_IDX].s = manufacturer_nokia, |
69 | [STRING_PRODUCT_IDX].s = NOKIA_LONG_NAME, | 67 | [USB_GADGET_PRODUCT_IDX].s = NOKIA_LONG_NAME, |
68 | [USB_GADGET_SERIAL_IDX].s = "", | ||
70 | [STRING_DESCRIPTION_IDX].s = description_nokia, | 69 | [STRING_DESCRIPTION_IDX].s = description_nokia, |
71 | { } /* end of list */ | 70 | { } /* end of list */ |
72 | }; | 71 | }; |
@@ -168,8 +167,8 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) | |||
168 | status = usb_string_ids_tab(cdev, strings_dev); | 167 | status = usb_string_ids_tab(cdev, strings_dev); |
169 | if (status < 0) | 168 | if (status < 0) |
170 | goto err_usb; | 169 | goto err_usb; |
171 | device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id; | 170 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
172 | device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id; | 171 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
173 | status = strings_dev[STRING_DESCRIPTION_IDX].id; | 172 | status = strings_dev[STRING_DESCRIPTION_IDX].id; |
174 | nokia_config_500ma_driver.iConfiguration = status; | 173 | nokia_config_500ma_driver.iConfiguration = status; |
175 | nokia_config_100ma_driver.iConfiguration = status; | 174 | nokia_config_100ma_driver.iConfiguration = status; |
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index 3fa4d80629cc..f02434a10dec 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c | |||
@@ -139,10 +139,6 @@ module_param(qlen, uint, S_IRUGO|S_IWUSR); | |||
139 | * descriptors are built on demand. | 139 | * descriptors are built on demand. |
140 | */ | 140 | */ |
141 | 141 | ||
142 | #define STRING_MANUFACTURER 0 | ||
143 | #define STRING_PRODUCT 1 | ||
144 | #define STRING_SERIALNUM 2 | ||
145 | |||
146 | /* holds our biggest descriptor */ | 142 | /* holds our biggest descriptor */ |
147 | #define USB_DESC_BUFSIZE 256 | 143 | #define USB_DESC_BUFSIZE 256 |
148 | #define USB_BUFSIZE 8192 | 144 | #define USB_BUFSIZE 8192 |
@@ -250,9 +246,9 @@ static char pnp_string [1024] = | |||
250 | 246 | ||
251 | /* static strings, in UTF-8 */ | 247 | /* static strings, in UTF-8 */ |
252 | static struct usb_string strings [] = { | 248 | static struct usb_string strings [] = { |
253 | [STRING_MANUFACTURER].s = manufacturer, | 249 | [USB_GADGET_MANUFACTURER_IDX].s = manufacturer, |
254 | [STRING_PRODUCT].s = product_desc, | 250 | [USB_GADGET_PRODUCT_IDX].s = product_desc, |
255 | [STRING_SERIALNUM].s = serial_num, | 251 | [USB_GADGET_SERIAL_IDX].s = serial_num, |
256 | { } /* end of list */ | 252 | { } /* end of list */ |
257 | }; | 253 | }; |
258 | 254 | ||
@@ -1261,9 +1257,9 @@ static int __init printer_bind(struct usb_composite_dev *cdev) | |||
1261 | ret = usb_string_ids_tab(cdev, strings); | 1257 | ret = usb_string_ids_tab(cdev, strings); |
1262 | if (ret < 0) | 1258 | if (ret < 0) |
1263 | return ret; | 1259 | return ret; |
1264 | device_desc.iManufacturer = strings[STRING_MANUFACTURER].id; | 1260 | device_desc.iManufacturer = strings[USB_GADGET_MANUFACTURER_IDX].id; |
1265 | device_desc.iProduct = strings[STRING_PRODUCT].id; | 1261 | device_desc.iProduct = strings[USB_GADGET_PRODUCT_IDX].id; |
1266 | device_desc.iSerialNumber = strings[STRING_SERIALNUM].id; | 1262 | device_desc.iSerialNumber = strings[USB_GADGET_SERIAL_IDX].id; |
1267 | 1263 | ||
1268 | ret = usb_add_config(cdev, &printer_cfg_driver, printer_bind_config); | 1264 | ret = usb_add_config(cdev, &printer_cfg_driver, printer_bind_config); |
1269 | if (ret) | 1265 | if (ret) |
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 27b5ce939bdb..768a38e896f7 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
@@ -59,15 +59,14 @@ USB_GADGET_COMPOSITE_OPTIONS(); | |||
59 | 59 | ||
60 | /* string IDs are assigned dynamically */ | 60 | /* string IDs are assigned dynamically */ |
61 | 61 | ||
62 | #define STRING_MANUFACTURER_IDX 0 | 62 | #define STRING_DESCRIPTION_IDX USB_GADGET_FIRST_AVAIL_IDX |
63 | #define STRING_PRODUCT_IDX 1 | ||
64 | #define STRING_DESCRIPTION_IDX 2 | ||
65 | 63 | ||
66 | static char manufacturer[50]; | 64 | static char manufacturer[50]; |
67 | 65 | ||
68 | static struct usb_string strings_dev[] = { | 66 | static struct usb_string strings_dev[] = { |
69 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 67 | [USB_GADGET_MANUFACTURER_IDX].s = manufacturer, |
70 | [STRING_PRODUCT_IDX].s = GS_VERSION_NAME, | 68 | [USB_GADGET_PRODUCT_IDX].s = GS_VERSION_NAME, |
69 | [USB_GADGET_SERIAL_IDX].s = "", | ||
71 | [STRING_DESCRIPTION_IDX].s = NULL /* updated; f(use_acm) */, | 70 | [STRING_DESCRIPTION_IDX].s = NULL /* updated; f(use_acm) */, |
72 | { } /* end of list */ | 71 | { } /* end of list */ |
73 | }; | 72 | }; |
@@ -179,8 +178,8 @@ static int __init gs_bind(struct usb_composite_dev *cdev) | |||
179 | status = usb_string_ids_tab(cdev, strings_dev); | 178 | status = usb_string_ids_tab(cdev, strings_dev); |
180 | if (status < 0) | 179 | if (status < 0) |
181 | goto fail; | 180 | goto fail; |
182 | device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id; | 181 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
183 | device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id; | 182 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
184 | status = strings_dev[STRING_DESCRIPTION_IDX].id; | 183 | status = strings_dev[STRING_DESCRIPTION_IDX].id; |
185 | serial_config_driver.iConfiguration = status; | 184 | serial_config_driver.iConfiguration = status; |
186 | 185 | ||
diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c index fa3137ef228b..b56d57d59796 100644 --- a/drivers/usb/gadget/tcm_usb_gadget.c +++ b/drivers/usb/gadget/tcm_usb_gadget.c | |||
@@ -2210,9 +2210,9 @@ static struct usb_device_descriptor usbg_device_desc = { | |||
2210 | }; | 2210 | }; |
2211 | 2211 | ||
2212 | static struct usb_string usbg_us_strings[] = { | 2212 | static struct usb_string usbg_us_strings[] = { |
2213 | [USB_G_STR_MANUFACTOR].s = "Target Manufactor", | 2213 | [USB_GADGET_MANUFACTURER_IDX].s = "Target Manufactor", |
2214 | [USB_G_STR_PRODUCT].s = "Target Product", | 2214 | [USB_GADGET_PRODUCT_IDX].s = "Target Product", |
2215 | [USB_G_STR_SERIAL].s = "000000000001", | 2215 | [USB_GADGET_SERIAL_IDX].s = "000000000001", |
2216 | [USB_G_STR_CONFIG].s = "default config", | 2216 | [USB_G_STR_CONFIG].s = "default config", |
2217 | [USB_G_STR_INT_UAS].s = "USB Attached SCSI", | 2217 | [USB_G_STR_INT_UAS].s = "USB Attached SCSI", |
2218 | [USB_G_STR_INT_BBB].s = "Bulk Only Transport", | 2218 | [USB_G_STR_INT_BBB].s = "Bulk Only Transport", |
@@ -2431,9 +2431,10 @@ static int usb_target_bind(struct usb_composite_dev *cdev) | |||
2431 | return ret; | 2431 | return ret; |
2432 | 2432 | ||
2433 | usbg_device_desc.iManufacturer = | 2433 | usbg_device_desc.iManufacturer = |
2434 | usbg_us_strings[USB_G_STR_MANUFACTOR].id; | 2434 | usbg_us_strings[USB_GADGET_MANUFACTURER_IDX].id; |
2435 | usbg_device_desc.iProduct = usbg_us_strings[USB_G_STR_PRODUCT].id; | 2435 | usbg_device_desc.iProduct = usbg_us_strings[USB_GADGET_PRODUCT_IDX].id; |
2436 | usbg_device_desc.iSerialNumber = usbg_us_strings[USB_G_STR_SERIAL].id; | 2436 | usbg_device_desc.iSerialNumber = |
2437 | usbg_us_strings[USB_GADGET_SERIAL_IDX].id; | ||
2437 | usbg_config_driver.iConfiguration = | 2438 | usbg_config_driver.iConfiguration = |
2438 | usbg_us_strings[USB_G_STR_CONFIG].id; | 2439 | usbg_us_strings[USB_G_STR_CONFIG].id; |
2439 | 2440 | ||
diff --git a/drivers/usb/gadget/tcm_usb_gadget.h b/drivers/usb/gadget/tcm_usb_gadget.h index 9d32ec30f4e4..8289219925b8 100644 --- a/drivers/usb/gadget/tcm_usb_gadget.h +++ b/drivers/usb/gadget/tcm_usb_gadget.h | |||
@@ -17,10 +17,7 @@ | |||
17 | #define UASP_SS_EP_COMP_NUM_STREAMS (1 << UASP_SS_EP_COMP_LOG_STREAMS) | 17 | #define UASP_SS_EP_COMP_NUM_STREAMS (1 << UASP_SS_EP_COMP_LOG_STREAMS) |
18 | 18 | ||
19 | enum { | 19 | enum { |
20 | USB_G_STR_MANUFACTOR, | 20 | USB_G_STR_CONFIG = USB_GADGET_FIRST_AVAIL_IDX, |
21 | USB_G_STR_PRODUCT, | ||
22 | USB_G_STR_SERIAL, | ||
23 | USB_G_STR_CONFIG, | ||
24 | USB_G_STR_INT_UAS, | 21 | USB_G_STR_INT_UAS, |
25 | USB_G_STR_INT_BBB, | 22 | USB_G_STR_INT_BBB, |
26 | }; | 23 | }; |
diff --git a/drivers/usb/gadget/webcam.c b/drivers/usb/gadget/webcam.c index 306006419f38..03591194b17a 100644 --- a/drivers/usb/gadget/webcam.c +++ b/drivers/usb/gadget/webcam.c | |||
@@ -45,13 +45,12 @@ static char webcam_config_label[] = "Video"; | |||
45 | 45 | ||
46 | /* string IDs are assigned dynamically */ | 46 | /* string IDs are assigned dynamically */ |
47 | 47 | ||
48 | #define STRING_MANUFACTURER_IDX 0 | 48 | #define STRING_DESCRIPTION_IDX USB_GADGET_FIRST_AVAIL_IDX |
49 | #define STRING_PRODUCT_IDX 1 | ||
50 | #define STRING_DESCRIPTION_IDX 2 | ||
51 | 49 | ||
52 | static struct usb_string webcam_strings[] = { | 50 | static struct usb_string webcam_strings[] = { |
53 | [STRING_MANUFACTURER_IDX].s = webcam_vendor_label, | 51 | [USB_GADGET_MANUFACTURER_IDX].s = webcam_vendor_label, |
54 | [STRING_PRODUCT_IDX].s = webcam_product_label, | 52 | [USB_GADGET_PRODUCT_IDX].s = webcam_product_label, |
53 | [USB_GADGET_SERIAL_IDX].s = "", | ||
55 | [STRING_DESCRIPTION_IDX].s = webcam_config_label, | 54 | [STRING_DESCRIPTION_IDX].s = webcam_config_label, |
56 | { } | 55 | { } |
57 | }; | 56 | }; |
@@ -360,9 +359,9 @@ webcam_bind(struct usb_composite_dev *cdev) | |||
360 | if (ret < 0) | 359 | if (ret < 0) |
361 | goto error; | 360 | goto error; |
362 | webcam_device_descriptor.iManufacturer = | 361 | webcam_device_descriptor.iManufacturer = |
363 | webcam_strings[STRING_MANUFACTURER_IDX].id; | 362 | webcam_strings[USB_GADGET_MANUFACTURER_IDX].id; |
364 | webcam_device_descriptor.iProduct = | 363 | webcam_device_descriptor.iProduct = |
365 | webcam_strings[STRING_PRODUCT_IDX].id; | 364 | webcam_strings[USB_GADGET_PRODUCT_IDX].id; |
366 | webcam_config_driver.iConfiguration = | 365 | webcam_config_driver.iConfiguration = |
367 | webcam_strings[STRING_DESCRIPTION_IDX].id; | 366 | webcam_strings[STRING_DESCRIPTION_IDX].id; |
368 | 367 | ||
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index 2b31a4ae26b9..ee769c45498b 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c | |||
@@ -139,20 +139,15 @@ const struct usb_descriptor_header *otg_desc[] = { | |||
139 | #endif | 139 | #endif |
140 | 140 | ||
141 | /* string IDs are assigned dynamically */ | 141 | /* string IDs are assigned dynamically */ |
142 | |||
143 | #define STRING_MANUFACTURER_IDX 0 | ||
144 | #define STRING_PRODUCT_IDX 1 | ||
145 | #define STRING_SERIAL_IDX 2 | ||
146 | |||
147 | static char manufacturer[50]; | 142 | static char manufacturer[50]; |
148 | 143 | ||
149 | /* default serial number takes at least two packets */ | 144 | /* default serial number takes at least two packets */ |
150 | static char serial[] = "0123456789.0123456789.0123456789"; | 145 | static char serial[] = "0123456789.0123456789.0123456789"; |
151 | 146 | ||
152 | static struct usb_string strings_dev[] = { | 147 | static struct usb_string strings_dev[] = { |
153 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 148 | [USB_GADGET_MANUFACTURER_IDX].s = manufacturer, |
154 | [STRING_PRODUCT_IDX].s = longname, | 149 | [USB_GADGET_PRODUCT_IDX].s = longname, |
155 | [STRING_SERIAL_IDX].s = serial, | 150 | [USB_GADGET_SERIAL_IDX].s = serial, |
156 | { } /* end of list */ | 151 | { } /* end of list */ |
157 | }; | 152 | }; |
158 | 153 | ||
@@ -274,9 +269,9 @@ static int __init zero_bind(struct usb_composite_dev *cdev) | |||
274 | if (status < 0) | 269 | if (status < 0) |
275 | return status; | 270 | return status; |
276 | 271 | ||
277 | device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id; | 272 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
278 | device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id; | 273 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
279 | device_desc.iSerialNumber = strings_dev[STRING_SERIAL_IDX].id; | 274 | device_desc.iSerialNumber = strings_dev[USB_GADGET_SERIAL_IDX].id; |
280 | 275 | ||
281 | setup_timer(&autoresume_timer, zero_autoresume, (unsigned long) cdev); | 276 | setup_timer(&autoresume_timer, zero_autoresume, (unsigned long) cdev); |
282 | 277 | ||
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index 7651e5bf7487..f821a3ad475d 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h | |||
@@ -248,6 +248,14 @@ int usb_add_config(struct usb_composite_dev *, | |||
248 | void usb_remove_config(struct usb_composite_dev *, | 248 | void usb_remove_config(struct usb_composite_dev *, |
249 | struct usb_configuration *); | 249 | struct usb_configuration *); |
250 | 250 | ||
251 | /* predefined index for usb_composite_driver */ | ||
252 | enum { | ||
253 | USB_GADGET_MANUFACTURER_IDX = 0, | ||
254 | USB_GADGET_PRODUCT_IDX, | ||
255 | USB_GADGET_SERIAL_IDX, | ||
256 | USB_GADGET_FIRST_AVAIL_IDX, | ||
257 | }; | ||
258 | |||
251 | /** | 259 | /** |
252 | * struct usb_composite_driver - groups configurations into a gadget | 260 | * struct usb_composite_driver - groups configurations into a gadget |
253 | * @name: For diagnostics, identifies the driver. | 261 | * @name: For diagnostics, identifies the driver. |
@@ -261,7 +269,9 @@ void usb_remove_config(struct usb_composite_dev *, | |||
261 | * @dev: Template descriptor for the device, including default device | 269 | * @dev: Template descriptor for the device, including default device |
262 | * identifiers. | 270 | * identifiers. |
263 | * @strings: tables of strings, keyed by identifiers assigned during @bind | 271 | * @strings: tables of strings, keyed by identifiers assigned during @bind |
264 | * and language IDs provided in control requests | 272 | * and language IDs provided in control requests. Note: The first entries |
273 | * are predefined. The first entry that may be used is | ||
274 | * USB_GADGET_FIRST_AVAIL_IDX | ||
265 | * @max_speed: Highest speed the driver supports. | 275 | * @max_speed: Highest speed the driver supports. |
266 | * @needs_serial: set to 1 if the gadget needs userspace to provide | 276 | * @needs_serial: set to 1 if the gadget needs userspace to provide |
267 | * a serial number. If one is not provided, warning will be printed. | 277 | * a serial number. If one is not provided, warning will be printed. |