Skip to content

Commit 62932df

Browse files
Ingo MolnarJaroslav Kysela
authored andcommitted
[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>
1 parent 8b7547f commit 62932df

43 files changed

Lines changed: 549 additions & 489 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎include/sound/ac97_codec.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,8 @@ struct snd_ac97 {
456456
struct snd_info_entry *proc_regs;
457457
unsigned short subsystem_vendor;
458458
unsigned short subsystem_device;
459-
struct semaphore reg_mutex;
460-
struct semaphore page_mutex; /* mutex for AD18xx multi-codecs and paging (2.3) */
459+
struct mutex reg_mutex;
460+
struct mutex page_mutex; /* mutex for AD18xx multi-codecs and paging (2.3) */
461461
unsigned short num; /* number of codec: 0 = primary, 1 = secondary */
462462
unsigned short addr; /* physical address of codec [0-3] */
463463
unsigned int id; /* identification of codec */

‎include/sound/ak4531_codec.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct snd_ak4531 {
7171
void (*private_free) (struct snd_ak4531 *ak4531);
7272
/* --- */
7373
unsigned char regs[0x20];
74-
struct semaphore reg_mutex;
74+
struct mutex reg_mutex;
7575
};
7676

7777
int snd_ak4531_mixer(struct snd_card *card, struct snd_ak4531 *_ak4531,

‎include/sound/cs46xx.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,7 @@ struct snd_cs46xx {
17111711
int current_gpio;
17121712
#endif
17131713
#ifdef CONFIG_SND_CS46XX_NEW_DSP
1714-
struct semaphore spos_mutex;
1714+
struct mutex spos_mutex;
17151715

17161716
struct dsp_spos_instance * dsp_spos_instance;
17171717

‎include/sound/emu10k1.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <sound/pcm-indirect.h>
3434
#include <sound/timer.h>
3535
#include <linux/interrupt.h>
36+
#include <linux/mutex.h>
3637
#include <asm/io.h>
3738

3839
/* ------------------- DEFINES -------------------- */
@@ -1022,7 +1023,7 @@ struct snd_emu10k1_fx8010 {
10221023
int gpr_size; /* size of allocated GPR controls */
10231024
int gpr_count; /* count of used kcontrols */
10241025
struct list_head gpr_ctl; /* GPR controls */
1025-
struct semaphore lock;
1026+
struct mutex lock;
10261027
struct snd_emu10k1_fx8010_pcm pcm[8];
10271028
spinlock_t irq_lock;
10281029
struct snd_emu10k1_fx8010_irq *irq_handlers;
@@ -1122,7 +1123,6 @@ struct snd_emu10k1 {
11221123
spinlock_t reg_lock;
11231124
spinlock_t emu_lock;
11241125
spinlock_t voice_lock;
1125-
struct semaphore ptb_lock;
11261126

11271127
struct snd_emu10k1_voice voices[NUM_G];
11281128
struct snd_emu10k1_voice p16v_voices[4];

‎sound/pci/ac97/ac97_codec.c‎

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
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) {

‎sound/pci/ac97/ac97_patch.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <linux/delay.h>
2828
#include <linux/init.h>
2929
#include <linux/slab.h>
30+
#include <linux/mutex.h>
31+
3032
#include <sound/core.h>
3133
#include <sound/pcm.h>
3234
#include <sound/control.h>
@@ -55,12 +57,12 @@ static int ac97_update_bits_page(struct snd_ac97 *ac97, unsigned short reg, unsi
5557
unsigned short page_save;
5658
int ret;
5759

58-
down(&ac97->page_mutex);
60+
mutex_lock(&ac97->page_mutex);
5961
page_save = snd_ac97_read(ac97, AC97_INT_PAGING) & AC97_PAGE_MASK;
6062
snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page);
6163
ret = snd_ac97_update_bits(ac97, reg, mask, value);
6264
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 */
6466
return ret;
6567
}
6668

@@ -897,12 +899,12 @@ static int snd_ac97_stac9708_put_bias(struct snd_kcontrol *kcontrol, struct snd_
897899
struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
898900
int err;
899901

900-
down(&ac97->page_mutex);
902+
mutex_lock(&ac97->page_mutex);
901903
snd_ac97_write(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
902904
err = snd_ac97_update_bits(ac97, AC97_SIGMATEL_BIAS2, 0x0010,
903905
(ucontrol->value.integer.value[0] & 1) << 4);
904906
snd_ac97_write(ac97, AC97_SIGMATEL_BIAS1, 0);
905-
up(&ac97->page_mutex);
907+
mutex_unlock(&ac97->page_mutex);
906908
return err;
907909
}
908910

‎sound/pci/ac97/ac97_pcm.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <linux/delay.h>
2828
#include <linux/init.h>
2929
#include <linux/slab.h>
30+
#include <linux/mutex.h>
31+
3032
#include <sound/core.h>
3133
#include <sound/pcm.h>
3234
#include <sound/control.h>
@@ -206,7 +208,7 @@ static int set_spdif_rate(struct snd_ac97 *ac97, unsigned short rate)
206208
mask = AC97_SC_SPSR_MASK;
207209
}
208210

209-
down(&ac97->reg_mutex);
211+
mutex_lock(&ac97->reg_mutex);
210212
old = snd_ac97_read(ac97, reg) & mask;
211213
if (old != bits) {
212214
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)
231233
ac97->spdif_status = sbits;
232234
}
233235
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);
235237
return 0;
236238
}
237239

‎sound/pci/ac97/ac97_proc.c‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
#include <sound/driver.h>
2626
#include <linux/slab.h>
27+
#include <linux/mutex.h>
28+
2729
#include <sound/core.h>
2830
#include <sound/ac97_codec.h>
2931
#include <sound/asoundef.h>
@@ -338,7 +340,7 @@ static void snd_ac97_proc_read(struct snd_info_entry *entry, struct snd_info_buf
338340
{
339341
struct snd_ac97 *ac97 = entry->private_data;
340342

341-
down(&ac97->page_mutex);
343+
mutex_lock(&ac97->page_mutex);
342344
if ((ac97->id & 0xffffff40) == AC97_ID_AD1881) { // Analog Devices AD1881/85/86
343345
int idx;
344346
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
364366
} else {
365367
snd_ac97_proc_read_main(ac97, buffer, 0);
366368
}
367-
up(&ac97->page_mutex);
369+
mutex_unlock(&ac97->page_mutex);
368370
}
369371

370372
#ifdef CONFIG_SND_DEBUG
@@ -374,15 +376,15 @@ static void snd_ac97_proc_regs_write(struct snd_info_entry *entry, struct snd_in
374376
struct snd_ac97 *ac97 = entry->private_data;
375377
char line[64];
376378
unsigned int reg, val;
377-
down(&ac97->page_mutex);
379+
mutex_lock(&ac97->page_mutex);
378380
while (!snd_info_get_line(buffer, line, sizeof(line))) {
379381
if (sscanf(line, "%x %x", &reg, &val) != 2)
380382
continue;
381383
/* register must be even */
382384
if (reg < 0x80 && (reg & 1) == 0 && val <= 0xffff)
383385
snd_ac97_write_cache(ac97, reg, val);
384386
}
385-
up(&ac97->page_mutex);
387+
mutex_unlock(&ac97->page_mutex);
386388
}
387389
#endif
388390

@@ -401,7 +403,7 @@ static void snd_ac97_proc_regs_read(struct snd_info_entry *entry,
401403
{
402404
struct snd_ac97 *ac97 = entry->private_data;
403405

404-
down(&ac97->page_mutex);
406+
mutex_lock(&ac97->page_mutex);
405407
if ((ac97->id & 0xffffff40) == AC97_ID_AD1881) { // Analog Devices AD1881/85/86
406408

407409
int idx;
@@ -417,7 +419,7 @@ static void snd_ac97_proc_regs_read(struct snd_info_entry *entry,
417419
} else {
418420
snd_ac97_proc_regs_read_main(ac97, buffer, 0);
419421
}
420-
up(&ac97->page_mutex);
422+
mutex_unlock(&ac97->page_mutex);
421423
}
422424

423425
void snd_ac97_proc_init(struct snd_ac97 * ac97)

0 commit comments

Comments
 (0)