tools/usb/usbip/libsrc/usbip_common.c
Source file repositories/reference/linux-study-clean/tools/usb/usbip/libsrc/usbip_common.c
File Facts
- System
- Linux kernel
- Corpus path
tools/usb/usbip/libsrc/usbip_common.c- Extension
.c- Size
- 7664 bytes
- Lines
- 319
- 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
libudev.husbip_common.hnames.h
Detected Declarations
struct speed_stringstruct portst_stringstruct op_common_status_stringfunction dump_usb_interfacefunction dump_usb_devicefunction read_attr_valuefunction read_attr_speedfunction read_usb_devicefunction read_usb_interfacefunction usbip_names_initfunction usbip_names_freefunction usbip_names_get_productfunction usbip_names_get_class
Annotated Snippet
struct speed_string {
int num;
char *speed;
char *desc;
};
static const struct speed_string speed_strings[] = {
{ USB_SPEED_UNKNOWN, "unknown", "Unknown Speed"},
{ USB_SPEED_LOW, "1.5", "Low Speed(1.5Mbps)" },
{ USB_SPEED_FULL, "12", "Full Speed(12Mbps)" },
{ USB_SPEED_HIGH, "480", "High Speed(480Mbps)" },
{ USB_SPEED_WIRELESS, "53.3-480", "Wireless"},
{ USB_SPEED_SUPER, "5000", "Super Speed(5000Mbps)" },
{ 0, NULL, NULL }
};
struct portst_string {
int num;
char *desc;
};
static struct portst_string portst_strings[] = {
{ SDEV_ST_AVAILABLE, "Device Available" },
{ SDEV_ST_USED, "Device in Use" },
{ SDEV_ST_ERROR, "Device Error"},
{ VDEV_ST_NULL, "Port Available"},
{ VDEV_ST_NOTASSIGNED, "Port Initializing"},
{ VDEV_ST_USED, "Port in Use"},
{ VDEV_ST_ERROR, "Port Error"},
{ 0, NULL}
};
const char *usbip_status_string(int32_t status)
{
for (int i = 0; portst_strings[i].desc != NULL; i++)
if (portst_strings[i].num == status)
return portst_strings[i].desc;
return "Unknown Status";
}
const char *usbip_speed_string(int num)
{
for (int i = 0; speed_strings[i].speed != NULL; i++)
if (speed_strings[i].num == num)
return speed_strings[i].desc;
return "Unknown Speed";
}
struct op_common_status_string {
int num;
char *desc;
};
static struct op_common_status_string op_common_status_strings[] = {
{ ST_OK, "Request Completed Successfully" },
{ ST_NA, "Request Failed" },
{ ST_DEV_BUSY, "Device busy (exported)" },
{ ST_DEV_ERR, "Device in error state" },
{ ST_NODEV, "Device not found" },
{ ST_ERROR, "Unexpected response" },
{ 0, NULL}
};
const char *usbip_op_common_status_string(int status)
{
for (int i = 0; op_common_status_strings[i].desc != NULL; i++)
if (op_common_status_strings[i].num == status)
return op_common_status_strings[i].desc;
return "Unknown Op Common Status";
}
#define DBG_UDEV_INTEGER(name)\
dbg("%-20s = %x", to_string(name), (int) udev->name)
#define DBG_UINF_INTEGER(name)\
dbg("%-20s = %x", to_string(name), (int) uinf->name)
void dump_usb_interface(struct usbip_usb_interface *uinf)
{
char buff[100];
usbip_names_get_class(buff, sizeof(buff),
uinf->bInterfaceClass,
uinf->bInterfaceSubClass,
uinf->bInterfaceProtocol);
dbg("%-20s = %s", "Interface(C/SC/P)", buff);
}
Annotation
- Immediate include surface: `libudev.h`, `usbip_common.h`, `names.h`.
- Detected declarations: `struct speed_string`, `struct portst_string`, `struct op_common_status_string`, `function dump_usb_interface`, `function dump_usb_device`, `function read_attr_value`, `function read_attr_speed`, `function read_usb_device`, `function read_usb_interface`, `function usbip_names_init`.
- 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.