Lines Matching refs:hdr

40 	struct snd_util_memhdr *hdr;  in snd_util_memhdr_new()  local
42 hdr = kzalloc(sizeof(*hdr), GFP_KERNEL); in snd_util_memhdr_new()
43 if (hdr == NULL) in snd_util_memhdr_new()
45 hdr->size = memsize; in snd_util_memhdr_new()
46 mutex_init(&hdr->block_mutex); in snd_util_memhdr_new()
47 INIT_LIST_HEAD(&hdr->block); in snd_util_memhdr_new()
49 return hdr; in snd_util_memhdr_new()
55 void snd_util_memhdr_free(struct snd_util_memhdr *hdr) in snd_util_memhdr_free() argument
59 if (!hdr) in snd_util_memhdr_free()
62 while ((p = hdr->block.next) != &hdr->block) { in snd_util_memhdr_free()
66 kfree(hdr); in snd_util_memhdr_free()
73 __snd_util_mem_alloc(struct snd_util_memhdr *hdr, int size) in __snd_util_mem_alloc() argument
79 if (snd_BUG_ON(!hdr || size <= 0)) in __snd_util_mem_alloc()
86 if (units > hdr->size) in __snd_util_mem_alloc()
91 list_for_each(p, &hdr->block) { in __snd_util_mem_alloc()
97 if (hdr->size - prev_offset < units) in __snd_util_mem_alloc()
101 return __snd_util_memblk_new(hdr, units, p->prev); in __snd_util_mem_alloc()
110 __snd_util_memblk_new(struct snd_util_memhdr *hdr, unsigned int units, in __snd_util_memblk_new() argument
115 blk = kmalloc(sizeof(struct snd_util_memblk) + hdr->block_extra_size, in __snd_util_memblk_new()
120 if (prev == &hdr->block) in __snd_util_memblk_new()
128 hdr->nblocks++; in __snd_util_memblk_new()
129 hdr->used += units; in __snd_util_memblk_new()
138 snd_util_mem_alloc(struct snd_util_memhdr *hdr, int size) in snd_util_mem_alloc() argument
141 mutex_lock(&hdr->block_mutex); in snd_util_mem_alloc()
142 blk = __snd_util_mem_alloc(hdr, size); in snd_util_mem_alloc()
143 mutex_unlock(&hdr->block_mutex); in snd_util_mem_alloc()
153 __snd_util_mem_free(struct snd_util_memhdr *hdr, struct snd_util_memblk *blk) in __snd_util_mem_free() argument
156 hdr->nblocks--; in __snd_util_mem_free()
157 hdr->used -= blk->size; in __snd_util_mem_free()
164 int snd_util_mem_free(struct snd_util_memhdr *hdr, struct snd_util_memblk *blk) in snd_util_mem_free() argument
166 if (snd_BUG_ON(!hdr || !blk)) in snd_util_mem_free()
169 mutex_lock(&hdr->block_mutex); in snd_util_mem_free()
170 __snd_util_mem_free(hdr, blk); in snd_util_mem_free()
171 mutex_unlock(&hdr->block_mutex); in snd_util_mem_free()
178 int snd_util_mem_avail(struct snd_util_memhdr *hdr) in snd_util_mem_avail() argument
181 mutex_lock(&hdr->block_mutex); in snd_util_mem_avail()
182 size = hdr->size - hdr->used; in snd_util_mem_avail()
183 mutex_unlock(&hdr->block_mutex); in snd_util_mem_avail()