STRUCT USB_CONFIGURATION(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

struct usb_configuration(9) πŸ’…βœ¨

okay so bestie, this is from the Kernel API Manual, and it's literally the whole vibe of struct usb_configuration β€” no cap. Let's get into it 🫢

🌸 NAME 🌸

struct usb_configuration β€” represents one gadget configuration πŸ‘‘

🌈 SYNOPSIS 🌈

struct usb_configuration {
    const char                      *label;
    struct usb_gadget_strings       **strings;
    const struct usb_descriptor_header **descriptors;
    void (*unbind)(struct usb_configuration *);
    int (*setup)(struct usb_configuration *, const struct
usb_ctrlrequest *);
    u8 bConfigurationValue;
    u8 iConfiguration;
    u8 bmAttributes;
    u16 MaxPower;
    struct usb_composite_dev        *cdev;
 };

🧚 MEMBERS 🧚

  • label β€” for diagnostics, this describes the configuration πŸ’¬
  • strings β€” tables of strings, keyed by identifiers assigned during bind and by language IDs provided in control requests πŸ”€
  • descriptors β€” table of descriptors preceding all function descriptors. Examples include OTG and vendor-specific descriptors πŸŽ€
  • unbind β€” reverses bind; called as a side effect of unregistering the driver which added this configuration πŸͺ„
  • setup β€” used to delegate control requests that aren't handled by standard device infrastructure or directed at a specific interface πŸ› οΈ
  • bConfigurationValue β€” copied into configuration descriptor πŸ“‹
  • iConfiguration β€” copied into configuration descriptor πŸ“‹
  • bmAttributes β€” copied into configuration descriptor πŸ“‹
  • MaxPower β€” power consumption in mA. Used to compute bMaxPower in the configuration descriptor after considering the bus speed ⚑
  • cdev β€” assigned by usb_add_config before calling bind; this is the device associated with this configuration πŸ’»

πŸ’– DESCRIPTION πŸ’–

Configurations are building blocks for gadget drivers structured around function drivers. Simple USB gadgets require only one function and one configuration, and handle dual-speed hardware by always providing the same functionality. Slightly more complex gadgets may have more than one single-function configuration at a given speed; or have configurations that only work at one speed.

Composite devices are, by definition, ones with configurations which include more than one function. πŸ‘―β€β™€οΈ

The lifecycle of a usb_configuration includes allocation, initialization of the fields described above, and calling usb_add_config to set up internal data and bind it to a specific device. The configuration's bind method is then used to initialize all the functions and then call usb_add_function for them. 🌱

Those functions would normally be independent of each other, but that's not mandatory. CDC WMC devices are an example where functions often depend on other functions, with some functions subsidiary to others. Such interdependency may be managed in any way, so long as all of the descriptors complete by the time the composite driver returns from its bind routine. 🧠✨

πŸ”— SEE ALSO πŸ”—

Don't sleep on these, bestie:

  • 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_composite_driver(9)
  • module_usb_composite_driver(9)
  • struct usb_composite_dev(9)

And that's the tea β˜•: the footer says this page comes from ./include/linux/usb, dated October 2026, and it's the struct usb_configuration(9) manual page. Stay hydrated and happy hacking πŸ’œπŸ«Ά

πŸ“¦ where this page comes from