diff options
Diffstat (limited to 'sound/pci/emu10k1')
-rw-r--r-- | sound/pci/emu10k1/emu10k1_main.c | 5 | ||||
-rw-r--r-- | sound/pci/emu10k1/emufx.c | 22 | ||||
-rw-r--r-- | sound/pci/emu10k1/memory.c | 26 |
3 files changed, 29 insertions, 24 deletions
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 3c7043b7d4c9..103a3f7708b7 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c | |||
@@ -36,6 +36,8 @@ | |||
36 | #include <linux/pci.h> | 36 | #include <linux/pci.h> |
37 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
38 | #include <linux/vmalloc.h> | 38 | #include <linux/vmalloc.h> |
39 | #include <linux/mutex.h> | ||
40 | |||
39 | 41 | ||
40 | #include <sound/core.h> | 42 | #include <sound/core.h> |
41 | #include <sound/emu10k1.h> | 43 | #include <sound/emu10k1.h> |
@@ -1097,8 +1099,7 @@ int __devinit snd_emu10k1_create(struct snd_card *card, | |||
1097 | spin_lock_init(&emu->voice_lock); | 1099 | spin_lock_init(&emu->voice_lock); |
1098 | spin_lock_init(&emu->synth_lock); | 1100 | spin_lock_init(&emu->synth_lock); |
1099 | spin_lock_init(&emu->memblk_lock); | 1101 | spin_lock_init(&emu->memblk_lock); |
1100 | init_MUTEX(&emu->ptb_lock); | 1102 | mutex_init(&emu->fx8010.lock); |
1101 | init_MUTEX(&emu->fx8010.lock); | ||
1102 | INIT_LIST_HEAD(&emu->mapped_link_head); | 1103 | INIT_LIST_HEAD(&emu->mapped_link_head); |
1103 | INIT_LIST_HEAD(&emu->mapped_order_link_head); | 1104 | INIT_LIST_HEAD(&emu->mapped_order_link_head); |
1104 | emu->pci = pci; | 1105 | emu->pci = pci; |
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index 509837252735..dfba00230d4d 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c | |||
@@ -32,6 +32,8 @@ | |||
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/vmalloc.h> | 33 | #include <linux/vmalloc.h> |
34 | #include <linux/init.h> | 34 | #include <linux/init.h> |
35 | #include <linux/mutex.h> | ||
36 | |||
35 | #include <sound/core.h> | 37 | #include <sound/core.h> |
36 | #include <sound/emu10k1.h> | 38 | #include <sound/emu10k1.h> |
37 | 39 | ||
@@ -874,7 +876,7 @@ static int snd_emu10k1_icode_poke(struct snd_emu10k1 *emu, | |||
874 | { | 876 | { |
875 | int err = 0; | 877 | int err = 0; |
876 | 878 | ||
877 | down(&emu->fx8010.lock); | 879 | mutex_lock(&emu->fx8010.lock); |
878 | if ((err = snd_emu10k1_verify_controls(emu, icode)) < 0) | 880 | if ((err = snd_emu10k1_verify_controls(emu, icode)) < 0) |
879 | goto __error; | 881 | goto __error; |
880 | strlcpy(emu->fx8010.name, icode->name, sizeof(emu->fx8010.name)); | 882 | strlcpy(emu->fx8010.name, icode->name, sizeof(emu->fx8010.name)); |
@@ -897,7 +899,7 @@ static int snd_emu10k1_icode_poke(struct snd_emu10k1 *emu, | |||
897 | else | 899 | else |
898 | snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg); | 900 | snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg); |
899 | __error: | 901 | __error: |
900 | up(&emu->fx8010.lock); | 902 | mutex_unlock(&emu->fx8010.lock); |
901 | return err; | 903 | return err; |
902 | } | 904 | } |
903 | 905 | ||
@@ -906,7 +908,7 @@ static int snd_emu10k1_icode_peek(struct snd_emu10k1 *emu, | |||
906 | { | 908 | { |
907 | int err; | 909 | int err; |
908 | 910 | ||
909 | down(&emu->fx8010.lock); | 911 | mutex_lock(&emu->fx8010.lock); |
910 | strlcpy(icode->name, emu->fx8010.name, sizeof(icode->name)); | 912 | strlcpy(icode->name, emu->fx8010.name, sizeof(icode->name)); |
911 | /* ok, do the main job */ | 913 | /* ok, do the main job */ |
912 | err = snd_emu10k1_gpr_peek(emu, icode); | 914 | err = snd_emu10k1_gpr_peek(emu, icode); |
@@ -916,7 +918,7 @@ static int snd_emu10k1_icode_peek(struct snd_emu10k1 *emu, | |||
916 | err = snd_emu10k1_code_peek(emu, icode); | 918 | err = snd_emu10k1_code_peek(emu, icode); |
917 | if (err >= 0) | 919 | if (err >= 0) |
918 | err = snd_emu10k1_list_controls(emu, icode); | 920 | err = snd_emu10k1_list_controls(emu, icode); |
919 | up(&emu->fx8010.lock); | 921 | mutex_unlock(&emu->fx8010.lock); |
920 | return err; | 922 | return err; |
921 | } | 923 | } |
922 | 924 | ||
@@ -932,7 +934,7 @@ static int snd_emu10k1_ipcm_poke(struct snd_emu10k1 *emu, | |||
932 | if (ipcm->channels > 32) | 934 | if (ipcm->channels > 32) |
933 | return -EINVAL; | 935 | return -EINVAL; |
934 | pcm = &emu->fx8010.pcm[ipcm->substream]; | 936 | pcm = &emu->fx8010.pcm[ipcm->substream]; |
935 | down(&emu->fx8010.lock); | 937 | mutex_lock(&emu->fx8010.lock); |
936 | spin_lock_irq(&emu->reg_lock); | 938 | spin_lock_irq(&emu->reg_lock); |
937 | if (pcm->opened) { | 939 | if (pcm->opened) { |
938 | err = -EBUSY; | 940 | err = -EBUSY; |
@@ -962,7 +964,7 @@ static int snd_emu10k1_ipcm_poke(struct snd_emu10k1 *emu, | |||
962 | } | 964 | } |
963 | __error: | 965 | __error: |
964 | spin_unlock_irq(&emu->reg_lock); | 966 | spin_unlock_irq(&emu->reg_lock); |
965 | up(&emu->fx8010.lock); | 967 | mutex_unlock(&emu->fx8010.lock); |
966 | return err; | 968 | return err; |
967 | } | 969 | } |
968 | 970 | ||
@@ -976,7 +978,7 @@ static int snd_emu10k1_ipcm_peek(struct snd_emu10k1 *emu, | |||
976 | if (ipcm->substream >= EMU10K1_FX8010_PCM_COUNT) | 978 | if (ipcm->substream >= EMU10K1_FX8010_PCM_COUNT) |
977 | return -EINVAL; | 979 | return -EINVAL; |
978 | pcm = &emu->fx8010.pcm[ipcm->substream]; | 980 | pcm = &emu->fx8010.pcm[ipcm->substream]; |
979 | down(&emu->fx8010.lock); | 981 | mutex_lock(&emu->fx8010.lock); |
980 | spin_lock_irq(&emu->reg_lock); | 982 | spin_lock_irq(&emu->reg_lock); |
981 | ipcm->channels = pcm->channels; | 983 | ipcm->channels = pcm->channels; |
982 | ipcm->tram_start = pcm->tram_start; | 984 | ipcm->tram_start = pcm->tram_start; |
@@ -992,7 +994,7 @@ static int snd_emu10k1_ipcm_peek(struct snd_emu10k1 *emu, | |||
992 | ipcm->res1 = ipcm->res2 = 0; | 994 | ipcm->res1 = ipcm->res2 = 0; |
993 | ipcm->pad = 0; | 995 | ipcm->pad = 0; |
994 | spin_unlock_irq(&emu->reg_lock); | 996 | spin_unlock_irq(&emu->reg_lock); |
995 | up(&emu->fx8010.lock); | 997 | mutex_unlock(&emu->fx8010.lock); |
996 | return err; | 998 | return err; |
997 | } | 999 | } |
998 | 1000 | ||
@@ -2308,9 +2310,9 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un | |||
2308 | return -EPERM; | 2310 | return -EPERM; |
2309 | if (get_user(addr, (unsigned int __user *)argp)) | 2311 | if (get_user(addr, (unsigned int __user *)argp)) |
2310 | return -EFAULT; | 2312 | return -EFAULT; |
2311 | down(&emu->fx8010.lock); | 2313 | mutex_lock(&emu->fx8010.lock); |
2312 | res = snd_emu10k1_fx8010_tram_setup(emu, addr); | 2314 | res = snd_emu10k1_fx8010_tram_setup(emu, addr); |
2313 | up(&emu->fx8010.lock); | 2315 | mutex_unlock(&emu->fx8010.lock); |
2314 | return res; | 2316 | return res; |
2315 | case SNDRV_EMU10K1_IOCTL_STOP: | 2317 | case SNDRV_EMU10K1_IOCTL_STOP: |
2316 | if (!capable(CAP_SYS_ADMIN)) | 2318 | if (!capable(CAP_SYS_ADMIN)) |
diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c index 68c795c03109..e7ec98649f04 100644 --- a/sound/pci/emu10k1/memory.c +++ b/sound/pci/emu10k1/memory.c | |||
@@ -24,6 +24,8 @@ | |||
24 | #include <sound/driver.h> | 24 | #include <sound/driver.h> |
25 | #include <linux/pci.h> | 25 | #include <linux/pci.h> |
26 | #include <linux/time.h> | 26 | #include <linux/time.h> |
27 | #include <linux/mutex.h> | ||
28 | |||
27 | #include <sound/core.h> | 29 | #include <sound/core.h> |
28 | #include <sound/emu10k1.h> | 30 | #include <sound/emu10k1.h> |
29 | 31 | ||
@@ -302,10 +304,10 @@ snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *subst | |||
302 | hdr = emu->memhdr; | 304 | hdr = emu->memhdr; |
303 | snd_assert(hdr, return NULL); | 305 | snd_assert(hdr, return NULL); |
304 | 306 | ||
305 | down(&hdr->block_mutex); | 307 | mutex_lock(&hdr->block_mutex); |
306 | blk = search_empty(emu, runtime->dma_bytes); | 308 | blk = search_empty(emu, runtime->dma_bytes); |
307 | if (blk == NULL) { | 309 | if (blk == NULL) { |
308 | up(&hdr->block_mutex); | 310 | mutex_unlock(&hdr->block_mutex); |
309 | return NULL; | 311 | return NULL; |
310 | } | 312 | } |
311 | /* fill buffer addresses but pointers are not stored so that | 313 | /* fill buffer addresses but pointers are not stored so that |
@@ -318,14 +320,14 @@ snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *subst | |||
318 | if (idx >= sgbuf->pages) { | 320 | if (idx >= sgbuf->pages) { |
319 | printk(KERN_ERR "emu: pages overflow! (%d-%d) for %d\n", | 321 | printk(KERN_ERR "emu: pages overflow! (%d-%d) for %d\n", |
320 | blk->first_page, blk->last_page, sgbuf->pages); | 322 | blk->first_page, blk->last_page, sgbuf->pages); |
321 | up(&hdr->block_mutex); | 323 | mutex_unlock(&hdr->block_mutex); |
322 | return NULL; | 324 | return NULL; |
323 | } | 325 | } |
324 | #endif | 326 | #endif |
325 | addr = sgbuf->table[idx].addr; | 327 | addr = sgbuf->table[idx].addr; |
326 | if (! is_valid_page(emu, addr)) { | 328 | if (! is_valid_page(emu, addr)) { |
327 | printk(KERN_ERR "emu: failure page = %d\n", idx); | 329 | printk(KERN_ERR "emu: failure page = %d\n", idx); |
328 | up(&hdr->block_mutex); | 330 | mutex_unlock(&hdr->block_mutex); |
329 | return NULL; | 331 | return NULL; |
330 | } | 332 | } |
331 | emu->page_addr_table[page] = addr; | 333 | emu->page_addr_table[page] = addr; |
@@ -337,10 +339,10 @@ snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *subst | |||
337 | err = snd_emu10k1_memblk_map(emu, blk); | 339 | err = snd_emu10k1_memblk_map(emu, blk); |
338 | if (err < 0) { | 340 | if (err < 0) { |
339 | __snd_util_mem_free(hdr, (struct snd_util_memblk *)blk); | 341 | __snd_util_mem_free(hdr, (struct snd_util_memblk *)blk); |
340 | up(&hdr->block_mutex); | 342 | mutex_unlock(&hdr->block_mutex); |
341 | return NULL; | 343 | return NULL; |
342 | } | 344 | } |
343 | up(&hdr->block_mutex); | 345 | mutex_unlock(&hdr->block_mutex); |
344 | return (struct snd_util_memblk *)blk; | 346 | return (struct snd_util_memblk *)blk; |
345 | } | 347 | } |
346 | 348 | ||
@@ -369,19 +371,19 @@ snd_emu10k1_synth_alloc(struct snd_emu10k1 *hw, unsigned int size) | |||
369 | struct snd_emu10k1_memblk *blk; | 371 | struct snd_emu10k1_memblk *blk; |
370 | struct snd_util_memhdr *hdr = hw->memhdr; | 372 | struct snd_util_memhdr *hdr = hw->memhdr; |
371 | 373 | ||
372 | down(&hdr->block_mutex); | 374 | mutex_lock(&hdr->block_mutex); |
373 | blk = (struct snd_emu10k1_memblk *)__snd_util_mem_alloc(hdr, size); | 375 | blk = (struct snd_emu10k1_memblk *)__snd_util_mem_alloc(hdr, size); |
374 | if (blk == NULL) { | 376 | if (blk == NULL) { |
375 | up(&hdr->block_mutex); | 377 | mutex_unlock(&hdr->block_mutex); |
376 | return NULL; | 378 | return NULL; |
377 | } | 379 | } |
378 | if (synth_alloc_pages(hw, blk)) { | 380 | if (synth_alloc_pages(hw, blk)) { |
379 | __snd_util_mem_free(hdr, (struct snd_util_memblk *)blk); | 381 | __snd_util_mem_free(hdr, (struct snd_util_memblk *)blk); |
380 | up(&hdr->block_mutex); | 382 | mutex_unlock(&hdr->block_mutex); |
381 | return NULL; | 383 | return NULL; |
382 | } | 384 | } |
383 | snd_emu10k1_memblk_map(hw, blk); | 385 | snd_emu10k1_memblk_map(hw, blk); |
384 | up(&hdr->block_mutex); | 386 | mutex_unlock(&hdr->block_mutex); |
385 | return (struct snd_util_memblk *)blk; | 387 | return (struct snd_util_memblk *)blk; |
386 | } | 388 | } |
387 | 389 | ||
@@ -396,14 +398,14 @@ snd_emu10k1_synth_free(struct snd_emu10k1 *emu, struct snd_util_memblk *memblk) | |||
396 | struct snd_emu10k1_memblk *blk = (struct snd_emu10k1_memblk *)memblk; | 398 | struct snd_emu10k1_memblk *blk = (struct snd_emu10k1_memblk *)memblk; |
397 | unsigned long flags; | 399 | unsigned long flags; |
398 | 400 | ||
399 | down(&hdr->block_mutex); | 401 | mutex_lock(&hdr->block_mutex); |
400 | spin_lock_irqsave(&emu->memblk_lock, flags); | 402 | spin_lock_irqsave(&emu->memblk_lock, flags); |
401 | if (blk->mapped_page >= 0) | 403 | if (blk->mapped_page >= 0) |
402 | unmap_memblk(emu, blk); | 404 | unmap_memblk(emu, blk); |
403 | spin_unlock_irqrestore(&emu->memblk_lock, flags); | 405 | spin_unlock_irqrestore(&emu->memblk_lock, flags); |
404 | synth_free_pages(emu, blk); | 406 | synth_free_pages(emu, blk); |
405 | __snd_util_mem_free(hdr, memblk); | 407 | __snd_util_mem_free(hdr, memblk); |
406 | up(&hdr->block_mutex); | 408 | mutex_unlock(&hdr->block_mutex); |
407 | return 0; | 409 | return 0; |
408 | } | 410 | } |
409 | 411 | ||