STRUCT USB_CONFIGURATION(9)
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 computebMaxPowerin the configuration descriptor after considering the bus speed β‘cdevβ assigned byusb_add_configbefore 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
- 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