Lines Matching defs:hdr
27 struct snd_util_memhdr *hdr;
29 hdr = kzalloc(sizeof(*hdr), GFP_KERNEL);
30 if (hdr == NULL)
32 hdr->size = memsize;
33 mutex_init(&hdr->block_mutex);
34 INIT_LIST_HEAD(&hdr->block);
36 return hdr;
42 void snd_util_memhdr_free(struct snd_util_memhdr *hdr)
46 if (!hdr)
49 while ((p = hdr->block.next) != &hdr->block) {
53 kfree(hdr);
60 __snd_util_mem_alloc(struct snd_util_memhdr *hdr, int size)
66 if (snd_BUG_ON(!hdr || size <= 0))
73 if (units > hdr->size)
78 list_for_each(p, &hdr->block) {
84 if (hdr->size - prev_offset < units)
88 return __snd_util_memblk_new(hdr, units, p->prev);
97 __snd_util_memblk_new(struct snd_util_memhdr *hdr, unsigned int units,
102 blk = kmalloc(sizeof(struct snd_util_memblk) + hdr->block_extra_size,
107 if (prev == &hdr->block)
115 hdr->nblocks++;
116 hdr->used += units;
125 snd_util_mem_alloc(struct snd_util_memhdr *hdr, int size)
127 guard(mutex)(&hdr->block_mutex);
128 return __snd_util_mem_alloc(hdr, size);
137 __snd_util_mem_free(struct snd_util_memhdr *hdr, struct snd_util_memblk *blk)
140 hdr->nblocks--;
141 hdr->used -= blk->size;
148 int snd_util_mem_free(struct snd_util_memhdr *hdr, struct snd_util_memblk *blk)
150 if (snd_BUG_ON(!hdr || !blk))
153 guard(mutex)(&hdr->block_mutex);
154 __snd_util_mem_free(hdr, blk);
161 int snd_util_mem_avail(struct snd_util_memhdr *hdr)
163 guard(mutex)(&hdr->block_mutex);
164 return hdr->size - hdr->used;