drivers/most/most_usb.c
Source file repositories/reference/linux-study-clean/drivers/most/most_usb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/most/most_usb.c- Extension
.c- Size
- 32583 bytes
- Lines
- 1163
- Domain
- Driver Families
- Bucket
- drivers/most
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/module.hlinux/fs.hlinux/usb.hlinux/slab.hlinux/init.hlinux/cdev.hlinux/device.hlinux/list.hlinux/completion.hlinux/mutex.hlinux/spinlock.hlinux/interrupt.hlinux/workqueue.hlinux/sysfs.hlinux/dma-mapping.hlinux/etherdevice.hlinux/uaccess.hlinux/most.h
Detected Declarations
struct most_dci_objstruct most_devstruct clear_hold_workstruct most_devstruct regsfunction drci_rd_regfunction drci_wr_regfunction start_sync_epfunction get_stream_frame_sizefunction hdm_poison_channelfunction hdm_add_paddingfunction hdm_remove_paddingfunction hdm_write_completionfunction hdm_read_completionfunction hdm_enqueuefunction hdm_dma_freefunction controllerfunction hdm_request_netinfofunction link_stat_timer_handlerfunction wq_netinfofunction wq_clear_haltfunction get_stat_reg_addrfunction value_showfunction value_storefunction release_dcifunction release_mdevfunction hdm_probefunction le16_to_cpufunction hdm_disconnectfunction hdm_suspendfunction hdm_resume
Annotated Snippet
static const struct file_operations hdm_usb_fops = {
.owner = THIS_MODULE,
};
/*
* usb_device_id - ID table for HCD device probing
*/
static const struct usb_device_id usbid[] = {
{ USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_BRDG), },
{ USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_OS81118), },
{ USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_OS81119), },
{ USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_OS81210), },
{ } /* Terminating entry */
};
struct regs {
const char *name;
u16 reg;
};
static const struct regs ro_regs[] = {
{ "ni_state", DRCI_REG_NI_STATE },
{ "packet_bandwidth", DRCI_REG_PACKET_BW },
{ "node_address", DRCI_REG_NODE_ADDR },
{ "node_position", DRCI_REG_NODE_POS },
};
static const struct regs rw_regs[] = {
{ "mep_filter", DRCI_REG_MEP_FILTER },
{ "mep_hash0", DRCI_REG_HASH_TBL0 },
{ "mep_hash1", DRCI_REG_HASH_TBL1 },
{ "mep_hash2", DRCI_REG_HASH_TBL2 },
{ "mep_hash3", DRCI_REG_HASH_TBL3 },
{ "mep_eui48_hi", DRCI_REG_HW_ADDR_HI },
{ "mep_eui48_mi", DRCI_REG_HW_ADDR_MI },
{ "mep_eui48_lo", DRCI_REG_HW_ADDR_LO },
};
static int get_stat_reg_addr(const struct regs *regs, int size,
const char *name, u16 *reg_addr)
{
int i;
for (i = 0; i < size; i++) {
if (sysfs_streq(name, regs[i].name)) {
*reg_addr = regs[i].reg;
return 0;
}
}
return -EINVAL;
}
#define get_static_reg_addr(regs, name, reg_addr) \
get_stat_reg_addr(regs, ARRAY_SIZE(regs), name, reg_addr)
static ssize_t value_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
const char *name = attr->attr.name;
struct most_dci_obj *dci_obj = to_dci_obj(dev);
u16 val;
u16 reg_addr;
int err;
if (sysfs_streq(name, "arb_address"))
return sysfs_emit(buf, "%04x\n", dci_obj->reg_addr);
if (sysfs_streq(name, "arb_value"))
reg_addr = dci_obj->reg_addr;
else if (get_static_reg_addr(ro_regs, name, ®_addr) &&
get_static_reg_addr(rw_regs, name, ®_addr))
return -EINVAL;
err = drci_rd_reg(dci_obj->usb_device, reg_addr, &val);
if (err < 0)
return err;
return sysfs_emit(buf, "%04x\n", val);
}
static ssize_t value_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
u16 val;
u16 reg_addr;
const char *name = attr->attr.name;
struct most_dci_obj *dci_obj = to_dci_obj(dev);
struct usb_device *usb_dev = dci_obj->usb_device;
int err;
Annotation
- Immediate include surface: `linux/module.h`, `linux/fs.h`, `linux/usb.h`, `linux/slab.h`, `linux/init.h`, `linux/cdev.h`, `linux/device.h`, `linux/list.h`.
- Detected declarations: `struct most_dci_obj`, `struct most_dev`, `struct clear_hold_work`, `struct most_dev`, `struct regs`, `function drci_rd_reg`, `function drci_wr_reg`, `function start_sync_ep`, `function get_stream_frame_size`, `function hdm_poison_channel`.
- Atlas domain: Driver Families / drivers/most.
- Implementation status: pattern 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.