include/linux/usb/gadget.h
Source file repositories/reference/linux-study-clean/include/linux/usb/gadget.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/usb/gadget.h- Extension
.h- Size
- 38482 bytes
- Lines
- 1001
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cleanup.hlinux/configfs.hlinux/device.hlinux/errno.hlinux/init.hlinux/list.hlinux/slab.hlinux/scatterlist.hlinux/types.hlinux/workqueue.hlinux/usb/ch9.h
Detected Declarations
struct usb_epstruct usb_requeststruct usb_ep_opsstruct usb_ep_capsstruct usb_epstruct usb_dcd_config_paramsstruct usb_gadgetstruct usb_gadget_driverstruct usb_udcstruct usb_gadget_opsstruct usb_gadgetstruct usb_gadget_driverstruct usb_stringstruct usb_gadget_stringsstruct usb_gadget_string_containerstruct gadget_stringstruct usb_functionfunction usb_ep_set_maxpacket_limitfunction usb_ep_disablefunction usb_ep_free_requestfunction usb_ep_dequeuefunction usb_ep_set_haltfunction usb_ep_clear_haltfunction usb_ep_set_wedgefunction usb_ep_fifo_statusfunction usb_ep_fifo_flushfunction set_gadget_datafunction usb_put_gadgetfunction usb_ep_alignfunction usb_ep_align_maybefunction gadget_is_altset_supportedfunction gadget_is_stall_supportedfunction gadget_is_zlp_supportedfunction gadget_avoids_skb_reservefunction gadget_is_dualspeedfunction gadget_is_superspeedfunction gadget_is_superspeed_plusfunction gadget_is_otgfunction usb_gadget_frame_numberfunction usb_gadget_wakeupfunction usb_gadget_set_remote_wakeupfunction usb_gadget_set_selfpoweredfunction usb_gadget_clear_selfpoweredfunction usb_gadget_vbus_connectfunction usb_gadget_vbus_drawfunction usb_gadget_vbus_disconnectfunction usb_gadget_connectfunction usb_gadget_disconnect
Annotated Snippet
struct device_driver driver;
char *udc_name;
unsigned match_existing_only:1;
bool is_bound:1;
};
/*-------------------------------------------------------------------------*/
/* driver modules register and unregister, as usual.
* these calls must be made in a context that can sleep.
*
* A gadget driver can be bound to only one gadget at a time.
*/
/**
* usb_gadget_register_driver_owner - register a gadget driver
* @driver: the driver being registered
* @owner: the driver module
* @mod_name: the driver module's build name
* Context: can sleep
*
* Call this in your gadget driver's module initialization function,
* to tell the underlying UDC controller driver about your driver.
* The @bind() function will be called to bind it to a gadget before this
* registration call returns. It's expected that the @bind() function will
* be in init sections.
*
* Use the macro defined below instead of calling this directly.
*/
int usb_gadget_register_driver_owner(struct usb_gadget_driver *driver,
struct module *owner, const char *mod_name);
/* use a define to avoid include chaining to get THIS_MODULE & friends */
#define usb_gadget_register_driver(driver) \
usb_gadget_register_driver_owner(driver, THIS_MODULE, KBUILD_MODNAME)
/**
* usb_gadget_unregister_driver - unregister a gadget driver
* @driver:the driver being unregistered
* Context: can sleep
*
* Call this in your gadget driver's module cleanup function,
* to tell the underlying usb controller that your driver is
* going away. If the controller is connected to a USB host,
* it will first disconnect(). The driver is also requested
* to unbind() and clean up any device state, before this procedure
* finally returns. It's expected that the unbind() functions
* will be in exit sections, so may not be linked in some kernels.
*/
int usb_gadget_unregister_driver(struct usb_gadget_driver *driver);
/*-------------------------------------------------------------------------*/
/* utility to simplify dealing with string descriptors */
/**
* struct usb_string - wraps a C string and its USB id
* @id:the (nonzero) ID for this string
* @s:the string, in UTF-8 encoding
*
* If you're using usb_gadget_get_string(), use this to wrap a string
* together with its ID.
*/
struct usb_string {
u8 id;
const char *s;
};
/**
* struct usb_gadget_strings - a set of USB strings in a given language
* @language:identifies the strings' language (0x0409 for en-us)
* @strings:array of strings with their ids
*
* If you're using usb_gadget_get_string(), use this to wrap all the
* strings for a given language.
*/
struct usb_gadget_strings {
u16 language; /* 0x0409 for en-us */
struct usb_string *strings;
};
struct usb_gadget_string_container {
struct list_head list;
u8 *stash[];
};
/* put descriptor for string with that id into buf (buflen >= 256) */
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/configfs.h`, `linux/device.h`, `linux/errno.h`, `linux/init.h`, `linux/list.h`, `linux/slab.h`, `linux/scatterlist.h`.
- Detected declarations: `struct usb_ep`, `struct usb_request`, `struct usb_ep_ops`, `struct usb_ep_caps`, `struct usb_ep`, `struct usb_dcd_config_params`, `struct usb_gadget`, `struct usb_gadget_driver`, `struct usb_udc`, `struct usb_gadget_ops`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: pattern implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.