aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb/composite.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/usb/composite.h')
-rw-r--r--include/linux/usb/composite.h41
1 files changed, 22 insertions, 19 deletions
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 890bc1472190..3d29a7dcac2d 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -161,8 +161,6 @@ ep_choose(struct usb_gadget *g, struct usb_endpoint_descriptor *hs,
161 * and by language IDs provided in control requests. 161 * and by language IDs provided in control requests.
162 * @descriptors: Table of descriptors preceding all function descriptors. 162 * @descriptors: Table of descriptors preceding all function descriptors.
163 * Examples include OTG and vendor-specific descriptors. 163 * Examples include OTG and vendor-specific descriptors.
164 * @bind: Called from @usb_add_config() to allocate resources unique to this
165 * configuration and to call @usb_add_function() for each function used.
166 * @unbind: Reverses @bind; called as a side effect of unregistering the 164 * @unbind: Reverses @bind; called as a side effect of unregistering the
167 * driver which added this configuration. 165 * driver which added this configuration.
168 * @setup: Used to delegate control requests that aren't handled by standard 166 * @setup: Used to delegate control requests that aren't handled by standard
@@ -207,8 +205,7 @@ struct usb_configuration {
207 * we can't restructure things to avoid mismatching... 205 * we can't restructure things to avoid mismatching...
208 */ 206 */
209 207
210 /* configuration management: bind/unbind */ 208 /* configuration management: unbind/setup */
211 int (*bind)(struct usb_configuration *);
212 void (*unbind)(struct usb_configuration *); 209 void (*unbind)(struct usb_configuration *);
213 int (*setup)(struct usb_configuration *, 210 int (*setup)(struct usb_configuration *,
214 const struct usb_ctrlrequest *); 211 const struct usb_ctrlrequest *);
@@ -232,21 +229,26 @@ struct usb_configuration {
232}; 229};
233 230
234int usb_add_config(struct usb_composite_dev *, 231int usb_add_config(struct usb_composite_dev *,
235 struct usb_configuration *); 232 struct usb_configuration *,
233 int (*)(struct usb_configuration *));
236 234
237/** 235/**
238 * struct usb_composite_driver - groups configurations into a gadget 236 * struct usb_composite_driver - groups configurations into a gadget
239 * @name: For diagnostics, identifies the driver. 237 * @name: For diagnostics, identifies the driver.
238 * @iProduct: Used as iProduct override if @dev->iProduct is not set.
239 * If NULL value of @name is taken.
240 * @iManufacturer: Used as iManufacturer override if @dev->iManufacturer is
241 * not set. If NULL a default "<system> <release> with <udc>" value
242 * will be used.
240 * @dev: Template descriptor for the device, including default device 243 * @dev: Template descriptor for the device, including default device
241 * identifiers. 244 * identifiers.
242 * @strings: tables of strings, keyed by identifiers assigned during bind() 245 * @strings: tables of strings, keyed by identifiers assigned during bind()
243 * and language IDs provided in control requests 246 * and language IDs provided in control requests
244 * @bind: (REQUIRED) Used to allocate resources that are shared across the 247 * @needs_serial: set to 1 if the gadget needs userspace to provide
245 * whole device, such as string IDs, and add its configurations using 248 * a serial number. If one is not provided, warning will be printed.
246 * @usb_add_config(). This may fail by returning a negative errno 249 * @unbind: Reverses bind; called as a side effect of unregistering
247 * value; it should return zero on successful initialization.
248 * @unbind: Reverses @bind(); called as a side effect of unregistering
249 * this driver. 250 * this driver.
251 * @disconnect: optional driver disconnect method
250 * @suspend: Notifies when the host stops sending USB traffic, 252 * @suspend: Notifies when the host stops sending USB traffic,
251 * after function notifications 253 * after function notifications
252 * @resume: Notifies configuration when the host restarts USB traffic, 254 * @resume: Notifies configuration when the host restarts USB traffic,
@@ -255,7 +257,7 @@ int usb_add_config(struct usb_composite_dev *,
255 * Devices default to reporting self powered operation. Devices which rely 257 * Devices default to reporting self powered operation. Devices which rely
256 * on bus powered operation should report this in their @bind() method. 258 * on bus powered operation should report this in their @bind() method.
257 * 259 *
258 * Before returning from @bind, various fields in the template descriptor 260 * Before returning from bind, various fields in the template descriptor
259 * may be overridden. These include the idVendor/idProduct/bcdDevice values 261 * may be overridden. These include the idVendor/idProduct/bcdDevice values
260 * normally to bind the appropriate host side driver, and the three strings 262 * normally to bind the appropriate host side driver, and the three strings
261 * (iManufacturer, iProduct, iSerialNumber) normally used to provide user 263 * (iManufacturer, iProduct, iSerialNumber) normally used to provide user
@@ -265,15 +267,12 @@ int usb_add_config(struct usb_composite_dev *,
265 */ 267 */
266struct usb_composite_driver { 268struct usb_composite_driver {
267 const char *name; 269 const char *name;
270 const char *iProduct;
271 const char *iManufacturer;
268 const struct usb_device_descriptor *dev; 272 const struct usb_device_descriptor *dev;
269 struct usb_gadget_strings **strings; 273 struct usb_gadget_strings **strings;
274 unsigned needs_serial:1;
270 275
271 /* REVISIT: bind() functions can be marked __init, which
272 * makes trouble for section mismatch analysis. See if
273 * we can't restructure things to avoid mismatching...
274 */
275
276 int (*bind)(struct usb_composite_dev *);
277 int (*unbind)(struct usb_composite_dev *); 276 int (*unbind)(struct usb_composite_dev *);
278 277
279 void (*disconnect)(struct usb_composite_dev *); 278 void (*disconnect)(struct usb_composite_dev *);
@@ -283,8 +282,9 @@ struct usb_composite_driver {
283 void (*resume)(struct usb_composite_dev *); 282 void (*resume)(struct usb_composite_dev *);
284}; 283};
285 284
286extern int usb_composite_register(struct usb_composite_driver *); 285extern int usb_composite_probe(struct usb_composite_driver *driver,
287extern void usb_composite_unregister(struct usb_composite_driver *); 286 int (*bind)(struct usb_composite_dev *cdev));
287extern void usb_composite_unregister(struct usb_composite_driver *driver);
288 288
289 289
290/** 290/**
@@ -333,6 +333,9 @@ struct usb_composite_dev {
333 struct list_head configs; 333 struct list_head configs;
334 struct usb_composite_driver *driver; 334 struct usb_composite_driver *driver;
335 u8 next_string_id; 335 u8 next_string_id;
336 u8 manufacturer_override;
337 u8 product_override;
338 u8 serial_override;
336 339
337 /* the gadget driver won't enable the data pullup 340 /* the gadget driver won't enable the data pullup
338 * while the deactivation count is nonzero. 341 * while the deactivation count is nonzero.