sound/core/seq_device.c
Source file repositories/reference/linux-study-clean/sound/core/seq_device.c
File Facts
- System
- Linux kernel
- Corpus path
sound/core/seq_device.c- Extension
.c- Size
- 7843 bytes
- Lines
- 338
- Domain
- Driver Families
- Bucket
- sound/core
- 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/device.hlinux/init.hlinux/module.hsound/core.hsound/info.hsound/seq_device.hsound/seq_kernel.hsound/initval.hlinux/kmod.hlinux/slab.hlinux/mutex.h
Detected Declarations
function snd_seq_bus_matchfunction snd_seq_bus_probefunction snd_seq_bus_removefunction print_dev_infofunction snd_seq_device_infofunction request_seq_drvfunction autoload_driversfunction queue_autoload_driversfunction snd_seq_autoload_initfunction snd_seq_autoload_exitfunction snd_seq_device_load_driversfunction cancel_autoload_driversfunction queue_autoload_driversfunction snd_seq_device_dev_registerfunction snd_seq_device_dev_disconnectfunction snd_seq_dev_releasefunction snd_seq_device_newfunction __snd_seq_driver_registerfunction snd_seq_driver_unregisterfunction seq_dev_proc_initfunction alsa_seq_device_initfunction alsa_seq_device_exitmodule init alsa_seq_device_initexport snd_seq_autoload_initexport snd_seq_autoload_exitexport snd_seq_device_load_driversexport snd_seq_device_newexport __snd_seq_driver_registerexport snd_seq_driver_unregister
Annotated Snippet
static int snd_seq_bus_match(struct device *dev, const struct device_driver *drv)
{
struct snd_seq_device *sdev = to_seq_dev(dev);
const struct snd_seq_driver *sdrv = to_seq_drv(drv);
return strcmp(sdrv->id, sdev->id) == 0 &&
sdrv->argsize == sdev->argsize;
}
static int snd_seq_bus_probe(struct device *dev)
{
struct snd_seq_device *sdev = to_seq_dev(dev);
const struct snd_seq_driver *sdrv = to_seq_drv(dev->driver);
if (sdrv->probe)
return sdrv->probe(sdev);
else
return 0;
}
static void snd_seq_bus_remove(struct device *dev)
{
struct snd_seq_device *sdev = to_seq_dev(dev);
const struct snd_seq_driver *sdrv = to_seq_drv(dev->driver);
if (sdrv->remove)
sdrv->remove(sdev);
}
static const struct bus_type snd_seq_bus_type = {
.name = "snd_seq",
.match = snd_seq_bus_match,
.probe = snd_seq_bus_probe,
.remove = snd_seq_bus_remove,
};
/*
* proc interface -- just for compatibility
*/
#ifdef CONFIG_SND_PROC_FS
static struct snd_info_entry *info_entry;
static int print_dev_info(struct device *dev, void *data)
{
struct snd_seq_device *sdev = to_seq_dev(dev);
struct snd_info_buffer *buffer = data;
snd_iprintf(buffer, "snd-%s,%s,%d\n", sdev->id,
dev->driver ? "loaded" : "empty",
dev->driver ? 1 : 0);
return 0;
}
static void snd_seq_device_info(struct snd_info_entry *entry,
struct snd_info_buffer *buffer)
{
bus_for_each_dev(&snd_seq_bus_type, NULL, buffer, print_dev_info);
}
#endif
/*
* load all registered drivers (called from seq_clientmgr.c)
*/
#ifdef CONFIG_MODULES
/* flag to block auto-loading */
static atomic_t snd_seq_in_init = ATOMIC_INIT(1); /* blocked as default */
static int request_seq_drv(struct device *dev, void *data)
{
struct snd_seq_device *sdev = to_seq_dev(dev);
if (!dev->driver)
request_module("snd-%s", sdev->id);
return 0;
}
static void autoload_drivers(struct work_struct *work)
{
/* avoid reentrance */
if (atomic_inc_return(&snd_seq_in_init) == 1)
bus_for_each_dev(&snd_seq_bus_type, NULL, NULL,
request_seq_drv);
atomic_dec(&snd_seq_in_init);
}
static DECLARE_WORK(autoload_work, autoload_drivers);
static void queue_autoload_drivers(void)
{
Annotation
- Immediate include surface: `linux/device.h`, `linux/init.h`, `linux/module.h`, `sound/core.h`, `sound/info.h`, `sound/seq_device.h`, `sound/seq_kernel.h`, `sound/initval.h`.
- Detected declarations: `function snd_seq_bus_match`, `function snd_seq_bus_probe`, `function snd_seq_bus_remove`, `function print_dev_info`, `function snd_seq_device_info`, `function request_seq_drv`, `function autoload_drivers`, `function queue_autoload_drivers`, `function snd_seq_autoload_init`, `function snd_seq_autoload_exit`.
- Atlas domain: Driver Families / sound/core.
- 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.