aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2006-01-16 10:34:20 -0500
committerJaroslav Kysela <perex@suse.cz>2006-03-22 04:25:29 -0500
commit62932df8fb20ba2fb53a95fa52445eba22e821fe (patch)
tree335178d7438395a68a453a9c23624b3e9fc5ec40
parent8b7547f95cbe8a5940df62ed730646fdfcba5fda (diff)
[ALSA] semaphore -> mutex (PCI part)
Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--include/sound/ac97_codec.h4
-rw-r--r--include/sound/ak4531_codec.h2
-rw-r--r--include/sound/cs46xx.h2
-rw-r--r--include/sound/emu10k1.h4
-rw-r--r--sound/pci/ac97/ac97_codec.c45
-rw-r--r--sound/pci/ac97/ac97_patch.c10
-rw-r--r--sound/pci/ac97/ac97_pcm.c6
-rw-r--r--sound/pci/ac97/ac97_proc.c14
-rw-r--r--sound/pci/ac97/ak4531_codec.c28
-rw-r--r--sound/pci/atiixp.c21
-rw-r--r--sound/pci/atiixp_modem.c13
-rw-r--r--sound/pci/cmipci.c25
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c52
-rw-r--r--sound/pci/cs46xx/dsp_spos.c58
-rw-r--r--sound/pci/cs46xx/dsp_spos_scb_lib.c6
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c5
-rw-r--r--sound/pci/emu10k1/emufx.c22
-rw-r--r--sound/pci/emu10k1/memory.c26
-rw-r--r--sound/pci/ens1370.c32
-rw-r--r--sound/pci/es1968.c22
-rw-r--r--sound/pci/hda/hda_codec.c51
-rw-r--r--sound/pci/hda/hda_codec.h4
-rw-r--r--sound/pci/hda/hda_intel.c17
-rw-r--r--sound/pci/hda/patch_analog.c28
-rw-r--r--sound/pci/ice1712/aureon.c38
-rw-r--r--sound/pci/ice1712/delta.c26
-rw-r--r--sound/pci/ice1712/hoontech.c26
-rw-r--r--sound/pci/ice1712/ice1712.c7
-rw-r--r--sound/pci/ice1712/ice1712.h10
-rw-r--r--sound/pci/ice1712/ice1724.c37
-rw-r--r--sound/pci/ice1712/phase.c10
-rw-r--r--sound/pci/ice1712/pontis.c86
-rw-r--r--sound/pci/korg1212/korg1212.c17
-rw-r--r--sound/pci/mixart/mixart.c21
-rw-r--r--sound/pci/mixart/mixart.h7
-rw-r--r--sound/pci/mixart/mixart_core.c18
-rw-r--r--sound/pci/mixart/mixart_mixer.c52
-rw-r--r--sound/pci/nm256/nm256.c16
-rw-r--r--sound/pci/pcxhr/pcxhr.c36
-rw-r--r--sound/pci/pcxhr/pcxhr.h5
-rw-r--r--sound/pci/pcxhr/pcxhr_mixer.c75
-rw-r--r--sound/pci/trident/trident_memory.c36
-rw-r--r--sound/pci/vx222/vx222_ops.c18
43 files changed, 549 insertions, 489 deletions
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index b0b3ea7b365e..ad3fe046f6cf 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -456,8 +456,8 @@ struct snd_ac97 {
456 struct snd_info_entry *proc_regs; 456 struct snd_info_entry *proc_regs;
457 unsigned short subsystem_vendor; 457 unsigned short subsystem_vendor;
458 unsigned short subsystem_device; 458 unsigned short subsystem_device;
459 struct semaphore reg_mutex; 459 struct mutex reg_mutex;
460 struct semaphore page_mutex; /* mutex for AD18xx multi-codecs and paging (2.3) */ 460 struct mutex page_mutex; /* mutex for AD18xx multi-codecs and paging (2.3) */
461 unsigned short num; /* number of codec: 0 = primary, 1 = secondary */ 461 unsigned short num; /* number of codec: 0 = primary, 1 = secondary */
462 unsigned short addr; /* physical address of codec [0-3] */ 462 unsigned short addr; /* physical address of codec [0-3] */
463 unsigned int id; /* identification of codec */ 463 unsigned int id; /* identification of codec */
diff --git a/include/sound/ak4531_codec.h b/include/sound/ak4531_codec.h
index edf04070ce7c..fb30faab43a8 100644
--- a/include/sound/ak4531_codec.h
+++ b/include/sound/ak4531_codec.h
@@ -71,7 +71,7 @@ struct snd_ak4531 {
71 void (*private_free) (struct snd_ak4531 *ak4531); 71 void (*private_free) (struct snd_ak4531 *ak4531);
72 /* --- */ 72 /* --- */
73 unsigned char regs[0x20]; 73 unsigned char regs[0x20];
74 struct semaphore reg_mutex; 74 struct mutex reg_mutex;
75}; 75};
76 76
77int snd_ak4531_mixer(struct snd_card *card, struct snd_ak4531 *_ak4531, 77int snd_ak4531_mixer(struct snd_card *card, struct snd_ak4531 *_ak4531,
diff --git a/include/sound/cs46xx.h b/include/sound/cs46xx.h
index 199b5098ff7e..80b2979c0cba 100644
--- a/include/sound/cs46xx.h
+++ b/include/sound/cs46xx.h
@@ -1711,7 +1711,7 @@ struct snd_cs46xx {
1711 int current_gpio; 1711 int current_gpio;
1712#endif 1712#endif
1713#ifdef CONFIG_SND_CS46XX_NEW_DSP 1713#ifdef CONFIG_SND_CS46XX_NEW_DSP
1714 struct semaphore spos_mutex; 1714 struct mutex spos_mutex;
1715 1715
1716 struct dsp_spos_instance * dsp_spos_instance; 1716 struct dsp_spos_instance * dsp_spos_instance;
1717 1717
diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h
index 951e40d720d9..186e00ad9e79 100644
--- a/include/sound/emu10k1.h
+++ b/include/sound/emu10k1.h
@@ -33,6 +33,7 @@
33#include <sound/pcm-indirect.h> 33#include <sound/pcm-indirect.h>
34#include <sound/timer.h> 34#include <sound/timer.h>
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/mutex.h>
36#include <asm/io.h> 37#include <asm/io.h>
37 38
38/* ------------------- DEFINES -------------------- */ 39/* ------------------- DEFINES -------------------- */
@@ -1022,7 +1023,7 @@ struct snd_emu10k1_fx8010 {
1022 int gpr_size; /* size of allocated GPR controls */ 1023 int gpr_size; /* size of allocated GPR controls */
1023 int gpr_count; /* count of used kcontrols */ 1024 int gpr_count; /* count of used kcontrols */
1024 struct list_head gpr_ctl; /* GPR controls */ 1025 struct list_head gpr_ctl; /* GPR controls */
1025 struct semaphore lock; 1026 struct mutex lock;
1026 struct snd_emu10k1_fx8010_pcm pcm[8]; 1027 struct snd_emu10k1_fx8010_pcm pcm[8];
1027 spinlock_t irq_lock; 1028 spinlock_t irq_lock;
1028 struct snd_emu10k1_fx8010_irq *irq_handlers; 1029 struct snd_emu10k1_fx8010_irq *irq_handlers;
@@ -1122,7 +1123,6 @@ struct snd_emu10k1 {
1122 spinlock_t reg_lock; 1123 spinlock_t reg_lock;
1123 spinlock_t emu_lock; 1124 spinlock_t emu_lock;
1124 spinlock_t voice_lock; 1125 spinlock_t voice_lock;
1125 struct semaphore ptb_lock;
1126 1126
1127 struct snd_emu10k1_voice voices[NUM_G]; 1127 struct snd_emu10k1_voice voices[NUM_G];
1128 struct snd_emu10k1_voice p16v_voices[4]; 1128 struct snd_emu10k1_voice p16v_voices[4];
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index 3020ca2b602b..6108cdc5efb6 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -28,6 +28,7 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/pci.h> 29#include <linux/pci.h>
30#include <linux/moduleparam.h> 30#include <linux/moduleparam.h>
31#include <linux/mutex.h>
31#include <sound/core.h> 32#include <sound/core.h>
32#include <sound/pcm.h> 33#include <sound/pcm.h>
33#include <sound/ac97_codec.h> 34#include <sound/ac97_codec.h>
@@ -296,11 +297,11 @@ void snd_ac97_write_cache(struct snd_ac97 *ac97, unsigned short reg, unsigned sh
296{ 297{
297 if (!snd_ac97_valid_reg(ac97, reg)) 298 if (!snd_ac97_valid_reg(ac97, reg))
298 return; 299 return;
299 down(&ac97->reg_mutex); 300 mutex_lock(&ac97->reg_mutex);
300 ac97->regs[reg] = value; 301 ac97->regs[reg] = value;
301 ac97->bus->ops->write(ac97, reg, value); 302 ac97->bus->ops->write(ac97, reg, value);
302 set_bit(reg, ac97->reg_accessed); 303 set_bit(reg, ac97->reg_accessed);
303 up(&ac97->reg_mutex); 304 mutex_unlock(&ac97->reg_mutex);
304} 305}
305 306
306/** 307/**
@@ -321,14 +322,14 @@ int snd_ac97_update(struct snd_ac97 *ac97, unsigned short reg, unsigned short va
321 322
322 if (!snd_ac97_valid_reg(ac97, reg)) 323 if (!snd_ac97_valid_reg(ac97, reg))
323 return -EINVAL; 324 return -EINVAL;
324 down(&ac97->reg_mutex); 325 mutex_lock(&ac97->reg_mutex);
325 change = ac97->regs[reg] != value; 326 change = ac97->regs[reg] != value;
326 if (change) { 327 if (change) {
327 ac97->regs[reg] = value; 328 ac97->regs[reg] = value;
328 ac97->bus->ops->write(ac97, reg, value); 329 ac97->bus->ops->write(ac97, reg, value);
329 } 330 }
330 set_bit(reg, ac97->reg_accessed); 331 set_bit(reg, ac97->reg_accessed);
331 up(&ac97->reg_mutex); 332 mutex_unlock(&ac97->reg_mutex);
332 return change; 333 return change;
333} 334}
334 335
@@ -351,9 +352,9 @@ int snd_ac97_update_bits(struct snd_ac97 *ac97, unsigned short reg, unsigned sho
351 352
352 if (!snd_ac97_valid_reg(ac97, reg)) 353 if (!snd_ac97_valid_reg(ac97, reg))
353 return -EINVAL; 354 return -EINVAL;
354 down(&ac97->reg_mutex); 355 mutex_lock(&ac97->reg_mutex);
355 change = snd_ac97_update_bits_nolock(ac97, reg, mask, value); 356 change = snd_ac97_update_bits_nolock(ac97, reg, mask, value);
356 up(&ac97->reg_mutex); 357 mutex_unlock(&ac97->reg_mutex);
357 return change; 358 return change;
358} 359}
359 360
@@ -380,12 +381,12 @@ static int snd_ac97_ad18xx_update_pcm_bits(struct snd_ac97 *ac97, int codec, uns
380 int change; 381 int change;
381 unsigned short old, new, cfg; 382 unsigned short old, new, cfg;
382 383
383 down(&ac97->page_mutex); 384 mutex_lock(&ac97->page_mutex);
384 old = ac97->spec.ad18xx.pcmreg[codec]; 385 old = ac97->spec.ad18xx.pcmreg[codec];
385 new = (old & ~mask) | value; 386 new = (old & ~mask) | value;
386 change = old != new; 387 change = old != new;
387 if (change) { 388 if (change) {
388 down(&ac97->reg_mutex); 389 mutex_lock(&ac97->reg_mutex);
389 cfg = snd_ac97_read_cache(ac97, AC97_AD_SERIAL_CFG); 390 cfg = snd_ac97_read_cache(ac97, AC97_AD_SERIAL_CFG);
390 ac97->spec.ad18xx.pcmreg[codec] = new; 391 ac97->spec.ad18xx.pcmreg[codec] = new;
391 /* select single codec */ 392 /* select single codec */
@@ -397,9 +398,9 @@ static int snd_ac97_ad18xx_update_pcm_bits(struct snd_ac97 *ac97, int codec, uns
397 /* select all codecs */ 398 /* select all codecs */
398 ac97->bus->ops->write(ac97, AC97_AD_SERIAL_CFG, 399 ac97->bus->ops->write(ac97, AC97_AD_SERIAL_CFG,
399 cfg | 0x7000); 400 cfg | 0x7000);
400 up(&ac97->reg_mutex); 401 mutex_unlock(&ac97->reg_mutex);
401 } 402 }
402 up(&ac97->page_mutex); 403 mutex_unlock(&ac97->page_mutex);
403 return change; 404 return change;
404} 405}
405 406
@@ -467,7 +468,7 @@ static int snd_ac97_page_save(struct snd_ac97 *ac97, int reg, struct snd_kcontro
467 (ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23 && 468 (ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23 &&
468 (reg >= 0x60 && reg < 0x70)) { 469 (reg >= 0x60 && reg < 0x70)) {
469 unsigned short page = (kcontrol->private_value >> 26) & 0x0f; 470 unsigned short page = (kcontrol->private_value >> 26) & 0x0f;
470 down(&ac97->page_mutex); /* lock paging */ 471 mutex_lock(&ac97->page_mutex); /* lock paging */
471 page_save = snd_ac97_read(ac97, AC97_INT_PAGING) & AC97_PAGE_MASK; 472 page_save = snd_ac97_read(ac97, AC97_INT_PAGING) & AC97_PAGE_MASK;
472 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page); 473 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page);
473 } 474 }
@@ -478,7 +479,7 @@ static void snd_ac97_page_restore(struct snd_ac97 *ac97, int page_save)
478{ 479{
479 if (page_save >= 0) { 480 if (page_save >= 0) {
480 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page_save); 481 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page_save);
481 up(&ac97->page_mutex); /* unlock paging */ 482 mutex_unlock(&ac97->page_mutex); /* unlock paging */
482 } 483 }
483} 484}
484 485
@@ -674,12 +675,12 @@ static int snd_ac97_spdif_default_get(struct snd_kcontrol *kcontrol, struct snd_
674{ 675{
675 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 676 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
676 677
677 down(&ac97->reg_mutex); 678 mutex_lock(&ac97->reg_mutex);
678 ucontrol->value.iec958.status[0] = ac97->spdif_status & 0xff; 679 ucontrol->value.iec958.status[0] = ac97->spdif_status & 0xff;
679 ucontrol->value.iec958.status[1] = (ac97->spdif_status >> 8) & 0xff; 680 ucontrol->value.iec958.status[1] = (ac97->spdif_status >> 8) & 0xff;
680 ucontrol->value.iec958.status[2] = (ac97->spdif_status >> 16) & 0xff; 681 ucontrol->value.iec958.status[2] = (ac97->spdif_status >> 16) & 0xff;
681 ucontrol->value.iec958.status[3] = (ac97->spdif_status >> 24) & 0xff; 682 ucontrol->value.iec958.status[3] = (ac97->spdif_status >> 24) & 0xff;
682 up(&ac97->reg_mutex); 683 mutex_unlock(&ac97->reg_mutex);
683 return 0; 684 return 0;
684} 685}
685 686
@@ -718,7 +719,7 @@ static int snd_ac97_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_
718 } 719 }
719 } 720 }
720 721
721 down(&ac97->reg_mutex); 722 mutex_lock(&ac97->reg_mutex);
722 change = ac97->spdif_status != new; 723 change = ac97->spdif_status != new;
723 ac97->spdif_status = new; 724 ac97->spdif_status = new;
724 725
@@ -746,7 +747,7 @@ static int snd_ac97_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_
746 snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); /* turn on again */ 747 snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); /* turn on again */
747 } 748 }
748 } 749 }
749 up(&ac97->reg_mutex); 750 mutex_unlock(&ac97->reg_mutex);
750 751
751 return change; 752 return change;
752} 753}
@@ -763,7 +764,7 @@ static int snd_ac97_put_spsa(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
763 764
764 value = (ucontrol->value.integer.value[0] & mask); 765 value = (ucontrol->value.integer.value[0] & mask);
765 766
766 down(&ac97->reg_mutex); 767 mutex_lock(&ac97->reg_mutex);
767 mask <<= shift; 768 mask <<= shift;
768 value <<= shift; 769 value <<= shift;
769 old = snd_ac97_read_cache(ac97, reg); 770 old = snd_ac97_read_cache(ac97, reg);
@@ -777,7 +778,7 @@ static int snd_ac97_put_spsa(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
777 if (extst & AC97_EA_SPDIF) 778 if (extst & AC97_EA_SPDIF)
778 snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); /* turn on again */ 779 snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); /* turn on again */
779 } 780 }
780 up(&ac97->reg_mutex); 781 mutex_unlock(&ac97->reg_mutex);
781 return change; 782 return change;
782} 783}
783 784
@@ -888,10 +889,10 @@ static int snd_ac97_ad18xx_pcm_get_volume(struct snd_kcontrol *kcontrol, struct
888 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 889 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
889 int codec = kcontrol->private_value & 3; 890 int codec = kcontrol->private_value & 3;
890 891
891 down(&ac97->page_mutex); 892 mutex_lock(&ac97->page_mutex);
892 ucontrol->value.integer.value[0] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 0) & 31); 893 ucontrol->value.integer.value[0] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 0) & 31);
893 ucontrol->value.integer.value[1] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 8) & 31); 894 ucontrol->value.integer.value[1] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 8) & 31);
894 up(&ac97->page_mutex); 895 mutex_unlock(&ac97->page_mutex);
895 return 0; 896 return 0;
896} 897}
897 898
@@ -1856,8 +1857,8 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
1856 ac97->limited_regs = template->limited_regs; 1857 ac97->limited_regs = template->limited_regs;
1857 memcpy(ac97->reg_accessed, template->reg_accessed, sizeof(ac97->reg_accessed)); 1858 memcpy(ac97->reg_accessed, template->reg_accessed, sizeof(ac97->reg_accessed));
1858 bus->codec[ac97->num] = ac97; 1859 bus->codec[ac97->num] = ac97;
1859 init_MUTEX(&ac97->reg_mutex); 1860 mutex_init(&ac97->reg_mutex);
1860 init_MUTEX(&ac97->page_mutex); 1861 mutex_init(&ac97->page_mutex);
1861 1862
1862#ifdef CONFIG_PCI 1863#ifdef CONFIG_PCI
1863 if (ac97->pci) { 1864 if (ac97->pci) {
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index a444a78c7c94..8bc79cbe3215 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -27,6 +27,8 @@
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/mutex.h>
31
30#include <sound/core.h> 32#include <sound/core.h>
31#include <sound/pcm.h> 33#include <sound/pcm.h>
32#include <sound/control.h> 34#include <sound/control.h>
@@ -55,12 +57,12 @@ static int ac97_update_bits_page(struct snd_ac97 *ac97, unsigned short reg, unsi
55 unsigned short page_save; 57 unsigned short page_save;
56 int ret; 58 int ret;
57 59
58 down(&ac97->page_mutex); 60 mutex_lock(&ac97->page_mutex);
59 page_save = snd_ac97_read(ac97, AC97_INT_PAGING) & AC97_PAGE_MASK; 61 page_save = snd_ac97_read(ac97, AC97_INT_PAGING) & AC97_PAGE_MASK;
60 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page); 62 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page);
61 ret = snd_ac97_update_bits(ac97, reg, mask, value); 63 ret = snd_ac97_update_bits(ac97, reg, mask, value);
62 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page_save); 64 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page_save);
63 up(&ac97->page_mutex); /* unlock paging */ 65 mutex_unlock(&ac97->page_mutex); /* unlock paging */
64 return ret; 66 return ret;
65} 67}
66 68
@@ -897,12 +899,12 @@ static int snd_ac97_stac9708_put_bias(struct snd_kcontrol *kcontrol, struct snd_
897 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 899 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
898 int err; 900 int err;
899 901
900 down(&ac97->page_mutex); 902 mutex_lock(&ac97->page_mutex);
901 snd_ac97_write(ac97, AC97_SIGMATEL_BIAS1, 0xabba); 903 snd_ac97_write(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
902 err = snd_ac97_update_bits(ac97, AC97_SIGMATEL_BIAS2, 0x0010, 904 err = snd_ac97_update_bits(ac97, AC97_SIGMATEL_BIAS2, 0x0010,
903 (ucontrol->value.integer.value[0] & 1) << 4); 905 (ucontrol->value.integer.value[0] & 1) << 4);
904 snd_ac97_write(ac97, AC97_SIGMATEL_BIAS1, 0); 906 snd_ac97_write(ac97, AC97_SIGMATEL_BIAS1, 0);
905 up(&ac97->page_mutex); 907 mutex_unlock(&ac97->page_mutex);
906 return err; 908 return err;
907} 909}
908 910
diff --git a/sound/pci/ac97/ac97_pcm.c b/sound/pci/ac97/ac97_pcm.c
index c3e590bf7a02..512a3583b0ce 100644
--- a/sound/pci/ac97/ac97_pcm.c
+++ b/sound/pci/ac97/ac97_pcm.c
@@ -27,6 +27,8 @@
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/mutex.h>
31
30#include <sound/core.h> 32#include <sound/core.h>
31#include <sound/pcm.h> 33#include <sound/pcm.h>
32#include <sound/control.h> 34#include <sound/control.h>
@@ -206,7 +208,7 @@ static int set_spdif_rate(struct snd_ac97 *ac97, unsigned short rate)
206 mask = AC97_SC_SPSR_MASK; 208 mask = AC97_SC_SPSR_MASK;
207 } 209 }
208 210
209 down(&ac97->reg_mutex); 211 mutex_lock(&ac97->reg_mutex);
210 old = snd_ac97_read(ac97, reg) & mask; 212 old = snd_ac97_read(ac97, reg) & mask;
211 if (old != bits) { 213 if (old != bits) {
212 snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, 0); 214 snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, 0);
@@ -231,7 +233,7 @@ static int set_spdif_rate(struct snd_ac97 *ac97, unsigned short rate)
231 ac97->spdif_status = sbits; 233 ac97->spdif_status = sbits;
232 } 234 }
233 snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); 235 snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF);
234 up(&ac97->reg_mutex); 236 mutex_unlock(&ac97->reg_mutex);
235 return 0; 237 return 0;
236} 238}
237 239
diff --git a/sound/pci/ac97/ac97_proc.c b/sound/pci/ac97/ac97_proc.c
index 7134b3f55fb5..4d523df79cc7 100644
--- a/sound/pci/ac97/ac97_proc.c
+++ b/sound/pci/ac97/ac97_proc.c
@@ -24,6 +24,8 @@
24 24
25#include <sound/driver.h> 25#include <sound/driver.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/mutex.h>
28
27#include <sound/core.h> 29#include <sound/core.h>
28#include <sound/ac97_codec.h> 30#include <sound/ac97_codec.h>
29#include <sound/asoundef.h> 31#include <sound/asoundef.h>
@@ -338,7 +340,7 @@ static void snd_ac97_proc_read(struct snd_info_entry *entry, struct snd_info_buf
338{ 340{
339 struct snd_ac97 *ac97 = entry->private_data; 341 struct snd_ac97 *ac97 = entry->private_data;
340 342
341 down(&ac97->page_mutex); 343 mutex_lock(&ac97->page_mutex);
342 if ((ac97->id & 0xffffff40) == AC97_ID_AD1881) { // Analog Devices AD1881/85/86 344 if ((ac97->id & 0xffffff40) == AC97_ID_AD1881) { // Analog Devices AD1881/85/86
343 int idx; 345 int idx;
344 for (idx = 0; idx < 3; idx++) 346 for (idx = 0; idx < 3; idx++)
@@ -364,7 +366,7 @@ static void snd_ac97_proc_read(struct snd_info_entry *entry, struct snd_info_buf
364 } else { 366 } else {
365 snd_ac97_proc_read_main(ac97, buffer, 0); 367 snd_ac97_proc_read_main(ac97, buffer, 0);
366 } 368 }
367 up(&ac97->page_mutex); 369 mutex_unlock(&ac97->page_mutex);
368} 370}
369 371
370#ifdef CONFIG_SND_DEBUG 372#ifdef CONFIG_SND_DEBUG
@@ -374,7 +376,7 @@ static void snd_ac97_proc_regs_write(struct snd_info_entry *entry, struct snd_in
374 struct snd_ac97 *ac97 = entry->private_data; 376 struct snd_ac97 *ac97 = entry->private_data;
375 char line[64]; 377 char line[64];
376 unsigned int reg, val; 378 unsigned int reg, val;
377 down(&ac97->page_mutex); 379 mutex_lock(&ac97->page_mutex);
378 while (!snd_info_get_line(buffer, line, sizeof(line))) { 380 while (!snd_info_get_line(buffer, line, sizeof(line))) {
379 if (sscanf(line, "%x %x", &reg, &val) != 2) 381 if (sscanf(line, "%x %x", &reg, &val) != 2)
380 continue; 382 continue;
@@ -382,7 +384,7 @@ static void snd_ac97_proc_regs_write(struct snd_info_entry *entry, struct snd_in
382 if (reg < 0x80 && (reg & 1) == 0 && val <= 0xffff) 384 if (reg < 0x80 && (reg & 1) == 0 && val <= 0xffff)
383 snd_ac97_write_cache(ac97, reg, val); 385 snd_ac97_write_cache(ac97, reg, val);
384 } 386 }
385 up(&ac97->page_mutex); 387 mutex_unlock(&ac97->page_mutex);
386} 388}
387#endif 389#endif
388 390
@@ -401,7 +403,7 @@ static void snd_ac97_proc_regs_read(struct snd_info_entry *entry,
401{ 403{
402 struct snd_ac97 *ac97 = entry->private_data; 404 struct snd_ac97 *ac97 = entry->private_data;
403 405
404 down(&ac97->page_mutex); 406 mutex_lock(&ac97->page_mutex);
405 if ((ac97->id & 0xffffff40) == AC97_ID_AD1881) { // Analog Devices AD1881/85/86 407 if ((ac97->id & 0xffffff40) == AC97_ID_AD1881) { // Analog Devices AD1881/85/86
406 408
407 int idx; 409 int idx;
@@ -417,7 +419,7 @@ static void snd_ac97_proc_regs_read(struct snd_info_entry *entry,
417 } else { 419 } else {
418 snd_ac97_proc_regs_read_main(ac97, buffer, 0); 420 snd_ac97_proc_regs_read_main(ac97, buffer, 0);
419 } 421 }
420 up(&ac97->page_mutex); 422 mutex_unlock(&ac97->page_mutex);
421} 423}
422 424
423void snd_ac97_proc_init(struct snd_ac97 * ac97) 425void snd_ac97_proc_init(struct snd_ac97 * ac97)
diff --git a/sound/pci/ac97/ak4531_codec.c b/sound/pci/ac97/ak4531_codec.c
index dcfb5036ff8b..0fb7b3407312 100644
--- a/sound/pci/ac97/ak4531_codec.c
+++ b/sound/pci/ac97/ak4531_codec.c
@@ -23,6 +23,8 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/mutex.h>
27
26#include <sound/core.h> 28#include <sound/core.h>
27#include <sound/ak4531_codec.h> 29#include <sound/ak4531_codec.h>
28 30
@@ -82,9 +84,9 @@ static int snd_ak4531_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_e
82 int invert = (kcontrol->private_value >> 22) & 1; 84 int invert = (kcontrol->private_value >> 22) & 1;
83 int val; 85 int val;
84 86
85 down(&ak4531->reg_mutex); 87 mutex_lock(&ak4531->reg_mutex);
86 val = (ak4531->regs[reg] >> shift) & mask; 88 val = (ak4531->regs[reg] >> shift) & mask;
87 up(&ak4531->reg_mutex); 89 mutex_unlock(&ak4531->reg_mutex);
88 if (invert) { 90 if (invert) {
89 val = mask - val; 91 val = mask - val;
90 } 92 }
@@ -107,11 +109,11 @@ static int snd_ak4531_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_e
107 val = mask - val; 109 val = mask - val;
108 } 110 }
109 val <<= shift; 111 val <<= shift;
110 down(&ak4531->reg_mutex); 112 mutex_lock(&ak4531->reg_mutex);
111 val = (ak4531->regs[reg] & ~(mask << shift)) | val; 113 val = (ak4531->regs[reg] & ~(mask << shift)) | val;
112 change = val != ak4531->regs[reg]; 114 change = val != ak4531->regs[reg];
113 ak4531->write(ak4531, reg, ak4531->regs[reg] = val); 115 ak4531->write(ak4531, reg, ak4531->regs[reg] = val);
114 up(&ak4531->reg_mutex); 116 mutex_unlock(&ak4531->reg_mutex);
115 return change; 117 return change;
116} 118}
117 119
@@ -143,10 +145,10 @@ static int snd_ak4531_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_e
143 int invert = (kcontrol->private_value >> 22) & 1; 145 int invert = (kcontrol->private_value >> 22) & 1;
144 int left, right; 146 int left, right;
145 147
146 down(&ak4531->reg_mutex); 148 mutex_lock(&ak4531->reg_mutex);
147 left = (ak4531->regs[left_reg] >> left_shift) & mask; 149 left = (ak4531->regs[left_reg] >> left_shift) & mask;
148 right = (ak4531->regs[right_reg] >> right_shift) & mask; 150 right = (ak4531->regs[right_reg] >> right_shift) & mask;
149 up(&ak4531->reg_mutex); 151 mutex_unlock(&ak4531->reg_mutex);
150 if (invert) { 152 if (invert) {
151 left = mask - left; 153 left = mask - left;
152 right = mask - right; 154 right = mask - right;
@@ -176,7 +178,7 @@ static int snd_ak4531_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_e
176 } 178 }
177 left <<= left_shift; 179 left <<= left_shift;
178 right <<= right_shift; 180 right <<= right_shift;
179 down(&ak4531->reg_mutex); 181 mutex_lock(&ak4531->reg_mutex);
180 if (left_reg == right_reg) { 182 if (left_reg == right_reg) {
181 left = (ak4531->regs[left_reg] & ~((mask << left_shift) | (mask << right_shift))) | left | right; 183 left = (ak4531->regs[left_reg] & ~((mask << left_shift) | (mask << right_shift))) | left | right;
182 change = left != ak4531->regs[left_reg]; 184 change = left != ak4531->regs[left_reg];
@@ -188,7 +190,7 @@ static int snd_ak4531_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_e
188 ak4531->write(ak4531, left_reg, ak4531->regs[left_reg] = left); 190 ak4531->write(ak4531, left_reg, ak4531->regs[left_reg] = left);
189 ak4531->write(ak4531, right_reg, ak4531->regs[right_reg] = right); 191 ak4531->write(ak4531, right_reg, ak4531->regs[right_reg] = right);
190 } 192 }
191 up(&ak4531->reg_mutex); 193 mutex_unlock(&ak4531->reg_mutex);
192 return change; 194 return change;
193} 195}
194 196
@@ -215,12 +217,12 @@ static int snd_ak4531_get_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl
215 int left_shift = (kcontrol->private_value >> 16) & 0x0f; 217 int left_shift = (kcontrol->private_value >> 16) & 0x0f;
216 int right_shift = (kcontrol->private_value >> 24) & 0x0f; 218 int right_shift = (kcontrol->private_value >> 24) & 0x0f;
217 219
218 down(&ak4531->reg_mutex); 220 mutex_lock(&ak4531->reg_mutex);
219 ucontrol->value.integer.value[0] = (ak4531->regs[reg1] >> left_shift) & 1; 221 ucontrol->value.integer.value[0] = (ak4531->regs[reg1] >> left_shift) & 1;
220 ucontrol->value.integer.value[1] = (ak4531->regs[reg2] >> left_shift) & 1; 222 ucontrol->value.integer.value[1] = (ak4531->regs[reg2] >> left_shift) & 1;
221 ucontrol->value.integer.value[2] = (ak4531->regs[reg1] >> right_shift) & 1; 223 ucontrol->value.integer.value[2] = (ak4531->regs[reg1] >> right_shift) & 1;
222 ucontrol->value.integer.value[3] = (ak4531->regs[reg2] >> right_shift) & 1; 224 ucontrol->value.integer.value[3] = (ak4531->regs[reg2] >> right_shift) & 1;
223 up(&ak4531->reg_mutex); 225 mutex_unlock(&ak4531->reg_mutex);
224 return 0; 226 return 0;
225} 227}
226 228
@@ -234,7 +236,7 @@ static int snd_ak4531_put_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl
234 int change; 236 int change;
235 int val1, val2; 237 int val1, val2;
236 238
237 down(&ak4531->reg_mutex); 239 mutex_lock(&ak4531->reg_mutex);
238 val1 = ak4531->regs[reg1] & ~((1 << left_shift) | (1 << right_shift)); 240 val1 = ak4531->regs[reg1] & ~((1 << left_shift) | (1 << right_shift));
239 val2 = ak4531->regs[reg2] & ~((1 << left_shift) | (1 << right_shift)); 241 val2 = ak4531->regs[reg2] & ~((1 << left_shift) | (1 << right_shift));
240 val1 |= (ucontrol->value.integer.value[0] & 1) << left_shift; 242 val1 |= (ucontrol->value.integer.value[0] & 1) << left_shift;
@@ -244,7 +246,7 @@ static int snd_ak4531_put_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl
244 change = val1 != ak4531->regs[reg1] || val2 != ak4531->regs[reg2]; 246 change = val1 != ak4531->regs[reg1] || val2 != ak4531->regs[reg2];
245 ak4531->write(ak4531, reg1, ak4531->regs[reg1] = val1); 247 ak4531->write(ak4531, reg1, ak4531->regs[reg1] = val1);
246 ak4531->write(ak4531, reg2, ak4531->regs[reg2] = val2); 248 ak4531->write(ak4531, reg2, ak4531->regs[reg2] = val2);
247 up(&ak4531->reg_mutex); 249 mutex_unlock(&ak4531->reg_mutex);
248 return change; 250 return change;
249} 251}
250 252
@@ -366,7 +368,7 @@ int snd_ak4531_mixer(struct snd_card *card, struct snd_ak4531 *_ak4531,
366 if (ak4531 == NULL) 368 if (ak4531 == NULL)
367 return -ENOMEM; 369 return -ENOMEM;
368 *ak4531 = *_ak4531; 370 *ak4531 = *_ak4531;
369 init_MUTEX(&ak4531->reg_mutex); 371 mutex_init(&ak4531->reg_mutex);
370 if ((err = snd_component_add(card, "AK4531")) < 0) { 372 if ((err = snd_component_add(card, "AK4531")) < 0) {
371 snd_ak4531_free(ak4531); 373 snd_ak4531_free(ak4531);
372 return err; 374 return err;
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index b7217adaf1d7..12e618851262 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -27,6 +27,7 @@
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/mutex.h>
30#include <sound/core.h> 31#include <sound/core.h>
31#include <sound/pcm.h> 32#include <sound/pcm.h>
32#include <sound/pcm_params.h> 33#include <sound/pcm_params.h>
@@ -277,7 +278,7 @@ struct atiixp {
277 unsigned int codec_not_ready_bits; /* for codec detection */ 278 unsigned int codec_not_ready_bits; /* for codec detection */
278 279
279 int spdif_over_aclink; /* passed from the module option */ 280 int spdif_over_aclink; /* passed from the module option */
280 struct semaphore open_mutex; /* playback open mutex */ 281 struct mutex open_mutex; /* playback open mutex */
281}; 282};
282 283
283 284
@@ -1051,9 +1052,9 @@ static int snd_atiixp_playback_open(struct snd_pcm_substream *substream)
1051 struct atiixp *chip = snd_pcm_substream_chip(substream); 1052 struct atiixp *chip = snd_pcm_substream_chip(substream);
1052 int err; 1053 int err;
1053 1054
1054 down(&chip->open_mutex); 1055 mutex_lock(&chip->open_mutex);
1055 err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_PLAYBACK], 0); 1056 err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_PLAYBACK], 0);
1056 up(&chip->open_mutex); 1057 mutex_unlock(&chip->open_mutex);
1057 if (err < 0) 1058 if (err < 0)
1058 return err; 1059 return err;
1059 substream->runtime->hw.channels_max = chip->max_channels; 1060 substream->runtime->hw.channels_max = chip->max_channels;
@@ -1068,9 +1069,9 @@ static int snd_atiixp_playback_close(struct snd_pcm_substream *substream)
1068{ 1069{
1069 struct atiixp *chip = snd_pcm_substream_chip(substream); 1070 struct atiixp *chip = snd_pcm_substream_chip(substream);
1070 int err; 1071 int err;
1071 down(&chip->open_mutex); 1072 mutex_lock(&chip->open_mutex);
1072 err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]); 1073 err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]);
1073 up(&chip->open_mutex); 1074 mutex_unlock(&chip->open_mutex);
1074 return err; 1075 return err;
1075} 1076}
1076 1077
@@ -1090,12 +1091,12 @@ static int snd_atiixp_spdif_open(struct snd_pcm_substream *substream)
1090{ 1091{
1091 struct atiixp *chip = snd_pcm_substream_chip(substream); 1092 struct atiixp *chip = snd_pcm_substream_chip(substream);
1092 int err; 1093 int err;
1093 down(&chip->open_mutex); 1094 mutex_lock(&chip->open_mutex);
1094 if (chip->spdif_over_aclink) /* share DMA_PLAYBACK */ 1095 if (chip->spdif_over_aclink) /* share DMA_PLAYBACK */
1095 err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_PLAYBACK], 2); 1096 err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_PLAYBACK], 2);
1096 else 1097 else
1097 err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_SPDIF], -1); 1098 err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_SPDIF], -1);
1098 up(&chip->open_mutex); 1099 mutex_unlock(&chip->open_mutex);
1099 return err; 1100 return err;
1100} 1101}
1101 1102
@@ -1103,12 +1104,12 @@ static int snd_atiixp_spdif_close(struct snd_pcm_substream *substream)
1103{ 1104{
1104 struct atiixp *chip = snd_pcm_substream_chip(substream); 1105 struct atiixp *chip = snd_pcm_substream_chip(substream);
1105 int err; 1106 int err;
1106 down(&chip->open_mutex); 1107 mutex_lock(&chip->open_mutex);
1107 if (chip->spdif_over_aclink) 1108 if (chip->spdif_over_aclink)
1108 err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]); 1109 err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]);
1109 else 1110 else
1110 err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_SPDIF]); 1111 err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_SPDIF]);
1111 up(&chip->open_mutex); 1112 mutex_unlock(&chip->open_mutex);
1112 return err; 1113 return err;
1113} 1114}
1114 1115
@@ -1560,7 +1561,7 @@ static int __devinit snd_atiixp_create(struct snd_card *card,
1560 } 1561 }
1561 1562
1562 spin_lock_init(&chip->reg_lock); 1563 spin_lock_init(&chip->reg_lock);
1563 init_MUTEX(&chip->open_mutex); 1564 mutex_init(&chip->open_mutex);
1564 chip->card = card; 1565 chip->card = card;
1565 chip->pci = pci; 1566 chip->pci = pci;
1566 chip->irq = -1; 1567 chip->irq = -1;
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index 8d8fd5a4ed35..1d3766044643 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -27,6 +27,7 @@
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/mutex.h>
30#include <sound/core.h> 31#include <sound/core.h>
31#include <sound/pcm.h> 32#include <sound/pcm.h>
32#include <sound/pcm_params.h> 33#include <sound/pcm_params.h>
@@ -255,7 +256,7 @@ struct atiixp_modem {
255 unsigned int codec_not_ready_bits; /* for codec detection */ 256 unsigned int codec_not_ready_bits; /* for codec detection */
256 257
257 int spdif_over_aclink; /* passed from the module option */ 258 int spdif_over_aclink; /* passed from the module option */
258 struct semaphore open_mutex; /* playback open mutex */ 259 struct mutex open_mutex; /* playback open mutex */
259}; 260};
260 261
261 262
@@ -911,9 +912,9 @@ static int snd_atiixp_playback_open(struct snd_pcm_substream *substream)
911 struct atiixp_modem *chip = snd_pcm_substream_chip(substream); 912 struct atiixp_modem *chip = snd_pcm_substream_chip(substream);
912 int err; 913 int err;
913 914
914 down(&chip->open_mutex); 915 mutex_lock(&chip->open_mutex);
915 err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_PLAYBACK], 0); 916 err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_PLAYBACK], 0);
916 up(&chip->open_mutex); 917 mutex_unlock(&chip->open_mutex);
917 if (err < 0) 918 if (err < 0)
918 return err; 919 return err;
919 return 0; 920 return 0;
@@ -923,9 +924,9 @@ static int snd_atiixp_playback_close(struct snd_pcm_substream *substream)
923{ 924{
924 struct atiixp_modem *chip = snd_pcm_substream_chip(substream); 925 struct atiixp_modem *chip = snd_pcm_substream_chip(substream);
925 int err; 926 int err;
926 down(&chip->open_mutex); 927 mutex_lock(&chip->open_mutex);
927 err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]); 928 err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]);
928 up(&chip->open_mutex); 929 mutex_unlock(&chip->open_mutex);
929 return err; 930 return err;
930} 931}
931 932
@@ -1233,7 +1234,7 @@ static int __devinit snd_atiixp_create(struct snd_card *card,
1233 } 1234 }
1234 1235
1235 spin_lock_init(&chip->reg_lock); 1236 spin_lock_init(&chip->reg_lock);
1236 init_MUTEX(&chip->open_mutex); 1237 mutex_init(&chip->open_mutex);
1237 chip->card = card; 1238 chip->card = card;
1238 chip->pci = pci; 1239 chip->pci = pci;
1239 chip->irq = -1; 1240 chip->irq = -1;
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;
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 8fb275d6eb77..69dbf542a6de 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -53,6 +53,8 @@
53#include <linux/interrupt.h> 53#include <linux/interrupt.h>
54#include <linux/slab.h> 54#include <linux/slab.h>
55#include <linux/gameport.h> 55#include <linux/gameport.h>
56#include <linux/mutex.h>
57
56 58
57#include <sound/core.h> 59#include <sound/core.h>
58#include <sound/control.h> 60#include <sound/control.h>
@@ -909,22 +911,22 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream,
909#ifdef CONFIG_SND_CS46XX_NEW_DSP 911#ifdef CONFIG_SND_CS46XX_NEW_DSP
910 snd_assert (sample_rate != 0, return -ENXIO); 912 snd_assert (sample_rate != 0, return -ENXIO);
911 913
912 down (&chip->spos_mutex); 914 mutex_lock(&chip->spos_mutex);
913 915
914 if (_cs46xx_adjust_sample_rate (chip,cpcm,sample_rate)) { 916 if (_cs46xx_adjust_sample_rate (chip,cpcm,sample_rate)) {
915 up (&chip->spos_mutex); 917 mutex_unlock(&chip->spos_mutex);
916 return -ENXIO; 918 return -ENXIO;
917 } 919 }
918 920
919 snd_assert (cpcm->pcm_channel != NULL); 921 snd_assert (cpcm->pcm_channel != NULL);
920 if (!cpcm->pcm_channel) { 922 if (!cpcm->pcm_channel) {
921 up (&chip->spos_mutex); 923 mutex_unlock(&chip->spos_mutex);
922 return -ENXIO; 924 return -ENXIO;
923 } 925 }
924 926
925 927
926 if (cs46xx_dsp_pcm_channel_set_period (chip,cpcm->pcm_channel,period_size)) { 928 if (cs46xx_dsp_pcm_channel_set_period (chip,cpcm->pcm_channel,period_size)) {
927 up (&chip->spos_mutex); 929 mutex_unlock(&chip->spos_mutex);
928 return -EINVAL; 930 return -EINVAL;
929 } 931 }
930 932
@@ -965,7 +967,7 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream,
965 } 967 }
966 if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) { 968 if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) {
967#ifdef CONFIG_SND_CS46XX_NEW_DSP 969#ifdef CONFIG_SND_CS46XX_NEW_DSP
968 up (&chip->spos_mutex); 970 mutex_unlock(&chip->spos_mutex);
969#endif 971#endif
970 return err; 972 return err;
971 } 973 }
@@ -989,7 +991,7 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream,
989 } 991 }
990 992
991#ifdef CONFIG_SND_CS46XX_NEW_DSP 993#ifdef CONFIG_SND_CS46XX_NEW_DSP
992 up (&chip->spos_mutex); 994 mutex_unlock(&chip->spos_mutex);
993#endif 995#endif
994 996
995 return 0; 997 return 0;
@@ -1319,7 +1321,7 @@ static int _cs46xx_playback_open_channel (struct snd_pcm_substream *substream,in
1319 1321
1320 cpcm->substream = substream; 1322 cpcm->substream = substream;
1321#ifdef CONFIG_SND_CS46XX_NEW_DSP 1323#ifdef CONFIG_SND_CS46XX_NEW_DSP
1322 down (&chip->spos_mutex); 1324 mutex_lock(&chip->spos_mutex);
1323 cpcm->pcm_channel = NULL; 1325 cpcm->pcm_channel = NULL;
1324 cpcm->pcm_channel_id = pcm_channel_id; 1326 cpcm->pcm_channel_id = pcm_channel_id;
1325 1327
@@ -1328,7 +1330,7 @@ static int _cs46xx_playback_open_channel (struct snd_pcm_substream *substream,in
1328 SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 1330 SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
1329 &hw_constraints_period_sizes); 1331 &hw_constraints_period_sizes);
1330 1332
1331 up (&chip->spos_mutex); 1333 mutex_unlock(&chip->spos_mutex);
1332#else 1334#else
1333 chip->playback_pcm = cpcm; /* HACK */ 1335 chip->playback_pcm = cpcm; /* HACK */
1334#endif 1336#endif
@@ -1367,9 +1369,9 @@ static int snd_cs46xx_playback_open_iec958(struct snd_pcm_substream *substream)
1367 1369
1368 snd_printdd("open raw iec958 channel\n"); 1370 snd_printdd("open raw iec958 channel\n");
1369 1371
1370 down (&chip->spos_mutex); 1372 mutex_lock(&chip->spos_mutex);
1371 cs46xx_iec958_pre_open (chip); 1373 cs46xx_iec958_pre_open (chip);
1372 up (&chip->spos_mutex); 1374 mutex_unlock(&chip->spos_mutex);
1373 1375
1374 return _cs46xx_playback_open_channel(substream,DSP_IEC958_CHANNEL); 1376 return _cs46xx_playback_open_channel(substream,DSP_IEC958_CHANNEL);
1375} 1377}
@@ -1385,9 +1387,9 @@ static int snd_cs46xx_playback_close_iec958(struct snd_pcm_substream *substream)
1385 1387
1386 err = snd_cs46xx_playback_close(substream); 1388 err = snd_cs46xx_playback_close(substream);
1387 1389
1388 down (&chip->spos_mutex); 1390 mutex_lock(&chip->spos_mutex);
1389 cs46xx_iec958_post_close (chip); 1391 cs46xx_iec958_post_close (chip);
1390 up (&chip->spos_mutex); 1392 mutex_unlock(&chip->spos_mutex);
1391 1393
1392 return err; 1394 return err;
1393} 1395}
@@ -1428,12 +1430,12 @@ static int snd_cs46xx_playback_close(struct snd_pcm_substream *substream)
1428 if (!cpcm) return -ENXIO; 1430 if (!cpcm) return -ENXIO;
1429 1431
1430#ifdef CONFIG_SND_CS46XX_NEW_DSP 1432#ifdef CONFIG_SND_CS46XX_NEW_DSP
1431 down (&chip->spos_mutex); 1433 mutex_lock(&chip->spos_mutex);
1432 if (cpcm->pcm_channel) { 1434 if (cpcm->pcm_channel) {
1433 cs46xx_dsp_destroy_pcm_channel(chip,cpcm->pcm_channel); 1435 cs46xx_dsp_destroy_pcm_channel(chip,cpcm->pcm_channel);
1434 cpcm->pcm_channel = NULL; 1436 cpcm->pcm_channel = NULL;
1435 } 1437 }
1436 up (&chip->spos_mutex); 1438 mutex_unlock(&chip->spos_mutex);
1437#else 1439#else
1438 chip->playback_pcm = NULL; 1440 chip->playback_pcm = NULL;
1439#endif 1441#endif
@@ -1848,7 +1850,7 @@ static int snd_cs46xx_iec958_put(struct snd_kcontrol *kcontrol,
1848 1850
1849 switch (kcontrol->private_value) { 1851 switch (kcontrol->private_value) {
1850 case CS46XX_MIXER_SPDIF_OUTPUT_ELEMENT: 1852 case CS46XX_MIXER_SPDIF_OUTPUT_ELEMENT:
1851 down (&chip->spos_mutex); 1853 mutex_lock(&chip->spos_mutex);
1852 change = (chip->dsp_spos_instance->spdif_status_out & DSP_SPDIF_STATUS_OUTPUT_ENABLED); 1854 change = (chip->dsp_spos_instance->spdif_status_out & DSP_SPDIF_STATUS_OUTPUT_ENABLED);
1853 if (ucontrol->value.integer.value[0] && !change) 1855 if (ucontrol->value.integer.value[0] && !change)
1854 cs46xx_dsp_enable_spdif_out(chip); 1856 cs46xx_dsp_enable_spdif_out(chip);
@@ -1856,7 +1858,7 @@ static int snd_cs46xx_iec958_put(struct snd_kcontrol *kcontrol,
1856 cs46xx_dsp_disable_spdif_out(chip); 1858 cs46xx_dsp_disable_spdif_out(chip);
1857 1859
1858 res = (change != (chip->dsp_spos_instance->spdif_status_out & DSP_SPDIF_STATUS_OUTPUT_ENABLED)); 1860 res = (change != (chip->dsp_spos_instance->spdif_status_out & DSP_SPDIF_STATUS_OUTPUT_ENABLED));
1859 up (&chip->spos_mutex); 1861 mutex_unlock(&chip->spos_mutex);
1860 break; 1862 break;
1861 case CS46XX_MIXER_SPDIF_INPUT_ELEMENT: 1863 case CS46XX_MIXER_SPDIF_INPUT_ELEMENT:
1862 change = chip->dsp_spos_instance->spdif_status_in; 1864 change = chip->dsp_spos_instance->spdif_status_in;
@@ -1997,12 +1999,12 @@ static int snd_cs46xx_spdif_default_get(struct snd_kcontrol *kcontrol,
1997 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); 1999 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol);
1998 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 2000 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1999 2001
2000 down (&chip->spos_mutex); 2002 mutex_lock(&chip->spos_mutex);
2001 ucontrol->value.iec958.status[0] = _wrap_all_bits((ins->spdif_csuv_default >> 24) & 0xff); 2003 ucontrol->value.iec958.status[0] = _wrap_all_bits((ins->spdif_csuv_default >> 24) & 0xff);
2002 ucontrol->value.iec958.status[1] = _wrap_all_bits((ins->spdif_csuv_default >> 16) & 0xff); 2004 ucontrol->value.iec958.status[1] = _wrap_all_bits((ins->spdif_csuv_default >> 16) & 0xff);
2003 ucontrol->value.iec958.status[2] = 0; 2005 ucontrol->value.iec958.status[2] = 0;
2004 ucontrol->value.iec958.status[3] = _wrap_all_bits((ins->spdif_csuv_default) & 0xff); 2006 ucontrol->value.iec958.status[3] = _wrap_all_bits((ins->spdif_csuv_default) & 0xff);
2005 up (&chip->spos_mutex); 2007 mutex_unlock(&chip->spos_mutex);
2006 2008
2007 return 0; 2009 return 0;
2008} 2010}
@@ -2015,7 +2017,7 @@ static int snd_cs46xx_spdif_default_put(struct snd_kcontrol *kcontrol,
2015 unsigned int val; 2017 unsigned int val;
2016 int change; 2018 int change;
2017 2019
2018 down (&chip->spos_mutex); 2020 mutex_lock(&chip->spos_mutex);
2019 val = ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[0]) << 24) | 2021 val = ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[0]) << 24) |
2020 ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[2]) << 16) | 2022 ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[2]) << 16) |
2021 ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[3])) | 2023 ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[3])) |
@@ -2029,7 +2031,7 @@ static int snd_cs46xx_spdif_default_put(struct snd_kcontrol *kcontrol,
2029 if ( !(ins->spdif_status_out & DSP_SPDIF_STATUS_PLAYBACK_OPEN) ) 2031 if ( !(ins->spdif_status_out & DSP_SPDIF_STATUS_PLAYBACK_OPEN) )
2030 cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV,val); 2032 cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV,val);
2031 2033
2032 up (&chip->spos_mutex); 2034 mutex_unlock(&chip->spos_mutex);
2033 2035
2034 return change; 2036 return change;
2035} 2037}
@@ -2050,12 +2052,12 @@ static int snd_cs46xx_spdif_stream_get(struct snd_kcontrol *kcontrol,
2050 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); 2052 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol);
2051 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 2053 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
2052 2054
2053 down (&chip->spos_mutex); 2055 mutex_lock(&chip->spos_mutex);
2054 ucontrol->value.iec958.status[0] = _wrap_all_bits((ins->spdif_csuv_stream >> 24) & 0xff); 2056 ucontrol->value.iec958.status[0] = _wrap_all_bits((ins->spdif_csuv_stream >> 24) & 0xff);
2055 ucontrol->value.iec958.status[1] = _wrap_all_bits((ins->spdif_csuv_stream >> 16) & 0xff); 2057 ucontrol->value.iec958.status[1] = _wrap_all_bits((ins->spdif_csuv_stream >> 16) & 0xff);
2056 ucontrol->value.iec958.status[2] = 0; 2058 ucontrol->value.iec958.status[2] = 0;
2057 ucontrol->value.iec958.status[3] = _wrap_all_bits((ins->spdif_csuv_stream) & 0xff); 2059 ucontrol->value.iec958.status[3] = _wrap_all_bits((ins->spdif_csuv_stream) & 0xff);
2058 up (&chip->spos_mutex); 2060 mutex_unlock(&chip->spos_mutex);
2059 2061
2060 return 0; 2062 return 0;
2061} 2063}
@@ -2068,7 +2070,7 @@ static int snd_cs46xx_spdif_stream_put(struct snd_kcontrol *kcontrol,
2068 unsigned int val; 2070 unsigned int val;
2069 int change; 2071 int change;
2070 2072
2071 down (&chip->spos_mutex); 2073 mutex_lock(&chip->spos_mutex);
2072 val = ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[0]) << 24) | 2074 val = ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[0]) << 24) |
2073 ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[1]) << 16) | 2075 ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[1]) << 16) |
2074 ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[3])) | 2076 ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[3])) |
@@ -2082,7 +2084,7 @@ static int snd_cs46xx_spdif_stream_put(struct snd_kcontrol *kcontrol,
2082 if ( ins->spdif_status_out & DSP_SPDIF_STATUS_PLAYBACK_OPEN ) 2084 if ( ins->spdif_status_out & DSP_SPDIF_STATUS_PLAYBACK_OPEN )
2083 cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV,val); 2085 cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV,val);
2084 2086
2085 up (&chip->spos_mutex); 2087 mutex_unlock(&chip->spos_mutex);
2086 2088
2087 return change; 2089 return change;
2088} 2090}
@@ -3755,7 +3757,7 @@ int __devinit snd_cs46xx_create(struct snd_card *card,
3755 } 3757 }
3756 spin_lock_init(&chip->reg_lock); 3758 spin_lock_init(&chip->reg_lock);
3757#ifdef CONFIG_SND_CS46XX_NEW_DSP 3759#ifdef CONFIG_SND_CS46XX_NEW_DSP
3758 init_MUTEX(&chip->spos_mutex); 3760 mutex_init(&chip->spos_mutex);
3759#endif 3761#endif
3760 chip->card = card; 3762 chip->card = card;
3761 chip->pci = pci; 3763 chip->pci = pci;
diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c
index 445a448949e7..8726a68051e7 100644
--- a/sound/pci/cs46xx/dsp_spos.c
+++ b/sound/pci/cs46xx/dsp_spos.c
@@ -28,6 +28,8 @@
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/vmalloc.h> 30#include <linux/vmalloc.h>
31#include <linux/mutex.h>
32
31#include <sound/core.h> 33#include <sound/core.h>
32#include <sound/control.h> 34#include <sound/control.h>
33#include <sound/info.h> 35#include <sound/info.h>
@@ -287,7 +289,7 @@ void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip)
287 289
288 snd_assert(ins != NULL, return); 290 snd_assert(ins != NULL, return);
289 291
290 down(&chip->spos_mutex); 292 mutex_lock(&chip->spos_mutex);
291 for (i = 0; i < ins->nscb; ++i) { 293 for (i = 0; i < ins->nscb; ++i) {
292 if (ins->scbs[i].deleted) continue; 294 if (ins->scbs[i].deleted) continue;
293 295
@@ -298,7 +300,7 @@ void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip)
298 vfree(ins->symbol_table.symbols); 300 vfree(ins->symbol_table.symbols);
299 kfree(ins->modules); 301 kfree(ins->modules);
300 kfree(ins); 302 kfree(ins);
301 up(&chip->spos_mutex); 303 mutex_unlock(&chip->spos_mutex);
302} 304}
303 305
304int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module) 306int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module)
@@ -497,7 +499,7 @@ static void cs46xx_dsp_proc_modules_read (struct snd_info_entry *entry,
497 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 499 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
498 int i,j; 500 int i,j;
499 501
500 down(&chip->spos_mutex); 502 mutex_lock(&chip->spos_mutex);
501 snd_iprintf(buffer, "MODULES:\n"); 503 snd_iprintf(buffer, "MODULES:\n");
502 for ( i = 0; i < ins->nmodules; ++i ) { 504 for ( i = 0; i < ins->nmodules; ++i ) {
503 snd_iprintf(buffer, "\n%s:\n", ins->modules[i].module_name); 505 snd_iprintf(buffer, "\n%s:\n", ins->modules[i].module_name);
@@ -510,7 +512,7 @@ static void cs46xx_dsp_proc_modules_read (struct snd_info_entry *entry,
510 desc->segment_type,desc->offset, desc->size); 512 desc->segment_type,desc->offset, desc->size);
511 } 513 }
512 } 514 }
513 up(&chip->spos_mutex); 515 mutex_unlock(&chip->spos_mutex);
514} 516}
515 517
516static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry *entry, 518static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry *entry,
@@ -521,7 +523,7 @@ static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry *entry,
521 int i, j, col; 523 int i, j, col;
522 void __iomem *dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET; 524 void __iomem *dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET;
523 525
524 down(&chip->spos_mutex); 526 mutex_lock(&chip->spos_mutex);
525 snd_iprintf(buffer, "TASK TREES:\n"); 527 snd_iprintf(buffer, "TASK TREES:\n");
526 for ( i = 0; i < ins->ntask; ++i) { 528 for ( i = 0; i < ins->ntask; ++i) {
527 snd_iprintf(buffer,"\n%04x %s:\n",ins->tasks[i].address,ins->tasks[i].task_name); 529 snd_iprintf(buffer,"\n%04x %s:\n",ins->tasks[i].address,ins->tasks[i].task_name);
@@ -538,7 +540,7 @@ static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry *entry,
538 } 540 }
539 541
540 snd_iprintf(buffer,"\n"); 542 snd_iprintf(buffer,"\n");
541 up(&chip->spos_mutex); 543 mutex_unlock(&chip->spos_mutex);
542} 544}
543 545
544static void cs46xx_dsp_proc_scb_read (struct snd_info_entry *entry, 546static void cs46xx_dsp_proc_scb_read (struct snd_info_entry *entry,
@@ -548,7 +550,7 @@ static void cs46xx_dsp_proc_scb_read (struct snd_info_entry *entry,
548 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 550 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
549 int i; 551 int i;
550 552
551 down(&chip->spos_mutex); 553 mutex_lock(&chip->spos_mutex);
552 snd_iprintf(buffer, "SCB's:\n"); 554 snd_iprintf(buffer, "SCB's:\n");
553 for ( i = 0; i < ins->nscb; ++i) { 555 for ( i = 0; i < ins->nscb; ++i) {
554 if (ins->scbs[i].deleted) 556 if (ins->scbs[i].deleted)
@@ -571,7 +573,7 @@ static void cs46xx_dsp_proc_scb_read (struct snd_info_entry *entry,
571 } 573 }
572 574
573 snd_iprintf(buffer,"\n"); 575 snd_iprintf(buffer,"\n");
574 up(&chip->spos_mutex); 576 mutex_unlock(&chip->spos_mutex);
575} 577}
576 578
577static void cs46xx_dsp_proc_parameter_dump_read (struct snd_info_entry *entry, 579static void cs46xx_dsp_proc_parameter_dump_read (struct snd_info_entry *entry,
@@ -852,14 +854,14 @@ int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip)
852 } 854 }
853 ins->proc_scb_info_entry = entry; 855 ins->proc_scb_info_entry = entry;
854 856
855 down(&chip->spos_mutex); 857 mutex_lock(&chip->spos_mutex);
856 /* register/update SCB's entries on proc */ 858 /* register/update SCB's entries on proc */
857 for (i = 0; i < ins->nscb; ++i) { 859 for (i = 0; i < ins->nscb; ++i) {
858 if (ins->scbs[i].deleted) continue; 860 if (ins->scbs[i].deleted) continue;
859 861
860 cs46xx_dsp_proc_register_scb_desc (chip, (ins->scbs + i)); 862 cs46xx_dsp_proc_register_scb_desc (chip, (ins->scbs + i));
861 } 863 }
862 up(&chip->spos_mutex); 864 mutex_unlock(&chip->spos_mutex);
863 865
864 return 0; 866 return 0;
865} 867}
@@ -899,12 +901,12 @@ int cs46xx_dsp_proc_done (struct snd_cs46xx *chip)
899 ins->proc_task_info_entry = NULL; 901 ins->proc_task_info_entry = NULL;
900 } 902 }
901 903
902 down(&chip->spos_mutex); 904 mutex_lock(&chip->spos_mutex);
903 for (i = 0; i < ins->nscb; ++i) { 905 for (i = 0; i < ins->nscb; ++i) {
904 if (ins->scbs[i].deleted) continue; 906 if (ins->scbs[i].deleted) continue;
905 cs46xx_dsp_proc_free_scb_desc ( (ins->scbs + i) ); 907 cs46xx_dsp_proc_free_scb_desc ( (ins->scbs + i) );
906 } 908 }
907 up(&chip->spos_mutex); 909 mutex_unlock(&chip->spos_mutex);
908 910
909 if (ins->proc_dsp_dir) { 911 if (ins->proc_dsp_dir) {
910 snd_info_unregister (ins->proc_dsp_dir); 912 snd_info_unregister (ins->proc_dsp_dir);
@@ -1694,7 +1696,7 @@ int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip)
1694 snd_assert (ins->asynch_rx_scb == NULL,return -EINVAL); 1696 snd_assert (ins->asynch_rx_scb == NULL,return -EINVAL);
1695 snd_assert (ins->spdif_in_src != NULL,return -EINVAL); 1697 snd_assert (ins->spdif_in_src != NULL,return -EINVAL);
1696 1698
1697 down(&chip->spos_mutex); 1699 mutex_lock(&chip->spos_mutex);
1698 1700
1699 if ( ! (ins->spdif_status_out & DSP_SPDIF_STATUS_INPUT_CTRL_ENABLED) ) { 1701 if ( ! (ins->spdif_status_out & DSP_SPDIF_STATUS_INPUT_CTRL_ENABLED) ) {
1700 /* time countdown enable */ 1702 /* time countdown enable */
@@ -1738,7 +1740,7 @@ int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip)
1738 1740
1739 /* monitor state */ 1741 /* monitor state */
1740 ins->spdif_status_in = 1; 1742 ins->spdif_status_in = 1;
1741 up(&chip->spos_mutex); 1743 mutex_unlock(&chip->spos_mutex);
1742 1744
1743 return 0; 1745 return 0;
1744} 1746}
@@ -1750,7 +1752,7 @@ int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip)
1750 snd_assert (ins->asynch_rx_scb != NULL, return -EINVAL); 1752 snd_assert (ins->asynch_rx_scb != NULL, return -EINVAL);
1751 snd_assert (ins->spdif_in_src != NULL,return -EINVAL); 1753 snd_assert (ins->spdif_in_src != NULL,return -EINVAL);
1752 1754
1753 down(&chip->spos_mutex); 1755 mutex_lock(&chip->spos_mutex);
1754 1756
1755 /* Remove the asynchronous receiver SCB */ 1757 /* Remove the asynchronous receiver SCB */
1756 cs46xx_dsp_remove_scb (chip,ins->asynch_rx_scb); 1758 cs46xx_dsp_remove_scb (chip,ins->asynch_rx_scb);
@@ -1760,7 +1762,7 @@ int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip)
1760 1762
1761 /* monitor state */ 1763 /* monitor state */
1762 ins->spdif_status_in = 0; 1764 ins->spdif_status_in = 0;
1763 up(&chip->spos_mutex); 1765 mutex_unlock(&chip->spos_mutex);
1764 1766
1765 /* restore amplifier */ 1767 /* restore amplifier */
1766 chip->active_ctrl(chip, -1); 1768 chip->active_ctrl(chip, -1);
@@ -1776,10 +1778,10 @@ int cs46xx_dsp_enable_pcm_capture (struct snd_cs46xx *chip)
1776 snd_assert (ins->pcm_input == NULL,return -EINVAL); 1778 snd_assert (ins->pcm_input == NULL,return -EINVAL);
1777 snd_assert (ins->ref_snoop_scb != NULL,return -EINVAL); 1779 snd_assert (ins->ref_snoop_scb != NULL,return -EINVAL);
1778 1780
1779 down(&chip->spos_mutex); 1781 mutex_lock(&chip->spos_mutex);
1780 ins->pcm_input = cs46xx_add_record_source(chip,ins->ref_snoop_scb,PCMSERIALIN_PCM_SCB_ADDR, 1782 ins->pcm_input = cs46xx_add_record_source(chip,ins->ref_snoop_scb,PCMSERIALIN_PCM_SCB_ADDR,
1781 "PCMSerialInput_Wave"); 1783 "PCMSerialInput_Wave");
1782 up(&chip->spos_mutex); 1784 mutex_unlock(&chip->spos_mutex);
1783 1785
1784 return 0; 1786 return 0;
1785} 1787}
@@ -1790,10 +1792,10 @@ int cs46xx_dsp_disable_pcm_capture (struct snd_cs46xx *chip)
1790 1792
1791 snd_assert (ins->pcm_input != NULL,return -EINVAL); 1793 snd_assert (ins->pcm_input != NULL,return -EINVAL);
1792 1794
1793 down(&chip->spos_mutex); 1795 mutex_lock(&chip->spos_mutex);
1794 cs46xx_dsp_remove_scb (chip,ins->pcm_input); 1796 cs46xx_dsp_remove_scb (chip,ins->pcm_input);
1795 ins->pcm_input = NULL; 1797 ins->pcm_input = NULL;
1796 up(&chip->spos_mutex); 1798 mutex_unlock(&chip->spos_mutex);
1797 1799
1798 return 0; 1800 return 0;
1799} 1801}
@@ -1805,10 +1807,10 @@ int cs46xx_dsp_enable_adc_capture (struct snd_cs46xx *chip)
1805 snd_assert (ins->adc_input == NULL,return -EINVAL); 1807 snd_assert (ins->adc_input == NULL,return -EINVAL);
1806 snd_assert (ins->codec_in_scb != NULL,return -EINVAL); 1808 snd_assert (ins->codec_in_scb != NULL,return -EINVAL);
1807 1809
1808 down(&chip->spos_mutex); 1810 mutex_lock(&chip->spos_mutex);
1809 ins->adc_input = cs46xx_add_record_source(chip,ins->codec_in_scb,PCMSERIALIN_SCB_ADDR, 1811 ins->adc_input = cs46xx_add_record_source(chip,ins->codec_in_scb,PCMSERIALIN_SCB_ADDR,
1810 "PCMSerialInput_ADC"); 1812 "PCMSerialInput_ADC");
1811 up(&chip->spos_mutex); 1813 mutex_unlock(&chip->spos_mutex);
1812 1814
1813 return 0; 1815 return 0;
1814} 1816}
@@ -1819,10 +1821,10 @@ int cs46xx_dsp_disable_adc_capture (struct snd_cs46xx *chip)
1819 1821
1820 snd_assert (ins->adc_input != NULL,return -EINVAL); 1822 snd_assert (ins->adc_input != NULL,return -EINVAL);
1821 1823
1822 down(&chip->spos_mutex); 1824 mutex_lock(&chip->spos_mutex);
1823 cs46xx_dsp_remove_scb (chip,ins->adc_input); 1825 cs46xx_dsp_remove_scb (chip,ins->adc_input);
1824 ins->adc_input = NULL; 1826 ins->adc_input = NULL;
1825 up(&chip->spos_mutex); 1827 mutex_unlock(&chip->spos_mutex);
1826 1828
1827 return 0; 1829 return 0;
1828} 1830}
@@ -1869,7 +1871,7 @@ int cs46xx_dsp_set_dac_volume (struct snd_cs46xx * chip, u16 left, u16 right)
1869 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1871 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1870 struct dsp_scb_descriptor * scb; 1872 struct dsp_scb_descriptor * scb;
1871 1873
1872 down(&chip->spos_mutex); 1874 mutex_lock(&chip->spos_mutex);
1873 1875
1874 /* main output */ 1876 /* main output */
1875 scb = ins->master_mix_scb->sub_list_ptr; 1877 scb = ins->master_mix_scb->sub_list_ptr;
@@ -1888,7 +1890,7 @@ int cs46xx_dsp_set_dac_volume (struct snd_cs46xx * chip, u16 left, u16 right)
1888 ins->dac_volume_left = left; 1890 ins->dac_volume_left = left;
1889 ins->dac_volume_right = right; 1891 ins->dac_volume_right = right;
1890 1892
1891 up(&chip->spos_mutex); 1893 mutex_unlock(&chip->spos_mutex);
1892 1894
1893 return 0; 1895 return 0;
1894} 1896}
@@ -1897,7 +1899,7 @@ int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right)
1897{ 1899{
1898 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1900 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1899 1901
1900 down(&chip->spos_mutex); 1902 mutex_lock(&chip->spos_mutex);
1901 1903
1902 if (ins->asynch_rx_scb != NULL) 1904 if (ins->asynch_rx_scb != NULL)
1903 cs46xx_dsp_scb_set_volume (chip,ins->asynch_rx_scb, 1905 cs46xx_dsp_scb_set_volume (chip,ins->asynch_rx_scb,
@@ -1906,7 +1908,7 @@ int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right)
1906 ins->spdif_input_volume_left = left; 1908 ins->spdif_input_volume_left = left;
1907 ins->spdif_input_volume_right = right; 1909 ins->spdif_input_volume_right = right;
1908 1910
1909 up(&chip->spos_mutex); 1911 mutex_unlock(&chip->spos_mutex);
1910 1912
1911 return 0; 1913 return 0;
1912} 1914}
diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c
index d4e0fb39bd06..2c4ee45fe10c 100644
--- a/sound/pci/cs46xx/dsp_spos_scb_lib.c
+++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c
@@ -28,6 +28,8 @@
28#include <linux/pm.h> 28#include <linux/pm.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/mutex.h>
32
31#include <sound/core.h> 33#include <sound/core.h>
32#include <sound/control.h> 34#include <sound/control.h>
33#include <sound/info.h> 35#include <sound/info.h>
@@ -77,7 +79,7 @@ static void cs46xx_dsp_proc_scb_info_read (struct snd_info_entry *entry,
77 79
78 ins = chip->dsp_spos_instance; 80 ins = chip->dsp_spos_instance;
79 81
80 down(&chip->spos_mutex); 82 mutex_lock(&chip->spos_mutex);
81 snd_iprintf(buffer,"%04x %s:\n",scb->address,scb->scb_name); 83 snd_iprintf(buffer,"%04x %s:\n",scb->address,scb->scb_name);
82 84
83 for (col = 0,j = 0;j < 0x10; j++,col++) { 85 for (col = 0,j = 0;j < 0x10; j++,col++) {
@@ -105,7 +107,7 @@ static void cs46xx_dsp_proc_scb_info_read (struct snd_info_entry *entry,
105 scb->task_entry->address); 107 scb->task_entry->address);
106 108
107 snd_iprintf(buffer,"index [%d] ref_count [%d]\n",scb->index,scb->ref_count); 109 snd_iprintf(buffer,"index [%d] ref_count [%d]\n",scb->index,scb->ref_count);
108 up(&chip->spos_mutex); 110 mutex_unlock(&chip->spos_mutex);
109} 111}
110#endif 112#endif
111 113
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
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index bee382995fe9..a5533c86b0b6 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -35,6 +35,8 @@
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/gameport.h> 36#include <linux/gameport.h>
37#include <linux/moduleparam.h> 37#include <linux/moduleparam.h>
38#include <linux/mutex.h>
39
38#include <sound/core.h> 40#include <sound/core.h>
39#include <sound/control.h> 41#include <sound/control.h>
40#include <sound/pcm.h> 42#include <sound/pcm.h>
@@ -379,7 +381,7 @@ MODULE_PARM_DESC(lineio, "Line In to Rear Out (0 = auto, 1 = force).");
379 381
380struct ensoniq { 382struct ensoniq {
381 spinlock_t reg_lock; 383 spinlock_t reg_lock;
382 struct semaphore src_mutex; 384 struct mutex src_mutex;
383 385
384 int irq; 386 int irq;
385 387
@@ -609,7 +611,7 @@ static void snd_es1371_codec_write(struct snd_ac97 *ac97,
609 struct ensoniq *ensoniq = ac97->private_data; 611 struct ensoniq *ensoniq = ac97->private_data;
610 unsigned int t, x; 612 unsigned int t, x;
611 613
612 down(&ensoniq->src_mutex); 614 mutex_lock(&ensoniq->src_mutex);
613 for (t = 0; t < POLL_COUNT; t++) { 615 for (t = 0; t < POLL_COUNT; t++) {
614 if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP)) { 616 if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP)) {
615 /* save the current state for latter */ 617 /* save the current state for latter */
@@ -634,11 +636,11 @@ static void snd_es1371_codec_write(struct snd_ac97 *ac97,
634 /* restore SRC reg */ 636 /* restore SRC reg */
635 snd_es1371_wait_src_ready(ensoniq); 637 snd_es1371_wait_src_ready(ensoniq);
636 outl(x, ES_REG(ensoniq, 1371_SMPRATE)); 638 outl(x, ES_REG(ensoniq, 1371_SMPRATE));
637 up(&ensoniq->src_mutex); 639 mutex_unlock(&ensoniq->src_mutex);
638 return; 640 return;
639 } 641 }
640 } 642 }
641 up(&ensoniq->src_mutex); 643 mutex_unlock(&ensoniq->src_mutex);
642 snd_printk(KERN_ERR "codec write timeout at 0x%lx [0x%x]\n", 644 snd_printk(KERN_ERR "codec write timeout at 0x%lx [0x%x]\n",
643 ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); 645 ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC)));
644} 646}
@@ -650,7 +652,7 @@ static unsigned short snd_es1371_codec_read(struct snd_ac97 *ac97,
650 unsigned int t, x, fail = 0; 652 unsigned int t, x, fail = 0;
651 653
652 __again: 654 __again:
653 down(&ensoniq->src_mutex); 655 mutex_lock(&ensoniq->src_mutex);
654 for (t = 0; t < POLL_COUNT; t++) { 656 for (t = 0; t < POLL_COUNT; t++) {
655 if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP)) { 657 if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP)) {
656 /* save the current state for latter */ 658 /* save the current state for latter */
@@ -683,11 +685,11 @@ static unsigned short snd_es1371_codec_read(struct snd_ac97 *ac97,
683 /* now wait for the stinkin' data (RDY) */ 685 /* now wait for the stinkin' data (RDY) */
684 for (t = 0; t < POLL_COUNT; t++) { 686 for (t = 0; t < POLL_COUNT; t++) {
685 if ((x = inl(ES_REG(ensoniq, 1371_CODEC))) & ES_1371_CODEC_RDY) { 687 if ((x = inl(ES_REG(ensoniq, 1371_CODEC))) & ES_1371_CODEC_RDY) {
686 up(&ensoniq->src_mutex); 688 mutex_unlock(&ensoniq->src_mutex);
687 return ES_1371_CODEC_READ(x); 689 return ES_1371_CODEC_READ(x);
688 } 690 }
689 } 691 }
690 up(&ensoniq->src_mutex); 692 mutex_unlock(&ensoniq->src_mutex);
691 if (++fail > 10) { 693 if (++fail > 10) {
692 snd_printk(KERN_ERR "codec read timeout (final) " 694 snd_printk(KERN_ERR "codec read timeout (final) "
693 "at 0x%lx, reg = 0x%x [0x%x]\n", 695 "at 0x%lx, reg = 0x%x [0x%x]\n",
@@ -698,7 +700,7 @@ static unsigned short snd_es1371_codec_read(struct snd_ac97 *ac97,
698 goto __again; 700 goto __again;
699 } 701 }
700 } 702 }
701 up(&ensoniq->src_mutex); 703 mutex_unlock(&ensoniq->src_mutex);
702 snd_printk(KERN_ERR "es1371: codec read timeout at 0x%lx [0x%x]\n", 704 snd_printk(KERN_ERR "es1371: codec read timeout at 0x%lx [0x%x]\n",
703 ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); 705 ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC)));
704 return 0; 706 return 0;
@@ -717,7 +719,7 @@ static void snd_es1371_adc_rate(struct ensoniq * ensoniq, unsigned int rate)
717{ 719{
718 unsigned int n, truncm, freq, result; 720 unsigned int n, truncm, freq, result;
719 721
720 down(&ensoniq->src_mutex); 722 mutex_lock(&ensoniq->src_mutex);
721 n = rate / 3000; 723 n = rate / 3000;
722 if ((1 << n) & ((1 << 15) | (1 << 13) | (1 << 11) | (1 << 9))) 724 if ((1 << n) & ((1 << 15) | (1 << 13) | (1 << 11) | (1 << 9)))
723 n--; 725 n--;
@@ -742,14 +744,14 @@ static void snd_es1371_adc_rate(struct ensoniq * ensoniq, unsigned int rate)
742 snd_es1371_src_write(ensoniq, ES_SMPREG_ADC + ES_SMPREG_VFREQ_FRAC, freq & 0x7fff); 744 snd_es1371_src_write(ensoniq, ES_SMPREG_ADC + ES_SMPREG_VFREQ_FRAC, freq & 0x7fff);
743 snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC, n << 8); 745 snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC, n << 8);
744 snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC + 1, n << 8); 746 snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC + 1, n << 8);
745 up(&ensoniq->src_mutex); 747 mutex_unlock(&ensoniq->src_mutex);
746} 748}
747 749
748static void snd_es1371_dac1_rate(struct ensoniq * ensoniq, unsigned int rate) 750static void snd_es1371_dac1_rate(struct ensoniq * ensoniq, unsigned int rate)
749{ 751{
750 unsigned int freq, r; 752 unsigned int freq, r;
751 753
752 down(&ensoniq->src_mutex); 754 mutex_lock(&ensoniq->src_mutex);
753 freq = ((rate << 15) + 1500) / 3000; 755 freq = ((rate << 15) + 1500) / 3000;
754 r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | 756 r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE |
755 ES_1371_DIS_P2 | ES_1371_DIS_R1)) | 757 ES_1371_DIS_P2 | ES_1371_DIS_R1)) |
@@ -763,14 +765,14 @@ static void snd_es1371_dac1_rate(struct ensoniq * ensoniq, unsigned int rate)
763 r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | 765 r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE |
764 ES_1371_DIS_P2 | ES_1371_DIS_R1)); 766 ES_1371_DIS_P2 | ES_1371_DIS_R1));
765 outl(r, ES_REG(ensoniq, 1371_SMPRATE)); 767 outl(r, ES_REG(ensoniq, 1371_SMPRATE));
766 up(&ensoniq->src_mutex); 768 mutex_unlock(&ensoniq->src_mutex);
767} 769}
768 770
769static void snd_es1371_dac2_rate(struct ensoniq * ensoniq, unsigned int rate) 771static void snd_es1371_dac2_rate(struct ensoniq * ensoniq, unsigned int rate)
770{ 772{
771 unsigned int freq, r; 773 unsigned int freq, r;
772 774
773 down(&ensoniq->src_mutex); 775 mutex_lock(&ensoniq->src_mutex);
774 freq = ((rate << 15) + 1500) / 3000; 776 freq = ((rate << 15) + 1500) / 3000;
775 r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | 777 r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE |
776 ES_1371_DIS_P1 | ES_1371_DIS_R1)) | 778 ES_1371_DIS_P1 | ES_1371_DIS_R1)) |
@@ -785,7 +787,7 @@ static void snd_es1371_dac2_rate(struct ensoniq * ensoniq, unsigned int rate)
785 r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | 787 r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE |
786 ES_1371_DIS_P1 | ES_1371_DIS_R1)); 788 ES_1371_DIS_P1 | ES_1371_DIS_R1));
787 outl(r, ES_REG(ensoniq, 1371_SMPRATE)); 789 outl(r, ES_REG(ensoniq, 1371_SMPRATE));
788 up(&ensoniq->src_mutex); 790 mutex_unlock(&ensoniq->src_mutex);
789} 791}
790 792
791#endif /* CHIP1371 */ 793#endif /* CHIP1371 */
@@ -2123,7 +2125,7 @@ static int __devinit snd_ensoniq_create(struct snd_card *card,
2123 return -ENOMEM; 2125 return -ENOMEM;
2124 } 2126 }
2125 spin_lock_init(&ensoniq->reg_lock); 2127 spin_lock_init(&ensoniq->reg_lock);
2126 init_MUTEX(&ensoniq->src_mutex); 2128 mutex_init(&ensoniq->src_mutex);
2127 ensoniq->card = card; 2129 ensoniq->card = card;
2128 ensoniq->pci = pci; 2130 ensoniq->pci = pci;
2129 ensoniq->irq = -1; 2131 ensoniq->irq = -1;
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 3747a436f0cd..6a265ab3894e 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -103,6 +103,8 @@
103#include <linux/slab.h> 103#include <linux/slab.h>
104#include <linux/gameport.h> 104#include <linux/gameport.h>
105#include <linux/moduleparam.h> 105#include <linux/moduleparam.h>
106#include <linux/mutex.h>
107
106#include <sound/core.h> 108#include <sound/core.h>
107#include <sound/pcm.h> 109#include <sound/pcm.h>
108#include <sound/mpu401.h> 110#include <sound/mpu401.h>
@@ -569,7 +571,7 @@ struct es1968 {
569 u16 maestro_map[32]; 571 u16 maestro_map[32];
570 int bobclient; /* active timer instancs */ 572 int bobclient; /* active timer instancs */
571 int bob_freq; /* timer frequency */ 573 int bob_freq; /* timer frequency */
572 struct semaphore memory_mutex; /* memory lock */ 574 struct mutex memory_mutex; /* memory lock */
573 575
574 /* APU states */ 576 /* APU states */
575 unsigned char apu[NR_APUS]; 577 unsigned char apu[NR_APUS];
@@ -1356,13 +1358,13 @@ static int calc_available_memory_size(struct es1968 *chip)
1356 struct list_head *p; 1358 struct list_head *p;
1357 int max_size = 0; 1359 int max_size = 0;
1358 1360
1359 down(&chip->memory_mutex); 1361 mutex_lock(&chip->memory_mutex);
1360 list_for_each(p, &chip->buf_list) { 1362 list_for_each(p, &chip->buf_list) {
1361 struct esm_memory *buf = list_entry(p, struct esm_memory, list); 1363 struct esm_memory *buf = list_entry(p, struct esm_memory, list);
1362 if (buf->empty && buf->buf.bytes > max_size) 1364 if (buf->empty && buf->buf.bytes > max_size)
1363 max_size = buf->buf.bytes; 1365 max_size = buf->buf.bytes;
1364 } 1366 }
1365 up(&chip->memory_mutex); 1367 mutex_unlock(&chip->memory_mutex);
1366 if (max_size >= 128*1024) 1368 if (max_size >= 128*1024)
1367 max_size = 127*1024; 1369 max_size = 127*1024;
1368 return max_size; 1370 return max_size;
@@ -1375,20 +1377,20 @@ static struct esm_memory *snd_es1968_new_memory(struct es1968 *chip, int size)
1375 struct list_head *p; 1377 struct list_head *p;
1376 1378
1377 size = ((size + ESM_MEM_ALIGN - 1) / ESM_MEM_ALIGN) * ESM_MEM_ALIGN; 1379 size = ((size + ESM_MEM_ALIGN - 1) / ESM_MEM_ALIGN) * ESM_MEM_ALIGN;
1378 down(&chip->memory_mutex); 1380 mutex_lock(&chip->memory_mutex);
1379 list_for_each(p, &chip->buf_list) { 1381 list_for_each(p, &chip->buf_list) {
1380 buf = list_entry(p, struct esm_memory, list); 1382 buf = list_entry(p, struct esm_memory, list);
1381 if (buf->empty && buf->buf.bytes >= size) 1383 if (buf->empty && buf->buf.bytes >= size)
1382 goto __found; 1384 goto __found;
1383 } 1385 }
1384 up(&chip->memory_mutex); 1386 mutex_unlock(&chip->memory_mutex);
1385 return NULL; 1387 return NULL;
1386 1388
1387__found: 1389__found:
1388 if (buf->buf.bytes > size) { 1390 if (buf->buf.bytes > size) {
1389 struct esm_memory *chunk = kmalloc(sizeof(*chunk), GFP_KERNEL); 1391 struct esm_memory *chunk = kmalloc(sizeof(*chunk), GFP_KERNEL);
1390 if (chunk == NULL) { 1392 if (chunk == NULL) {
1391 up(&chip->memory_mutex); 1393 mutex_unlock(&chip->memory_mutex);
1392 return NULL; 1394 return NULL;
1393 } 1395 }
1394 chunk->buf = buf->buf; 1396 chunk->buf = buf->buf;
@@ -1400,7 +1402,7 @@ __found:
1400 list_add(&chunk->list, &buf->list); 1402 list_add(&chunk->list, &buf->list);
1401 } 1403 }
1402 buf->empty = 0; 1404 buf->empty = 0;
1403 up(&chip->memory_mutex); 1405 mutex_unlock(&chip->memory_mutex);
1404 return buf; 1406 return buf;
1405} 1407}
1406 1408
@@ -1409,7 +1411,7 @@ static void snd_es1968_free_memory(struct es1968 *chip, struct esm_memory *buf)
1409{ 1411{
1410 struct esm_memory *chunk; 1412 struct esm_memory *chunk;
1411 1413
1412 down(&chip->memory_mutex); 1414 mutex_lock(&chip->memory_mutex);
1413 buf->empty = 1; 1415 buf->empty = 1;
1414 if (buf->list.prev != &chip->buf_list) { 1416 if (buf->list.prev != &chip->buf_list) {
1415 chunk = list_entry(buf->list.prev, struct esm_memory, list); 1417 chunk = list_entry(buf->list.prev, struct esm_memory, list);
@@ -1428,7 +1430,7 @@ static void snd_es1968_free_memory(struct es1968 *chip, struct esm_memory *buf)
1428 kfree(chunk); 1430 kfree(chunk);
1429 } 1431 }
1430 } 1432 }
1431 up(&chip->memory_mutex); 1433 mutex_unlock(&chip->memory_mutex);
1432} 1434}
1433 1435
1434static void snd_es1968_free_dmabuf(struct es1968 *chip) 1436static void snd_es1968_free_dmabuf(struct es1968 *chip)
@@ -2579,7 +2581,7 @@ static int __devinit snd_es1968_create(struct snd_card *card,
2579 INIT_LIST_HEAD(&chip->buf_list); 2581 INIT_LIST_HEAD(&chip->buf_list);
2580 INIT_LIST_HEAD(&chip->substream_list); 2582 INIT_LIST_HEAD(&chip->substream_list);
2581 spin_lock_init(&chip->ac97_lock); 2583 spin_lock_init(&chip->ac97_lock);
2582 init_MUTEX(&chip->memory_mutex); 2584 mutex_init(&chip->memory_mutex);
2583 tasklet_init(&chip->hwvol_tq, es1968_update_hw_volume, (unsigned long)chip); 2585 tasklet_init(&chip->hwvol_tq, es1968_update_hw_volume, (unsigned long)chip);
2584 chip->card = card; 2586 chip->card = card;
2585 chip->pci = pci; 2587 chip->pci = pci;
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 4a6dd97deba6..208a3341ec20 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -25,6 +25,7 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/moduleparam.h> 27#include <linux/moduleparam.h>
28#include <linux/mutex.h>
28#include <sound/core.h> 29#include <sound/core.h>
29#include "hda_codec.h" 30#include "hda_codec.h"
30#include <sound/asoundef.h> 31#include <sound/asoundef.h>
@@ -76,12 +77,12 @@ unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, int dire
76 unsigned int verb, unsigned int parm) 77 unsigned int verb, unsigned int parm)
77{ 78{
78 unsigned int res; 79 unsigned int res;
79 down(&codec->bus->cmd_mutex); 80 mutex_lock(&codec->bus->cmd_mutex);
80 if (! codec->bus->ops.command(codec, nid, direct, verb, parm)) 81 if (! codec->bus->ops.command(codec, nid, direct, verb, parm))
81 res = codec->bus->ops.get_response(codec); 82 res = codec->bus->ops.get_response(codec);
82 else 83 else
83 res = (unsigned int)-1; 84 res = (unsigned int)-1;
84 up(&codec->bus->cmd_mutex); 85 mutex_unlock(&codec->bus->cmd_mutex);
85 return res; 86 return res;
86} 87}
87 88
@@ -101,9 +102,9 @@ int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int direct,
101 unsigned int verb, unsigned int parm) 102 unsigned int verb, unsigned int parm)
102{ 103{
103 int err; 104 int err;
104 down(&codec->bus->cmd_mutex); 105 mutex_lock(&codec->bus->cmd_mutex);
105 err = codec->bus->ops.command(codec, nid, direct, verb, parm); 106 err = codec->bus->ops.command(codec, nid, direct, verb, parm);
106 up(&codec->bus->cmd_mutex); 107 mutex_unlock(&codec->bus->cmd_mutex);
107 return err; 108 return err;
108} 109}
109 110
@@ -371,7 +372,7 @@ int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp,
371 bus->modelname = temp->modelname; 372 bus->modelname = temp->modelname;
372 bus->ops = temp->ops; 373 bus->ops = temp->ops;
373 374
374 init_MUTEX(&bus->cmd_mutex); 375 mutex_init(&bus->cmd_mutex);
375 INIT_LIST_HEAD(&bus->codec_list); 376 INIT_LIST_HEAD(&bus->codec_list);
376 377
377 if ((err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops)) < 0) { 378 if ((err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops)) < 0) {
@@ -523,7 +524,7 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
523 524
524 codec->bus = bus; 525 codec->bus = bus;
525 codec->addr = codec_addr; 526 codec->addr = codec_addr;
526 init_MUTEX(&codec->spdif_mutex); 527 mutex_init(&codec->spdif_mutex);
527 init_amp_hash(codec); 528 init_amp_hash(codec);
528 529
529 list_add_tail(&codec->list, &bus->codec_list); 530 list_add_tail(&codec->list, &bus->codec_list);
@@ -881,12 +882,12 @@ int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_
881 unsigned long pval; 882 unsigned long pval;
882 int err; 883 int err;
883 884
884 down(&codec->spdif_mutex); /* reuse spdif_mutex */ 885 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
885 pval = kcontrol->private_value; 886 pval = kcontrol->private_value;
886 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */ 887 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
887 err = snd_hda_mixer_amp_switch_get(kcontrol, ucontrol); 888 err = snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
888 kcontrol->private_value = pval; 889 kcontrol->private_value = pval;
889 up(&codec->spdif_mutex); 890 mutex_unlock(&codec->spdif_mutex);
890 return err; 891 return err;
891} 892}
892 893
@@ -896,7 +897,7 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
896 unsigned long pval; 897 unsigned long pval;
897 int i, indices, err = 0, change = 0; 898 int i, indices, err = 0, change = 0;
898 899
899 down(&codec->spdif_mutex); /* reuse spdif_mutex */ 900 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
900 pval = kcontrol->private_value; 901 pval = kcontrol->private_value;
901 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT; 902 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
902 for (i = 0; i < indices; i++) { 903 for (i = 0; i < indices; i++) {
@@ -907,7 +908,7 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
907 change |= err; 908 change |= err;
908 } 909 }
909 kcontrol->private_value = pval; 910 kcontrol->private_value = pval;
910 up(&codec->spdif_mutex); 911 mutex_unlock(&codec->spdif_mutex);
911 return err < 0 ? err : change; 912 return err < 0 ? err : change;
912} 913}
913 914
@@ -1011,7 +1012,7 @@ static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_c
1011 unsigned short val; 1012 unsigned short val;
1012 int change; 1013 int change;
1013 1014
1014 down(&codec->spdif_mutex); 1015 mutex_lock(&codec->spdif_mutex);
1015 codec->spdif_status = ucontrol->value.iec958.status[0] | 1016 codec->spdif_status = ucontrol->value.iec958.status[0] |
1016 ((unsigned int)ucontrol->value.iec958.status[1] << 8) | 1017 ((unsigned int)ucontrol->value.iec958.status[1] << 8) |
1017 ((unsigned int)ucontrol->value.iec958.status[2] << 16) | 1018 ((unsigned int)ucontrol->value.iec958.status[2] << 16) |
@@ -1026,7 +1027,7 @@ static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_c
1026 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_2, val >> 8); 1027 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_2, val >> 8);
1027 } 1028 }
1028 1029
1029 up(&codec->spdif_mutex); 1030 mutex_unlock(&codec->spdif_mutex);
1030 return change; 1031 return change;
1031} 1032}
1032 1033
@@ -1054,7 +1055,7 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, struct sn
1054 unsigned short val; 1055 unsigned short val;
1055 int change; 1056 int change;
1056 1057
1057 down(&codec->spdif_mutex); 1058 mutex_lock(&codec->spdif_mutex);
1058 val = codec->spdif_ctls & ~1; 1059 val = codec->spdif_ctls & ~1;
1059 if (ucontrol->value.integer.value[0]) 1060 if (ucontrol->value.integer.value[0])
1060 val |= 1; 1061 val |= 1;
@@ -1066,7 +1067,7 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, struct sn
1066 AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | 1067 AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT |
1067 AC_AMP_SET_OUTPUT | ((val & 1) ? 0 : 0x80)); 1068 AC_AMP_SET_OUTPUT | ((val & 1) ? 0 : 0x80));
1068 } 1069 }
1069 up(&codec->spdif_mutex); 1070 mutex_unlock(&codec->spdif_mutex);
1070 return change; 1071 return change;
1071} 1072}
1072 1073
@@ -1150,13 +1151,13 @@ static int snd_hda_spdif_in_switch_put(struct snd_kcontrol *kcontrol, struct snd
1150 unsigned int val = !!ucontrol->value.integer.value[0]; 1151 unsigned int val = !!ucontrol->value.integer.value[0];
1151 int change; 1152 int change;
1152 1153
1153 down(&codec->spdif_mutex); 1154 mutex_lock(&codec->spdif_mutex);
1154 change = codec->spdif_in_enable != val; 1155 change = codec->spdif_in_enable != val;
1155 if (change || codec->in_resume) { 1156 if (change || codec->in_resume) {
1156 codec->spdif_in_enable = val; 1157 codec->spdif_in_enable = val;
1157 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val); 1158 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val);
1158 } 1159 }
1159 up(&codec->spdif_mutex); 1160 mutex_unlock(&codec->spdif_mutex);
1160 return change; 1161 return change;
1161} 1162}
1162 1163
@@ -1824,13 +1825,13 @@ int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *i
1824 */ 1825 */
1825int snd_hda_multi_out_dig_open(struct hda_codec *codec, struct hda_multi_out *mout) 1826int snd_hda_multi_out_dig_open(struct hda_codec *codec, struct hda_multi_out *mout)
1826{ 1827{
1827 down(&codec->spdif_mutex); 1828 mutex_lock(&codec->spdif_mutex);
1828 if (mout->dig_out_used) { 1829 if (mout->dig_out_used) {
1829 up(&codec->spdif_mutex); 1830 mutex_unlock(&codec->spdif_mutex);
1830 return -EBUSY; /* already being used */ 1831 return -EBUSY; /* already being used */
1831 } 1832 }
1832 mout->dig_out_used = HDA_DIG_EXCLUSIVE; 1833 mout->dig_out_used = HDA_DIG_EXCLUSIVE;
1833 up(&codec->spdif_mutex); 1834 mutex_unlock(&codec->spdif_mutex);
1834 return 0; 1835 return 0;
1835} 1836}
1836 1837
@@ -1839,9 +1840,9 @@ int snd_hda_multi_out_dig_open(struct hda_codec *codec, struct hda_multi_out *mo
1839 */ 1840 */
1840int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *mout) 1841int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *mout)
1841{ 1842{
1842 down(&codec->spdif_mutex); 1843 mutex_lock(&codec->spdif_mutex);
1843 mout->dig_out_used = 0; 1844 mout->dig_out_used = 0;
1844 up(&codec->spdif_mutex); 1845 mutex_unlock(&codec->spdif_mutex);
1845 return 0; 1846 return 0;
1846} 1847}
1847 1848
@@ -1869,7 +1870,7 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_o
1869 int chs = substream->runtime->channels; 1870 int chs = substream->runtime->channels;
1870 int i; 1871 int i;
1871 1872
1872 down(&codec->spdif_mutex); 1873 mutex_lock(&codec->spdif_mutex);
1873 if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) { 1874 if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) {
1874 if (chs == 2 && 1875 if (chs == 2 &&
1875 snd_hda_is_supported_format(codec, mout->dig_out_nid, format) && 1876 snd_hda_is_supported_format(codec, mout->dig_out_nid, format) &&
@@ -1883,7 +1884,7 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_o
1883 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0); 1884 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0);
1884 } 1885 }
1885 } 1886 }
1886 up(&codec->spdif_mutex); 1887 mutex_unlock(&codec->spdif_mutex);
1887 1888
1888 /* front */ 1889 /* front */
1889 snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag, 0, format); 1890 snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag, 0, format);
@@ -1914,12 +1915,12 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, struct hda_multi_o
1914 snd_hda_codec_setup_stream(codec, nids[i], 0, 0, 0); 1915 snd_hda_codec_setup_stream(codec, nids[i], 0, 0, 0);
1915 if (mout->hp_nid) 1916 if (mout->hp_nid)
1916 snd_hda_codec_setup_stream(codec, mout->hp_nid, 0, 0, 0); 1917 snd_hda_codec_setup_stream(codec, mout->hp_nid, 0, 0, 0);
1917 down(&codec->spdif_mutex); 1918 mutex_lock(&codec->spdif_mutex);
1918 if (mout->dig_out_nid && mout->dig_out_used == HDA_DIG_ANALOG_DUP) { 1919 if (mout->dig_out_nid && mout->dig_out_used == HDA_DIG_ANALOG_DUP) {
1919 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0); 1920 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0);
1920 mout->dig_out_used = 0; 1921 mout->dig_out_used = 0;
1921 } 1922 }
1922 up(&codec->spdif_mutex); 1923 mutex_unlock(&codec->spdif_mutex);
1923 return 0; 1924 return 0;
1924} 1925}
1925 1926
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 63e26c7a2b7a..40520e9d5a4b 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -438,7 +438,7 @@ struct hda_bus {
438 struct list_head codec_list; 438 struct list_head codec_list;
439 struct hda_codec *caddr_tbl[HDA_MAX_CODEC_ADDRESS + 1]; /* caddr -> codec */ 439 struct hda_codec *caddr_tbl[HDA_MAX_CODEC_ADDRESS + 1]; /* caddr -> codec */
440 440
441 struct semaphore cmd_mutex; 441 struct mutex cmd_mutex;
442 442
443 /* unsolicited event queue */ 443 /* unsolicited event queue */
444 struct hda_bus_unsolicited *unsol; 444 struct hda_bus_unsolicited *unsol;
@@ -559,7 +559,7 @@ struct hda_codec {
559 int amp_info_size; 559 int amp_info_size;
560 struct hda_amp_info *amp_info; 560 struct hda_amp_info *amp_info;
561 561
562 struct semaphore spdif_mutex; 562 struct mutex spdif_mutex;
563 unsigned int spdif_status; /* IEC958 status bits */ 563 unsigned int spdif_status; /* IEC958 status bits */
564 unsigned short spdif_ctls; /* SPDIF control bits */ 564 unsigned short spdif_ctls; /* SPDIF control bits */
565 unsigned int spdif_in_enable; /* SPDIF input enable? */ 565 unsigned int spdif_in_enable; /* SPDIF input enable? */
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index b3f37e7b33c0..dbed2644a192 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -43,6 +43,7 @@
43#include <linux/init.h> 43#include <linux/init.h>
44#include <linux/slab.h> 44#include <linux/slab.h>
45#include <linux/pci.h> 45#include <linux/pci.h>
46#include <linux/mutex.h>
46#include <sound/core.h> 47#include <sound/core.h>
47#include <sound/initval.h> 48#include <sound/initval.h>
48#include "hda_codec.h" 49#include "hda_codec.h"
@@ -297,7 +298,7 @@ struct azx {
297 298
298 /* locks */ 299 /* locks */
299 spinlock_t reg_lock; 300 spinlock_t reg_lock;
300 struct semaphore open_mutex; 301 struct mutex open_mutex;
301 302
302 /* streams (x num_streams) */ 303 /* streams (x num_streams) */
303 struct azx_dev *azx_dev; 304 struct azx_dev *azx_dev;
@@ -993,10 +994,10 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
993 unsigned long flags; 994 unsigned long flags;
994 int err; 995 int err;
995 996
996 down(&chip->open_mutex); 997 mutex_lock(&chip->open_mutex);
997 azx_dev = azx_assign_device(chip, substream->stream); 998 azx_dev = azx_assign_device(chip, substream->stream);
998 if (azx_dev == NULL) { 999 if (azx_dev == NULL) {
999 up(&chip->open_mutex); 1000 mutex_unlock(&chip->open_mutex);
1000 return -EBUSY; 1001 return -EBUSY;
1001 } 1002 }
1002 runtime->hw = azx_pcm_hw; 1003 runtime->hw = azx_pcm_hw;
@@ -1008,7 +1009,7 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
1008 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); 1009 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
1009 if ((err = hinfo->ops.open(hinfo, apcm->codec, substream)) < 0) { 1010 if ((err = hinfo->ops.open(hinfo, apcm->codec, substream)) < 0) {
1010 azx_release_device(azx_dev); 1011 azx_release_device(azx_dev);
1011 up(&chip->open_mutex); 1012 mutex_unlock(&chip->open_mutex);
1012 return err; 1013 return err;
1013 } 1014 }
1014 spin_lock_irqsave(&chip->reg_lock, flags); 1015 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -1017,7 +1018,7 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
1017 spin_unlock_irqrestore(&chip->reg_lock, flags); 1018 spin_unlock_irqrestore(&chip->reg_lock, flags);
1018 1019
1019 runtime->private_data = azx_dev; 1020 runtime->private_data = azx_dev;
1020 up(&chip->open_mutex); 1021 mutex_unlock(&chip->open_mutex);
1021 return 0; 1022 return 0;
1022} 1023}
1023 1024
@@ -1029,14 +1030,14 @@ static int azx_pcm_close(struct snd_pcm_substream *substream)
1029 struct azx_dev *azx_dev = get_azx_dev(substream); 1030 struct azx_dev *azx_dev = get_azx_dev(substream);
1030 unsigned long flags; 1031 unsigned long flags;
1031 1032
1032 down(&chip->open_mutex); 1033 mutex_lock(&chip->open_mutex);
1033 spin_lock_irqsave(&chip->reg_lock, flags); 1034 spin_lock_irqsave(&chip->reg_lock, flags);
1034 azx_dev->substream = NULL; 1035 azx_dev->substream = NULL;
1035 azx_dev->running = 0; 1036 azx_dev->running = 0;
1036 spin_unlock_irqrestore(&chip->reg_lock, flags); 1037 spin_unlock_irqrestore(&chip->reg_lock, flags);
1037 azx_release_device(azx_dev); 1038 azx_release_device(azx_dev);
1038 hinfo->ops.close(hinfo, apcm->codec, substream); 1039 hinfo->ops.close(hinfo, apcm->codec, substream);
1039 up(&chip->open_mutex); 1040 mutex_unlock(&chip->open_mutex);
1040 return 0; 1041 return 0;
1041} 1042}
1042 1043
@@ -1408,7 +1409,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
1408 } 1409 }
1409 1410
1410 spin_lock_init(&chip->reg_lock); 1411 spin_lock_init(&chip->reg_lock);
1411 init_MUTEX(&chip->open_mutex); 1412 mutex_init(&chip->open_mutex);
1412 chip->card = card; 1413 chip->card = card;
1413 chip->pci = pci; 1414 chip->pci = pci;
1414 chip->irq = -1; 1415 chip->irq = -1;
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 1ada1b075c9a..5a3821ae93a8 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -23,6 +23,8 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/mutex.h>
27
26#include <sound/core.h> 28#include <sound/core.h>
27#include "hda_codec.h" 29#include "hda_codec.h"
28#include "hda_local.h" 30#include "hda_local.h"
@@ -60,7 +62,7 @@ struct ad198x_spec {
60 /* PCM information */ 62 /* PCM information */
61 struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */ 63 struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */
62 64
63 struct semaphore amp_mutex; /* PCM volume/mute control mutex */ 65 struct mutex amp_mutex; /* PCM volume/mute control mutex */
64 unsigned int spdif_route; 66 unsigned int spdif_route;
65 67
66 /* dynamic controls, init_verbs and input_mux */ 68 /* dynamic controls, init_verbs and input_mux */
@@ -371,9 +373,9 @@ static int ad1986a_pcm_amp_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl
371 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 373 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
372 struct ad198x_spec *ad = codec->spec; 374 struct ad198x_spec *ad = codec->spec;
373 375
374 down(&ad->amp_mutex); 376 mutex_lock(&ad->amp_mutex);
375 snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); 377 snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
376 up(&ad->amp_mutex); 378 mutex_unlock(&ad->amp_mutex);
377 return 0; 379 return 0;
378} 380}
379 381
@@ -383,13 +385,13 @@ static int ad1986a_pcm_amp_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl
383 struct ad198x_spec *ad = codec->spec; 385 struct ad198x_spec *ad = codec->spec;
384 int i, change = 0; 386 int i, change = 0;
385 387
386 down(&ad->amp_mutex); 388 mutex_lock(&ad->amp_mutex);
387 for (i = 0; i < ARRAY_SIZE(ad1986a_dac_nids); i++) { 389 for (i = 0; i < ARRAY_SIZE(ad1986a_dac_nids); i++) {
388 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(ad1986a_dac_nids[i], 3, 0, HDA_OUTPUT); 390 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(ad1986a_dac_nids[i], 3, 0, HDA_OUTPUT);
389 change |= snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); 391 change |= snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
390 } 392 }
391 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT); 393 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT);
392 up(&ad->amp_mutex); 394 mutex_unlock(&ad->amp_mutex);
393 return change; 395 return change;
394} 396}
395 397
@@ -400,9 +402,9 @@ static int ad1986a_pcm_amp_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_
400 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 402 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
401 struct ad198x_spec *ad = codec->spec; 403 struct ad198x_spec *ad = codec->spec;
402 404
403 down(&ad->amp_mutex); 405 mutex_lock(&ad->amp_mutex);
404 snd_hda_mixer_amp_switch_get(kcontrol, ucontrol); 406 snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
405 up(&ad->amp_mutex); 407 mutex_unlock(&ad->amp_mutex);
406 return 0; 408 return 0;
407} 409}
408 410
@@ -412,13 +414,13 @@ static int ad1986a_pcm_amp_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
412 struct ad198x_spec *ad = codec->spec; 414 struct ad198x_spec *ad = codec->spec;
413 int i, change = 0; 415 int i, change = 0;
414 416
415 down(&ad->amp_mutex); 417 mutex_lock(&ad->amp_mutex);
416 for (i = 0; i < ARRAY_SIZE(ad1986a_dac_nids); i++) { 418 for (i = 0; i < ARRAY_SIZE(ad1986a_dac_nids); i++) {
417 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(ad1986a_dac_nids[i], 3, 0, HDA_OUTPUT); 419 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(ad1986a_dac_nids[i], 3, 0, HDA_OUTPUT);
418 change |= snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); 420 change |= snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
419 } 421 }
420 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT); 422 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT);
421 up(&ad->amp_mutex); 423 mutex_unlock(&ad->amp_mutex);
422 return change; 424 return change;
423} 425}
424 426
@@ -544,7 +546,7 @@ static int patch_ad1986a(struct hda_codec *codec)
544 if (spec == NULL) 546 if (spec == NULL)
545 return -ENOMEM; 547 return -ENOMEM;
546 548
547 init_MUTEX(&spec->amp_mutex); 549 mutex_init(&spec->amp_mutex);
548 codec->spec = spec; 550 codec->spec = spec;
549 551
550 spec->multiout.max_channels = 6; 552 spec->multiout.max_channels = 6;
@@ -708,7 +710,7 @@ static int patch_ad1983(struct hda_codec *codec)
708 if (spec == NULL) 710 if (spec == NULL)
709 return -ENOMEM; 711 return -ENOMEM;
710 712
711 init_MUTEX(&spec->amp_mutex); 713 mutex_init(&spec->amp_mutex);
712 codec->spec = spec; 714 codec->spec = spec;
713 715
714 spec->multiout.max_channels = 2; 716 spec->multiout.max_channels = 2;
@@ -854,7 +856,7 @@ static int patch_ad1981(struct hda_codec *codec)
854 if (spec == NULL) 856 if (spec == NULL)
855 return -ENOMEM; 857 return -ENOMEM;
856 858
857 init_MUTEX(&spec->amp_mutex); 859 mutex_init(&spec->amp_mutex);
858 codec->spec = spec; 860 codec->spec = spec;
859 861
860 spec->multiout.max_channels = 2; 862 spec->multiout.max_channels = 2;
@@ -2032,7 +2034,7 @@ static int patch_ad1988(struct hda_codec *codec)
2032 if (spec == NULL) 2034 if (spec == NULL)
2033 return -ENOMEM; 2035 return -ENOMEM;
2034 2036
2035 init_MUTEX(&spec->amp_mutex); 2037 mutex_init(&spec->amp_mutex);
2036 codec->spec = spec; 2038 codec->spec = spec;
2037 2039
2038 if (codec->revision_id == AD1988A_REV2) 2040 if (codec->revision_id == AD1988A_REV2)
diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c
index 2175f6721347..0f7f4d8263c0 100644
--- a/sound/pci/ice1712/aureon.c
+++ b/sound/pci/ice1712/aureon.c
@@ -53,6 +53,8 @@
53#include <linux/interrupt.h> 53#include <linux/interrupt.h>
54#include <linux/init.h> 54#include <linux/init.h>
55#include <linux/slab.h> 55#include <linux/slab.h>
56#include <linux/mutex.h>
57
56#include <sound/core.h> 58#include <sound/core.h>
57 59
58#include "ice1712.h" 60#include "ice1712.h"
@@ -210,14 +212,14 @@ static int aureon_ac97_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
210 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 212 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
211 unsigned short vol; 213 unsigned short vol;
212 214
213 down(&ice->gpio_mutex); 215 mutex_lock(&ice->gpio_mutex);
214 216
215 vol = aureon_ac97_read(ice, kcontrol->private_value & 0x7F); 217 vol = aureon_ac97_read(ice, kcontrol->private_value & 0x7F);
216 ucontrol->value.integer.value[0] = 0x1F - (vol & 0x1F); 218 ucontrol->value.integer.value[0] = 0x1F - (vol & 0x1F);
217 if (kcontrol->private_value & AUREON_AC97_STEREO) 219 if (kcontrol->private_value & AUREON_AC97_STEREO)
218 ucontrol->value.integer.value[1] = 0x1F - ((vol >> 8) & 0x1F); 220 ucontrol->value.integer.value[1] = 0x1F - ((vol >> 8) & 0x1F);
219 221
220 up(&ice->gpio_mutex); 222 mutex_unlock(&ice->gpio_mutex);
221 return 0; 223 return 0;
222} 224}
223 225
@@ -252,11 +254,11 @@ static int aureon_ac97_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_el
252{ 254{
253 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 255 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
254 256
255 down(&ice->gpio_mutex); 257 mutex_lock(&ice->gpio_mutex);
256 258
257 ucontrol->value.integer.value[0] = aureon_ac97_read(ice, kcontrol->private_value & 0x7F) & 0x8000 ? 0 : 1; 259 ucontrol->value.integer.value[0] = aureon_ac97_read(ice, kcontrol->private_value & 0x7F) & 0x8000 ? 0 : 1;
258 260
259 up(&ice->gpio_mutex); 261 mutex_unlock(&ice->gpio_mutex);
260 return 0; 262 return 0;
261} 263}
262 264
@@ -288,11 +290,11 @@ static int aureon_ac97_micboost_get(struct snd_kcontrol *kcontrol, struct snd_ct
288{ 290{
289 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 291 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
290 292
291 down(&ice->gpio_mutex); 293 mutex_lock(&ice->gpio_mutex);
292 294
293 ucontrol->value.integer.value[0] = aureon_ac97_read(ice, AC97_MIC) & 0x0020 ? 0 : 1; 295 ucontrol->value.integer.value[0] = aureon_ac97_read(ice, AC97_MIC) & 0x0020 ? 0 : 1;
294 296
295 up(&ice->gpio_mutex); 297 mutex_unlock(&ice->gpio_mutex);
296 return 0; 298 return 0;
297} 299}
298 300
@@ -488,11 +490,11 @@ static int aureon_ac97_mmute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
488{ 490{
489 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 491 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
490 492
491 down(&ice->gpio_mutex); 493 mutex_lock(&ice->gpio_mutex);
492 494
493 ucontrol->value.integer.value[0] = (wm_get(ice, WM_OUT_MUX1) >> 1) & 0x01; 495 ucontrol->value.integer.value[0] = (wm_get(ice, WM_OUT_MUX1) >> 1) & 0x01;
494 496
495 up(&ice->gpio_mutex); 497 mutex_unlock(&ice->gpio_mutex);
496 return 0; 498 return 0;
497} 499}
498 500
@@ -557,9 +559,9 @@ static int wm_pcm_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_va
557{ 559{
558 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 560 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
559 561
560 down(&ice->gpio_mutex); 562 mutex_lock(&ice->gpio_mutex);
561 ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ? 0 : 1; 563 ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ? 0 : 1;
562 up(&ice->gpio_mutex); 564 mutex_unlock(&ice->gpio_mutex);
563 return 0; 565 return 0;
564} 566}
565 567
@@ -782,11 +784,11 @@ static int wm_pcm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
782 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 784 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
783 unsigned short val; 785 unsigned short val;
784 786
785 down(&ice->gpio_mutex); 787 mutex_lock(&ice->gpio_mutex);
786 val = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff; 788 val = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff;
787 val = val > PCM_MIN ? (val - PCM_MIN) : 0; 789 val = val > PCM_MIN ? (val - PCM_MIN) : 0;
788 ucontrol->value.integer.value[0] = val; 790 ucontrol->value.integer.value[0] = val;
789 up(&ice->gpio_mutex); 791 mutex_unlock(&ice->gpio_mutex);
790 return 0; 792 return 0;
791} 793}
792 794
@@ -827,12 +829,12 @@ static int wm_adc_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_va
827 unsigned short val; 829 unsigned short val;
828 int i; 830 int i;
829 831
830 down(&ice->gpio_mutex); 832 mutex_lock(&ice->gpio_mutex);
831 for (i = 0; i < 2; i++) { 833 for (i = 0; i < 2; i++) {
832 val = wm_get(ice, WM_ADC_GAIN + i); 834 val = wm_get(ice, WM_ADC_GAIN + i);
833 ucontrol->value.integer.value[i] = ~val>>5 & 0x1; 835 ucontrol->value.integer.value[i] = ~val>>5 & 0x1;
834 } 836 }
835 up(&ice->gpio_mutex); 837 mutex_unlock(&ice->gpio_mutex);
836 return 0; 838 return 0;
837} 839}
838 840
@@ -874,13 +876,13 @@ static int wm_adc_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
874 int i, idx; 876 int i, idx;
875 unsigned short vol; 877 unsigned short vol;
876 878
877 down(&ice->gpio_mutex); 879 mutex_lock(&ice->gpio_mutex);
878 for (i = 0; i < 2; i++) { 880 for (i = 0; i < 2; i++) {
879 idx = WM_ADC_GAIN + i; 881 idx = WM_ADC_GAIN + i;
880 vol = wm_get(ice, idx) & 0x1f; 882 vol = wm_get(ice, idx) & 0x1f;
881 ucontrol->value.integer.value[i] = vol; 883 ucontrol->value.integer.value[i] = vol;
882 } 884 }
883 up(&ice->gpio_mutex); 885 mutex_unlock(&ice->gpio_mutex);
884 return 0; 886 return 0;
885} 887}
886 888
@@ -951,11 +953,11 @@ static int wm_adc_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
951 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 953 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
952 unsigned short val; 954 unsigned short val;
953 955
954 down(&ice->gpio_mutex); 956 mutex_lock(&ice->gpio_mutex);
955 val = wm_get(ice, WM_ADC_MUX); 957 val = wm_get(ice, WM_ADC_MUX);
956 ucontrol->value.integer.value[0] = val & 7; 958 ucontrol->value.integer.value[0] = val & 7;
957 ucontrol->value.integer.value[1] = (val >> 4) & 7; 959 ucontrol->value.integer.value[1] = (val >> 4) & 7;
958 up(&ice->gpio_mutex); 960 mutex_unlock(&ice->gpio_mutex);
959 return 0; 961 return 0;
960} 962}
961 963
diff --git a/sound/pci/ice1712/delta.c b/sound/pci/ice1712/delta.c
index 9a51d34e6817..4bbf1e2ae653 100644
--- a/sound/pci/ice1712/delta.c
+++ b/sound/pci/ice1712/delta.c
@@ -28,6 +28,8 @@
28#include <linux/interrupt.h> 28#include <linux/interrupt.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/mutex.h>
32
31#include <sound/core.h> 33#include <sound/core.h>
32#include <sound/cs8427.h> 34#include <sound/cs8427.h>
33#include <sound/asoundef.h> 35#include <sound/asoundef.h>
@@ -130,13 +132,13 @@ static int ap_cs8427_sendbytes(struct snd_i2c_device *device, unsigned char *byt
130 int res = count; 132 int res = count;
131 unsigned char tmp; 133 unsigned char tmp;
132 134
133 down(&ice->gpio_mutex); 135 mutex_lock(&ice->gpio_mutex);
134 tmp = ap_cs8427_codec_select(ice); 136 tmp = ap_cs8427_codec_select(ice);
135 ap_cs8427_write_byte(ice, (device->addr << 1) | 0, tmp); /* address + write mode */ 137 ap_cs8427_write_byte(ice, (device->addr << 1) | 0, tmp); /* address + write mode */
136 while (count-- > 0) 138 while (count-- > 0)
137 ap_cs8427_write_byte(ice, *bytes++, tmp); 139 ap_cs8427_write_byte(ice, *bytes++, tmp);
138 ap_cs8427_codec_deassert(ice, tmp); 140 ap_cs8427_codec_deassert(ice, tmp);
139 up(&ice->gpio_mutex); 141 mutex_unlock(&ice->gpio_mutex);
140 return res; 142 return res;
141} 143}
142 144
@@ -147,13 +149,13 @@ static int ap_cs8427_readbytes(struct snd_i2c_device *device, unsigned char *byt
147 int res = count; 149 int res = count;
148 unsigned char tmp; 150 unsigned char tmp;
149 151
150 down(&ice->gpio_mutex); 152 mutex_lock(&ice->gpio_mutex);
151 tmp = ap_cs8427_codec_select(ice); 153 tmp = ap_cs8427_codec_select(ice);
152 ap_cs8427_write_byte(ice, (device->addr << 1) | 1, tmp); /* address + read mode */ 154 ap_cs8427_write_byte(ice, (device->addr << 1) | 1, tmp); /* address + read mode */
153 while (count-- > 0) 155 while (count-- > 0)
154 *bytes++ = ap_cs8427_read_byte(ice, tmp); 156 *bytes++ = ap_cs8427_read_byte(ice, tmp);
155 ap_cs8427_codec_deassert(ice, tmp); 157 ap_cs8427_codec_deassert(ice, tmp);
156 up(&ice->gpio_mutex); 158 mutex_unlock(&ice->gpio_mutex);
157 return res; 159 return res;
158} 160}
159 161
@@ -180,7 +182,7 @@ static void snd_ice1712_delta_cs8403_spdif_write(struct snd_ice1712 *ice, unsign
180 /* send byte to transmitter */ 182 /* send byte to transmitter */
181 mask1 = ICE1712_DELTA_SPDIF_OUT_STAT_CLOCK; 183 mask1 = ICE1712_DELTA_SPDIF_OUT_STAT_CLOCK;
182 mask2 = ICE1712_DELTA_SPDIF_OUT_STAT_DATA; 184 mask2 = ICE1712_DELTA_SPDIF_OUT_STAT_DATA;
183 down(&ice->gpio_mutex); 185 mutex_lock(&ice->gpio_mutex);
184 tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA); 186 tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
185 for (idx = 7; idx >= 0; idx--) { 187 for (idx = 7; idx >= 0; idx--) {
186 tmp &= ~(mask1 | mask2); 188 tmp &= ~(mask1 | mask2);
@@ -194,7 +196,7 @@ static void snd_ice1712_delta_cs8403_spdif_write(struct snd_ice1712 *ice, unsign
194 } 196 }
195 tmp &= ~mask1; 197 tmp &= ~mask1;
196 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp); 198 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
197 up(&ice->gpio_mutex); 199 mutex_unlock(&ice->gpio_mutex);
198} 200}
199 201
200 202
@@ -296,14 +298,14 @@ static void delta_1010_set_rate_val(struct snd_ice1712 *ice, unsigned int rate)
296 if (rate == 0) /* no hint - S/PDIF input is master, simply return */ 298 if (rate == 0) /* no hint - S/PDIF input is master, simply return */
297 return; 299 return;
298 300
299 down(&ice->gpio_mutex); 301 mutex_lock(&ice->gpio_mutex);
300 tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA); 302 tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
301 tmp2 = tmp & ~ICE1712_DELTA_DFS; 303 tmp2 = tmp & ~ICE1712_DELTA_DFS;
302 if (rate > 48000) 304 if (rate > 48000)
303 tmp2 |= ICE1712_DELTA_DFS; 305 tmp2 |= ICE1712_DELTA_DFS;
304 if (tmp != tmp2) 306 if (tmp != tmp2)
305 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp2); 307 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp2);
306 up(&ice->gpio_mutex); 308 mutex_unlock(&ice->gpio_mutex);
307} 309}
308 310
309/* 311/*
@@ -318,9 +320,9 @@ static void delta_ak4524_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
318 return; 320 return;
319 321
320 /* check before reset ak4524 to avoid unnecessary clicks */ 322 /* check before reset ak4524 to avoid unnecessary clicks */
321 down(&ice->gpio_mutex); 323 mutex_lock(&ice->gpio_mutex);
322 tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA); 324 tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
323 up(&ice->gpio_mutex); 325 mutex_unlock(&ice->gpio_mutex);
324 tmp2 = tmp & ~ICE1712_DELTA_DFS; 326 tmp2 = tmp & ~ICE1712_DELTA_DFS;
325 if (rate > 48000) 327 if (rate > 48000)
326 tmp2 |= ICE1712_DELTA_DFS; 328 tmp2 |= ICE1712_DELTA_DFS;
@@ -329,12 +331,12 @@ static void delta_ak4524_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
329 331
330 /* do it again */ 332 /* do it again */
331 snd_akm4xxx_reset(ak, 1); 333 snd_akm4xxx_reset(ak, 1);
332 down(&ice->gpio_mutex); 334 mutex_lock(&ice->gpio_mutex);
333 tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & ~ICE1712_DELTA_DFS; 335 tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & ~ICE1712_DELTA_DFS;
334 if (rate > 48000) 336 if (rate > 48000)
335 tmp |= ICE1712_DELTA_DFS; 337 tmp |= ICE1712_DELTA_DFS;
336 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp); 338 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
337 up(&ice->gpio_mutex); 339 mutex_unlock(&ice->gpio_mutex);
338 snd_akm4xxx_reset(ak, 0); 340 snd_akm4xxx_reset(ak, 0);
339} 341}
340 342
diff --git a/sound/pci/ice1712/hoontech.c b/sound/pci/ice1712/hoontech.c
index 3f2f918536f5..3f27d04e7d3c 100644
--- a/sound/pci/ice1712/hoontech.c
+++ b/sound/pci/ice1712/hoontech.c
@@ -27,6 +27,8 @@
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/mutex.h>
31
30#include <sound/core.h> 32#include <sound/core.h>
31 33
32#include "ice1712.h" 34#include "ice1712.h"
@@ -48,31 +50,31 @@ static void __devinit snd_ice1712_stdsp24_gpio_write(struct snd_ice1712 *ice, un
48 50
49static void __devinit snd_ice1712_stdsp24_darear(struct snd_ice1712 *ice, int activate) 51static void __devinit snd_ice1712_stdsp24_darear(struct snd_ice1712 *ice, int activate)
50{ 52{
51 down(&ice->gpio_mutex); 53 mutex_lock(&ice->gpio_mutex);
52 ICE1712_STDSP24_0_DAREAR(ice->spec.hoontech.boxbits, activate); 54 ICE1712_STDSP24_0_DAREAR(ice->spec.hoontech.boxbits, activate);
53 snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[0]); 55 snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[0]);
54 up(&ice->gpio_mutex); 56 mutex_unlock(&ice->gpio_mutex);
55} 57}
56 58
57static void __devinit snd_ice1712_stdsp24_mute(struct snd_ice1712 *ice, int activate) 59static void __devinit snd_ice1712_stdsp24_mute(struct snd_ice1712 *ice, int activate)
58{ 60{
59 down(&ice->gpio_mutex); 61 mutex_lock(&ice->gpio_mutex);
60 ICE1712_STDSP24_3_MUTE(ice->spec.hoontech.boxbits, activate); 62 ICE1712_STDSP24_3_MUTE(ice->spec.hoontech.boxbits, activate);
61 snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[3]); 63 snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[3]);
62 up(&ice->gpio_mutex); 64 mutex_unlock(&ice->gpio_mutex);
63} 65}
64 66
65static void __devinit snd_ice1712_stdsp24_insel(struct snd_ice1712 *ice, int activate) 67static void __devinit snd_ice1712_stdsp24_insel(struct snd_ice1712 *ice, int activate)
66{ 68{
67 down(&ice->gpio_mutex); 69 mutex_lock(&ice->gpio_mutex);
68 ICE1712_STDSP24_3_INSEL(ice->spec.hoontech.boxbits, activate); 70 ICE1712_STDSP24_3_INSEL(ice->spec.hoontech.boxbits, activate);
69 snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[3]); 71 snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[3]);
70 up(&ice->gpio_mutex); 72 mutex_unlock(&ice->gpio_mutex);
71} 73}
72 74
73static void __devinit snd_ice1712_stdsp24_box_channel(struct snd_ice1712 *ice, int box, int chn, int activate) 75static void __devinit snd_ice1712_stdsp24_box_channel(struct snd_ice1712 *ice, int box, int chn, int activate)
74{ 76{
75 down(&ice->gpio_mutex); 77 mutex_lock(&ice->gpio_mutex);
76 78
77 /* select box */ 79 /* select box */
78 ICE1712_STDSP24_0_BOX(ice->spec.hoontech.boxbits, box); 80 ICE1712_STDSP24_0_BOX(ice->spec.hoontech.boxbits, box);
@@ -115,12 +117,12 @@ static void __devinit snd_ice1712_stdsp24_box_channel(struct snd_ice1712 *ice, i
115 ICE1712_STDSP24_2_MIDI1(ice->spec.hoontech.boxbits, 0); 117 ICE1712_STDSP24_2_MIDI1(ice->spec.hoontech.boxbits, 0);
116 snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[2]); 118 snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[2]);
117 119
118 up(&ice->gpio_mutex); 120 mutex_unlock(&ice->gpio_mutex);
119} 121}
120 122
121static void __devinit snd_ice1712_stdsp24_box_midi(struct snd_ice1712 *ice, int box, int master) 123static void __devinit snd_ice1712_stdsp24_box_midi(struct snd_ice1712 *ice, int box, int master)
122{ 124{
123 down(&ice->gpio_mutex); 125 mutex_lock(&ice->gpio_mutex);
124 126
125 /* select box */ 127 /* select box */
126 ICE1712_STDSP24_0_BOX(ice->spec.hoontech.boxbits, box); 128 ICE1712_STDSP24_0_BOX(ice->spec.hoontech.boxbits, box);
@@ -141,15 +143,15 @@ static void __devinit snd_ice1712_stdsp24_box_midi(struct snd_ice1712 *ice, int
141 ICE1712_STDSP24_2_MIDIIN(ice->spec.hoontech.boxbits, 1); 143 ICE1712_STDSP24_2_MIDIIN(ice->spec.hoontech.boxbits, 1);
142 snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[2]); 144 snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[2]);
143 145
144 up(&ice->gpio_mutex); 146 mutex_unlock(&ice->gpio_mutex);
145} 147}
146 148
147static void __devinit snd_ice1712_stdsp24_midi2(struct snd_ice1712 *ice, int activate) 149static void __devinit snd_ice1712_stdsp24_midi2(struct snd_ice1712 *ice, int activate)
148{ 150{
149 down(&ice->gpio_mutex); 151 mutex_lock(&ice->gpio_mutex);
150 ICE1712_STDSP24_3_MIDI2(ice->spec.hoontech.boxbits, activate); 152 ICE1712_STDSP24_3_MIDI2(ice->spec.hoontech.boxbits, activate);
151 snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[3]); 153 snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[3]);
152 up(&ice->gpio_mutex); 154 mutex_unlock(&ice->gpio_mutex);
153} 155}
154 156
155static int __devinit snd_ice1712_hoontech_init(struct snd_ice1712 *ice) 157static int __devinit snd_ice1712_hoontech_init(struct snd_ice1712 *ice)
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index ef6f18558c95..3156a3132990 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -55,6 +55,7 @@
55#include <linux/pci.h> 55#include <linux/pci.h>
56#include <linux/slab.h> 56#include <linux/slab.h>
57#include <linux/moduleparam.h> 57#include <linux/moduleparam.h>
58#include <linux/mutex.h>
58#include <sound/core.h> 59#include <sound/core.h>
59#include <sound/cs8427.h> 60#include <sound/cs8427.h>
60#include <sound/info.h> 61#include <sound/info.h>
@@ -2557,9 +2558,9 @@ static int __devinit snd_ice1712_create(struct snd_card *card,
2557 cs8427_timeout = 1000; 2558 cs8427_timeout = 1000;
2558 ice->cs8427_timeout = cs8427_timeout; 2559 ice->cs8427_timeout = cs8427_timeout;
2559 spin_lock_init(&ice->reg_lock); 2560 spin_lock_init(&ice->reg_lock);
2560 init_MUTEX(&ice->gpio_mutex); 2561 mutex_init(&ice->gpio_mutex);
2561 init_MUTEX(&ice->i2c_mutex); 2562 mutex_init(&ice->i2c_mutex);
2562 init_MUTEX(&ice->open_mutex); 2563 mutex_init(&ice->open_mutex);
2563 ice->gpio.set_mask = snd_ice1712_set_gpio_mask; 2564 ice->gpio.set_mask = snd_ice1712_set_gpio_mask;
2564 ice->gpio.set_dir = snd_ice1712_set_gpio_dir; 2565 ice->gpio.set_dir = snd_ice1712_set_gpio_dir;
2565 ice->gpio.set_data = snd_ice1712_set_gpio_data; 2566 ice->gpio.set_data = snd_ice1712_set_gpio_data;
diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h
index ce96b3bb6531..d7416a83fcac 100644
--- a/sound/pci/ice1712/ice1712.h
+++ b/sound/pci/ice1712/ice1712.h
@@ -334,7 +334,7 @@ struct snd_ice1712 {
334 unsigned int num_total_adcs; /* total ADCs */ 334 unsigned int num_total_adcs; /* total ADCs */
335 unsigned int cur_rate; /* current rate */ 335 unsigned int cur_rate; /* current rate */
336 336
337 struct semaphore open_mutex; 337 struct mutex open_mutex;
338 struct snd_pcm_substream *pcm_reserved[4]; 338 struct snd_pcm_substream *pcm_reserved[4];
339 struct snd_pcm_hw_constraint_list *hw_rates; /* card-specific rate constraints */ 339 struct snd_pcm_hw_constraint_list *hw_rates; /* card-specific rate constraints */
340 340
@@ -342,7 +342,7 @@ struct snd_ice1712 {
342 struct snd_akm4xxx *akm; 342 struct snd_akm4xxx *akm;
343 struct snd_ice1712_spdif spdif; 343 struct snd_ice1712_spdif spdif;
344 344
345 struct semaphore i2c_mutex; /* I2C mutex for ICE1724 registers */ 345 struct mutex i2c_mutex; /* I2C mutex for ICE1724 registers */
346 struct snd_i2c_bus *i2c; /* I2C bus */ 346 struct snd_i2c_bus *i2c; /* I2C bus */
347 struct snd_i2c_device *cs8427; /* CS8427 I2C device */ 347 struct snd_i2c_device *cs8427; /* CS8427 I2C device */
348 unsigned int cs8427_timeout; /* CS8427 reset timeout in HZ/100 */ 348 unsigned int cs8427_timeout; /* CS8427 reset timeout in HZ/100 */
@@ -360,7 +360,7 @@ struct snd_ice1712 {
360 void (*set_pro_rate)(struct snd_ice1712 *ice, unsigned int rate); 360 void (*set_pro_rate)(struct snd_ice1712 *ice, unsigned int rate);
361 void (*i2s_mclk_changed)(struct snd_ice1712 *ice); 361 void (*i2s_mclk_changed)(struct snd_ice1712 *ice);
362 } gpio; 362 } gpio;
363 struct semaphore gpio_mutex; 363 struct mutex gpio_mutex;
364 364
365 /* other board-specific data */ 365 /* other board-specific data */
366 union { 366 union {
@@ -423,7 +423,7 @@ static inline unsigned int snd_ice1712_gpio_read(struct snd_ice1712 *ice)
423 */ 423 */
424static inline void snd_ice1712_save_gpio_status(struct snd_ice1712 *ice) 424static inline void snd_ice1712_save_gpio_status(struct snd_ice1712 *ice)
425{ 425{
426 down(&ice->gpio_mutex); 426 mutex_lock(&ice->gpio_mutex);
427 ice->gpio.saved[0] = ice->gpio.direction; 427 ice->gpio.saved[0] = ice->gpio.direction;
428 ice->gpio.saved[1] = ice->gpio.write_mask; 428 ice->gpio.saved[1] = ice->gpio.write_mask;
429} 429}
@@ -434,7 +434,7 @@ static inline void snd_ice1712_restore_gpio_status(struct snd_ice1712 *ice)
434 ice->gpio.set_mask(ice, ice->gpio.saved[1]); 434 ice->gpio.set_mask(ice, ice->gpio.saved[1]);
435 ice->gpio.direction = ice->gpio.saved[0]; 435 ice->gpio.direction = ice->gpio.saved[0];
436 ice->gpio.write_mask = ice->gpio.saved[1]; 436 ice->gpio.write_mask = ice->gpio.saved[1];
437 up(&ice->gpio_mutex); 437 mutex_unlock(&ice->gpio_mutex);
438} 438}
439 439
440/* for bit controls */ 440/* for bit controls */
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 71f08c036019..fce616c2761f 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -30,6 +30,7 @@
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/moduleparam.h> 32#include <linux/moduleparam.h>
33#include <linux/mutex.h>
33#include <sound/core.h> 34#include <sound/core.h>
34#include <sound/info.h> 35#include <sound/info.h>
35#include <sound/mpu401.h> 36#include <sound/mpu401.h>
@@ -487,7 +488,7 @@ static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream,
487 int i, chs; 488 int i, chs;
488 489
489 chs = params_channels(hw_params); 490 chs = params_channels(hw_params);
490 down(&ice->open_mutex); 491 mutex_lock(&ice->open_mutex);
491 /* mark surround channels */ 492 /* mark surround channels */
492 if (substream == ice->playback_pro_substream) { 493 if (substream == ice->playback_pro_substream) {
493 /* PDMA0 can be multi-channel up to 8 */ 494 /* PDMA0 can be multi-channel up to 8 */
@@ -495,7 +496,7 @@ static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream,
495 for (i = 0; i < chs; i++) { 496 for (i = 0; i < chs; i++) {
496 if (ice->pcm_reserved[i] && 497 if (ice->pcm_reserved[i] &&
497 ice->pcm_reserved[i] != substream) { 498 ice->pcm_reserved[i] != substream) {
498 up(&ice->open_mutex); 499 mutex_unlock(&ice->open_mutex);
499 return -EBUSY; 500 return -EBUSY;
500 } 501 }
501 ice->pcm_reserved[i] = substream; 502 ice->pcm_reserved[i] = substream;
@@ -510,7 +511,7 @@ static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream,
510 if (ice->playback_con_substream_ds[i] == substream) { 511 if (ice->playback_con_substream_ds[i] == substream) {
511 if (ice->pcm_reserved[i] && 512 if (ice->pcm_reserved[i] &&
512 ice->pcm_reserved[i] != substream) { 513 ice->pcm_reserved[i] != substream) {
513 up(&ice->open_mutex); 514 mutex_unlock(&ice->open_mutex);
514 return -EBUSY; 515 return -EBUSY;
515 } 516 }
516 ice->pcm_reserved[i] = substream; 517 ice->pcm_reserved[i] = substream;
@@ -518,7 +519,7 @@ static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream,
518 } 519 }
519 } 520 }
520 } 521 }
521 up(&ice->open_mutex); 522 mutex_unlock(&ice->open_mutex);
522 snd_vt1724_set_pro_rate(ice, params_rate(hw_params), 0); 523 snd_vt1724_set_pro_rate(ice, params_rate(hw_params), 0);
523 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 524 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
524} 525}
@@ -528,12 +529,12 @@ static int snd_vt1724_pcm_hw_free(struct snd_pcm_substream *substream)
528 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 529 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
529 int i; 530 int i;
530 531
531 down(&ice->open_mutex); 532 mutex_lock(&ice->open_mutex);
532 /* unmark surround channels */ 533 /* unmark surround channels */
533 for (i = 0; i < 3; i++) 534 for (i = 0; i < 3; i++)
534 if (ice->pcm_reserved[i] == substream) 535 if (ice->pcm_reserved[i] == substream)
535 ice->pcm_reserved[i] = NULL; 536 ice->pcm_reserved[i] = NULL;
536 up(&ice->open_mutex); 537 mutex_unlock(&ice->open_mutex);
537 return snd_pcm_lib_free_pages(substream); 538 return snd_pcm_lib_free_pages(substream);
538} 539}
539 540
@@ -778,7 +779,7 @@ static int snd_vt1724_playback_pro_open(struct snd_pcm_substream *substream)
778 snd_pcm_set_sync(substream); 779 snd_pcm_set_sync(substream);
779 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); 780 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
780 set_rate_constraints(ice, substream); 781 set_rate_constraints(ice, substream);
781 down(&ice->open_mutex); 782 mutex_lock(&ice->open_mutex);
782 /* calculate the currently available channels */ 783 /* calculate the currently available channels */
783 for (chs = 0; chs < 3; chs++) { 784 for (chs = 0; chs < 3; chs++) {
784 if (ice->pcm_reserved[chs]) 785 if (ice->pcm_reserved[chs])
@@ -788,7 +789,7 @@ static int snd_vt1724_playback_pro_open(struct snd_pcm_substream *substream)
788 runtime->hw.channels_max = chs; 789 runtime->hw.channels_max = chs;
789 if (chs > 2) /* channels must be even */ 790 if (chs > 2) /* channels must be even */
790 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 2); 791 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 2);
791 up(&ice->open_mutex); 792 mutex_unlock(&ice->open_mutex);
792 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 793 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
793 VT1724_BUFFER_ALIGN); 794 VT1724_BUFFER_ALIGN);
794 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 795 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
@@ -1128,13 +1129,13 @@ static int snd_vt1724_playback_indep_open(struct snd_pcm_substream *substream)
1128 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 1129 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1129 struct snd_pcm_runtime *runtime = substream->runtime; 1130 struct snd_pcm_runtime *runtime = substream->runtime;
1130 1131
1131 down(&ice->open_mutex); 1132 mutex_lock(&ice->open_mutex);
1132 /* already used by PDMA0? */ 1133 /* already used by PDMA0? */
1133 if (ice->pcm_reserved[substream->number]) { 1134 if (ice->pcm_reserved[substream->number]) {
1134 up(&ice->open_mutex); 1135 mutex_unlock(&ice->open_mutex);
1135 return -EBUSY; /* FIXME: should handle blocking mode properly */ 1136 return -EBUSY; /* FIXME: should handle blocking mode properly */
1136 } 1137 }
1137 up(&ice->open_mutex); 1138 mutex_unlock(&ice->open_mutex);
1138 runtime->private_data = &vt1724_playback_dma_regs[substream->number]; 1139 runtime->private_data = &vt1724_playback_dma_regs[substream->number];
1139 ice->playback_con_substream_ds[substream->number] = substream; 1140 ice->playback_con_substream_ds[substream->number] = substream;
1140 runtime->hw = snd_vt1724_2ch_stereo; 1141 runtime->hw = snd_vt1724_2ch_stereo;
@@ -1978,12 +1979,12 @@ unsigned char snd_vt1724_read_i2c(struct snd_ice1712 *ice,
1978{ 1979{
1979 unsigned char val; 1980 unsigned char val;
1980 1981
1981 down(&ice->i2c_mutex); 1982 mutex_lock(&ice->i2c_mutex);
1982 outb(addr, ICEREG1724(ice, I2C_BYTE_ADDR)); 1983 outb(addr, ICEREG1724(ice, I2C_BYTE_ADDR));
1983 outb(dev & ~VT1724_I2C_WRITE, ICEREG1724(ice, I2C_DEV_ADDR)); 1984 outb(dev & ~VT1724_I2C_WRITE, ICEREG1724(ice, I2C_DEV_ADDR));
1984 wait_i2c_busy(ice); 1985 wait_i2c_busy(ice);
1985 val = inb(ICEREG1724(ice, I2C_DATA)); 1986 val = inb(ICEREG1724(ice, I2C_DATA));
1986 up(&ice->i2c_mutex); 1987 mutex_unlock(&ice->i2c_mutex);
1987 //printk("i2c_read: [0x%x,0x%x] = 0x%x\n", dev, addr, val); 1988 //printk("i2c_read: [0x%x,0x%x] = 0x%x\n", dev, addr, val);
1988 return val; 1989 return val;
1989} 1990}
@@ -1991,14 +1992,14 @@ unsigned char snd_vt1724_read_i2c(struct snd_ice1712 *ice,
1991void snd_vt1724_write_i2c(struct snd_ice1712 *ice, 1992void snd_vt1724_write_i2c(struct snd_ice1712 *ice,
1992 unsigned char dev, unsigned char addr, unsigned char data) 1993 unsigned char dev, unsigned char addr, unsigned char data)
1993{ 1994{
1994 down(&ice->i2c_mutex); 1995 mutex_lock(&ice->i2c_mutex);
1995 wait_i2c_busy(ice); 1996 wait_i2c_busy(ice);
1996 //printk("i2c_write: [0x%x,0x%x] = 0x%x\n", dev, addr, data); 1997 //printk("i2c_write: [0x%x,0x%x] = 0x%x\n", dev, addr, data);
1997 outb(addr, ICEREG1724(ice, I2C_BYTE_ADDR)); 1998 outb(addr, ICEREG1724(ice, I2C_BYTE_ADDR));
1998 outb(data, ICEREG1724(ice, I2C_DATA)); 1999 outb(data, ICEREG1724(ice, I2C_DATA));
1999 outb(dev | VT1724_I2C_WRITE, ICEREG1724(ice, I2C_DEV_ADDR)); 2000 outb(dev | VT1724_I2C_WRITE, ICEREG1724(ice, I2C_DEV_ADDR));
2000 wait_i2c_busy(ice); 2001 wait_i2c_busy(ice);
2001 up(&ice->i2c_mutex); 2002 mutex_unlock(&ice->i2c_mutex);
2002} 2003}
2003 2004
2004static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice, 2005static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
@@ -2229,9 +2230,9 @@ static int __devinit snd_vt1724_create(struct snd_card *card,
2229 } 2230 }
2230 ice->vt1724 = 1; 2231 ice->vt1724 = 1;
2231 spin_lock_init(&ice->reg_lock); 2232 spin_lock_init(&ice->reg_lock);
2232 init_MUTEX(&ice->gpio_mutex); 2233 mutex_init(&ice->gpio_mutex);
2233 init_MUTEX(&ice->open_mutex); 2234 mutex_init(&ice->open_mutex);
2234 init_MUTEX(&ice->i2c_mutex); 2235 mutex_init(&ice->i2c_mutex);
2235 ice->gpio.set_mask = snd_vt1724_set_gpio_mask; 2236 ice->gpio.set_mask = snd_vt1724_set_gpio_mask;
2236 ice->gpio.set_dir = snd_vt1724_set_gpio_dir; 2237 ice->gpio.set_dir = snd_vt1724_set_gpio_dir;
2237 ice->gpio.set_data = snd_vt1724_set_gpio_data; 2238 ice->gpio.set_data = snd_vt1724_set_gpio_data;
diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c
index ec3757834b93..502da1c8b5f7 100644
--- a/sound/pci/ice1712/phase.c
+++ b/sound/pci/ice1712/phase.c
@@ -39,6 +39,8 @@
39#include <linux/interrupt.h> 39#include <linux/interrupt.h>
40#include <linux/init.h> 40#include <linux/init.h>
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <linux/mutex.h>
43
42#include <sound/core.h> 44#include <sound/core.h>
43 45
44#include "ice1712.h" 46#include "ice1712.h"
@@ -273,9 +275,9 @@ static int wm_pcm_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_va
273{ 275{
274 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 276 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
275 277
276 down(&ice->gpio_mutex); 278 mutex_lock(&ice->gpio_mutex);
277 ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ? 0 : 1; 279 ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ? 0 : 1;
278 up(&ice->gpio_mutex); 280 mutex_unlock(&ice->gpio_mutex);
279 return 0; 281 return 0;
280} 282}
281 283
@@ -584,11 +586,11 @@ static int wm_pcm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
584 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 586 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
585 unsigned short val; 587 unsigned short val;
586 588
587 down(&ice->gpio_mutex); 589 mutex_lock(&ice->gpio_mutex);
588 val = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff; 590 val = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff;
589 val = val > PCM_MIN ? (val - PCM_MIN) : 0; 591 val = val > PCM_MIN ? (val - PCM_MIN) : 0;
590 ucontrol->value.integer.value[0] = val; 592 ucontrol->value.integer.value[0] = val;
591 up(&ice->gpio_mutex); 593 mutex_unlock(&ice->gpio_mutex);
592 return 0; 594 return 0;
593} 595}
594 596
diff --git a/sound/pci/ice1712/pontis.c b/sound/pci/ice1712/pontis.c
index 0dccd7707a4b..d23fb3fc2133 100644
--- a/sound/pci/ice1712/pontis.c
+++ b/sound/pci/ice1712/pontis.c
@@ -27,6 +27,8 @@
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/mutex.h>
31
30#include <sound/core.h> 32#include <sound/core.h>
31#include <sound/info.h> 33#include <sound/info.h>
32 34
@@ -124,13 +126,13 @@ static int wm_dac_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
124 unsigned short val; 126 unsigned short val;
125 int i; 127 int i;
126 128
127 down(&ice->gpio_mutex); 129 mutex_lock(&ice->gpio_mutex);
128 for (i = 0; i < 2; i++) { 130 for (i = 0; i < 2; i++) {
129 val = wm_get(ice, WM_DAC_ATTEN_L + i) & 0xff; 131 val = wm_get(ice, WM_DAC_ATTEN_L + i) & 0xff;
130 val = val > DAC_MIN ? (val - DAC_MIN) : 0; 132 val = val > DAC_MIN ? (val - DAC_MIN) : 0;
131 ucontrol->value.integer.value[i] = val; 133 ucontrol->value.integer.value[i] = val;
132 } 134 }
133 up(&ice->gpio_mutex); 135 mutex_unlock(&ice->gpio_mutex);
134 return 0; 136 return 0;
135} 137}
136 138
@@ -140,7 +142,7 @@ static int wm_dac_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
140 unsigned short oval, nval; 142 unsigned short oval, nval;
141 int i, idx, change = 0; 143 int i, idx, change = 0;
142 144
143 down(&ice->gpio_mutex); 145 mutex_lock(&ice->gpio_mutex);
144 for (i = 0; i < 2; i++) { 146 for (i = 0; i < 2; i++) {
145 nval = ucontrol->value.integer.value[i]; 147 nval = ucontrol->value.integer.value[i];
146 nval = (nval ? (nval + DAC_MIN) : 0) & 0xff; 148 nval = (nval ? (nval + DAC_MIN) : 0) & 0xff;
@@ -152,7 +154,7 @@ static int wm_dac_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
152 change = 1; 154 change = 1;
153 } 155 }
154 } 156 }
155 up(&ice->gpio_mutex); 157 mutex_unlock(&ice->gpio_mutex);
156 return change; 158 return change;
157} 159}
158 160
@@ -179,13 +181,13 @@ static int wm_adc_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
179 unsigned short val; 181 unsigned short val;
180 int i; 182 int i;
181 183
182 down(&ice->gpio_mutex); 184 mutex_lock(&ice->gpio_mutex);
183 for (i = 0; i < 2; i++) { 185 for (i = 0; i < 2; i++) {
184 val = wm_get(ice, WM_ADC_ATTEN_L + i) & 0xff; 186 val = wm_get(ice, WM_ADC_ATTEN_L + i) & 0xff;
185 val = val > ADC_MIN ? (val - ADC_MIN) : 0; 187 val = val > ADC_MIN ? (val - ADC_MIN) : 0;
186 ucontrol->value.integer.value[i] = val; 188 ucontrol->value.integer.value[i] = val;
187 } 189 }
188 up(&ice->gpio_mutex); 190 mutex_unlock(&ice->gpio_mutex);
189 return 0; 191 return 0;
190} 192}
191 193
@@ -195,7 +197,7 @@ static int wm_adc_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
195 unsigned short ovol, nvol; 197 unsigned short ovol, nvol;
196 int i, idx, change = 0; 198 int i, idx, change = 0;
197 199
198 down(&ice->gpio_mutex); 200 mutex_lock(&ice->gpio_mutex);
199 for (i = 0; i < 2; i++) { 201 for (i = 0; i < 2; i++) {
200 nvol = ucontrol->value.integer.value[i]; 202 nvol = ucontrol->value.integer.value[i];
201 nvol = nvol ? (nvol + ADC_MIN) : 0; 203 nvol = nvol ? (nvol + ADC_MIN) : 0;
@@ -206,7 +208,7 @@ static int wm_adc_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
206 change = 1; 208 change = 1;
207 } 209 }
208 } 210 }
209 up(&ice->gpio_mutex); 211 mutex_unlock(&ice->gpio_mutex);
210 return change; 212 return change;
211} 213}
212 214
@@ -227,9 +229,9 @@ static int wm_adc_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
227 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 229 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
228 int bit = kcontrol->private_value; 230 int bit = kcontrol->private_value;
229 231
230 down(&ice->gpio_mutex); 232 mutex_lock(&ice->gpio_mutex);
231 ucontrol->value.integer.value[0] = (wm_get(ice, WM_ADC_MUX) & (1 << bit)) ? 1 : 0; 233 ucontrol->value.integer.value[0] = (wm_get(ice, WM_ADC_MUX) & (1 << bit)) ? 1 : 0;
232 up(&ice->gpio_mutex); 234 mutex_unlock(&ice->gpio_mutex);
233 return 0; 235 return 0;
234} 236}
235 237
@@ -240,7 +242,7 @@ static int wm_adc_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
240 unsigned short oval, nval; 242 unsigned short oval, nval;
241 int change; 243 int change;
242 244
243 down(&ice->gpio_mutex); 245 mutex_lock(&ice->gpio_mutex);
244 nval = oval = wm_get(ice, WM_ADC_MUX); 246 nval = oval = wm_get(ice, WM_ADC_MUX);
245 if (ucontrol->value.integer.value[0]) 247 if (ucontrol->value.integer.value[0])
246 nval |= (1 << bit); 248 nval |= (1 << bit);
@@ -250,7 +252,7 @@ static int wm_adc_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
250 if (change) { 252 if (change) {
251 wm_put(ice, WM_ADC_MUX, nval); 253 wm_put(ice, WM_ADC_MUX, nval);
252 } 254 }
253 up(&ice->gpio_mutex); 255 mutex_unlock(&ice->gpio_mutex);
254 return 0; 256 return 0;
255} 257}
256 258
@@ -270,9 +272,9 @@ static int wm_bypass_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
270{ 272{
271 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 273 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
272 274
273 down(&ice->gpio_mutex); 275 mutex_lock(&ice->gpio_mutex);
274 ucontrol->value.integer.value[0] = (wm_get(ice, WM_OUT_MUX) & 0x04) ? 1 : 0; 276 ucontrol->value.integer.value[0] = (wm_get(ice, WM_OUT_MUX) & 0x04) ? 1 : 0;
275 up(&ice->gpio_mutex); 277 mutex_unlock(&ice->gpio_mutex);
276 return 0; 278 return 0;
277} 279}
278 280
@@ -282,7 +284,7 @@ static int wm_bypass_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
282 unsigned short val, oval; 284 unsigned short val, oval;
283 int change = 0; 285 int change = 0;
284 286
285 down(&ice->gpio_mutex); 287 mutex_lock(&ice->gpio_mutex);
286 val = oval = wm_get(ice, WM_OUT_MUX); 288 val = oval = wm_get(ice, WM_OUT_MUX);
287 if (ucontrol->value.integer.value[0]) 289 if (ucontrol->value.integer.value[0])
288 val |= 0x04; 290 val |= 0x04;
@@ -292,7 +294,7 @@ static int wm_bypass_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
292 wm_put(ice, WM_OUT_MUX, val); 294 wm_put(ice, WM_OUT_MUX, val);
293 change = 1; 295 change = 1;
294 } 296 }
295 up(&ice->gpio_mutex); 297 mutex_unlock(&ice->gpio_mutex);
296 return change; 298 return change;
297} 299}
298 300
@@ -312,9 +314,9 @@ static int wm_chswap_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
312{ 314{
313 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 315 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
314 316
315 down(&ice->gpio_mutex); 317 mutex_lock(&ice->gpio_mutex);
316 ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL1) & 0xf0) != 0x90; 318 ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL1) & 0xf0) != 0x90;
317 up(&ice->gpio_mutex); 319 mutex_unlock(&ice->gpio_mutex);
318 return 0; 320 return 0;
319} 321}
320 322
@@ -324,7 +326,7 @@ static int wm_chswap_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
324 unsigned short val, oval; 326 unsigned short val, oval;
325 int change = 0; 327 int change = 0;
326 328
327 down(&ice->gpio_mutex); 329 mutex_lock(&ice->gpio_mutex);
328 oval = wm_get(ice, WM_DAC_CTRL1); 330 oval = wm_get(ice, WM_DAC_CTRL1);
329 val = oval & 0x0f; 331 val = oval & 0x0f;
330 if (ucontrol->value.integer.value[0]) 332 if (ucontrol->value.integer.value[0])
@@ -336,7 +338,7 @@ static int wm_chswap_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
336 wm_put_nocache(ice, WM_DAC_CTRL1, val); 338 wm_put_nocache(ice, WM_DAC_CTRL1, val);
337 change = 1; 339 change = 1;
338 } 340 }
339 up(&ice->gpio_mutex); 341 mutex_unlock(&ice->gpio_mutex);
340 return change; 342 return change;
341} 343}
342 344
@@ -449,9 +451,9 @@ static int cs_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
449{ 451{
450 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 452 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
451 453
452 down(&ice->gpio_mutex); 454 mutex_lock(&ice->gpio_mutex);
453 ucontrol->value.enumerated.item[0] = ice->gpio.saved[0]; 455 ucontrol->value.enumerated.item[0] = ice->gpio.saved[0];
454 up(&ice->gpio_mutex); 456 mutex_unlock(&ice->gpio_mutex);
455 return 0; 457 return 0;
456} 458}
457 459
@@ -461,14 +463,14 @@ static int cs_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
461 unsigned char val; 463 unsigned char val;
462 int change = 0; 464 int change = 0;
463 465
464 down(&ice->gpio_mutex); 466 mutex_lock(&ice->gpio_mutex);
465 if (ucontrol->value.enumerated.item[0] != ice->gpio.saved[0]) { 467 if (ucontrol->value.enumerated.item[0] != ice->gpio.saved[0]) {
466 ice->gpio.saved[0] = ucontrol->value.enumerated.item[0] & 3; 468 ice->gpio.saved[0] = ucontrol->value.enumerated.item[0] & 3;
467 val = 0x80 | (ice->gpio.saved[0] << 3); 469 val = 0x80 | (ice->gpio.saved[0] << 3);
468 spi_write(ice, CS_DEV, 0x04, val); 470 spi_write(ice, CS_DEV, 0x04, val);
469 change = 1; 471 change = 1;
470 } 472 }
471 up(&ice->gpio_mutex); 473 mutex_unlock(&ice->gpio_mutex);
472 return 0; 474 return 0;
473} 475}
474 476
@@ -488,10 +490,10 @@ static int pontis_gpio_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_e
488static int pontis_gpio_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 490static int pontis_gpio_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
489{ 491{
490 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 492 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
491 down(&ice->gpio_mutex); 493 mutex_lock(&ice->gpio_mutex);
492 /* 4-7 reserved */ 494 /* 4-7 reserved */
493 ucontrol->value.integer.value[0] = (~ice->gpio.write_mask & 0xffff) | 0x00f0; 495 ucontrol->value.integer.value[0] = (~ice->gpio.write_mask & 0xffff) | 0x00f0;
494 up(&ice->gpio_mutex); 496 mutex_unlock(&ice->gpio_mutex);
495 return 0; 497 return 0;
496} 498}
497 499
@@ -500,22 +502,22 @@ static int pontis_gpio_mask_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
500 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 502 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
501 unsigned int val; 503 unsigned int val;
502 int changed; 504 int changed;
503 down(&ice->gpio_mutex); 505 mutex_lock(&ice->gpio_mutex);
504 /* 4-7 reserved */ 506 /* 4-7 reserved */
505 val = (~ucontrol->value.integer.value[0] & 0xffff) | 0x00f0; 507 val = (~ucontrol->value.integer.value[0] & 0xffff) | 0x00f0;
506 changed = val != ice->gpio.write_mask; 508 changed = val != ice->gpio.write_mask;
507 ice->gpio.write_mask = val; 509 ice->gpio.write_mask = val;
508 up(&ice->gpio_mutex); 510 mutex_unlock(&ice->gpio_mutex);
509 return changed; 511 return changed;
510} 512}
511 513
512static int pontis_gpio_dir_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 514static int pontis_gpio_dir_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
513{ 515{
514 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 516 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
515 down(&ice->gpio_mutex); 517 mutex_lock(&ice->gpio_mutex);
516 /* 4-7 reserved */ 518 /* 4-7 reserved */
517 ucontrol->value.integer.value[0] = ice->gpio.direction & 0xff0f; 519 ucontrol->value.integer.value[0] = ice->gpio.direction & 0xff0f;
518 up(&ice->gpio_mutex); 520 mutex_unlock(&ice->gpio_mutex);
519 return 0; 521 return 0;
520} 522}
521 523
@@ -524,23 +526,23 @@ static int pontis_gpio_dir_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
524 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 526 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
525 unsigned int val; 527 unsigned int val;
526 int changed; 528 int changed;
527 down(&ice->gpio_mutex); 529 mutex_lock(&ice->gpio_mutex);
528 /* 4-7 reserved */ 530 /* 4-7 reserved */
529 val = ucontrol->value.integer.value[0] & 0xff0f; 531 val = ucontrol->value.integer.value[0] & 0xff0f;
530 changed = (val != ice->gpio.direction); 532 changed = (val != ice->gpio.direction);
531 ice->gpio.direction = val; 533 ice->gpio.direction = val;
532 up(&ice->gpio_mutex); 534 mutex_unlock(&ice->gpio_mutex);
533 return changed; 535 return changed;
534} 536}
535 537
536static int pontis_gpio_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 538static int pontis_gpio_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
537{ 539{
538 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 540 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
539 down(&ice->gpio_mutex); 541 mutex_lock(&ice->gpio_mutex);
540 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction); 542 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction);
541 snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask); 543 snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask);
542 ucontrol->value.integer.value[0] = snd_ice1712_gpio_read(ice) & 0xffff; 544 ucontrol->value.integer.value[0] = snd_ice1712_gpio_read(ice) & 0xffff;
543 up(&ice->gpio_mutex); 545 mutex_unlock(&ice->gpio_mutex);
544 return 0; 546 return 0;
545} 547}
546 548
@@ -549,7 +551,7 @@ static int pontis_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
549 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 551 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
550 unsigned int val, nval; 552 unsigned int val, nval;
551 int changed = 0; 553 int changed = 0;
552 down(&ice->gpio_mutex); 554 mutex_lock(&ice->gpio_mutex);
553 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction); 555 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction);
554 snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask); 556 snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask);
555 val = snd_ice1712_gpio_read(ice) & 0xffff; 557 val = snd_ice1712_gpio_read(ice) & 0xffff;
@@ -558,7 +560,7 @@ static int pontis_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
558 snd_ice1712_gpio_write(ice, nval); 560 snd_ice1712_gpio_write(ice, nval);
559 changed = 1; 561 changed = 1;
560 } 562 }
561 up(&ice->gpio_mutex); 563 mutex_unlock(&ice->gpio_mutex);
562 return changed; 564 return changed;
563} 565}
564 566
@@ -651,14 +653,14 @@ static void wm_proc_regs_write(struct snd_info_entry *entry, struct snd_info_buf
651 struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data; 653 struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data;
652 char line[64]; 654 char line[64];
653 unsigned int reg, val; 655 unsigned int reg, val;
654 down(&ice->gpio_mutex); 656 mutex_lock(&ice->gpio_mutex);
655 while (!snd_info_get_line(buffer, line, sizeof(line))) { 657 while (!snd_info_get_line(buffer, line, sizeof(line))) {
656 if (sscanf(line, "%x %x", &reg, &val) != 2) 658 if (sscanf(line, "%x %x", &reg, &val) != 2)
657 continue; 659 continue;
658 if (reg <= 0x17 && val <= 0xffff) 660 if (reg <= 0x17 && val <= 0xffff)
659 wm_put(ice, reg, val); 661 wm_put(ice, reg, val);
660 } 662 }
661 up(&ice->gpio_mutex); 663 mutex_unlock(&ice->gpio_mutex);
662} 664}
663 665
664static void wm_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) 666static void wm_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
@@ -666,12 +668,12 @@ static void wm_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buff
666 struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data; 668 struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data;
667 int reg, val; 669 int reg, val;
668 670
669 down(&ice->gpio_mutex); 671 mutex_lock(&ice->gpio_mutex);
670 for (reg = 0; reg <= 0x17; reg++) { 672 for (reg = 0; reg <= 0x17; reg++) {
671 val = wm_get(ice, reg); 673 val = wm_get(ice, reg);
672 snd_iprintf(buffer, "%02x = %04x\n", reg, val); 674 snd_iprintf(buffer, "%02x = %04x\n", reg, val);
673 } 675 }
674 up(&ice->gpio_mutex); 676 mutex_unlock(&ice->gpio_mutex);
675} 677}
676 678
677static void wm_proc_init(struct snd_ice1712 *ice) 679static void wm_proc_init(struct snd_ice1712 *ice)
@@ -690,14 +692,14 @@ static void cs_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buff
690 struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data; 692 struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data;
691 int reg, val; 693 int reg, val;
692 694
693 down(&ice->gpio_mutex); 695 mutex_lock(&ice->gpio_mutex);
694 for (reg = 0; reg <= 0x26; reg++) { 696 for (reg = 0; reg <= 0x26; reg++) {
695 val = spi_read(ice, CS_DEV, reg); 697 val = spi_read(ice, CS_DEV, reg);
696 snd_iprintf(buffer, "%02x = %02x\n", reg, val); 698 snd_iprintf(buffer, "%02x = %02x\n", reg, val);
697 } 699 }
698 val = spi_read(ice, CS_DEV, 0x7f); 700 val = spi_read(ice, CS_DEV, 0x7f);
699 snd_iprintf(buffer, "%02x = %02x\n", 0x7f, val); 701 snd_iprintf(buffer, "%02x = %02x\n", 0x7f, val);
700 up(&ice->gpio_mutex); 702 mutex_unlock(&ice->gpio_mutex);
701} 703}
702 704
703static void cs_proc_init(struct snd_ice1712 *ice) 705static void cs_proc_init(struct snd_ice1712 *ice)
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 4eddb512c12f..4721c096335e 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -27,6 +27,7 @@
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/wait.h> 28#include <linux/wait.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/mutex.h>
30 31
31#include <sound/core.h> 32#include <sound/core.h>
32#include <sound/info.h> 33#include <sound/info.h>
@@ -325,7 +326,7 @@ struct snd_korg1212 {
325 int irq; 326 int irq;
326 327
327 spinlock_t lock; 328 spinlock_t lock;
328 struct semaphore open_mutex; 329 struct mutex open_mutex;
329 330
330 struct timer_list timer; /* timer callback for checking ack of stop request */ 331 struct timer_list timer; /* timer callback for checking ack of stop request */
331 int stop_pending_cnt; /* counter for stop pending check */ 332 int stop_pending_cnt; /* counter for stop pending check */
@@ -667,13 +668,13 @@ static int snd_korg1212_OpenCard(struct snd_korg1212 * korg1212)
667{ 668{
668 K1212_DEBUG_PRINTK("K1212_DEBUG: OpenCard [%s] %d\n", 669 K1212_DEBUG_PRINTK("K1212_DEBUG: OpenCard [%s] %d\n",
669 stateName[korg1212->cardState], korg1212->opencnt); 670 stateName[korg1212->cardState], korg1212->opencnt);
670 down(&korg1212->open_mutex); 671 mutex_lock(&korg1212->open_mutex);
671 if (korg1212->opencnt++ == 0) { 672 if (korg1212->opencnt++ == 0) {
672 snd_korg1212_TurnOffIdleMonitor(korg1212); 673 snd_korg1212_TurnOffIdleMonitor(korg1212);
673 snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN); 674 snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN);
674 } 675 }
675 676
676 up(&korg1212->open_mutex); 677 mutex_unlock(&korg1212->open_mutex);
677 return 1; 678 return 1;
678} 679}
679 680
@@ -682,9 +683,9 @@ static int snd_korg1212_CloseCard(struct snd_korg1212 * korg1212)
682 K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard [%s] %d\n", 683 K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard [%s] %d\n",
683 stateName[korg1212->cardState], korg1212->opencnt); 684 stateName[korg1212->cardState], korg1212->opencnt);
684 685
685 down(&korg1212->open_mutex); 686 mutex_lock(&korg1212->open_mutex);
686 if (--(korg1212->opencnt)) { 687 if (--(korg1212->opencnt)) {
687 up(&korg1212->open_mutex); 688 mutex_unlock(&korg1212->open_mutex);
688 return 0; 689 return 0;
689 } 690 }
690 691
@@ -695,7 +696,7 @@ static int snd_korg1212_CloseCard(struct snd_korg1212 * korg1212)
695 K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard - RC = %d [%s]\n", 696 K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard - RC = %d [%s]\n",
696 rc, stateName[korg1212->cardState]); 697 rc, stateName[korg1212->cardState]);
697 if (rc != K1212_CMDRET_Success) { 698 if (rc != K1212_CMDRET_Success) {
698 up(&korg1212->open_mutex); 699 mutex_unlock(&korg1212->open_mutex);
699 return 0; 700 return 0;
700 } 701 }
701 } else if (korg1212->cardState > K1212_STATE_SETUP) { 702 } else if (korg1212->cardState > K1212_STATE_SETUP) {
@@ -707,7 +708,7 @@ static int snd_korg1212_CloseCard(struct snd_korg1212 * korg1212)
707 snd_korg1212_setCardState(korg1212, K1212_STATE_READY); 708 snd_korg1212_setCardState(korg1212, K1212_STATE_READY);
708 } 709 }
709 710
710 up(&korg1212->open_mutex); 711 mutex_unlock(&korg1212->open_mutex);
711 return 0; 712 return 0;
712} 713}
713 714
@@ -2179,7 +2180,7 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
2179 2180
2180 init_waitqueue_head(&korg1212->wait); 2181 init_waitqueue_head(&korg1212->wait);
2181 spin_lock_init(&korg1212->lock); 2182 spin_lock_init(&korg1212->lock);
2182 init_MUTEX(&korg1212->open_mutex); 2183 mutex_init(&korg1212->open_mutex);
2183 init_timer(&korg1212->timer); 2184 init_timer(&korg1212->timer);
2184 korg1212->timer.function = snd_korg1212_timer_func; 2185 korg1212->timer.function = snd_korg1212_timer_func;
2185 korg1212->timer.data = (unsigned long)korg1212; 2186 korg1212->timer.data = (unsigned long)korg1212;
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index b218e1d20c78..e79fb264532b 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -26,6 +26,7 @@
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
29#include <linux/mutex.h>
29#include <sound/core.h> 30#include <sound/core.h>
30#include <sound/initval.h> 31#include <sound/initval.h>
31#include <sound/info.h> 32#include <sound/info.h>
@@ -589,7 +590,7 @@ static int snd_mixart_hw_params(struct snd_pcm_substream *subs,
589 /* set up format for the stream */ 590 /* set up format for the stream */
590 format = params_format(hw); 591 format = params_format(hw);
591 592
592 down(&mgr->setup_mutex); 593 mutex_lock(&mgr->setup_mutex);
593 594
594 /* update the stream levels */ 595 /* update the stream levels */
595 if( stream->pcm_number <= MIXART_PCM_DIGITAL ) { 596 if( stream->pcm_number <= MIXART_PCM_DIGITAL ) {
@@ -628,7 +629,7 @@ static int snd_mixart_hw_params(struct snd_pcm_substream *subs,
628 bufferinfo[i].available_length, 629 bufferinfo[i].available_length,
629 subs->number); 630 subs->number);
630 } 631 }
631 up(&mgr->setup_mutex); 632 mutex_unlock(&mgr->setup_mutex);
632 633
633 return err; 634 return err;
634} 635}
@@ -700,7 +701,7 @@ static int snd_mixart_playback_open(struct snd_pcm_substream *subs)
700 int err = 0; 701 int err = 0;
701 int pcm_number; 702 int pcm_number;
702 703
703 down(&mgr->setup_mutex); 704 mutex_lock(&mgr->setup_mutex);
704 705
705 if ( pcm == chip->pcm ) { 706 if ( pcm == chip->pcm ) {
706 pcm_number = MIXART_PCM_ANALOG; 707 pcm_number = MIXART_PCM_ANALOG;
@@ -758,7 +759,7 @@ static int snd_mixart_playback_open(struct snd_pcm_substream *subs)
758 } 759 }
759 760
760 _exit_open: 761 _exit_open:
761 up(&mgr->setup_mutex); 762 mutex_unlock(&mgr->setup_mutex);
762 763
763 return err; 764 return err;
764} 765}
@@ -775,7 +776,7 @@ static int snd_mixart_capture_open(struct snd_pcm_substream *subs)
775 int err = 0; 776 int err = 0;
776 int pcm_number; 777 int pcm_number;
777 778
778 down(&mgr->setup_mutex); 779 mutex_lock(&mgr->setup_mutex);
779 780
780 if ( pcm == chip->pcm ) { 781 if ( pcm == chip->pcm ) {
781 pcm_number = MIXART_PCM_ANALOG; 782 pcm_number = MIXART_PCM_ANALOG;
@@ -836,7 +837,7 @@ static int snd_mixart_capture_open(struct snd_pcm_substream *subs)
836 } 837 }
837 838
838 _exit_open: 839 _exit_open:
839 up(&mgr->setup_mutex); 840 mutex_unlock(&mgr->setup_mutex);
840 841
841 return err; 842 return err;
842} 843}
@@ -849,7 +850,7 @@ static int snd_mixart_close(struct snd_pcm_substream *subs)
849 struct mixart_mgr *mgr = chip->mgr; 850 struct mixart_mgr *mgr = chip->mgr;
850 struct mixart_stream *stream = subs->runtime->private_data; 851 struct mixart_stream *stream = subs->runtime->private_data;
851 852
852 down(&mgr->setup_mutex); 853 mutex_lock(&mgr->setup_mutex);
853 854
854 snd_printdd("snd_mixart_close C%d/P%d/Sub%d\n", chip->chip_idx, stream->pcm_number, subs->number); 855 snd_printdd("snd_mixart_close C%d/P%d/Sub%d\n", chip->chip_idx, stream->pcm_number, subs->number);
855 856
@@ -868,7 +869,7 @@ static int snd_mixart_close(struct snd_pcm_substream *subs)
868 stream->status = MIXART_STREAM_STATUS_FREE; 869 stream->status = MIXART_STREAM_STATUS_FREE;
869 stream->substream = NULL; 870 stream->substream = NULL;
870 871
871 up(&mgr->setup_mutex); 872 mutex_unlock(&mgr->setup_mutex);
872 return 0; 873 return 0;
873} 874}
874 875
@@ -1335,12 +1336,12 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
1335 mgr->msg_fifo_writeptr = 0; 1336 mgr->msg_fifo_writeptr = 0;
1336 1337
1337 spin_lock_init(&mgr->msg_lock); 1338 spin_lock_init(&mgr->msg_lock);
1338 init_MUTEX(&mgr->msg_mutex); 1339 mutex_init(&mgr->msg_mutex);
1339 init_waitqueue_head(&mgr->msg_sleep); 1340 init_waitqueue_head(&mgr->msg_sleep);
1340 atomic_set(&mgr->msg_processed, 0); 1341 atomic_set(&mgr->msg_processed, 0);
1341 1342
1342 /* init setup mutex*/ 1343 /* init setup mutex*/
1343 init_MUTEX(&mgr->setup_mutex); 1344 mutex_init(&mgr->setup_mutex);
1344 1345
1345 /* init message taslket */ 1346 /* init message taslket */
1346 tasklet_init(&mgr->msg_taskq, snd_mixart_msg_tasklet, (unsigned long) mgr); 1347 tasklet_init(&mgr->msg_taskq, snd_mixart_msg_tasklet, (unsigned long) mgr);
diff --git a/sound/pci/mixart/mixart.h b/sound/pci/mixart/mixart.h
index 3e84863ca02c..561634d5c007 100644
--- a/sound/pci/mixart/mixart.h
+++ b/sound/pci/mixart/mixart.h
@@ -24,6 +24,7 @@
24#define __SOUND_MIXART_H 24#define __SOUND_MIXART_H
25 25
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/mutex.h>
27#include <sound/pcm.h> 28#include <sound/pcm.h>
28 29
29#define MIXART_DRIVER_VERSION 0x000100 /* 0.1.0 */ 30#define MIXART_DRIVER_VERSION 0x000100 /* 0.1.0 */
@@ -92,9 +93,9 @@ struct mixart_mgr {
92 93
93 spinlock_t lock; /* interrupt spinlock */ 94 spinlock_t lock; /* interrupt spinlock */
94 spinlock_t msg_lock; /* mailbox spinlock */ 95 spinlock_t msg_lock; /* mailbox spinlock */
95 struct semaphore msg_mutex; /* mutex for blocking_requests */ 96 struct mutex msg_mutex; /* mutex for blocking_requests */
96 97
97 struct semaphore setup_mutex; /* mutex used in hw_params, open and close */ 98 struct mutex setup_mutex; /* mutex used in hw_params, open and close */
98 99
99 /* hardware interface */ 100 /* hardware interface */
100 unsigned int dsp_loaded; /* bit flags of loaded dsp indices */ 101 unsigned int dsp_loaded; /* bit flags of loaded dsp indices */
@@ -107,7 +108,7 @@ struct mixart_mgr {
107 int sample_rate; 108 int sample_rate;
108 int ref_count_rate; 109 int ref_count_rate;
109 110
110 struct semaphore mixer_mutex; /* mutex for mixer */ 111 struct mutex mixer_mutex; /* mutex for mixer */
111 112
112}; 113};
113 114
diff --git a/sound/pci/mixart/mixart_core.c b/sound/pci/mixart/mixart_core.c
index 07c707d7ebbf..406ac3a9d42a 100644
--- a/sound/pci/mixart/mixart_core.c
+++ b/sound/pci/mixart/mixart_core.c
@@ -22,6 +22,8 @@
22 22
23#include <sound/driver.h> 23#include <sound/driver.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/mutex.h>
26
25#include <asm/io.h> 27#include <asm/io.h>
26#include <sound/core.h> 28#include <sound/core.h>
27#include "mixart.h" 29#include "mixart.h"
@@ -239,7 +241,7 @@ int snd_mixart_send_msg(struct mixart_mgr *mgr, struct mixart_msg *request, int
239 wait_queue_t wait; 241 wait_queue_t wait;
240 long timeout; 242 long timeout;
241 243
242 down(&mgr->msg_mutex); 244 mutex_lock(&mgr->msg_mutex);
243 245
244 init_waitqueue_entry(&wait, current); 246 init_waitqueue_entry(&wait, current);
245 247
@@ -248,7 +250,7 @@ int snd_mixart_send_msg(struct mixart_mgr *mgr, struct mixart_msg *request, int
248 err = send_msg(mgr, request, max_resp_size, 1, &msg_frame); /* send and mark the answer pending */ 250 err = send_msg(mgr, request, max_resp_size, 1, &msg_frame); /* send and mark the answer pending */
249 if (err) { 251 if (err) {
250 spin_unlock_irq(&mgr->msg_lock); 252 spin_unlock_irq(&mgr->msg_lock);
251 up(&mgr->msg_mutex); 253 mutex_unlock(&mgr->msg_mutex);
252 return err; 254 return err;
253 } 255 }
254 256
@@ -260,7 +262,7 @@ int snd_mixart_send_msg(struct mixart_mgr *mgr, struct mixart_msg *request, int
260 262
261 if (! timeout) { 263 if (! timeout) {
262 /* error - no ack */ 264 /* error - no ack */
263 up(&mgr->msg_mutex); 265 mutex_unlock(&mgr->msg_mutex);
264 snd_printk(KERN_ERR "error: no reponse on msg %x\n", msg_frame); 266 snd_printk(KERN_ERR "error: no reponse on msg %x\n", msg_frame);
265 return -EIO; 267 return -EIO;
266 } 268 }
@@ -276,7 +278,7 @@ int snd_mixart_send_msg(struct mixart_mgr *mgr, struct mixart_msg *request, int
276 if( request->message_id != resp.message_id ) 278 if( request->message_id != resp.message_id )
277 snd_printk(KERN_ERR "REPONSE ERROR!\n"); 279 snd_printk(KERN_ERR "REPONSE ERROR!\n");
278 280
279 up(&mgr->msg_mutex); 281 mutex_unlock(&mgr->msg_mutex);
280 return err; 282 return err;
281} 283}
282 284
@@ -292,7 +294,7 @@ int snd_mixart_send_msg_wait_notif(struct mixart_mgr *mgr,
292 snd_assert((notif_event & MSG_TYPE_MASK) == MSG_TYPE_NOTIFY, return -EINVAL); 294 snd_assert((notif_event & MSG_TYPE_MASK) == MSG_TYPE_NOTIFY, return -EINVAL);
293 snd_assert((notif_event & MSG_CANCEL_NOTIFY_MASK) == 0, return -EINVAL); 295 snd_assert((notif_event & MSG_CANCEL_NOTIFY_MASK) == 0, return -EINVAL);
294 296
295 down(&mgr->msg_mutex); 297 mutex_lock(&mgr->msg_mutex);
296 298
297 init_waitqueue_entry(&wait, current); 299 init_waitqueue_entry(&wait, current);
298 300
@@ -301,7 +303,7 @@ int snd_mixart_send_msg_wait_notif(struct mixart_mgr *mgr,
301 err = send_msg(mgr, request, MSG_DEFAULT_SIZE, 1, &notif_event); /* send and mark the notification event pending */ 303 err = send_msg(mgr, request, MSG_DEFAULT_SIZE, 1, &notif_event); /* send and mark the notification event pending */
302 if(err) { 304 if(err) {
303 spin_unlock_irq(&mgr->msg_lock); 305 spin_unlock_irq(&mgr->msg_lock);
304 up(&mgr->msg_mutex); 306 mutex_unlock(&mgr->msg_mutex);
305 return err; 307 return err;
306 } 308 }
307 309
@@ -313,12 +315,12 @@ int snd_mixart_send_msg_wait_notif(struct mixart_mgr *mgr,
313 315
314 if (! timeout) { 316 if (! timeout) {
315 /* error - no ack */ 317 /* error - no ack */
316 up(&mgr->msg_mutex); 318 mutex_unlock(&mgr->msg_mutex);
317 snd_printk(KERN_ERR "error: notification %x not received\n", notif_event); 319 snd_printk(KERN_ERR "error: notification %x not received\n", notif_event);
318 return -EIO; 320 return -EIO;
319 } 321 }
320 322
321 up(&mgr->msg_mutex); 323 mutex_unlock(&mgr->msg_mutex);
322 return 0; 324 return 0;
323} 325}
324 326
diff --git a/sound/pci/mixart/mixart_mixer.c b/sound/pci/mixart/mixart_mixer.c
index 36a7e9ddfb15..ed47b732c103 100644
--- a/sound/pci/mixart/mixart_mixer.c
+++ b/sound/pci/mixart/mixart_mixer.c
@@ -24,6 +24,8 @@
24#include <linux/time.h> 24#include <linux/time.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/mutex.h>
28
27#include <sound/core.h> 29#include <sound/core.h>
28#include "mixart.h" 30#include "mixart.h"
29#include "mixart_core.h" 31#include "mixart_core.h"
@@ -353,7 +355,7 @@ static int mixart_analog_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
353static int mixart_analog_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 355static int mixart_analog_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
354{ 356{
355 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); 357 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
356 down(&chip->mgr->mixer_mutex); 358 mutex_lock(&chip->mgr->mixer_mutex);
357 if(kcontrol->private_value == 0) { /* playback */ 359 if(kcontrol->private_value == 0) { /* playback */
358 ucontrol->value.integer.value[0] = chip->analog_playback_volume[0]; 360 ucontrol->value.integer.value[0] = chip->analog_playback_volume[0];
359 ucontrol->value.integer.value[1] = chip->analog_playback_volume[1]; 361 ucontrol->value.integer.value[1] = chip->analog_playback_volume[1];
@@ -361,7 +363,7 @@ static int mixart_analog_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
361 ucontrol->value.integer.value[0] = chip->analog_capture_volume[0]; 363 ucontrol->value.integer.value[0] = chip->analog_capture_volume[0];
362 ucontrol->value.integer.value[1] = chip->analog_capture_volume[1]; 364 ucontrol->value.integer.value[1] = chip->analog_capture_volume[1];
363 } 365 }
364 up(&chip->mgr->mixer_mutex); 366 mutex_unlock(&chip->mgr->mixer_mutex);
365 return 0; 367 return 0;
366} 368}
367 369
@@ -371,7 +373,7 @@ static int mixart_analog_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
371 int changed = 0; 373 int changed = 0;
372 int is_capture, i; 374 int is_capture, i;
373 375
374 down(&chip->mgr->mixer_mutex); 376 mutex_lock(&chip->mgr->mixer_mutex);
375 is_capture = (kcontrol->private_value != 0); 377 is_capture = (kcontrol->private_value != 0);
376 for(i=0; i<2; i++) { 378 for(i=0; i<2; i++) {
377 int new_volume = ucontrol->value.integer.value[i]; 379 int new_volume = ucontrol->value.integer.value[i];
@@ -382,7 +384,7 @@ static int mixart_analog_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
382 } 384 }
383 } 385 }
384 if(changed) mixart_update_analog_audio_level(chip, is_capture); 386 if(changed) mixart_update_analog_audio_level(chip, is_capture);
385 up(&chip->mgr->mixer_mutex); 387 mutex_unlock(&chip->mgr->mixer_mutex);
386 return changed; 388 return changed;
387} 389}
388 390
@@ -408,10 +410,10 @@ static int mixart_audio_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
408{ 410{
409 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); 411 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
410 412
411 down(&chip->mgr->mixer_mutex); 413 mutex_lock(&chip->mgr->mixer_mutex);
412 ucontrol->value.integer.value[0] = chip->analog_playback_active[0]; 414 ucontrol->value.integer.value[0] = chip->analog_playback_active[0];
413 ucontrol->value.integer.value[1] = chip->analog_playback_active[1]; 415 ucontrol->value.integer.value[1] = chip->analog_playback_active[1];
414 up(&chip->mgr->mixer_mutex); 416 mutex_unlock(&chip->mgr->mixer_mutex);
415 return 0; 417 return 0;
416} 418}
417 419
@@ -419,7 +421,7 @@ static int mixart_audio_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
419{ 421{
420 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); 422 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
421 int i, changed = 0; 423 int i, changed = 0;
422 down(&chip->mgr->mixer_mutex); 424 mutex_lock(&chip->mgr->mixer_mutex);
423 for(i=0; i<2; i++) { 425 for(i=0; i<2; i++) {
424 if(chip->analog_playback_active[i] != ucontrol->value.integer.value[i]) { 426 if(chip->analog_playback_active[i] != ucontrol->value.integer.value[i]) {
425 chip->analog_playback_active[i] = ucontrol->value.integer.value[i]; 427 chip->analog_playback_active[i] = ucontrol->value.integer.value[i];
@@ -427,7 +429,7 @@ static int mixart_audio_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
427 } 429 }
428 } 430 }
429 if(changed) mixart_update_analog_audio_level(chip, 0); /* update playback levels */ 431 if(changed) mixart_update_analog_audio_level(chip, 0); /* update playback levels */
430 up(&chip->mgr->mixer_mutex); 432 mutex_unlock(&chip->mgr->mixer_mutex);
431 return changed; 433 return changed;
432} 434}
433 435
@@ -817,7 +819,7 @@ static int mixart_pcm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
817 int *stored_volume; 819 int *stored_volume;
818 int is_capture = kcontrol->private_value & MIXART_VOL_REC_MASK; 820 int is_capture = kcontrol->private_value & MIXART_VOL_REC_MASK;
819 int is_aes = kcontrol->private_value & MIXART_VOL_AES_MASK; 821 int is_aes = kcontrol->private_value & MIXART_VOL_AES_MASK;
820 down(&chip->mgr->mixer_mutex); 822 mutex_lock(&chip->mgr->mixer_mutex);
821 if(is_capture) { 823 if(is_capture) {
822 if(is_aes) stored_volume = chip->digital_capture_volume[1]; /* AES capture */ 824 if(is_aes) stored_volume = chip->digital_capture_volume[1]; /* AES capture */
823 else stored_volume = chip->digital_capture_volume[0]; /* analog capture */ 825 else stored_volume = chip->digital_capture_volume[0]; /* analog capture */
@@ -828,7 +830,7 @@ static int mixart_pcm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
828 } 830 }
829 ucontrol->value.integer.value[0] = stored_volume[0]; 831 ucontrol->value.integer.value[0] = stored_volume[0];
830 ucontrol->value.integer.value[1] = stored_volume[1]; 832 ucontrol->value.integer.value[1] = stored_volume[1];
831 up(&chip->mgr->mixer_mutex); 833 mutex_unlock(&chip->mgr->mixer_mutex);
832 return 0; 834 return 0;
833} 835}
834 836
@@ -841,7 +843,7 @@ static int mixart_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
841 int is_aes = kcontrol->private_value & MIXART_VOL_AES_MASK; 843 int is_aes = kcontrol->private_value & MIXART_VOL_AES_MASK;
842 int* stored_volume; 844 int* stored_volume;
843 int i; 845 int i;
844 down(&chip->mgr->mixer_mutex); 846 mutex_lock(&chip->mgr->mixer_mutex);
845 if(is_capture) { 847 if(is_capture) {
846 if(is_aes) stored_volume = chip->digital_capture_volume[1]; /* AES capture */ 848 if(is_aes) stored_volume = chip->digital_capture_volume[1]; /* AES capture */
847 else stored_volume = chip->digital_capture_volume[0]; /* analog capture */ 849 else stored_volume = chip->digital_capture_volume[0]; /* analog capture */
@@ -860,7 +862,7 @@ static int mixart_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
860 if(is_capture) mixart_update_capture_stream_level(chip, is_aes); 862 if(is_capture) mixart_update_capture_stream_level(chip, is_aes);
861 else mixart_update_playback_stream_level(chip, is_aes, idx); 863 else mixart_update_playback_stream_level(chip, is_aes, idx);
862 } 864 }
863 up(&chip->mgr->mixer_mutex); 865 mutex_unlock(&chip->mgr->mixer_mutex);
864 return changed; 866 return changed;
865} 867}
866 868
@@ -880,12 +882,12 @@ static int mixart_pcm_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
880 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); 882 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
881 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ 883 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
882 snd_assert ( idx < MIXART_PLAYBACK_STREAMS ); 884 snd_assert ( idx < MIXART_PLAYBACK_STREAMS );
883 down(&chip->mgr->mixer_mutex); 885 mutex_lock(&chip->mgr->mixer_mutex);
884 if(kcontrol->private_value & MIXART_VOL_AES_MASK) /* AES playback */ 886 if(kcontrol->private_value & MIXART_VOL_AES_MASK) /* AES playback */
885 idx += MIXART_PLAYBACK_STREAMS; 887 idx += MIXART_PLAYBACK_STREAMS;
886 ucontrol->value.integer.value[0] = chip->digital_playback_active[idx][0]; 888 ucontrol->value.integer.value[0] = chip->digital_playback_active[idx][0];
887 ucontrol->value.integer.value[1] = chip->digital_playback_active[idx][1]; 889 ucontrol->value.integer.value[1] = chip->digital_playback_active[idx][1];
888 up(&chip->mgr->mixer_mutex); 890 mutex_unlock(&chip->mgr->mixer_mutex);
889 return 0; 891 return 0;
890} 892}
891 893
@@ -897,7 +899,7 @@ static int mixart_pcm_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
897 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ 899 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
898 int i, j; 900 int i, j;
899 snd_assert ( idx < MIXART_PLAYBACK_STREAMS ); 901 snd_assert ( idx < MIXART_PLAYBACK_STREAMS );
900 down(&chip->mgr->mixer_mutex); 902 mutex_lock(&chip->mgr->mixer_mutex);
901 j = idx; 903 j = idx;
902 if(is_aes) j += MIXART_PLAYBACK_STREAMS; 904 if(is_aes) j += MIXART_PLAYBACK_STREAMS;
903 for(i=0; i<2; i++) { 905 for(i=0; i<2; i++) {
@@ -907,7 +909,7 @@ static int mixart_pcm_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
907 } 909 }
908 } 910 }
909 if(changed) mixart_update_playback_stream_level(chip, is_aes, idx); 911 if(changed) mixart_update_playback_stream_level(chip, is_aes, idx);
910 up(&chip->mgr->mixer_mutex); 912 mutex_unlock(&chip->mgr->mixer_mutex);
911 return changed; 913 return changed;
912} 914}
913 915
@@ -956,10 +958,10 @@ static int mixart_update_monitoring(struct snd_mixart* chip, int channel)
956static int mixart_monitor_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 958static int mixart_monitor_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
957{ 959{
958 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); 960 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
959 down(&chip->mgr->mixer_mutex); 961 mutex_lock(&chip->mgr->mixer_mutex);
960 ucontrol->value.integer.value[0] = chip->monitoring_volume[0]; 962 ucontrol->value.integer.value[0] = chip->monitoring_volume[0];
961 ucontrol->value.integer.value[1] = chip->monitoring_volume[1]; 963 ucontrol->value.integer.value[1] = chip->monitoring_volume[1];
962 up(&chip->mgr->mixer_mutex); 964 mutex_unlock(&chip->mgr->mixer_mutex);
963 return 0; 965 return 0;
964} 966}
965 967
@@ -968,7 +970,7 @@ static int mixart_monitor_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
968 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); 970 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
969 int changed = 0; 971 int changed = 0;
970 int i; 972 int i;
971 down(&chip->mgr->mixer_mutex); 973 mutex_lock(&chip->mgr->mixer_mutex);
972 for(i=0; i<2; i++) { 974 for(i=0; i<2; i++) {
973 if(chip->monitoring_volume[i] != ucontrol->value.integer.value[i]) { 975 if(chip->monitoring_volume[i] != ucontrol->value.integer.value[i]) {
974 chip->monitoring_volume[i] = ucontrol->value.integer.value[i]; 976 chip->monitoring_volume[i] = ucontrol->value.integer.value[i];
@@ -976,7 +978,7 @@ static int mixart_monitor_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
976 changed = 1; 978 changed = 1;
977 } 979 }
978 } 980 }
979 up(&chip->mgr->mixer_mutex); 981 mutex_unlock(&chip->mgr->mixer_mutex);
980 return changed; 982 return changed;
981} 983}
982 984
@@ -995,10 +997,10 @@ static struct snd_kcontrol_new mixart_control_monitor_vol = {
995static int mixart_monitor_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 997static int mixart_monitor_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
996{ 998{
997 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); 999 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
998 down(&chip->mgr->mixer_mutex); 1000 mutex_lock(&chip->mgr->mixer_mutex);
999 ucontrol->value.integer.value[0] = chip->monitoring_active[0]; 1001 ucontrol->value.integer.value[0] = chip->monitoring_active[0];
1000 ucontrol->value.integer.value[1] = chip->monitoring_active[1]; 1002 ucontrol->value.integer.value[1] = chip->monitoring_active[1];
1001 up(&chip->mgr->mixer_mutex); 1003 mutex_unlock(&chip->mgr->mixer_mutex);
1002 return 0; 1004 return 0;
1003} 1005}
1004 1006
@@ -1007,7 +1009,7 @@ static int mixart_monitor_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
1007 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); 1009 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
1008 int changed = 0; 1010 int changed = 0;
1009 int i; 1011 int i;
1010 down(&chip->mgr->mixer_mutex); 1012 mutex_lock(&chip->mgr->mixer_mutex);
1011 for(i=0; i<2; i++) { 1013 for(i=0; i<2; i++) {
1012 if(chip->monitoring_active[i] != ucontrol->value.integer.value[i]) { 1014 if(chip->monitoring_active[i] != ucontrol->value.integer.value[i]) {
1013 chip->monitoring_active[i] = ucontrol->value.integer.value[i]; 1015 chip->monitoring_active[i] = ucontrol->value.integer.value[i];
@@ -1029,7 +1031,7 @@ static int mixart_monitor_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
1029 } 1031 }
1030 } 1032 }
1031 1033
1032 up(&chip->mgr->mixer_mutex); 1034 mutex_unlock(&chip->mgr->mixer_mutex);
1033 return (changed != 0); 1035 return (changed != 0);
1034} 1036}
1035 1037
@@ -1059,7 +1061,7 @@ int snd_mixart_create_mixer(struct mixart_mgr *mgr)
1059 struct snd_mixart *chip; 1061 struct snd_mixart *chip;
1060 int err, i; 1062 int err, i;
1061 1063
1062 init_MUTEX(&mgr->mixer_mutex); /* can be in another place */ 1064 mutex_init(&mgr->mixer_mutex); /* can be in another place */
1063 1065
1064 for(i=0; i<mgr->num_cards; i++) { 1066 for(i=0; i<mgr->num_cards; i++) {
1065 struct snd_kcontrol_new temp; 1067 struct snd_kcontrol_new temp;
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index 0d0ff54f0fc6..3a3ba6f547bc 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -32,6 +32,8 @@
32#include <linux/pci.h> 32#include <linux/pci.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/moduleparam.h> 34#include <linux/moduleparam.h>
35#include <linux/mutex.h>
36
35#include <sound/core.h> 37#include <sound/core.h>
36#include <sound/info.h> 38#include <sound/info.h>
37#include <sound/control.h> 39#include <sound/control.h>
@@ -235,7 +237,7 @@ struct nm256 {
235 int irq_acks; 237 int irq_acks;
236 irqreturn_t (*interrupt)(int, void *, struct pt_regs *); 238 irqreturn_t (*interrupt)(int, void *, struct pt_regs *);
237 int badintrcount; /* counter to check bogus interrupts */ 239 int badintrcount; /* counter to check bogus interrupts */
238 struct semaphore irq_mutex; 240 struct mutex irq_mutex;
239 241
240 struct nm256_stream streams[2]; 242 struct nm256_stream streams[2];
241 243
@@ -459,32 +461,32 @@ snd_nm256_set_format(struct nm256 *chip, struct nm256_stream *s,
459/* acquire interrupt */ 461/* acquire interrupt */
460static int snd_nm256_acquire_irq(struct nm256 *chip) 462static int snd_nm256_acquire_irq(struct nm256 *chip)
461{ 463{
462 down(&chip->irq_mutex); 464 mutex_lock(&chip->irq_mutex);
463 if (chip->irq < 0) { 465 if (chip->irq < 0) {
464 if (request_irq(chip->pci->irq, chip->interrupt, SA_INTERRUPT|SA_SHIRQ, 466 if (request_irq(chip->pci->irq, chip->interrupt, SA_INTERRUPT|SA_SHIRQ,
465 chip->card->driver, chip)) { 467 chip->card->driver, chip)) {
466 snd_printk(KERN_ERR "unable to grab IRQ %d\n", chip->pci->irq); 468 snd_printk(KERN_ERR "unable to grab IRQ %d\n", chip->pci->irq);
467 up(&chip->irq_mutex); 469 mutex_unlock(&chip->irq_mutex);
468 return -EBUSY; 470 return -EBUSY;
469 } 471 }
470 chip->irq = chip->pci->irq; 472 chip->irq = chip->pci->irq;
471 } 473 }
472 chip->irq_acks++; 474 chip->irq_acks++;
473 up(&chip->irq_mutex); 475 mutex_unlock(&chip->irq_mutex);
474 return 0; 476 return 0;
475} 477}
476 478
477/* release interrupt */ 479/* release interrupt */
478static void snd_nm256_release_irq(struct nm256 *chip) 480static void snd_nm256_release_irq(struct nm256 *chip)
479{ 481{
480 down(&chip->irq_mutex); 482 mutex_lock(&chip->irq_mutex);
481 if (chip->irq_acks > 0) 483 if (chip->irq_acks > 0)
482 chip->irq_acks--; 484 chip->irq_acks--;
483 if (chip->irq_acks == 0 && chip->irq >= 0) { 485 if (chip->irq_acks == 0 && chip->irq >= 0) {
484 free_irq(chip->irq, chip); 486 free_irq(chip->irq, chip);
485 chip->irq = -1; 487 chip->irq = -1;
486 } 488 }
487 up(&chip->irq_mutex); 489 mutex_unlock(&chip->irq_mutex);
488} 490}
489 491
490/* 492/*
@@ -1407,7 +1409,7 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci,
1407 chip->use_cache = use_cache; 1409 chip->use_cache = use_cache;
1408 spin_lock_init(&chip->reg_lock); 1410 spin_lock_init(&chip->reg_lock);
1409 chip->irq = -1; 1411 chip->irq = -1;
1410 init_MUTEX(&chip->irq_mutex); 1412 mutex_init(&chip->irq_mutex);
1411 1413
1412 /* store buffer sizes in bytes */ 1414 /* store buffer sizes in bytes */
1413 chip->streams[SNDRV_PCM_STREAM_PLAYBACK].bufsize = playback_bufsize * 1024; 1415 chip->streams[SNDRV_PCM_STREAM_PLAYBACK].bufsize = playback_bufsize * 1024;
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index b2cba75b6b16..31a3e8e1b234 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -28,6 +28,8 @@
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/moduleparam.h> 30#include <linux/moduleparam.h>
31#include <linux/mutex.h>
32
31#include <sound/core.h> 33#include <sound/core.h>
32#include <sound/initval.h> 34#include <sound/initval.h>
33#include <sound/info.h> 35#include <sound/info.h>
@@ -518,7 +520,7 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
518 struct timeval my_tv1, my_tv2; 520 struct timeval my_tv1, my_tv2;
519 do_gettimeofday(&my_tv1); 521 do_gettimeofday(&my_tv1);
520#endif 522#endif
521 down(&mgr->setup_mutex); 523 mutex_lock(&mgr->setup_mutex);
522 524
523 /* check the pipes concerned and build pipe_array */ 525 /* check the pipes concerned and build pipe_array */
524 for (i = 0; i < mgr->num_cards; i++) { 526 for (i = 0; i < mgr->num_cards; i++) {
@@ -537,7 +539,7 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
537 } 539 }
538 } 540 }
539 if (capture_mask == 0 && playback_mask == 0) { 541 if (capture_mask == 0 && playback_mask == 0) {
540 up(&mgr->setup_mutex); 542 mutex_unlock(&mgr->setup_mutex);
541 snd_printk(KERN_ERR "pcxhr_trigger_tasklet : no pipes\n"); 543 snd_printk(KERN_ERR "pcxhr_trigger_tasklet : no pipes\n");
542 return; 544 return;
543 } 545 }
@@ -548,7 +550,7 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
548 /* synchronous stop of all the pipes concerned */ 550 /* synchronous stop of all the pipes concerned */
549 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0); 551 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0);
550 if (err) { 552 if (err) {
551 up(&mgr->setup_mutex); 553 mutex_unlock(&mgr->setup_mutex);
552 snd_printk(KERN_ERR "pcxhr_trigger_tasklet : error stop pipes (P%x C%x)\n", 554 snd_printk(KERN_ERR "pcxhr_trigger_tasklet : error stop pipes (P%x C%x)\n",
553 playback_mask, capture_mask); 555 playback_mask, capture_mask);
554 return; 556 return;
@@ -592,7 +594,7 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
592 /* synchronous start of all the pipes concerned */ 594 /* synchronous start of all the pipes concerned */
593 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1); 595 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1);
594 if (err) { 596 if (err) {
595 up(&mgr->setup_mutex); 597 mutex_unlock(&mgr->setup_mutex);
596 snd_printk(KERN_ERR "pcxhr_trigger_tasklet : error start pipes (P%x C%x)\n", 598 snd_printk(KERN_ERR "pcxhr_trigger_tasklet : error start pipes (P%x C%x)\n",
597 playback_mask, capture_mask); 599 playback_mask, capture_mask);
598 return; 600 return;
@@ -619,7 +621,7 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
619 } 621 }
620 spin_unlock_irqrestore(&mgr->lock, flags); 622 spin_unlock_irqrestore(&mgr->lock, flags);
621 623
622 up(&mgr->setup_mutex); 624 mutex_unlock(&mgr->setup_mutex);
623 625
624#ifdef CONFIG_SND_DEBUG_DETECT 626#ifdef CONFIG_SND_DEBUG_DETECT
625 do_gettimeofday(&my_tv2); 627 do_gettimeofday(&my_tv2);
@@ -728,7 +730,7 @@ static int pcxhr_prepare(struct snd_pcm_substream *subs)
728 } 730 }
729 */ 731 */
730 732
731 down(&mgr->setup_mutex); 733 mutex_lock(&mgr->setup_mutex);
732 734
733 do { 735 do {
734 /* if the stream was stopped before, format and buffer were reset */ 736 /* if the stream was stopped before, format and buffer were reset */
@@ -755,7 +757,7 @@ static int pcxhr_prepare(struct snd_pcm_substream *subs)
755 } 757 }
756 } while(0); /* do only once (so we can use break instead of goto) */ 758 } while(0); /* do only once (so we can use break instead of goto) */
757 759
758 up(&mgr->setup_mutex); 760 mutex_unlock(&mgr->setup_mutex);
759 761
760 return err; 762 return err;
761} 763}
@@ -780,7 +782,7 @@ static int pcxhr_hw_params(struct snd_pcm_substream *subs,
780 /* set up format for the stream */ 782 /* set up format for the stream */
781 format = params_format(hw); 783 format = params_format(hw);
782 784
783 down(&mgr->setup_mutex); 785 mutex_lock(&mgr->setup_mutex);
784 786
785 stream->channels = channels; 787 stream->channels = channels;
786 stream->format = format; 788 stream->format = format;
@@ -789,7 +791,7 @@ static int pcxhr_hw_params(struct snd_pcm_substream *subs,
789 /* 791 /*
790 err = pcxhr_set_format(stream); 792 err = pcxhr_set_format(stream);
791 if(err) { 793 if(err) {
792 up(&mgr->setup_mutex); 794 mutex_unlock(&mgr->setup_mutex);
793 return err; 795 return err;
794 } 796 }
795 */ 797 */
@@ -801,7 +803,7 @@ static int pcxhr_hw_params(struct snd_pcm_substream *subs,
801 err = pcxhr_update_r_buffer(stream); 803 err = pcxhr_update_r_buffer(stream);
802 } 804 }
803 */ 805 */
804 up(&mgr->setup_mutex); 806 mutex_unlock(&mgr->setup_mutex);
805 807
806 return err; 808 return err;
807} 809}
@@ -847,7 +849,7 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
847 struct pcxhr_stream *stream; 849 struct pcxhr_stream *stream;
848 int is_capture; 850 int is_capture;
849 851
850 down(&mgr->setup_mutex); 852 mutex_lock(&mgr->setup_mutex);
851 853
852 /* copy the struct snd_pcm_hardware struct */ 854 /* copy the struct snd_pcm_hardware struct */
853 runtime->hw = pcxhr_caps; 855 runtime->hw = pcxhr_caps;
@@ -871,7 +873,7 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
871 /* streams in use */ 873 /* streams in use */
872 snd_printk(KERN_ERR "pcxhr_open chip%d subs%d in use\n", 874 snd_printk(KERN_ERR "pcxhr_open chip%d subs%d in use\n",
873 chip->chip_idx, subs->number); 875 chip->chip_idx, subs->number);
874 up(&mgr->setup_mutex); 876 mutex_unlock(&mgr->setup_mutex);
875 return -EBUSY; 877 return -EBUSY;
876 } 878 }
877 879
@@ -887,7 +889,7 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
887 &external_rate) || 889 &external_rate) ||
888 external_rate == 0) { 890 external_rate == 0) {
889 /* cannot detect the external clock rate */ 891 /* cannot detect the external clock rate */
890 up(&mgr->setup_mutex); 892 mutex_unlock(&mgr->setup_mutex);
891 return -EBUSY; 893 return -EBUSY;
892 } 894 }
893 runtime->hw.rate_min = runtime->hw.rate_max = external_rate; 895 runtime->hw.rate_min = runtime->hw.rate_max = external_rate;
@@ -905,7 +907,7 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
905 907
906 mgr->ref_count_rate++; 908 mgr->ref_count_rate++;
907 909
908 up(&mgr->setup_mutex); 910 mutex_unlock(&mgr->setup_mutex);
909 return 0; 911 return 0;
910} 912}
911 913
@@ -916,7 +918,7 @@ static int pcxhr_close(struct snd_pcm_substream *subs)
916 struct pcxhr_mgr *mgr = chip->mgr; 918 struct pcxhr_mgr *mgr = chip->mgr;
917 struct pcxhr_stream *stream = subs->runtime->private_data; 919 struct pcxhr_stream *stream = subs->runtime->private_data;
918 920
919 down(&mgr->setup_mutex); 921 mutex_lock(&mgr->setup_mutex);
920 922
921 snd_printdd("pcxhr_close chip%d subs%d\n", chip->chip_idx, subs->number); 923 snd_printdd("pcxhr_close chip%d subs%d\n", chip->chip_idx, subs->number);
922 924
@@ -929,7 +931,7 @@ static int pcxhr_close(struct snd_pcm_substream *subs)
929 stream->status = PCXHR_STREAM_STATUS_FREE; 931 stream->status = PCXHR_STREAM_STATUS_FREE;
930 stream->substream = NULL; 932 stream->substream = NULL;
931 933
932 up(&mgr->setup_mutex); 934 mutex_unlock(&mgr->setup_mutex);
933 935
934 return 0; 936 return 0;
935} 937}
@@ -1264,7 +1266,7 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id
1264 spin_lock_init(&mgr->msg_lock); 1266 spin_lock_init(&mgr->msg_lock);
1265 1267
1266 /* init setup mutex*/ 1268 /* init setup mutex*/
1267 init_MUTEX(&mgr->setup_mutex); 1269 mutex_init(&mgr->setup_mutex);
1268 1270
1269 /* init taslket */ 1271 /* init taslket */
1270 tasklet_init(&mgr->msg_taskq, pcxhr_msg_tasklet, (unsigned long) mgr); 1272 tasklet_init(&mgr->msg_taskq, pcxhr_msg_tasklet, (unsigned long) mgr);
diff --git a/sound/pci/pcxhr/pcxhr.h b/sound/pci/pcxhr/pcxhr.h
index 049f2b3f2867..652064787a55 100644
--- a/sound/pci/pcxhr/pcxhr.h
+++ b/sound/pci/pcxhr/pcxhr.h
@@ -24,6 +24,7 @@
24#define __SOUND_PCXHR_H 24#define __SOUND_PCXHR_H
25 25
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/mutex.h>
27#include <sound/pcm.h> 28#include <sound/pcm.h>
28 29
29#define PCXHR_DRIVER_VERSION 0x000804 /* 0.8.4 */ 30#define PCXHR_DRIVER_VERSION 0x000804 /* 0.8.4 */
@@ -76,8 +77,8 @@ struct pcxhr_mgr {
76 spinlock_t lock; /* interrupt spinlock */ 77 spinlock_t lock; /* interrupt spinlock */
77 spinlock_t msg_lock; /* message spinlock */ 78 spinlock_t msg_lock; /* message spinlock */
78 79
79 struct semaphore setup_mutex; /* mutex used in hw_params, open and close */ 80 struct mutex setup_mutex; /* mutex used in hw_params, open and close */
80 struct semaphore mixer_mutex; /* mutex for mixer */ 81 struct mutex mixer_mutex; /* mutex for mixer */
81 82
82 /* hardware interface */ 83 /* hardware interface */
83 unsigned int dsp_loaded; /* bit flags of loaded dsp indices */ 84 unsigned int dsp_loaded; /* bit flags of loaded dsp indices */
diff --git a/sound/pci/pcxhr/pcxhr_mixer.c b/sound/pci/pcxhr/pcxhr_mixer.c
index 760e733ac25e..94e63a1e90d9 100644
--- a/sound/pci/pcxhr/pcxhr_mixer.c
+++ b/sound/pci/pcxhr/pcxhr_mixer.c
@@ -25,6 +25,7 @@
25#include <linux/time.h> 25#include <linux/time.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/mutex.h>
28#include <sound/core.h> 29#include <sound/core.h>
29#include "pcxhr.h" 30#include "pcxhr.h"
30#include "pcxhr_hwdep.h" 31#include "pcxhr_hwdep.h"
@@ -92,7 +93,7 @@ static int pcxhr_analog_vol_get(struct snd_kcontrol *kcontrol,
92 struct snd_ctl_elem_value *ucontrol) 93 struct snd_ctl_elem_value *ucontrol)
93{ 94{
94 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); 95 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
95 down(&chip->mgr->mixer_mutex); 96 mutex_lock(&chip->mgr->mixer_mutex);
96 if (kcontrol->private_value == 0) { /* playback */ 97 if (kcontrol->private_value == 0) { /* playback */
97 ucontrol->value.integer.value[0] = chip->analog_playback_volume[0]; 98 ucontrol->value.integer.value[0] = chip->analog_playback_volume[0];
98 ucontrol->value.integer.value[1] = chip->analog_playback_volume[1]; 99 ucontrol->value.integer.value[1] = chip->analog_playback_volume[1];
@@ -100,7 +101,7 @@ static int pcxhr_analog_vol_get(struct snd_kcontrol *kcontrol,
100 ucontrol->value.integer.value[0] = chip->analog_capture_volume[0]; 101 ucontrol->value.integer.value[0] = chip->analog_capture_volume[0];
101 ucontrol->value.integer.value[1] = chip->analog_capture_volume[1]; 102 ucontrol->value.integer.value[1] = chip->analog_capture_volume[1];
102 } 103 }
103 up(&chip->mgr->mixer_mutex); 104 mutex_unlock(&chip->mgr->mixer_mutex);
104 return 0; 105 return 0;
105} 106}
106 107
@@ -111,7 +112,7 @@ static int pcxhr_analog_vol_put(struct snd_kcontrol *kcontrol,
111 int changed = 0; 112 int changed = 0;
112 int is_capture, i; 113 int is_capture, i;
113 114
114 down(&chip->mgr->mixer_mutex); 115 mutex_lock(&chip->mgr->mixer_mutex);
115 is_capture = (kcontrol->private_value != 0); 116 is_capture = (kcontrol->private_value != 0);
116 for (i = 0; i < 2; i++) { 117 for (i = 0; i < 2; i++) {
117 int new_volume = ucontrol->value.integer.value[i]; 118 int new_volume = ucontrol->value.integer.value[i];
@@ -123,7 +124,7 @@ static int pcxhr_analog_vol_put(struct snd_kcontrol *kcontrol,
123 pcxhr_update_analog_audio_level(chip, is_capture, i); 124 pcxhr_update_analog_audio_level(chip, is_capture, i);
124 } 125 }
125 } 126 }
126 up(&chip->mgr->mixer_mutex); 127 mutex_unlock(&chip->mgr->mixer_mutex);
127 return changed; 128 return changed;
128} 129}
129 130
@@ -150,10 +151,10 @@ static int pcxhr_audio_sw_get(struct snd_kcontrol *kcontrol,
150{ 151{
151 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); 152 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
152 153
153 down(&chip->mgr->mixer_mutex); 154 mutex_lock(&chip->mgr->mixer_mutex);
154 ucontrol->value.integer.value[0] = chip->analog_playback_active[0]; 155 ucontrol->value.integer.value[0] = chip->analog_playback_active[0];
155 ucontrol->value.integer.value[1] = chip->analog_playback_active[1]; 156 ucontrol->value.integer.value[1] = chip->analog_playback_active[1];
156 up(&chip->mgr->mixer_mutex); 157 mutex_unlock(&chip->mgr->mixer_mutex);
157 return 0; 158 return 0;
158} 159}
159 160
@@ -162,7 +163,7 @@ static int pcxhr_audio_sw_put(struct snd_kcontrol *kcontrol,
162{ 163{
163 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); 164 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
164 int i, changed = 0; 165 int i, changed = 0;
165 down(&chip->mgr->mixer_mutex); 166 mutex_lock(&chip->mgr->mixer_mutex);
166 for(i = 0; i < 2; i++) { 167 for(i = 0; i < 2; i++) {
167 if (chip->analog_playback_active[i] != ucontrol->value.integer.value[i]) { 168 if (chip->analog_playback_active[i] != ucontrol->value.integer.value[i]) {
168 chip->analog_playback_active[i] = ucontrol->value.integer.value[i]; 169 chip->analog_playback_active[i] = ucontrol->value.integer.value[i];
@@ -170,7 +171,7 @@ static int pcxhr_audio_sw_put(struct snd_kcontrol *kcontrol,
170 pcxhr_update_analog_audio_level(chip, 0, i); /* update playback levels */ 171 pcxhr_update_analog_audio_level(chip, 0, i); /* update playback levels */
171 } 172 }
172 } 173 }
173 up(&chip->mgr->mixer_mutex); 174 mutex_unlock(&chip->mgr->mixer_mutex);
174 return changed; 175 return changed;
175} 176}
176 177
@@ -299,14 +300,14 @@ static int pcxhr_pcm_vol_get(struct snd_kcontrol *kcontrol,
299 int *stored_volume; 300 int *stored_volume;
300 int is_capture = kcontrol->private_value; 301 int is_capture = kcontrol->private_value;
301 302
302 down(&chip->mgr->mixer_mutex); 303 mutex_lock(&chip->mgr->mixer_mutex);
303 if (is_capture) 304 if (is_capture)
304 stored_volume = chip->digital_capture_volume; /* digital capture */ 305 stored_volume = chip->digital_capture_volume; /* digital capture */
305 else 306 else
306 stored_volume = chip->digital_playback_volume[idx]; /* digital playback */ 307 stored_volume = chip->digital_playback_volume[idx]; /* digital playback */
307 ucontrol->value.integer.value[0] = stored_volume[0]; 308 ucontrol->value.integer.value[0] = stored_volume[0];
308 ucontrol->value.integer.value[1] = stored_volume[1]; 309 ucontrol->value.integer.value[1] = stored_volume[1];
309 up(&chip->mgr->mixer_mutex); 310 mutex_unlock(&chip->mgr->mixer_mutex);
310 return 0; 311 return 0;
311} 312}
312 313
@@ -320,7 +321,7 @@ static int pcxhr_pcm_vol_put(struct snd_kcontrol *kcontrol,
320 int *stored_volume; 321 int *stored_volume;
321 int i; 322 int i;
322 323
323 down(&chip->mgr->mixer_mutex); 324 mutex_lock(&chip->mgr->mixer_mutex);
324 if (is_capture) 325 if (is_capture)
325 stored_volume = chip->digital_capture_volume; /* digital capture */ 326 stored_volume = chip->digital_capture_volume; /* digital capture */
326 else 327 else
@@ -335,7 +336,7 @@ static int pcxhr_pcm_vol_put(struct snd_kcontrol *kcontrol,
335 } 336 }
336 if (! is_capture && changed) 337 if (! is_capture && changed)
337 pcxhr_update_playback_stream_level(chip, idx); /* update playback volume */ 338 pcxhr_update_playback_stream_level(chip, idx); /* update playback volume */
338 up(&chip->mgr->mixer_mutex); 339 mutex_unlock(&chip->mgr->mixer_mutex);
339 return changed; 340 return changed;
340} 341}
341 342
@@ -356,10 +357,10 @@ static int pcxhr_pcm_sw_get(struct snd_kcontrol *kcontrol,
356 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); 357 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
357 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ 358 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
358 359
359 down(&chip->mgr->mixer_mutex); 360 mutex_lock(&chip->mgr->mixer_mutex);
360 ucontrol->value.integer.value[0] = chip->digital_playback_active[idx][0]; 361 ucontrol->value.integer.value[0] = chip->digital_playback_active[idx][0];
361 ucontrol->value.integer.value[1] = chip->digital_playback_active[idx][1]; 362 ucontrol->value.integer.value[1] = chip->digital_playback_active[idx][1];
362 up(&chip->mgr->mixer_mutex); 363 mutex_unlock(&chip->mgr->mixer_mutex);
363 return 0; 364 return 0;
364} 365}
365 366
@@ -370,7 +371,7 @@ static int pcxhr_pcm_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
370 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ 371 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
371 int i, j; 372 int i, j;
372 373
373 down(&chip->mgr->mixer_mutex); 374 mutex_lock(&chip->mgr->mixer_mutex);
374 j = idx; 375 j = idx;
375 for (i = 0; i < 2; i++) { 376 for (i = 0; i < 2; i++) {
376 if (chip->digital_playback_active[j][i] != ucontrol->value.integer.value[i]) { 377 if (chip->digital_playback_active[j][i] != ucontrol->value.integer.value[i]) {
@@ -380,7 +381,7 @@ static int pcxhr_pcm_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
380 } 381 }
381 if (changed) 382 if (changed)
382 pcxhr_update_playback_stream_level(chip, idx); 383 pcxhr_update_playback_stream_level(chip, idx);
383 up(&chip->mgr->mixer_mutex); 384 mutex_unlock(&chip->mgr->mixer_mutex);
384 return changed; 385 return changed;
385} 386}
386 387
@@ -402,10 +403,10 @@ static int pcxhr_monitor_vol_get(struct snd_kcontrol *kcontrol,
402 struct snd_ctl_elem_value *ucontrol) 403 struct snd_ctl_elem_value *ucontrol)
403{ 404{
404 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); 405 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
405 down(&chip->mgr->mixer_mutex); 406 mutex_lock(&chip->mgr->mixer_mutex);
406 ucontrol->value.integer.value[0] = chip->monitoring_volume[0]; 407 ucontrol->value.integer.value[0] = chip->monitoring_volume[0];
407 ucontrol->value.integer.value[1] = chip->monitoring_volume[1]; 408 ucontrol->value.integer.value[1] = chip->monitoring_volume[1];
408 up(&chip->mgr->mixer_mutex); 409 mutex_unlock(&chip->mgr->mixer_mutex);
409 return 0; 410 return 0;
410} 411}
411 412
@@ -416,7 +417,7 @@ static int pcxhr_monitor_vol_put(struct snd_kcontrol *kcontrol,
416 int changed = 0; 417 int changed = 0;
417 int i; 418 int i;
418 419
419 down(&chip->mgr->mixer_mutex); 420 mutex_lock(&chip->mgr->mixer_mutex);
420 for (i = 0; i < 2; i++) { 421 for (i = 0; i < 2; i++) {
421 if (chip->monitoring_volume[i] != ucontrol->value.integer.value[i]) { 422 if (chip->monitoring_volume[i] != ucontrol->value.integer.value[i]) {
422 chip->monitoring_volume[i] = ucontrol->value.integer.value[i]; 423 chip->monitoring_volume[i] = ucontrol->value.integer.value[i];
@@ -426,7 +427,7 @@ static int pcxhr_monitor_vol_put(struct snd_kcontrol *kcontrol,
426 changed = 1; 427 changed = 1;
427 } 428 }
428 } 429 }
429 up(&chip->mgr->mixer_mutex); 430 mutex_unlock(&chip->mgr->mixer_mutex);
430 return changed; 431 return changed;
431} 432}
432 433
@@ -446,10 +447,10 @@ static int pcxhr_monitor_sw_get(struct snd_kcontrol *kcontrol,
446 struct snd_ctl_elem_value *ucontrol) 447 struct snd_ctl_elem_value *ucontrol)
447{ 448{
448 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); 449 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
449 down(&chip->mgr->mixer_mutex); 450 mutex_lock(&chip->mgr->mixer_mutex);
450 ucontrol->value.integer.value[0] = chip->monitoring_active[0]; 451 ucontrol->value.integer.value[0] = chip->monitoring_active[0];
451 ucontrol->value.integer.value[1] = chip->monitoring_active[1]; 452 ucontrol->value.integer.value[1] = chip->monitoring_active[1];
452 up(&chip->mgr->mixer_mutex); 453 mutex_unlock(&chip->mgr->mixer_mutex);
453 return 0; 454 return 0;
454} 455}
455 456
@@ -460,7 +461,7 @@ static int pcxhr_monitor_sw_put(struct snd_kcontrol *kcontrol,
460 int changed = 0; 461 int changed = 0;
461 int i; 462 int i;
462 463
463 down(&chip->mgr->mixer_mutex); 464 mutex_lock(&chip->mgr->mixer_mutex);
464 for (i = 0; i < 2; i++) { 465 for (i = 0; i < 2; i++) {
465 if (chip->monitoring_active[i] != ucontrol->value.integer.value[i]) { 466 if (chip->monitoring_active[i] != ucontrol->value.integer.value[i]) {
466 chip->monitoring_active[i] = ucontrol->value.integer.value[i]; 467 chip->monitoring_active[i] = ucontrol->value.integer.value[i];
@@ -474,7 +475,7 @@ static int pcxhr_monitor_sw_put(struct snd_kcontrol *kcontrol,
474 /* update right monitoring volume and mute */ 475 /* update right monitoring volume and mute */
475 pcxhr_update_audio_pipe_level(chip, 0, 1); 476 pcxhr_update_audio_pipe_level(chip, 0, 1);
476 477
477 up(&chip->mgr->mixer_mutex); 478 mutex_unlock(&chip->mgr->mixer_mutex);
478 return (changed != 0); 479 return (changed != 0);
479} 480}
480 481
@@ -571,13 +572,13 @@ static int pcxhr_audio_src_put(struct snd_kcontrol *kcontrol,
571 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); 572 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
572 int ret = 0; 573 int ret = 0;
573 574
574 down(&chip->mgr->mixer_mutex); 575 mutex_lock(&chip->mgr->mixer_mutex);
575 if (chip->audio_capture_source != ucontrol->value.enumerated.item[0]) { 576 if (chip->audio_capture_source != ucontrol->value.enumerated.item[0]) {
576 chip->audio_capture_source = ucontrol->value.enumerated.item[0]; 577 chip->audio_capture_source = ucontrol->value.enumerated.item[0];
577 pcxhr_set_audio_source(chip); 578 pcxhr_set_audio_source(chip);
578 ret = 1; 579 ret = 1;
579 } 580 }
580 up(&chip->mgr->mixer_mutex); 581 mutex_unlock(&chip->mgr->mixer_mutex);
581 return ret; 582 return ret;
582} 583}
583 584
@@ -636,9 +637,9 @@ static int pcxhr_clock_type_put(struct snd_kcontrol *kcontrol,
636 struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol); 637 struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol);
637 int rate, ret = 0; 638 int rate, ret = 0;
638 639
639 down(&mgr->mixer_mutex); 640 mutex_lock(&mgr->mixer_mutex);
640 if (mgr->use_clock_type != ucontrol->value.enumerated.item[0]) { 641 if (mgr->use_clock_type != ucontrol->value.enumerated.item[0]) {
641 down(&mgr->setup_mutex); 642 mutex_lock(&mgr->setup_mutex);
642 mgr->use_clock_type = ucontrol->value.enumerated.item[0]; 643 mgr->use_clock_type = ucontrol->value.enumerated.item[0];
643 if (mgr->use_clock_type) 644 if (mgr->use_clock_type)
644 pcxhr_get_external_clock(mgr, mgr->use_clock_type, &rate); 645 pcxhr_get_external_clock(mgr, mgr->use_clock_type, &rate);
@@ -649,10 +650,10 @@ static int pcxhr_clock_type_put(struct snd_kcontrol *kcontrol,
649 if (mgr->sample_rate) 650 if (mgr->sample_rate)
650 mgr->sample_rate = rate; 651 mgr->sample_rate = rate;
651 } 652 }
652 up(&mgr->setup_mutex); 653 mutex_unlock(&mgr->setup_mutex);
653 ret = 1; /* return 1 even if the set was not done. ok ? */ 654 ret = 1; /* return 1 even if the set was not done. ok ? */
654 } 655 }
655 up(&mgr->mixer_mutex); 656 mutex_unlock(&mgr->mixer_mutex);
656 return ret; 657 return ret;
657} 658}
658 659
@@ -685,7 +686,7 @@ static int pcxhr_clock_rate_get(struct snd_kcontrol *kcontrol,
685 struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol); 686 struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol);
686 int i, err, rate; 687 int i, err, rate;
687 688
688 down(&mgr->mixer_mutex); 689 mutex_lock(&mgr->mixer_mutex);
689 for(i = 0; i < 3 + mgr->capture_chips; i++) { 690 for(i = 0; i < 3 + mgr->capture_chips; i++) {
690 if (i == PCXHR_CLOCK_TYPE_INTERNAL) 691 if (i == PCXHR_CLOCK_TYPE_INTERNAL)
691 rate = mgr->sample_rate_real; 692 rate = mgr->sample_rate_real;
@@ -696,7 +697,7 @@ static int pcxhr_clock_rate_get(struct snd_kcontrol *kcontrol,
696 } 697 }
697 ucontrol->value.integer.value[i] = rate; 698 ucontrol->value.integer.value[i] = rate;
698 } 699 }
699 up(&mgr->mixer_mutex); 700 mutex_unlock(&mgr->mixer_mutex);
700 return 0; 701 return 0;
701} 702}
702 703
@@ -765,7 +766,7 @@ static int pcxhr_iec958_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
765 unsigned char aes_bits; 766 unsigned char aes_bits;
766 int i, err; 767 int i, err;
767 768
768 down(&chip->mgr->mixer_mutex); 769 mutex_lock(&chip->mgr->mixer_mutex);
769 for(i = 0; i < 5; i++) { 770 for(i = 0; i < 5; i++) {
770 if (kcontrol->private_value == 0) /* playback */ 771 if (kcontrol->private_value == 0) /* playback */
771 aes_bits = chip->aes_bits[i]; 772 aes_bits = chip->aes_bits[i];
@@ -776,7 +777,7 @@ static int pcxhr_iec958_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
776 } 777 }
777 ucontrol->value.iec958.status[i] = aes_bits; 778 ucontrol->value.iec958.status[i] = aes_bits;
778 } 779 }
779 up(&chip->mgr->mixer_mutex); 780 mutex_unlock(&chip->mgr->mixer_mutex);
780 return 0; 781 return 0;
781} 782}
782 783
@@ -828,14 +829,14 @@ static int pcxhr_iec958_put(struct snd_kcontrol *kcontrol,
828 int i, changed = 0; 829 int i, changed = 0;
829 830
830 /* playback */ 831 /* playback */
831 down(&chip->mgr->mixer_mutex); 832 mutex_lock(&chip->mgr->mixer_mutex);
832 for (i = 0; i < 5; i++) { 833 for (i = 0; i < 5; i++) {
833 if (ucontrol->value.iec958.status[i] != chip->aes_bits[i]) { 834 if (ucontrol->value.iec958.status[i] != chip->aes_bits[i]) {
834 pcxhr_iec958_update_byte(chip, i, ucontrol->value.iec958.status[i]); 835 pcxhr_iec958_update_byte(chip, i, ucontrol->value.iec958.status[i]);
835 changed = 1; 836 changed = 1;
836 } 837 }
837 } 838 }
838 up(&chip->mgr->mixer_mutex); 839 mutex_unlock(&chip->mgr->mixer_mutex);
839 return changed; 840 return changed;
840} 841}
841 842
@@ -916,7 +917,7 @@ int pcxhr_create_mixer(struct pcxhr_mgr *mgr)
916 struct snd_pcxhr *chip; 917 struct snd_pcxhr *chip;
917 int err, i; 918 int err, i;
918 919
919 init_MUTEX(&mgr->mixer_mutex); /* can be in another place */ 920 mutex_init(&mgr->mixer_mutex); /* can be in another place */
920 921
921 for (i = 0; i < mgr->num_cards; i++) { 922 for (i = 0; i < mgr->num_cards; i++) {
922 struct snd_kcontrol_new temp; 923 struct snd_kcontrol_new temp;
diff --git a/sound/pci/trident/trident_memory.c b/sound/pci/trident/trident_memory.c
index cf09ea99755c..46c6982c9e88 100644
--- a/sound/pci/trident/trident_memory.c
+++ b/sound/pci/trident/trident_memory.c
@@ -27,6 +27,8 @@
27#include <asm/io.h> 27#include <asm/io.h>
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/time.h> 29#include <linux/time.h>
30#include <linux/mutex.h>
31
30#include <sound/core.h> 32#include <sound/core.h>
31#include <sound/trident.h> 33#include <sound/trident.h>
32 34
@@ -201,16 +203,16 @@ snd_trident_alloc_sg_pages(struct snd_trident *trident,
201 203
202 204
203 205
204 down(&hdr->block_mutex); 206 mutex_lock(&hdr->block_mutex);
205 blk = search_empty(hdr, runtime->dma_bytes); 207 blk = search_empty(hdr, runtime->dma_bytes);
206 if (blk == NULL) { 208 if (blk == NULL) {
207 up(&hdr->block_mutex); 209 mutex_unlock(&hdr->block_mutex);
208 return NULL; 210 return NULL;
209 } 211 }
210 if (lastpg(blk) - firstpg(blk) >= sgbuf->pages) { 212 if (lastpg(blk) - firstpg(blk) >= sgbuf->pages) {
211 snd_printk(KERN_ERR "page calculation doesn't match: allocated pages = %d, trident = %d/%d\n", sgbuf->pages, firstpg(blk), lastpg(blk)); 213 snd_printk(KERN_ERR "page calculation doesn't match: allocated pages = %d, trident = %d/%d\n", sgbuf->pages, firstpg(blk), lastpg(blk));
212 __snd_util_mem_free(hdr, blk); 214 __snd_util_mem_free(hdr, blk);
213 up(&hdr->block_mutex); 215 mutex_unlock(&hdr->block_mutex);
214 return NULL; 216 return NULL;
215 } 217 }
216 218
@@ -221,12 +223,12 @@ snd_trident_alloc_sg_pages(struct snd_trident *trident,
221 unsigned long ptr = (unsigned long)sgbuf->table[idx].buf; 223 unsigned long ptr = (unsigned long)sgbuf->table[idx].buf;
222 if (! is_valid_page(addr)) { 224 if (! is_valid_page(addr)) {
223 __snd_util_mem_free(hdr, blk); 225 __snd_util_mem_free(hdr, blk);
224 up(&hdr->block_mutex); 226 mutex_unlock(&hdr->block_mutex);
225 return NULL; 227 return NULL;
226 } 228 }
227 set_tlb_bus(trident, page, ptr, addr); 229 set_tlb_bus(trident, page, ptr, addr);
228 } 230 }
229 up(&hdr->block_mutex); 231 mutex_unlock(&hdr->block_mutex);
230 return blk; 232 return blk;
231} 233}
232 234
@@ -248,10 +250,10 @@ snd_trident_alloc_cont_pages(struct snd_trident *trident,
248 hdr = trident->tlb.memhdr; 250 hdr = trident->tlb.memhdr;
249 snd_assert(hdr != NULL, return NULL); 251 snd_assert(hdr != NULL, return NULL);
250 252
251 down(&hdr->block_mutex); 253 mutex_lock(&hdr->block_mutex);
252 blk = search_empty(hdr, runtime->dma_bytes); 254 blk = search_empty(hdr, runtime->dma_bytes);
253 if (blk == NULL) { 255 if (blk == NULL) {
254 up(&hdr->block_mutex); 256 mutex_unlock(&hdr->block_mutex);
255 return NULL; 257 return NULL;
256 } 258 }
257 259
@@ -262,12 +264,12 @@ snd_trident_alloc_cont_pages(struct snd_trident *trident,
262 ptr += SNDRV_TRIDENT_PAGE_SIZE, addr += SNDRV_TRIDENT_PAGE_SIZE) { 264 ptr += SNDRV_TRIDENT_PAGE_SIZE, addr += SNDRV_TRIDENT_PAGE_SIZE) {
263 if (! is_valid_page(addr)) { 265 if (! is_valid_page(addr)) {
264 __snd_util_mem_free(hdr, blk); 266 __snd_util_mem_free(hdr, blk);
265 up(&hdr->block_mutex); 267 mutex_unlock(&hdr->block_mutex);
266 return NULL; 268 return NULL;
267 } 269 }
268 set_tlb_bus(trident, page, ptr, addr); 270 set_tlb_bus(trident, page, ptr, addr);
269 } 271 }
270 up(&hdr->block_mutex); 272 mutex_unlock(&hdr->block_mutex);
271 return blk; 273 return blk;
272} 274}
273 275
@@ -300,13 +302,13 @@ int snd_trident_free_pages(struct snd_trident *trident,
300 snd_assert(blk != NULL, return -EINVAL); 302 snd_assert(blk != NULL, return -EINVAL);
301 303
302 hdr = trident->tlb.memhdr; 304 hdr = trident->tlb.memhdr;
303 down(&hdr->block_mutex); 305 mutex_lock(&hdr->block_mutex);
304 /* reset TLB entries */ 306 /* reset TLB entries */
305 for (page = firstpg(blk); page <= lastpg(blk); page++) 307 for (page = firstpg(blk); page <= lastpg(blk); page++)
306 set_silent_tlb(trident, page); 308 set_silent_tlb(trident, page);
307 /* free memory block */ 309 /* free memory block */
308 __snd_util_mem_free(hdr, blk); 310 __snd_util_mem_free(hdr, blk);
309 up(&hdr->block_mutex); 311 mutex_unlock(&hdr->block_mutex);
310 return 0; 312 return 0;
311} 313}
312 314
@@ -332,18 +334,18 @@ snd_trident_synth_alloc(struct snd_trident *hw, unsigned int size)
332 struct snd_util_memblk *blk; 334 struct snd_util_memblk *blk;
333 struct snd_util_memhdr *hdr = hw->tlb.memhdr; 335 struct snd_util_memhdr *hdr = hw->tlb.memhdr;
334 336
335 down(&hdr->block_mutex); 337 mutex_lock(&hdr->block_mutex);
336 blk = __snd_util_mem_alloc(hdr, size); 338 blk = __snd_util_mem_alloc(hdr, size);
337 if (blk == NULL) { 339 if (blk == NULL) {
338 up(&hdr->block_mutex); 340 mutex_unlock(&hdr->block_mutex);
339 return NULL; 341 return NULL;
340 } 342 }
341 if (synth_alloc_pages(hw, blk)) { 343 if (synth_alloc_pages(hw, blk)) {
342 __snd_util_mem_free(hdr, blk); 344 __snd_util_mem_free(hdr, blk);
343 up(&hdr->block_mutex); 345 mutex_unlock(&hdr->block_mutex);
344 return NULL; 346 return NULL;
345 } 347 }
346 up(&hdr->block_mutex); 348 mutex_unlock(&hdr->block_mutex);
347 return blk; 349 return blk;
348} 350}
349 351
@@ -356,10 +358,10 @@ snd_trident_synth_free(struct snd_trident *hw, struct snd_util_memblk *blk)
356{ 358{
357 struct snd_util_memhdr *hdr = hw->tlb.memhdr; 359 struct snd_util_memhdr *hdr = hw->tlb.memhdr;
358 360
359 down(&hdr->block_mutex); 361 mutex_lock(&hdr->block_mutex);
360 synth_free_pages(hw, blk); 362 synth_free_pages(hw, blk);
361 __snd_util_mem_free(hdr, blk); 363 __snd_util_mem_free(hdr, blk);
362 up(&hdr->block_mutex); 364 mutex_unlock(&hdr->block_mutex);
363 return 0; 365 return 0;
364} 366}
365 367
diff --git a/sound/pci/vx222/vx222_ops.c b/sound/pci/vx222/vx222_ops.c
index c705af409b0f..9b6d345b83a6 100644
--- a/sound/pci/vx222/vx222_ops.c
+++ b/sound/pci/vx222/vx222_ops.c
@@ -24,6 +24,8 @@
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/device.h> 25#include <linux/device.h>
26#include <linux/firmware.h> 26#include <linux/firmware.h>
27#include <linux/mutex.h>
28
27#include <sound/core.h> 29#include <sound/core.h>
28#include <sound/control.h> 30#include <sound/control.h>
29#include <asm/io.h> 31#include <asm/io.h>
@@ -861,10 +863,10 @@ static int vx_input_level_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
861{ 863{
862 struct vx_core *_chip = snd_kcontrol_chip(kcontrol); 864 struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
863 struct snd_vx222 *chip = (struct snd_vx222 *)_chip; 865 struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
864 down(&_chip->mixer_mutex); 866 mutex_lock(&_chip->mixer_mutex);
865 ucontrol->value.integer.value[0] = chip->input_level[0]; 867 ucontrol->value.integer.value[0] = chip->input_level[0];
866 ucontrol->value.integer.value[1] = chip->input_level[1]; 868 ucontrol->value.integer.value[1] = chip->input_level[1];
867 up(&_chip->mixer_mutex); 869 mutex_unlock(&_chip->mixer_mutex);
868 return 0; 870 return 0;
869} 871}
870 872
@@ -872,16 +874,16 @@ static int vx_input_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
872{ 874{
873 struct vx_core *_chip = snd_kcontrol_chip(kcontrol); 875 struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
874 struct snd_vx222 *chip = (struct snd_vx222 *)_chip; 876 struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
875 down(&_chip->mixer_mutex); 877 mutex_lock(&_chip->mixer_mutex);
876 if (chip->input_level[0] != ucontrol->value.integer.value[0] || 878 if (chip->input_level[0] != ucontrol->value.integer.value[0] ||
877 chip->input_level[1] != ucontrol->value.integer.value[1]) { 879 chip->input_level[1] != ucontrol->value.integer.value[1]) {
878 chip->input_level[0] = ucontrol->value.integer.value[0]; 880 chip->input_level[0] = ucontrol->value.integer.value[0];
879 chip->input_level[1] = ucontrol->value.integer.value[1]; 881 chip->input_level[1] = ucontrol->value.integer.value[1];
880 vx2_set_input_level(chip); 882 vx2_set_input_level(chip);
881 up(&_chip->mixer_mutex); 883 mutex_unlock(&_chip->mixer_mutex);
882 return 1; 884 return 1;
883 } 885 }
884 up(&_chip->mixer_mutex); 886 mutex_unlock(&_chip->mixer_mutex);
885 return 0; 887 return 0;
886} 888}
887 889
@@ -907,14 +909,14 @@ static int vx_mic_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
907{ 909{
908 struct vx_core *_chip = snd_kcontrol_chip(kcontrol); 910 struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
909 struct snd_vx222 *chip = (struct snd_vx222 *)_chip; 911 struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
910 down(&_chip->mixer_mutex); 912 mutex_lock(&_chip->mixer_mutex);
911 if (chip->mic_level != ucontrol->value.integer.value[0]) { 913 if (chip->mic_level != ucontrol->value.integer.value[0]) {
912 chip->mic_level = ucontrol->value.integer.value[0]; 914 chip->mic_level = ucontrol->value.integer.value[0];
913 vx2_set_input_level(chip); 915 vx2_set_input_level(chip);
914 up(&_chip->mixer_mutex); 916 mutex_unlock(&_chip->mixer_mutex);
915 return 1; 917 return 1;
916 } 918 }
917 up(&_chip->mixer_mutex); 919 mutex_unlock(&_chip->mixer_mutex);
918 return 0; 920 return 0;
919} 921}
920 922