sound/core/info.c
Source file repositories/reference/linux-study-clean/sound/core/info.c
File Facts
- System
- Linux kernel
- Corpus path
sound/core/info.c- Extension
.c- Size
- 20231 bytes
- Lines
- 888
- Domain
- Driver Families
- Bucket
- sound/core
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/time.hlinux/mm.hlinux/slab.hlinux/string.hlinux/module.hsound/core.hsound/minors.hsound/info.hlinux/utsname.hlinux/proc_fs.hlinux/mutex.h
Detected Declarations
struct snd_info_private_datafunction Copyrightfunction alloc_info_privatefunction valid_posfunction snd_info_entry_llseekfunction snd_info_entry_readfunction snd_info_entry_writefunction snd_info_entry_pollfunction snd_info_entry_ioctlfunction snd_info_entry_mmapfunction snd_info_entry_openfunction snd_info_entry_releasefunction snd_info_text_entry_writefunction snd_info_seq_showfunction snd_info_text_entry_openfunction snd_info_text_entry_releasefunction snd_info_initfunction snd_info_donefunction snd_card_id_readfunction snd_info_card_createfunction snd_info_card_registerfunction snd_info_card_id_changefunction snd_info_card_disconnectfunction snd_info_card_freefunction snd_info_get_linefunction snd_info_create_card_entryfunction snd_info_clear_entriesfunction snd_info_free_entryfunction __snd_info_registerfunction snd_info_registerfunction list_for_each_entryfunction snd_card_registerfunction snd_info_version_readfunction snd_info_version_initexport snd_seq_rootexport snd_info_get_lineexport snd_info_get_strexport snd_info_create_module_entryexport snd_info_create_card_entryexport snd_info_free_entryexport snd_info_registerexport snd_card_rw_proc_new
Annotated Snippet
struct snd_info_private_data {
struct snd_info_buffer *rbuffer;
struct snd_info_buffer *wbuffer;
struct snd_info_entry *entry;
void *file_private_data;
};
static int snd_info_version_init(void);
static void snd_info_clear_entries(struct snd_info_entry *entry);
/*
*/
static struct snd_info_entry *snd_proc_root;
struct snd_info_entry *snd_seq_root;
EXPORT_SYMBOL(snd_seq_root);
#ifdef CONFIG_SND_OSSEMUL
struct snd_info_entry *snd_oss_root;
#endif
static int alloc_info_private(struct snd_info_entry *entry,
struct snd_info_private_data **ret)
{
struct snd_info_private_data *data;
if (!entry || !entry->p)
return -ENODEV;
if (!try_module_get(entry->module))
return -EFAULT;
data = kzalloc_obj(*data);
if (!data) {
module_put(entry->module);
return -ENOMEM;
}
data->entry = entry;
*ret = data;
return 0;
}
static bool valid_pos(loff_t pos, size_t count)
{
if (pos < 0 || (long) pos != pos || (ssize_t) count < 0)
return false;
if ((unsigned long) pos + (unsigned long) count < (unsigned long) pos)
return false;
return true;
}
/*
* file ops for binary proc files
*/
static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig)
{
struct snd_info_private_data *data;
struct snd_info_entry *entry;
loff_t size;
data = file->private_data;
entry = data->entry;
guard(mutex)(&entry->access);
if (entry->c.ops->llseek)
return entry->c.ops->llseek(entry,
data->file_private_data,
file, offset, orig);
size = entry->size;
switch (orig) {
case SEEK_SET:
break;
case SEEK_CUR:
offset += file->f_pos;
break;
case SEEK_END:
if (!size)
return -EINVAL;
offset += size;
break;
default:
return -EINVAL;
}
if (offset < 0)
return -EINVAL;
if (size && offset > size)
offset = size;
file->f_pos = offset;
return offset;
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/time.h`, `linux/mm.h`, `linux/slab.h`, `linux/string.h`, `linux/module.h`, `sound/core.h`, `sound/minors.h`.
- Detected declarations: `struct snd_info_private_data`, `function Copyright`, `function alloc_info_private`, `function valid_pos`, `function snd_info_entry_llseek`, `function snd_info_entry_read`, `function snd_info_entry_write`, `function snd_info_entry_poll`, `function snd_info_entry_ioctl`, `function snd_info_entry_mmap`.
- Atlas domain: Driver Families / sound/core.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.