arch/um/drivers/hostaudio_kern.c
Source file repositories/reference/linux-study-clean/arch/um/drivers/hostaudio_kern.c
File Facts
- System
- Linux kernel
- Corpus path
arch/um/drivers/hostaudio_kern.c- Extension
.c- Size
- 7711 bytes
- Lines
- 354
- Domain
- Architecture Layer
- Bucket
- arch/um
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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/fs.hlinux/module.hlinux/slab.hlinux/sound.hlinux/soundcard.hlinux/mutex.hlinux/uaccess.hinit.hos.h
Detected Declarations
struct hostaudio_statestruct hostmixer_statefunction set_dspfunction set_mixerfunction hostaudio_readfunction hostaudio_writefunction hostaudio_pollfunction hostaudio_ioctlfunction hostaudio_openfunction hostaudio_releasefunction hostmixer_ioctl_mixdevfunction hostmixer_open_mixdevfunction hostmixer_releasefunction hostaudio_init_modulefunction hostaudio_cleanup_modulemodule init hostaudio_init_module
Annotated Snippet
static const struct file_operations hostaudio_fops = {
.owner = THIS_MODULE,
.read = hostaudio_read,
.write = hostaudio_write,
.poll = hostaudio_poll,
.unlocked_ioctl = hostaudio_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.mmap = NULL,
.open = hostaudio_open,
.release = hostaudio_release,
};
static const struct file_operations hostmixer_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = hostmixer_ioctl_mixdev,
.open = hostmixer_open_mixdev,
.release = hostmixer_release,
};
static struct {
int dev_audio;
int dev_mixer;
} module_data;
MODULE_AUTHOR("Steve Schmidtke");
MODULE_DESCRIPTION("UML Audio Relay");
MODULE_LICENSE("GPL");
static int __init hostaudio_init_module(void)
{
kernel_param_lock(THIS_MODULE);
printk(KERN_INFO "UML Audio Relay (host dsp = %s, host mixer = %s)\n",
dsp, mixer);
kernel_param_unlock(THIS_MODULE);
module_data.dev_audio = register_sound_dsp(&hostaudio_fops, -1);
if (module_data.dev_audio < 0) {
printk(KERN_ERR "hostaudio: couldn't register DSP device!\n");
return -ENODEV;
}
module_data.dev_mixer = register_sound_mixer(&hostmixer_fops, -1);
if (module_data.dev_mixer < 0) {
printk(KERN_ERR "hostmixer: couldn't register mixer "
"device!\n");
unregister_sound_dsp(module_data.dev_audio);
return -ENODEV;
}
return 0;
}
static void __exit hostaudio_cleanup_module (void)
{
unregister_sound_mixer(module_data.dev_mixer);
unregister_sound_dsp(module_data.dev_audio);
}
module_init(hostaudio_init_module);
module_exit(hostaudio_cleanup_module);
Annotation
- Immediate include surface: `linux/fs.h`, `linux/module.h`, `linux/slab.h`, `linux/sound.h`, `linux/soundcard.h`, `linux/mutex.h`, `linux/uaccess.h`, `init.h`.
- Detected declarations: `struct hostaudio_state`, `struct hostmixer_state`, `function set_dsp`, `function set_mixer`, `function hostaudio_read`, `function hostaudio_write`, `function hostaudio_poll`, `function hostaudio_ioctl`, `function hostaudio_open`, `function hostaudio_release`.
- Atlas domain: Architecture Layer / arch/um.
- 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.