drivers/most/core.c
Source file repositories/reference/linux-study-clean/drivers/most/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/most/core.c- Extension
.c- Size
- 36090 bytes
- Lines
- 1498
- 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/slab.hlinux/init.hlinux/device.hlinux/list.hlinux/poll.hlinux/wait.hlinux/kobject.hlinux/mutex.hlinux/completion.hlinux/sysfs.hlinux/kthread.hlinux/dma-mapping.hlinux/idr.hlinux/most.h
Detected Declarations
struct pipestruct most_channelstruct interface_privatestruct show_links_datafunction most_free_mbo_coherentfunction flush_channel_fifosfunction flush_trash_fifofunction available_directions_showfunction available_datatypes_showfunction number_of_packet_buffers_showfunction number_of_stream_buffers_showfunction size_of_packet_buffer_showfunction size_of_stream_buffer_showfunction channel_starving_showfunction set_number_of_buffers_showfunction set_buffer_size_showfunction set_direction_showfunction set_datatype_showfunction set_subbuffer_size_showfunction set_packets_per_xact_showfunction set_dbr_size_showfunction channel_attr_is_visiblefunction description_showfunction interface_showfunction list_for_each_entryfunction print_linksfunction list_for_each_entryfunction most_matchfunction links_showfunction components_showfunction list_for_each_entryfunction link_channel_to_componentfunction most_set_cfg_buffer_sizefunction most_set_cfg_subbuffer_sizefunction most_set_cfg_dbr_sizefunction most_set_cfg_num_buffersfunction most_set_cfg_datatypefunction most_set_cfg_directionfunction most_set_cfg_packets_xactfunction most_cfg_completefunction most_add_linkfunction most_remove_linkfunction trash_mbofunction hdm_mbo_readyfunction nq_hdm_mbofunction hdm_enqueue_threadfunction run_enqueue_threadfunction arm_mbo
Annotated Snippet
static int most_match(struct device *dev, const struct device_driver *drv)
{
if (!strcmp(dev_name(dev), "most"))
return 0;
else
return 1;
}
static const struct bus_type mostbus = {
.name = "most",
.match = most_match,
};
static ssize_t links_show(struct device_driver *drv, char *buf)
{
struct show_links_data d = { .buf = buf };
bus_for_each_dev(&mostbus, NULL, &d, print_links);
return d.offs;
}
static ssize_t components_show(struct device_driver *drv, char *buf)
{
struct most_component *comp;
int offs = 0;
list_for_each_entry(comp, &comp_list, list) {
offs += scnprintf(buf + offs, PAGE_SIZE - offs, "%s\n",
comp->name);
}
return offs;
}
/**
* get_channel - get pointer to channel
* @mdev: name of the device interface
* @mdev_ch: name of channel
*/
static struct most_channel *get_channel(char *mdev, char *mdev_ch)
{
struct device *dev = NULL;
struct most_interface *iface;
struct most_channel *c, *tmp;
dev = bus_find_device_by_name(&mostbus, NULL, mdev);
if (!dev)
return NULL;
iface = dev_get_drvdata(dev);
put_device(dev);
list_for_each_entry_safe(c, tmp, &iface->p->channel_list, list) {
if (!strcmp(dev_name(&c->dev), mdev_ch))
return c;
}
return NULL;
}
static
inline int link_channel_to_component(struct most_channel *c,
struct most_component *comp,
char *name,
char *comp_param)
{
int ret;
struct most_component **comp_ptr;
if (!c->pipe0.comp)
comp_ptr = &c->pipe0.comp;
else if (!c->pipe1.comp)
comp_ptr = &c->pipe1.comp;
else
return -ENOSPC;
*comp_ptr = comp;
ret = comp->probe_channel(c->iface, c->channel_id, &c->cfg, name,
comp_param);
if (ret) {
*comp_ptr = NULL;
return ret;
}
return 0;
}
int most_set_cfg_buffer_size(char *mdev, char *mdev_ch, u16 val)
{
struct most_channel *c = get_channel(mdev, mdev_ch);
if (!c)
return -ENODEV;
c->cfg.buffer_size = val;
return 0;
Annotation
- Immediate include surface: `linux/module.h`, `linux/fs.h`, `linux/slab.h`, `linux/init.h`, `linux/device.h`, `linux/list.h`, `linux/poll.h`, `linux/wait.h`.
- Detected declarations: `struct pipe`, `struct most_channel`, `struct interface_private`, `struct show_links_data`, `function most_free_mbo_coherent`, `function flush_channel_fifos`, `function flush_trash_fifo`, `function available_directions_show`, `function available_datatypes_show`, `function number_of_packet_buffers_show`.
- 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.