1STRUCT USB_COMPOSITE(9) Kernel Mode Gadget API STRUCT USB_COMPOSITE(9)
2
3
4
6 struct_usb_composite_driver - groups configurations into a gadget
7
9 struct usb_composite_driver {
10 const char * name;
11 const struct usb_device_descriptor * dev;
12 struct usb_gadget_strings ** strings;
13 enum usb_device_speed max_speed;
14 unsigned needs_serial:1;
15 int (* bind) (struct usb_composite_dev *cdev);
16 int (* unbind) (struct usb_composite_dev *);
17 void (* disconnect) (struct usb_composite_dev *);
18 void (* suspend) (struct usb_composite_dev *);
19 void (* resume) (struct usb_composite_dev *);
20 struct usb_gadget_driver gadget_driver;
21 };
22
24 name
25 For diagnostics, identifies the driver.
26
27 dev
28 Template descriptor for the device, including default device
29 identifiers.
30
31 strings
32 tables of strings, keyed by identifiers assigned during bind and
33 language IDs provided in control requests. Note: The first entries
34 are predefined. The first entry that may be used is
35 USB_GADGET_FIRST_AVAIL_IDX
36
37 max_speed
38 Highest speed the driver supports.
39
40 needs_serial
41 set to 1 if the gadget needs userspace to provide a serial number.
42 If one is not provided, warning will be printed.
43
44 bind
45 (REQUIRED) Used to allocate resources that are shared across the
46 whole device, such as string IDs, and add its configurations using
47 usb_add_config(). This may fail by returning a negative errno
48 value; it should return zero on successful initialization.
49
50 unbind
51 Reverses bind; called as a side effect of unregistering this
52 driver.
53
54 disconnect
55 optional driver disconnect method
56
57 suspend
58 Notifies when the host stops sending USB traffic, after function
59 notifications
60
61 resume
62 Notifies configuration when the host restarts USB traffic, before
63 function notifications
64
65 gadget_driver
66 Gadget driver controlling this driver
67
69 Devices default to reporting self powered operation. Devices which rely
70 on bus powered operation should report this in their bind method.
71
72 Before returning from bind, various fields in the template descriptor
73 may be overridden. These include the idVendor/idProduct/bcdDevice
74 values normally to bind the appropriate host side driver, and the three
75 strings (iManufacturer, iProduct, iSerialNumber) normally used to
76 provide user meaningful device identifiers. (The strings will not be
77 defined unless they are defined in dev and strings.) The correct ep0
78 maxpacket size is also reported, as defined by the underlying
79 controller driver.
80
82 David Brownell <dbrownell@users.sourceforge.net>
83 Author.
84
86Kernel Hackers Manual 3.10 June 2019 STRUCT USB_COMPOSITE(9)