sound/core/sound_oss.c
Source file repositories/reference/linux-study-clean/sound/core/sound_oss.c
File Facts
- System
- Linux kernel
- Corpus path
sound/core/sound_oss.c- Extension
.c- Size
- 6520 bytes
- Lines
- 244
- 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.
- 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/init.hlinux/export.hlinux/slab.hlinux/time.hsound/core.hsound/minors.hsound/info.hlinux/sound.hlinux/mutex.h
Detected Declarations
function snd_oss_kernel_minorfunction snd_register_oss_devicefunction snd_unregister_oss_devicefunction snd_minor_info_oss_readfunction snd_minor_info_oss_initexport snd_lookup_oss_minor_dataexport snd_register_oss_deviceexport snd_unregister_oss_device
Annotated Snippet
const struct file_operations *f_ops, void *private_data)
{
int minor = snd_oss_kernel_minor(type, card, dev);
int minor_unit;
struct snd_minor *preg;
int cidx = SNDRV_MINOR_OSS_CARD(minor);
int track2 = -1;
int register1 = -1, register2 = -1;
struct device *carddev = snd_card_get_device_link(card);
if (card && card->number >= SNDRV_MINOR_OSS_DEVICES)
return 0; /* ignore silently */
if (minor < 0)
return minor;
preg = kmalloc_obj(struct snd_minor);
if (preg == NULL)
return -ENOMEM;
preg->type = type;
preg->card = card ? card->number : -1;
preg->device = dev;
preg->f_ops = f_ops;
preg->private_data = private_data;
preg->card_ptr = card;
guard(mutex)(&sound_oss_mutex);
snd_oss_minors[minor] = preg;
minor_unit = SNDRV_MINOR_OSS_DEVICE(minor);
switch (minor_unit) {
case SNDRV_MINOR_OSS_PCM:
track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_AUDIO);
break;
case SNDRV_MINOR_OSS_MIDI:
track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI);
break;
case SNDRV_MINOR_OSS_MIDI1:
track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI1);
break;
}
register1 = register_sound_special_device(f_ops, minor, carddev);
if (register1 != minor)
goto __end;
if (track2 >= 0) {
register2 = register_sound_special_device(f_ops, track2,
carddev);
if (register2 != track2)
goto __end;
snd_oss_minors[track2] = preg;
}
return 0;
__end:
if (register2 >= 0)
unregister_sound_special(register2);
if (register1 >= 0)
unregister_sound_special(register1);
snd_oss_minors[minor] = NULL;
kfree(preg);
return -EBUSY;
}
EXPORT_SYMBOL(snd_register_oss_device);
int snd_unregister_oss_device(int type, struct snd_card *card, int dev)
{
int minor = snd_oss_kernel_minor(type, card, dev);
int cidx = SNDRV_MINOR_OSS_CARD(minor);
int track2 = -1;
struct snd_minor *mptr;
if (card && card->number >= SNDRV_MINOR_OSS_DEVICES)
return 0;
if (minor < 0)
return minor;
guard(mutex)(&sound_oss_mutex);
mptr = snd_oss_minors[minor];
if (mptr == NULL)
return -ENOENT;
switch (SNDRV_MINOR_OSS_DEVICE(minor)) {
case SNDRV_MINOR_OSS_PCM:
track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_AUDIO);
break;
case SNDRV_MINOR_OSS_MIDI:
track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI);
break;
case SNDRV_MINOR_OSS_MIDI1:
track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI1);
break;
}
if (track2 >= 0)
snd_oss_minors[track2] = NULL;
snd_oss_minors[minor] = NULL;
Annotation
- Immediate include surface: `linux/init.h`, `linux/export.h`, `linux/slab.h`, `linux/time.h`, `sound/core.h`, `sound/minors.h`, `sound/info.h`, `linux/sound.h`.
- Detected declarations: `function snd_oss_kernel_minor`, `function snd_register_oss_device`, `function snd_unregister_oss_device`, `function snd_minor_info_oss_read`, `function snd_minor_info_oss_init`, `export snd_lookup_oss_minor_data`, `export snd_register_oss_device`, `export snd_unregister_oss_device`.
- Atlas domain: Driver Families / sound/core.
- Implementation status: pattern implementation candidate.
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.