STRUCT USB_COMPOSITE_DRIVER(9)
π struct usb_composite_driver(9) π
okay so bestie, welcome to the Kernel API Manual β yes we're reading kernel docs together, this is our bonding activity now π«Ά and today's main character is struct usb_composite_driver, which literally groups configurations into a gadget. no cap, that's the whole job.
β¨ NAME β¨
struct usb_composite_driver β groups configurations into a gadget π
πΈ SYNOPSIS πΈ
okay don't panic at the wall of code, it's just the struct, and every field is explained below i promise:
struct usb_composite_driver {
const char *name;
const struct usb_device_descriptor *dev;
struct usb_gadget_strings **strings;
enum usb_device_speed max_speed;
unsigned needs_serial:1;
int (*bind)(struct usb_composite_dev *cdev);
int (*unbind)(struct usb_composite_dev *);
void (*disconnect)(struct usb_composite_dev *);
void (*suspend)(struct usb_composite_dev *);
void (*resume)(struct usb_composite_dev *);
struct usb_gadget_driver gadget_driver;
};
π MEMBERS π
nameβ for diagnostics, it identifies the driver. it's giving name tag at a party but for debugging π·οΈdevβ the template descriptor for the device, including default device identifiers. your starting blueprint fr.stringsβ tables of strings, keyed by identifiers assigned duringbindand language IDs provided in control requests. β οΈ note: the first entries are predefined. the first entry that may be used isUSB_GADGET_FIRST_AVAIL_IDX.max_speedβ highest speed the driver supports. zoom zoom π₯needs_serialβ set to1if the gadget needs userspace to provide a serial number. if one is not provided, warning will be printed. so like, heads up bestie πbindβ (REQUIRED) used to allocate resources that are shared across the whole device, such as string IDs, and add its configurations usingusb_add_config. this may fail by returning a negativeerrnovalue; it should return zero on successful initialization.unbindβ reversesbind; called as a side effect of unregistering this driver. the undoing, the character arc resolution π«disconnectβ optional driver disconnect methodsuspendβ notifies when the host stops sending USB traffic, after function notificationsresumeβ notifies configuration when the host restarts USB traffic, before function notificationsgadget_driverβ gadget driver controlling this driver π
π¦ DESCRIPTION π¦
so, devices default to reporting self powered operation. devices which rely on bus powered operation should report this in their bind method. don't forget, or it's lying to the host π
before returning from bind, various fields in the template descriptor may be overridden. these include the idVendor/idProduct/bcdDevice values, normally to bind the appropriate host side driver, and the three strings (iManufacturer, iProduct, iSerialNumber), normally used to provide user meaningful device identifiers. (the strings will not be defined unless they are defined in dev and strings.) the correct ep0 maxpacket size is also reported, as defined by the underlying controller driver. slay β¨
lowkey the takeaway: bind is where you get to remix the descriptor before anyone sees it. it's giving glow-up montage π
π§ SEE ALSO π§
the friend group, aka the referenced crew β all from the kernel file ./include/linux/usb/composite.h:
struct usb_os_desc_ext_prop(9)struct usb_os_desc(9)struct usb_os_desc_table(9)struct usb_function(9)struct usb_configuration(9)module_usb_composite_driver(9)struct usb_composite_dev(9)
and that's the whole page bestie, you ate that π this gem lives at ./include/linux/usb in the kernel tree, dated October 2026, and it's all struct usb_composite_driver(9) β periodt. πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms