sound/core/timer.c
Source file repositories/reference/linux-study-clean/sound/core/timer.c
File Facts
- System
- Linux kernel
- Corpus path
sound/core/timer.c- Extension
.c- Size
- 65631 bytes
- Lines
- 2594
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/delay.hlinux/init.hlinux/slab.hlinux/time.hlinux/mutex.hlinux/device.hlinux/module.hlinux/string.hlinux/sched/signal.hlinux/anon_inodes.hlinux/idr.hsound/core.hsound/timer.hsound/control.hsound/info.hsound/minors.hsound/initval.hlinux/kmod.htimer_compat.c
Detected Declarations
struct snd_timer_tread32struct snd_timer_tread64struct snd_timer_userstruct snd_timer_status32struct snd_timer_status64struct snd_utimerstruct snd_timer_system_privateenum timer_tread_formatfunction snd_timer_instance_freefunction list_for_each_entryfunction snd_timer_requestfunction snd_timer_ref_getfunction snd_timer_ref_putfunction snd_timeri_timer_putfunction snd_timeri_timer_putfunction check_matching_master_slavefunction snd_timer_has_slave_keyfunction snd_timer_check_slavefunction list_for_each_entryfunction snd_timer_check_masterfunction snd_timer_openfunction remove_slave_linksfunction snd_timer_close_lockedfunction snd_timer_closefunction snd_timer_hw_resolutionfunction snd_timer_resolutionfunction snd_timer_notify1function snd_timer_start1function snd_timer_start_slavefunction snd_timer_stop1function snd_timer_stop_slavefunction snd_timer_startfunction snd_timer_stopfunction snd_timer_continuefunction snd_timer_pausefunction snd_timer_reschedulefunction list_for_each_entryfunction snd_timer_process_callbacksfunction snd_timer_clear_callbacksfunction snd_timer_workfunction snd_timer_interruptfunction list_for_each_entryfunction snd_timer_newfunction snd_timer_kref_releasefunction snd_timer_freefunction scoped_guardfunction snd_timer_dev_freefunction snd_timer_dev_register
Annotated Snippet
static const struct file_operations snd_utimer_fops = {
.llseek = noop_llseek,
.release = snd_utimer_release,
.unlocked_ioctl = snd_utimer_ioctl,
};
static int snd_utimer_start(struct snd_timer *t)
{
return 0;
}
static int snd_utimer_stop(struct snd_timer *t)
{
return 0;
}
static int snd_utimer_open(struct snd_timer *t)
{
return 0;
}
static int snd_utimer_close(struct snd_timer *t)
{
return 0;
}
static const struct snd_timer_hardware timer_hw = {
.flags = SNDRV_TIMER_HW_AUTO | SNDRV_TIMER_HW_WORK,
.open = snd_utimer_open,
.close = snd_utimer_close,
.start = snd_utimer_start,
.stop = snd_utimer_stop,
};
static int snd_utimer_create(struct snd_timer_uinfo *utimer_info,
struct snd_utimer **r_utimer)
{
struct snd_utimer *utimer;
struct snd_timer *timer;
struct snd_timer_id tid;
int utimer_id;
int err = 0;
if (!utimer_info || utimer_info->resolution == 0)
return -EINVAL;
utimer = kzalloc_obj(*utimer);
if (!utimer)
return -ENOMEM;
/* We hold the ioctl lock here so we won't get a race condition when allocating id */
utimer_id = snd_utimer_take_id();
if (utimer_id < 0) {
err = utimer_id;
goto err_take_id;
}
utimer->id = utimer_id;
utimer->name = kasprintf(GFP_KERNEL, "snd-utimer%d", utimer_id);
if (!utimer->name) {
err = -ENOMEM;
goto err_get_name;
}
tid.dev_sclass = SNDRV_TIMER_SCLASS_APPLICATION;
tid.dev_class = SNDRV_TIMER_CLASS_GLOBAL;
tid.card = -1;
tid.device = SNDRV_TIMER_GLOBAL_UDRIVEN;
tid.subdevice = utimer_id;
err = snd_timer_new(NULL, utimer->name, &tid, &timer);
if (err < 0) {
pr_err("Can't create userspace-driven timer\n");
goto err_timer_new;
}
timer->module = THIS_MODULE;
timer->hw = timer_hw;
timer->hw.resolution = utimer_info->resolution;
timer->hw.ticks = 1;
timer->max_instances = MAX_SLAVE_INSTANCES;
utimer->timer = timer;
err = snd_timer_global_register(timer);
if (err < 0) {
pr_err("Can't register a userspace-driven timer\n");
goto err_timer_reg;
}
Annotation
- Immediate include surface: `linux/delay.h`, `linux/init.h`, `linux/slab.h`, `linux/time.h`, `linux/mutex.h`, `linux/device.h`, `linux/module.h`, `linux/string.h`.
- Detected declarations: `struct snd_timer_tread32`, `struct snd_timer_tread64`, `struct snd_timer_user`, `struct snd_timer_status32`, `struct snd_timer_status64`, `struct snd_utimer`, `struct snd_timer_system_private`, `enum timer_tread_format`, `function snd_timer_instance_free`, `function list_for_each_entry`.
- Atlas domain: Driver Families / sound/core.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.