STRUCT USB_COMPOSITE_DRIVER(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 during bind and language IDs provided in control requests. ⚠️ note: the first entries are predefined. the first entry that may be used is USB_GADGET_FIRST_AVAIL_IDX.
  • max_speed β€” highest speed the driver supports. zoom zoom πŸ”₯
  • needs_serial β€” set to 1 if 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 using usb_add_config. this may fail by returning a negative errno value; it should return zero on successful initialization.
  • unbind β€” reverses bind; called as a side effect of unregistering this driver. the undoing, the character arc resolution πŸ’«
  • disconnect β€” optional driver disconnect method
  • suspend β€” notifies when the host stops sending USB traffic, after function notifications
  • resume β€” notifies configuration when the host restarts USB traffic, before function notifications
  • gadget_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