Skip to content

Commit ef9f0a4

Browse files
Ingo MolnarJaroslav Kysela
authored andcommitted
[ALSA] semaphore -> mutex (driver 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 1a60d4c commit ef9f0a4

22 files changed

Lines changed: 103 additions & 99 deletions

‎include/sound/emux_synth.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ struct snd_emux {
113113
struct snd_emux_voice *voices; /* Voices (EMU 'channel') */
114114
int use_time; /* allocation counter */
115115
spinlock_t voice_lock; /* Lock for voice access */
116-
struct semaphore register_mutex;
116+
struct mutex register_mutex;
117117
int client; /* For the sequencer client */
118118
int ports[SNDRV_EMUX_MAX_PORTS]; /* The ports for this device */
119119
struct snd_emux_port *portptrs[SNDRV_EMUX_MAX_PORTS];

‎include/sound/i2c.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct snd_i2c_bus {
5555
struct snd_card *card; /* card which I2C belongs to */
5656
char name[32]; /* some useful label */
5757

58-
struct semaphore lock_mutex;
58+
struct mutex lock_mutex;
5959

6060
struct snd_i2c_bus *master; /* master bus when SCK/SCL is shared */
6161
struct list_head buses; /* master: slave buses sharing SCK/SCL, slave: link list */
@@ -84,17 +84,17 @@ int snd_i2c_device_free(struct snd_i2c_device *device);
8484
static inline void snd_i2c_lock(struct snd_i2c_bus *bus)
8585
{
8686
if (bus->master)
87-
down(&bus->master->lock_mutex);
87+
mutex_lock(&bus->master->lock_mutex);
8888
else
89-
down(&bus->lock_mutex);
89+
mutex_lock(&bus->lock_mutex);
9090
}
9191

9292
static inline void snd_i2c_unlock(struct snd_i2c_bus *bus)
9393
{
9494
if (bus->master)
95-
up(&bus->master->lock_mutex);
95+
mutex_unlock(&bus->master->lock_mutex);
9696
else
97-
up(&bus->lock_mutex);
97+
mutex_unlock(&bus->lock_mutex);
9898
}
9999

100100
int snd_i2c_sendbytes(struct snd_i2c_device *device, unsigned char *bytes, int count);

‎include/sound/opl3.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353

5454
#include "driver.h"
5555
#include <linux/time.h>
56+
#include <linux/mutex.h>
5657
#include "core.h"
5758
#include "hwdep.h"
5859
#include "timer.h"
@@ -312,7 +313,7 @@ struct snd_opl3 {
312313
int sys_timer_status; /* system timer run status */
313314
spinlock_t sys_timer_lock; /* Lock for system timer access */
314315
#endif
315-
struct semaphore access_mutex; /* locking */
316+
struct mutex access_mutex; /* locking */
316317
};
317318

318319
/* opl3.c */

‎include/sound/soundfont.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ struct snd_sf_list {
9393
int sample_locked; /* locked time for sample */
9494
struct snd_sf_callback callback; /* callback functions */
9595
int presets_locked;
96-
struct semaphore presets_mutex;
96+
struct mutex presets_mutex;
9797
spinlock_t lock;
9898
struct snd_util_memhdr *memhdr;
9999
};

‎include/sound/util_mem.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#ifndef __SOUND_UTIL_MEM_H
22
#define __SOUND_UTIL_MEM_H
3+
4+
#include <linux/mutex.h>
35
/*
46
* Copyright (C) 2000 Takashi Iwai <tiwai@suse.de>
57
*
@@ -40,7 +42,7 @@ struct snd_util_memhdr {
4042
int nblocks; /* # of allocated blocks */
4143
unsigned int used; /* used memory size */
4244
int block_extra_size; /* extra data size of chunk */
43-
struct semaphore block_mutex; /* lock */
45+
struct mutex block_mutex; /* lock */
4446
};
4547

4648
/*

‎include/sound/vx_core.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ struct vx_core {
206206
int audio_monitor[4]; /* playback hw-monitor level */
207207
unsigned char audio_monitor_active[4]; /* playback hw-monitor mute/unmute */
208208

209-
struct semaphore mixer_mutex;
209+
struct mutex mixer_mutex;
210210

211211
const struct firmware *firmware[4]; /* loaded firmware data */
212212
};

‎sound/drivers/opl3/opl3_lib.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ int snd_opl3_new(struct snd_card *card,
358358
opl3->hardware = hardware;
359359
spin_lock_init(&opl3->reg_lock);
360360
spin_lock_init(&opl3->timer_lock);
361-
init_MUTEX(&opl3->access_mutex);
361+
mutex_init(&opl3->access_mutex);
362362

363363
if ((err = snd_device_new(card, SNDRV_DEV_CODEC, opl3, &ops)) < 0) {
364364
snd_opl3_free(opl3);

‎sound/drivers/opl3/opl3_seq.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ int snd_opl3_synth_setup(struct snd_opl3 * opl3)
5252
{
5353
int idx;
5454

55-
down(&opl3->access_mutex);
55+
mutex_lock(&opl3->access_mutex);
5656
if (opl3->used) {
57-
up(&opl3->access_mutex);
57+
mutex_unlock(&opl3->access_mutex);
5858
return -EBUSY;
5959
}
6060
opl3->used++;
61-
up(&opl3->access_mutex);
61+
mutex_unlock(&opl3->access_mutex);
6262

6363
snd_opl3_reset(opl3);
6464

@@ -91,9 +91,9 @@ void snd_opl3_synth_cleanup(struct snd_opl3 * opl3)
9191
spin_unlock_irqrestore(&opl3->sys_timer_lock, flags);
9292

9393
snd_opl3_reset(opl3);
94-
down(&opl3->access_mutex);
94+
mutex_lock(&opl3->access_mutex);
9595
opl3->used--;
96-
up(&opl3->access_mutex);
96+
mutex_unlock(&opl3->access_mutex);
9797
}
9898

9999
static int snd_opl3_synth_use(void *private_data, struct snd_seq_port_subscribe * info)

‎sound/drivers/opl3/opl3_synth.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ int snd_opl3_open(struct snd_hwdep * hw, struct file *file)
7676
{
7777
struct snd_opl3 *opl3 = hw->private_data;
7878

79-
down(&opl3->access_mutex);
79+
mutex_lock(&opl3->access_mutex);
8080
if (opl3->used) {
81-
up(&opl3->access_mutex);
81+
mutex_unlock(&opl3->access_mutex);
8282
return -EAGAIN;
8383
}
8484
opl3->used++;
85-
up(&opl3->access_mutex);
85+
mutex_unlock(&opl3->access_mutex);
8686

8787
return 0;
8888
}
@@ -179,9 +179,9 @@ int snd_opl3_release(struct snd_hwdep * hw, struct file *file)
179179
struct snd_opl3 *opl3 = hw->private_data;
180180

181181
snd_opl3_reset(opl3);
182-
down(&opl3->access_mutex);
182+
mutex_lock(&opl3->access_mutex);
183183
opl3->used--;
184-
up(&opl3->access_mutex);
184+
mutex_unlock(&opl3->access_mutex);
185185

186186
return 0;
187187
}

‎sound/drivers/opl4/opl4_lib.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ int snd_opl4_create(struct snd_card *card,
214214
opl4->fm_port = fm_port;
215215
opl4->pcm_port = pcm_port;
216216
spin_lock_init(&opl4->reg_lock);
217-
init_MUTEX(&opl4->access_mutex);
217+
mutex_init(&opl4->access_mutex);
218218

219219
err = snd_opl4_detect(opl4);
220220
if (err < 0) {

0 commit comments

Comments
 (0)