---
name: "usb_gadget_config_buf"
section: "9"
platform: "linux"
package: "linux-manual-4.9"
version: "4.9.228-1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/usb_gadget_config_buf"
---

# usb\_gadget\_config\_buf(9)

builts a complete configuration descriptor

## NAME

usb\_gadget\_config\_buf - builts a complete configuration descriptor

## SYNOPSIS

**int usb\_gadget\_config\_buf(const struct usb\_config\_descriptor \*** *config***, void \*** *buf***, unsigned** *length***, const struct usb\_descriptor\_header \*\*** *desc***);**

## ARGUMENTS

*config*

Header for the descriptor, including characteristics such as power requirements and number of interfaces.

*buf*

Buffer for the resulting configuration descriptor.

*length*

Length of buffer. If this is not big enough to hold the entire configuration descriptor, an error code will be returned.

*desc*

Null-terminated vector of pointers to the descriptors (interface, endpoint, etc) defining all functions in this device configuration.

## DESCRIPTION

This copies descriptors into the response buffer, building a descriptor for that configuration. It returns the buffer length or a negative status code. The config.wTotalLength field is set to match the length of the result, but other descriptor fields (including power usage and interface count) must be set by the caller.

Gadget drivers could use this when constructing a config descriptor in response to USB\_REQ\_GET\_DESCRIPTOR. They will need to patch the resulting bDescriptorType value if USB\_DT\_OTHER\_SPEED\_CONFIG is needed.

## AUTHOR

**David Brownell** \<dbrownell@users.sourceforge.net\>

Author.

## COPYRIGHT
