diff options
Diffstat (limited to 'sound/pci/emu10k1/memory.c')
-rw-r--r-- | sound/pci/emu10k1/memory.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c index 7d379f5131f..6a47672f930 100644 --- a/sound/pci/emu10k1/memory.c +++ b/sound/pci/emu10k1/memory.c | |||
@@ -107,7 +107,8 @@ static int search_empty_map_area(struct snd_emu10k1 *emu, int npages, struct lis | |||
107 | 107 | ||
108 | list_for_each (pos, &emu->mapped_link_head) { | 108 | list_for_each (pos, &emu->mapped_link_head) { |
109 | struct snd_emu10k1_memblk *blk = get_emu10k1_memblk(pos, mapped_link); | 109 | struct snd_emu10k1_memblk *blk = get_emu10k1_memblk(pos, mapped_link); |
110 | snd_assert(blk->mapped_page >= 0, continue); | 110 | if (blk->mapped_page < 0) |
111 | continue; | ||
111 | size = blk->mapped_page - page; | 112 | size = blk->mapped_page - page; |
112 | if (size == npages) { | 113 | if (size == npages) { |
113 | *nextp = pos; | 114 | *nextp = pos; |
@@ -295,15 +296,18 @@ struct snd_util_memblk * | |||
295 | snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *substream) | 296 | snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *substream) |
296 | { | 297 | { |
297 | struct snd_pcm_runtime *runtime = substream->runtime; | 298 | struct snd_pcm_runtime *runtime = substream->runtime; |
298 | struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream); | ||
299 | struct snd_util_memhdr *hdr; | 299 | struct snd_util_memhdr *hdr; |
300 | struct snd_emu10k1_memblk *blk; | 300 | struct snd_emu10k1_memblk *blk; |
301 | int page, err, idx; | 301 | int page, err, idx; |
302 | 302 | ||
303 | snd_assert(emu, return NULL); | 303 | if (snd_BUG_ON(!emu)) |
304 | snd_assert(runtime->dma_bytes > 0 && runtime->dma_bytes < MAXPAGES * EMUPAGESIZE, return NULL); | 304 | return NULL; |
305 | if (snd_BUG_ON(runtime->dma_bytes <= 0 || | ||
306 | runtime->dma_bytes >= MAXPAGES * EMUPAGESIZE)) | ||
307 | return NULL; | ||
305 | hdr = emu->memhdr; | 308 | hdr = emu->memhdr; |
306 | snd_assert(hdr, return NULL); | 309 | if (snd_BUG_ON(!hdr)) |
310 | return NULL; | ||
307 | 311 | ||
308 | mutex_lock(&hdr->block_mutex); | 312 | mutex_lock(&hdr->block_mutex); |
309 | blk = search_empty(emu, runtime->dma_bytes); | 313 | blk = search_empty(emu, runtime->dma_bytes); |
@@ -316,16 +320,9 @@ snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *subst | |||
316 | */ | 320 | */ |
317 | idx = 0; | 321 | idx = 0; |
318 | for (page = blk->first_page; page <= blk->last_page; page++, idx++) { | 322 | for (page = blk->first_page; page <= blk->last_page; page++, idx++) { |
323 | unsigned long ofs = idx << PAGE_SHIFT; | ||
319 | dma_addr_t addr; | 324 | dma_addr_t addr; |
320 | #ifdef CONFIG_SND_DEBUG | 325 | addr = snd_pcm_sgbuf_get_addr(substream, ofs); |
321 | if (idx >= sgbuf->pages) { | ||
322 | printk(KERN_ERR "emu: pages overflow! (%d-%d) for %d\n", | ||
323 | blk->first_page, blk->last_page, sgbuf->pages); | ||
324 | mutex_unlock(&hdr->block_mutex); | ||
325 | return NULL; | ||
326 | } | ||
327 | #endif | ||
328 | addr = sgbuf->table[idx].addr; | ||
329 | if (! is_valid_page(emu, addr)) { | 326 | if (! is_valid_page(emu, addr)) { |
330 | printk(KERN_ERR "emu: failure page = %d\n", idx); | 327 | printk(KERN_ERR "emu: failure page = %d\n", idx); |
331 | mutex_unlock(&hdr->block_mutex); | 328 | mutex_unlock(&hdr->block_mutex); |
@@ -353,7 +350,8 @@ snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *subst | |||
353 | */ | 350 | */ |
354 | int snd_emu10k1_free_pages(struct snd_emu10k1 *emu, struct snd_util_memblk *blk) | 351 | int snd_emu10k1_free_pages(struct snd_emu10k1 *emu, struct snd_util_memblk *blk) |
355 | { | 352 | { |
356 | snd_assert(emu && blk, return -EINVAL); | 353 | if (snd_BUG_ON(!emu || !blk)) |
354 | return -EINVAL; | ||
357 | return snd_emu10k1_synth_free(emu, blk); | 355 | return snd_emu10k1_synth_free(emu, blk); |
358 | } | 356 | } |
359 | 357 | ||
@@ -498,7 +496,8 @@ static int synth_free_pages(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk * | |||
498 | static inline void *offset_ptr(struct snd_emu10k1 *emu, int page, int offset) | 496 | static inline void *offset_ptr(struct snd_emu10k1 *emu, int page, int offset) |
499 | { | 497 | { |
500 | char *ptr; | 498 | char *ptr; |
501 | snd_assert(page >= 0 && page < emu->max_cache_pages, return NULL); | 499 | if (snd_BUG_ON(page < 0 || page >= emu->max_cache_pages)) |
500 | return NULL; | ||
502 | ptr = emu->page_ptr_table[page]; | 501 | ptr = emu->page_ptr_table[page]; |
503 | if (! ptr) { | 502 | if (! ptr) { |
504 | printk(KERN_ERR "emu10k1: access to NULL ptr: page = %d\n", page); | 503 | printk(KERN_ERR "emu10k1: access to NULL ptr: page = %d\n", page); |