aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ac97
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 /sound/pci/ac97
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>
Diffstat (limited to 'sound/pci/ac97')
-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
5 files changed, 56 insertions, 47 deletions
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;