sound/isa/gus/gus_mem.c
Source file repositories/reference/linux-study-clean/sound/isa/gus/gus_mem.c
File Facts
- System
- Linux kernel
- Corpus path
sound/isa/gus/gus_mem.c- Extension
.c- Size
- 8580 bytes
- Lines
- 317
- Domain
- Driver Families
- Bucket
- sound/isa
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/slab.hlinux/string.hsound/core.hsound/gus.hsound/info.h
Detected Declarations
function snd_gf1_mem_xallocfunction snd_gf1_mem_xfreefunction snd_gf1_mem_findfunction snd_gf1_mem_freefunction snd_gf1_mem_initfunction snd_gf1_mem_donefunction snd_gf1_mem_info_read
Annotated Snippet
if (pblock->ptr > nblock->ptr) {
nblock->prev = pblock->prev;
nblock->next = pblock;
pblock->prev = nblock;
if (pblock == alloc->first)
alloc->first = nblock;
else
nblock->prev->next = nblock;
return nblock;
}
pblock = pblock->next;
}
nblock->next = NULL;
if (alloc->last == NULL) {
nblock->prev = NULL;
alloc->first = alloc->last = nblock;
} else {
nblock->prev = alloc->last;
alloc->last->next = nblock;
alloc->last = nblock;
}
return nblock;
}
int snd_gf1_mem_xfree(struct snd_gf1_mem * alloc, struct snd_gf1_mem_block * block)
{
if (block->share) { /* ok.. shared block */
block->share--;
return 0;
}
if (alloc->first == block) {
alloc->first = block->next;
if (block->next)
block->next->prev = NULL;
} else {
block->prev->next = block->next;
if (block->next)
block->next->prev = block->prev;
}
if (alloc->last == block) {
alloc->last = block->prev;
if (block->prev)
block->prev->next = NULL;
} else {
block->next->prev = block->prev;
if (block->prev)
block->prev->next = block->next;
}
kfree(block->name);
kfree(block);
return 0;
}
static struct snd_gf1_mem_block *snd_gf1_mem_look(struct snd_gf1_mem * alloc,
unsigned int address)
{
struct snd_gf1_mem_block *block;
for (block = alloc->first; block; block = block->next) {
if (block->ptr == address) {
return block;
}
}
return NULL;
}
static struct snd_gf1_mem_block *snd_gf1_mem_share(struct snd_gf1_mem * alloc,
unsigned int *share_id)
{
struct snd_gf1_mem_block *block;
if (!share_id[0] && !share_id[1] &&
!share_id[2] && !share_id[3])
return NULL;
for (block = alloc->first; block; block = block->next)
if (!memcmp(share_id, block->share_id,
sizeof(block->share_id)))
return block;
return NULL;
}
static int snd_gf1_mem_find(struct snd_gf1_mem * alloc,
struct snd_gf1_mem_block * block,
unsigned int size, int w_16, int align)
{
struct snd_gf1_bank_info *info = w_16 ? alloc->banks_16 : alloc->banks_8;
unsigned int idx, boundary;
int size1;
struct snd_gf1_mem_block *pblock;
unsigned int ptr1, ptr2;
Annotation
- Immediate include surface: `linux/slab.h`, `linux/string.h`, `sound/core.h`, `sound/gus.h`, `sound/info.h`.
- Detected declarations: `function snd_gf1_mem_xalloc`, `function snd_gf1_mem_xfree`, `function snd_gf1_mem_find`, `function snd_gf1_mem_free`, `function snd_gf1_mem_init`, `function snd_gf1_mem_done`, `function snd_gf1_mem_info_read`.
- Atlas domain: Driver Families / sound/isa.
- Implementation status: source 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.