Lines Matching full:hdr
27 struct snd_util_memhdr *hdr; in snd_util_memhdr_new() local
29 hdr = kzalloc(sizeof(*hdr), GFP_KERNEL); in snd_util_memhdr_new()
30 if (hdr == NULL) in snd_util_memhdr_new()
32 hdr->size = memsize; in snd_util_memhdr_new()
33 mutex_init(&hdr->block_mutex); in snd_util_memhdr_new()
34 INIT_LIST_HEAD(&hdr->block); in snd_util_memhdr_new()
36 return hdr; in snd_util_memhdr_new()
42 void snd_util_memhdr_free(struct snd_util_memhdr *hdr) in snd_util_memhdr_free() argument
46 if (!hdr) in snd_util_memhdr_free()
49 while ((p = hdr->block.next) != &hdr->block) { in snd_util_memhdr_free()
53 kfree(hdr); in snd_util_memhdr_free()
60 __snd_util_mem_alloc(struct snd_util_memhdr *hdr, int size) in __snd_util_mem_alloc() argument
66 if (snd_BUG_ON(!hdr || size <= 0)) in __snd_util_mem_alloc()
73 if (units > hdr->size) in __snd_util_mem_alloc()
78 list_for_each(p, &hdr->block) { in __snd_util_mem_alloc()
84 if (hdr->size - prev_offset < units) in __snd_util_mem_alloc()
88 return __snd_util_memblk_new(hdr, units, p->prev); in __snd_util_mem_alloc()
97 __snd_util_memblk_new(struct snd_util_memhdr *hdr, unsigned int units, in __snd_util_memblk_new() argument
102 blk = kmalloc(sizeof(struct snd_util_memblk) + hdr->block_extra_size, in __snd_util_memblk_new()
107 if (prev == &hdr->block) in __snd_util_memblk_new()
115 hdr->nblocks++; in __snd_util_memblk_new()
116 hdr->used += units; in __snd_util_memblk_new()
125 snd_util_mem_alloc(struct snd_util_memhdr *hdr, int size) in snd_util_mem_alloc() argument
128 mutex_lock(&hdr->block_mutex); in snd_util_mem_alloc()
129 blk = __snd_util_mem_alloc(hdr, size); in snd_util_mem_alloc()
130 mutex_unlock(&hdr->block_mutex); in snd_util_mem_alloc()
140 __snd_util_mem_free(struct snd_util_memhdr *hdr, struct snd_util_memblk *blk) in __snd_util_mem_free() argument
143 hdr->nblocks--; in __snd_util_mem_free()
144 hdr->used -= blk->size; in __snd_util_mem_free()
151 int snd_util_mem_free(struct snd_util_memhdr *hdr, struct snd_util_memblk *blk) in snd_util_mem_free() argument
153 if (snd_BUG_ON(!hdr || !blk)) in snd_util_mem_free()
156 mutex_lock(&hdr->block_mutex); in snd_util_mem_free()
157 __snd_util_mem_free(hdr, blk); in snd_util_mem_free()
158 mutex_unlock(&hdr->block_mutex); in snd_util_mem_free()
165 int snd_util_mem_avail(struct snd_util_memhdr *hdr) in snd_util_mem_avail() argument
168 mutex_lock(&hdr->block_mutex); in snd_util_mem_avail()
169 size = hdr->size - hdr->used; in snd_util_mem_avail()
170 mutex_unlock(&hdr->block_mutex); in snd_util_mem_avail()