2828#include <linux/slab.h>
2929#include <linux/pci.h>
3030#include <linux/moduleparam.h>
31+ #include <linux/mutex.h>
3132#include <sound/core.h>
3233#include <sound/pcm.h>
3334#include <sound/ac97_codec.h>
@@ -296,11 +297,11 @@ void snd_ac97_write_cache(struct snd_ac97 *ac97, unsigned short reg, unsigned sh
296297{
297298 if (!snd_ac97_valid_reg (ac97 , reg ))
298299 return ;
299- down (& ac97 -> reg_mutex );
300+ mutex_lock (& ac97 -> reg_mutex );
300301 ac97 -> regs [reg ] = value ;
301302 ac97 -> bus -> ops -> write (ac97 , reg , value );
302303 set_bit (reg , ac97 -> reg_accessed );
303- up (& ac97 -> reg_mutex );
304+ mutex_unlock (& ac97 -> reg_mutex );
304305}
305306
306307/**
@@ -321,14 +322,14 @@ int snd_ac97_update(struct snd_ac97 *ac97, unsigned short reg, unsigned short va
321322
322323 if (!snd_ac97_valid_reg (ac97 , reg ))
323324 return - EINVAL ;
324- down (& ac97 -> reg_mutex );
325+ mutex_lock (& ac97 -> reg_mutex );
325326 change = ac97 -> regs [reg ] != value ;
326327 if (change ) {
327328 ac97 -> regs [reg ] = value ;
328329 ac97 -> bus -> ops -> write (ac97 , reg , value );
329330 }
330331 set_bit (reg , ac97 -> reg_accessed );
331- up (& ac97 -> reg_mutex );
332+ mutex_unlock (& ac97 -> reg_mutex );
332333 return change ;
333334}
334335
@@ -351,9 +352,9 @@ int snd_ac97_update_bits(struct snd_ac97 *ac97, unsigned short reg, unsigned sho
351352
352353 if (!snd_ac97_valid_reg (ac97 , reg ))
353354 return - EINVAL ;
354- down (& ac97 -> reg_mutex );
355+ mutex_lock (& ac97 -> reg_mutex );
355356 change = snd_ac97_update_bits_nolock (ac97 , reg , mask , value );
356- up (& ac97 -> reg_mutex );
357+ mutex_unlock (& ac97 -> reg_mutex );
357358 return change ;
358359}
359360
@@ -380,12 +381,12 @@ static int snd_ac97_ad18xx_update_pcm_bits(struct snd_ac97 *ac97, int codec, uns
380381 int change ;
381382 unsigned short old , new , cfg ;
382383
383- down (& ac97 -> page_mutex );
384+ mutex_lock (& ac97 -> page_mutex );
384385 old = ac97 -> spec .ad18xx .pcmreg [codec ];
385386 new = (old & ~mask ) | value ;
386387 change = old != new ;
387388 if (change ) {
388- down (& ac97 -> reg_mutex );
389+ mutex_lock (& ac97 -> reg_mutex );
389390 cfg = snd_ac97_read_cache (ac97 , AC97_AD_SERIAL_CFG );
390391 ac97 -> spec .ad18xx .pcmreg [codec ] = new ;
391392 /* select single codec */
@@ -397,9 +398,9 @@ static int snd_ac97_ad18xx_update_pcm_bits(struct snd_ac97 *ac97, int codec, uns
397398 /* select all codecs */
398399 ac97 -> bus -> ops -> write (ac97 , AC97_AD_SERIAL_CFG ,
399400 cfg | 0x7000 );
400- up (& ac97 -> reg_mutex );
401+ mutex_unlock (& ac97 -> reg_mutex );
401402 }
402- up (& ac97 -> page_mutex );
403+ mutex_unlock (& ac97 -> page_mutex );
403404 return change ;
404405}
405406
@@ -467,7 +468,7 @@ static int snd_ac97_page_save(struct snd_ac97 *ac97, int reg, struct snd_kcontro
467468 (ac97 -> ext_id & AC97_EI_REV_MASK ) >= AC97_EI_REV_23 &&
468469 (reg >= 0x60 && reg < 0x70 )) {
469470 unsigned short page = (kcontrol -> private_value >> 26 ) & 0x0f ;
470- down (& ac97 -> page_mutex ); /* lock paging */
471+ mutex_lock (& ac97 -> page_mutex ); /* lock paging */
471472 page_save = snd_ac97_read (ac97 , AC97_INT_PAGING ) & AC97_PAGE_MASK ;
472473 snd_ac97_update_bits (ac97 , AC97_INT_PAGING , AC97_PAGE_MASK , page );
473474 }
@@ -478,7 +479,7 @@ static void snd_ac97_page_restore(struct snd_ac97 *ac97, int page_save)
478479{
479480 if (page_save >= 0 ) {
480481 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 */
482483 }
483484}
484485
@@ -674,12 +675,12 @@ static int snd_ac97_spdif_default_get(struct snd_kcontrol *kcontrol, struct snd_
674675{
675676 struct snd_ac97 * ac97 = snd_kcontrol_chip (kcontrol );
676677
677- down (& ac97 -> reg_mutex );
678+ mutex_lock (& ac97 -> reg_mutex );
678679 ucontrol -> value .iec958 .status [0 ] = ac97 -> spdif_status & 0xff ;
679680 ucontrol -> value .iec958 .status [1 ] = (ac97 -> spdif_status >> 8 ) & 0xff ;
680681 ucontrol -> value .iec958 .status [2 ] = (ac97 -> spdif_status >> 16 ) & 0xff ;
681682 ucontrol -> value .iec958 .status [3 ] = (ac97 -> spdif_status >> 24 ) & 0xff ;
682- up (& ac97 -> reg_mutex );
683+ mutex_unlock (& ac97 -> reg_mutex );
683684 return 0 ;
684685}
685686
@@ -718,7 +719,7 @@ static int snd_ac97_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_
718719 }
719720 }
720721
721- down (& ac97 -> reg_mutex );
722+ mutex_lock (& ac97 -> reg_mutex );
722723 change = ac97 -> spdif_status != new ;
723724 ac97 -> spdif_status = new ;
724725
@@ -746,7 +747,7 @@ static int snd_ac97_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_
746747 snd_ac97_update_bits_nolock (ac97 , AC97_EXTENDED_STATUS , AC97_EA_SPDIF , AC97_EA_SPDIF ); /* turn on again */
747748 }
748749 }
749- up (& ac97 -> reg_mutex );
750+ mutex_unlock (& ac97 -> reg_mutex );
750751
751752 return change ;
752753}
@@ -763,7 +764,7 @@ static int snd_ac97_put_spsa(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
763764
764765 value = (ucontrol -> value .integer .value [0 ] & mask );
765766
766- down (& ac97 -> reg_mutex );
767+ mutex_lock (& ac97 -> reg_mutex );
767768 mask <<= shift ;
768769 value <<= shift ;
769770 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_
777778 if (extst & AC97_EA_SPDIF )
778779 snd_ac97_update_bits_nolock (ac97 , AC97_EXTENDED_STATUS , AC97_EA_SPDIF , AC97_EA_SPDIF ); /* turn on again */
779780 }
780- up (& ac97 -> reg_mutex );
781+ mutex_unlock (& ac97 -> reg_mutex );
781782 return change ;
782783}
783784
@@ -888,10 +889,10 @@ static int snd_ac97_ad18xx_pcm_get_volume(struct snd_kcontrol *kcontrol, struct
888889 struct snd_ac97 * ac97 = snd_kcontrol_chip (kcontrol );
889890 int codec = kcontrol -> private_value & 3 ;
890891
891- down (& ac97 -> page_mutex );
892+ mutex_lock (& ac97 -> page_mutex );
892893 ucontrol -> value .integer .value [0 ] = 31 - ((ac97 -> spec .ad18xx .pcmreg [codec ] >> 0 ) & 31 );
893894 ucontrol -> value .integer .value [1 ] = 31 - ((ac97 -> spec .ad18xx .pcmreg [codec ] >> 8 ) & 31 );
894- up (& ac97 -> page_mutex );
895+ mutex_unlock (& ac97 -> page_mutex );
895896 return 0 ;
896897}
897898
@@ -1856,8 +1857,8 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
18561857 ac97 -> limited_regs = template -> limited_regs ;
18571858 memcpy (ac97 -> reg_accessed , template -> reg_accessed , sizeof (ac97 -> reg_accessed ));
18581859 bus -> codec [ac97 -> num ] = ac97 ;
1859- init_MUTEX (& ac97 -> reg_mutex );
1860- init_MUTEX (& ac97 -> page_mutex );
1860+ mutex_init (& ac97 -> reg_mutex );
1861+ mutex_init (& ac97 -> page_mutex );
18611862
18621863#ifdef CONFIG_PCI
18631864 if (ac97 -> pci ) {
0 commit comments