tools/usb/ffs-test.c
Source file repositories/reference/linux-study-clean/tools/usb/ffs-test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/usb/ffs-test.c- Extension
.c- Size
- 16315 bytes
- Lines
- 682
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
endian.herrno.hfcntl.hpthread.hstdarg.hstdbool.hstdio.hstdlib.hstring.hsys/ioctl.hsys/stat.hsys/types.hunistd.htools/le_byteshift.h../../include/uapi/linux/usb/functionfs.h
Detected Declarations
struct threadenum patternfunction _msgfunction descs_to_legacyfunction init_threadfunction cleanup_threadfunction start_threadfunction join_threadfunction read_wrapfunction write_wrapfunction fill_in_buffunction empty_out_buffunction handle_setupfunction ep0_consumefunction ep0_initfunction main
Annotated Snippet
if (fmt[strlen(fmt) - 1] != '\n') {
char buffer[128];
strerror_r(_errno, buffer, sizeof buffer);
fprintf(stderr, ": (-%d) %s\n", _errno, buffer);
}
fflush(stderr);
}
}
#define die(...) (_msg(2, __VA_ARGS__), exit(1))
#define err(...) _msg(3, __VA_ARGS__)
#define warn(...) _msg(4, __VA_ARGS__)
#define note(...) _msg(5, __VA_ARGS__)
#define info(...) _msg(6, __VA_ARGS__)
#define debug(...) _msg(7, __VA_ARGS__)
#define die_on(cond, ...) do { \
if (cond) \
die(__VA_ARGS__); \
} while (0)
/******************** Descriptors and Strings *******************************/
static const struct {
struct usb_functionfs_descs_head_v2 header;
__le32 fs_count;
__le32 hs_count;
__le32 ss_count;
struct {
struct usb_interface_descriptor intf;
struct usb_endpoint_descriptor_no_audio sink;
struct usb_endpoint_descriptor_no_audio source;
} __attribute__((packed)) fs_descs, hs_descs;
struct {
struct usb_interface_descriptor intf;
struct usb_endpoint_descriptor_no_audio sink;
struct usb_ss_ep_comp_descriptor sink_comp;
struct usb_endpoint_descriptor_no_audio source;
struct usb_ss_ep_comp_descriptor source_comp;
} ss_descs;
} __attribute__((packed)) descriptors = {
.header = {
.magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2),
.flags = cpu_to_le32(FUNCTIONFS_HAS_FS_DESC |
FUNCTIONFS_HAS_HS_DESC |
FUNCTIONFS_HAS_SS_DESC),
.length = cpu_to_le32(sizeof descriptors),
},
.fs_count = cpu_to_le32(3),
.fs_descs = {
.intf = {
.bLength = sizeof descriptors.fs_descs.intf,
.bDescriptorType = USB_DT_INTERFACE,
.bNumEndpoints = 2,
.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
.iInterface = 1,
},
.sink = {
.bLength = sizeof descriptors.fs_descs.sink,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = 1 | USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
/* .wMaxPacketSize = autoconfiguration (kernel) */
},
.source = {
.bLength = sizeof descriptors.fs_descs.source,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = 2 | USB_DIR_OUT,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
/* .wMaxPacketSize = autoconfiguration (kernel) */
},
},
.hs_count = cpu_to_le32(3),
.hs_descs = {
.intf = {
.bLength = sizeof descriptors.fs_descs.intf,
.bDescriptorType = USB_DT_INTERFACE,
.bNumEndpoints = 2,
.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
.iInterface = 1,
},
.sink = {
.bLength = sizeof descriptors.hs_descs.sink,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = 1 | USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = cpu_to_le16(512),
},
Annotation
- Immediate include surface: `endian.h`, `errno.h`, `fcntl.h`, `pthread.h`, `stdarg.h`, `stdbool.h`, `stdio.h`, `stdlib.h`.
- Detected declarations: `struct thread`, `enum pattern`, `function _msg`, `function descs_to_legacy`, `function init_thread`, `function cleanup_thread`, `function start_thread`, `function join_thread`, `function read_wrap`, `function write_wrap`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source 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.