aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/trident
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-08-21 07:00:13 -0400
committerJaroslav Kysela <perex@perex.cz>2008-08-25 03:57:18 -0400
commit77a23f2695bb2de0cd74599400dc55109c531b72 (patch)
tree4960195e04016928dea83deb85e0f3bf97024a8a /sound/pci/trident
parent46480b3a5f88f20dbf25d95fe74d7b4798d5bc86 (diff)
ALSA: Clean up SG-buffer helper functions and macros
Clean up SG-buffer helper functions and macros. Helpers take substream as arguments now. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/trident')
-rw-r--r--sound/pci/trident/trident_memory.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/sound/pci/trident/trident_memory.c b/sound/pci/trident/trident_memory.c
index 2fe3b1fab53a..f9779e23fe57 100644
--- a/sound/pci/trident/trident_memory.c
+++ b/sound/pci/trident/trident_memory.c
@@ -194,7 +194,6 @@ snd_trident_alloc_sg_pages(struct snd_trident *trident,
194 struct snd_util_memblk *blk; 194 struct snd_util_memblk *blk;
195 struct snd_pcm_runtime *runtime = substream->runtime; 195 struct snd_pcm_runtime *runtime = substream->runtime;
196 int idx, page; 196 int idx, page;
197 struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream);
198 197
199 if (snd_BUG_ON(runtime->dma_bytes <= 0 || 198 if (snd_BUG_ON(runtime->dma_bytes <= 0 ||
200 runtime->dma_bytes > SNDRV_TRIDENT_MAX_PAGES * 199 runtime->dma_bytes > SNDRV_TRIDENT_MAX_PAGES *
@@ -212,18 +211,14 @@ snd_trident_alloc_sg_pages(struct snd_trident *trident,
212 mutex_unlock(&hdr->block_mutex); 211 mutex_unlock(&hdr->block_mutex);
213 return NULL; 212 return NULL;
214 } 213 }
215 if (lastpg(blk) - firstpg(blk) >= sgbuf->pages) {
216 snd_printk(KERN_ERR "page calculation doesn't match: allocated pages = %d, trident = %d/%d\n", sgbuf->pages, firstpg(blk), lastpg(blk));
217 __snd_util_mem_free(hdr, blk);
218 mutex_unlock(&hdr->block_mutex);
219 return NULL;
220 }
221 214
222 /* set TLB entries */ 215 /* set TLB entries */
223 idx = 0; 216 idx = 0;
224 for (page = firstpg(blk); page <= lastpg(blk); page++, idx++) { 217 for (page = firstpg(blk); page <= lastpg(blk); page++, idx++) {
225 dma_addr_t addr = sgbuf->table[idx].addr; 218 unsigned long ofs = idx << PAGE_SHIFT;
226 unsigned long ptr = (unsigned long)sgbuf->table[idx].buf; 219 dma_addr_t addr = snd_pcm_sgbuf_get_addr(substream, ofs);
220 unsigned long ptr = (unsigned long)
221 snd_pcm_sgbuf_get_ptr(substream, ofs);
227 if (! is_valid_page(addr)) { 222 if (! is_valid_page(addr)) {
228 __snd_util_mem_free(hdr, blk); 223 __snd_util_mem_free(hdr, blk);
229 mutex_unlock(&hdr->block_mutex); 224 mutex_unlock(&hdr->block_mutex);