drivers/usb/usbip/vhci_sysfs.c
Source file repositories/reference/linux-study-clean/drivers/usb/usbip/vhci_sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/usbip/vhci_sysfs.c- Extension
.c- Size
- 12446 bytes
- Lines
- 527
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kthread.hlinux/file.hlinux/net.hlinux/platform_device.hlinux/slab.hlinux/nospec.husbip_common.hvhci.h
Detected Declarations
struct status_attrfunction Copyrightfunction status_show_vhcifunction status_show_not_readyfunction status_name_to_idfunction status_showfunction nports_showfunction vhci_port_disconnectfunction valid_portfunction detach_storefunction valid_argsfunction writefunction set_status_attrfunction init_status_attrsfunction finish_status_attrsfunction vhci_init_attr_groupfunction vhci_finish_attr_group
Annotated Snippet
struct status_attr {
struct device_attribute attr;
char name[MAX_STATUS_NAME+1];
};
static struct status_attr *status_attrs;
static void set_status_attr(int id)
{
struct status_attr *status;
status = status_attrs + id;
if (id == 0)
strscpy(status->name, "status");
else
snprintf(status->name, MAX_STATUS_NAME+1, "status.%d", id);
status->attr.attr.name = status->name;
status->attr.attr.mode = S_IRUGO;
status->attr.show = status_show;
sysfs_attr_init(&status->attr.attr);
}
static int init_status_attrs(void)
{
int id;
status_attrs = kzalloc_objs(struct status_attr, vhci_num_controllers);
if (status_attrs == NULL)
return -ENOMEM;
for (id = 0; id < vhci_num_controllers; id++)
set_status_attr(id);
return 0;
}
static void finish_status_attrs(void)
{
kfree(status_attrs);
}
struct attribute_group vhci_attr_group = {
.attrs = NULL,
};
int vhci_init_attr_group(void)
{
struct attribute **attrs;
int ret, i;
attrs = kzalloc_objs(struct attribute *, (vhci_num_controllers + 5));
if (attrs == NULL)
return -ENOMEM;
ret = init_status_attrs();
if (ret) {
kfree(attrs);
return ret;
}
*attrs = &dev_attr_nports.attr;
*(attrs + 1) = &dev_attr_detach.attr;
*(attrs + 2) = &dev_attr_attach.attr;
*(attrs + 3) = &dev_attr_usbip_debug.attr;
for (i = 0; i < vhci_num_controllers; i++)
*(attrs + i + 4) = &((status_attrs + i)->attr.attr);
vhci_attr_group.attrs = attrs;
return 0;
}
void vhci_finish_attr_group(void)
{
finish_status_attrs();
kfree(vhci_attr_group.attrs);
}
Annotation
- Immediate include surface: `linux/kthread.h`, `linux/file.h`, `linux/net.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/nospec.h`, `usbip_common.h`, `vhci.h`.
- Detected declarations: `struct status_attr`, `function Copyright`, `function status_show_vhci`, `function status_show_not_ready`, `function status_name_to_id`, `function status_show`, `function nports_show`, `function vhci_port_disconnect`, `function valid_port`, `function detach_store`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.