aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/cmipci.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/cmipci.c')
-rw-r--r--sound/pci/cmipci.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index c03b0a0a3b27..2ecbddbbdcf0 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -29,6 +29,7 @@
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/gameport.h> 30#include <linux/gameport.h>
31#include <linux/moduleparam.h> 31#include <linux/moduleparam.h>
32#include <linux/mutex.h>
32#include <sound/core.h> 33#include <sound/core.h>
33#include <sound/info.h> 34#include <sound/info.h>
34#include <sound/control.h> 35#include <sound/control.h>
@@ -439,7 +440,7 @@ struct cmipci {
439 struct snd_pcm_hardware *hw_info[3]; /* for playbacks */ 440 struct snd_pcm_hardware *hw_info[3]; /* for playbacks */
440 441
441 int opened[2]; /* open mode */ 442 int opened[2]; /* open mode */
442 struct semaphore open_mutex; 443 struct mutex open_mutex;
443 444
444 unsigned int mixer_insensitive: 1; 445 unsigned int mixer_insensitive: 1;
445 struct snd_kcontrol *mixer_res_ctl[CM_SAVED_MIXERS]; 446 struct snd_kcontrol *mixer_res_ctl[CM_SAVED_MIXERS];
@@ -641,14 +642,14 @@ static int snd_cmipci_playback2_hw_params(struct snd_pcm_substream *substream,
641{ 642{
642 struct cmipci *cm = snd_pcm_substream_chip(substream); 643 struct cmipci *cm = snd_pcm_substream_chip(substream);
643 if (params_channels(hw_params) > 2) { 644 if (params_channels(hw_params) > 2) {
644 down(&cm->open_mutex); 645 mutex_lock(&cm->open_mutex);
645 if (cm->opened[CM_CH_PLAY]) { 646 if (cm->opened[CM_CH_PLAY]) {
646 up(&cm->open_mutex); 647 mutex_unlock(&cm->open_mutex);
647 return -EBUSY; 648 return -EBUSY;
648 } 649 }
649 /* reserve the channel A */ 650 /* reserve the channel A */
650 cm->opened[CM_CH_PLAY] = CM_OPEN_PLAYBACK_MULTI; 651 cm->opened[CM_CH_PLAY] = CM_OPEN_PLAYBACK_MULTI;
651 up(&cm->open_mutex); 652 mutex_unlock(&cm->open_mutex);
652 } 653 }
653 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 654 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
654} 655}
@@ -1461,9 +1462,9 @@ static int open_device_check(struct cmipci *cm, int mode, struct snd_pcm_substre
1461 * pcm framework doesn't pass file pointer before actually opened, 1462 * pcm framework doesn't pass file pointer before actually opened,
1462 * we can't know whether blocking mode or not in open callback.. 1463 * we can't know whether blocking mode or not in open callback..
1463 */ 1464 */
1464 down(&cm->open_mutex); 1465 mutex_lock(&cm->open_mutex);
1465 if (cm->opened[ch]) { 1466 if (cm->opened[ch]) {
1466 up(&cm->open_mutex); 1467 mutex_unlock(&cm->open_mutex);
1467 return -EBUSY; 1468 return -EBUSY;
1468 } 1469 }
1469 cm->opened[ch] = mode; 1470 cm->opened[ch] = mode;
@@ -1475,7 +1476,7 @@ static int open_device_check(struct cmipci *cm, int mode, struct snd_pcm_substre
1475 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_ENDBDAC); 1476 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_ENDBDAC);
1476 spin_unlock_irq(&cm->reg_lock); 1477 spin_unlock_irq(&cm->reg_lock);
1477 } 1478 }
1478 up(&cm->open_mutex); 1479 mutex_unlock(&cm->open_mutex);
1479 return 0; 1480 return 0;
1480} 1481}
1481 1482
@@ -1483,7 +1484,7 @@ static void close_device_check(struct cmipci *cm, int mode)
1483{ 1484{
1484 int ch = mode & CM_OPEN_CH_MASK; 1485 int ch = mode & CM_OPEN_CH_MASK;
1485 1486
1486 down(&cm->open_mutex); 1487 mutex_lock(&cm->open_mutex);
1487 if (cm->opened[ch] == mode) { 1488 if (cm->opened[ch] == mode) {
1488 if (cm->channel[ch].substream) { 1489 if (cm->channel[ch].substream) {
1489 snd_cmipci_ch_reset(cm, ch); 1490 snd_cmipci_ch_reset(cm, ch);
@@ -1499,7 +1500,7 @@ static void close_device_check(struct cmipci *cm, int mode)
1499 spin_unlock_irq(&cm->reg_lock); 1500 spin_unlock_irq(&cm->reg_lock);
1500 } 1501 }
1501 } 1502 }
1502 up(&cm->open_mutex); 1503 mutex_unlock(&cm->open_mutex);
1503} 1504}
1504 1505
1505/* 1506/*
@@ -1546,7 +1547,7 @@ static int snd_cmipci_playback2_open(struct snd_pcm_substream *substream)
1546 if ((err = open_device_check(cm, CM_OPEN_PLAYBACK2, substream)) < 0) /* use channel B */ 1547 if ((err = open_device_check(cm, CM_OPEN_PLAYBACK2, substream)) < 0) /* use channel B */
1547 return err; 1548 return err;
1548 runtime->hw = snd_cmipci_playback2; 1549 runtime->hw = snd_cmipci_playback2;
1549 down(&cm->open_mutex); 1550 mutex_lock(&cm->open_mutex);
1550 if (! cm->opened[CM_CH_PLAY]) { 1551 if (! cm->opened[CM_CH_PLAY]) {
1551 if (cm->can_multi_ch) { 1552 if (cm->can_multi_ch) {
1552 runtime->hw.channels_max = cm->max_channels; 1553 runtime->hw.channels_max = cm->max_channels;
@@ -1559,7 +1560,7 @@ static int snd_cmipci_playback2_open(struct snd_pcm_substream *substream)
1559 } 1560 }
1560 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x10000); 1561 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x10000);
1561 } 1562 }
1562 up(&cm->open_mutex); 1563 mutex_unlock(&cm->open_mutex);
1563 return 0; 1564 return 0;
1564} 1565}
1565 1566
@@ -2844,7 +2845,7 @@ static int __devinit snd_cmipci_create(struct snd_card *card, struct pci_dev *pc
2844 } 2845 }
2845 2846
2846 spin_lock_init(&cm->reg_lock); 2847 spin_lock_init(&cm->reg_lock);
2847 init_MUTEX(&cm->open_mutex); 2848 mutex_init(&cm->open_mutex);
2848 cm->device = pci->device; 2849 cm->device = pci->device;
2849 cm->card = card; 2850 cm->card = card;
2850 cm->pci = pci; 2851 cm->pci = pci;