Skip to content

Commit

Permalink
[ALSA] semaphore -> mutex (driver part)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ingo Molnar authored and Jaroslav Kysela committed Mar 22, 2006
1 parent 1a60d4c commit ef9f0a4
Show file tree
Hide file tree
Showing 22 changed files with 103 additions and 99 deletions.
2 changes: 1 addition & 1 deletion include/sound/emux_synth.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ struct snd_emux {
struct snd_emux_voice *voices; /* Voices (EMU 'channel') */
int use_time; /* allocation counter */
spinlock_t voice_lock; /* Lock for voice access */
struct semaphore register_mutex;
struct mutex register_mutex;
int client; /* For the sequencer client */
int ports[SNDRV_EMUX_MAX_PORTS]; /* The ports for this device */
struct snd_emux_port *portptrs[SNDRV_EMUX_MAX_PORTS];
Expand Down
10 changes: 5 additions & 5 deletions include/sound/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct snd_i2c_bus {
struct snd_card *card; /* card which I2C belongs to */
char name[32]; /* some useful label */

struct semaphore lock_mutex;
struct mutex lock_mutex;

struct snd_i2c_bus *master; /* master bus when SCK/SCL is shared */
struct list_head buses; /* master: slave buses sharing SCK/SCL, slave: link list */
Expand Down Expand Up @@ -84,17 +84,17 @@ int snd_i2c_device_free(struct snd_i2c_device *device);
static inline void snd_i2c_lock(struct snd_i2c_bus *bus)
{
if (bus->master)
down(&bus->master->lock_mutex);
mutex_lock(&bus->master->lock_mutex);
else
down(&bus->lock_mutex);
mutex_lock(&bus->lock_mutex);
}

static inline void snd_i2c_unlock(struct snd_i2c_bus *bus)
{
if (bus->master)
up(&bus->master->lock_mutex);
mutex_unlock(&bus->master->lock_mutex);
else
up(&bus->lock_mutex);
mutex_unlock(&bus->lock_mutex);
}

int snd_i2c_sendbytes(struct snd_i2c_device *device, unsigned char *bytes, int count);
Expand Down
3 changes: 2 additions & 1 deletion include/sound/opl3.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

#include "driver.h"
#include <linux/time.h>
#include <linux/mutex.h>
#include "core.h"
#include "hwdep.h"
#include "timer.h"
Expand Down Expand Up @@ -312,7 +313,7 @@ struct snd_opl3 {
int sys_timer_status; /* system timer run status */
spinlock_t sys_timer_lock; /* Lock for system timer access */
#endif
struct semaphore access_mutex; /* locking */
struct mutex access_mutex; /* locking */
};

/* opl3.c */
Expand Down
2 changes: 1 addition & 1 deletion include/sound/soundfont.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct snd_sf_list {
int sample_locked; /* locked time for sample */
struct snd_sf_callback callback; /* callback functions */
int presets_locked;
struct semaphore presets_mutex;
struct mutex presets_mutex;
spinlock_t lock;
struct snd_util_memhdr *memhdr;
};
Expand Down
4 changes: 3 additions & 1 deletion include/sound/util_mem.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#ifndef __SOUND_UTIL_MEM_H
#define __SOUND_UTIL_MEM_H

#include <linux/mutex.h>
/*
* Copyright (C) 2000 Takashi Iwai <tiwai@suse.de>
*
Expand Down Expand Up @@ -40,7 +42,7 @@ struct snd_util_memhdr {
int nblocks; /* # of allocated blocks */
unsigned int used; /* used memory size */
int block_extra_size; /* extra data size of chunk */
struct semaphore block_mutex; /* lock */
struct mutex block_mutex; /* lock */
};

/*
Expand Down
2 changes: 1 addition & 1 deletion include/sound/vx_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ struct vx_core {
int audio_monitor[4]; /* playback hw-monitor level */
unsigned char audio_monitor_active[4]; /* playback hw-monitor mute/unmute */

struct semaphore mixer_mutex;
struct mutex mixer_mutex;

const struct firmware *firmware[4]; /* loaded firmware data */
};
Expand Down
2 changes: 1 addition & 1 deletion sound/drivers/opl3/opl3_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ int snd_opl3_new(struct snd_card *card,
opl3->hardware = hardware;
spin_lock_init(&opl3->reg_lock);
spin_lock_init(&opl3->timer_lock);
init_MUTEX(&opl3->access_mutex);
mutex_init(&opl3->access_mutex);

if ((err = snd_device_new(card, SNDRV_DEV_CODEC, opl3, &ops)) < 0) {
snd_opl3_free(opl3);
Expand Down
10 changes: 5 additions & 5 deletions sound/drivers/opl3/opl3_seq.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ int snd_opl3_synth_setup(struct snd_opl3 * opl3)
{
int idx;

down(&opl3->access_mutex);
mutex_lock(&opl3->access_mutex);
if (opl3->used) {
up(&opl3->access_mutex);
mutex_unlock(&opl3->access_mutex);
return -EBUSY;
}
opl3->used++;
up(&opl3->access_mutex);
mutex_unlock(&opl3->access_mutex);

snd_opl3_reset(opl3);

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

snd_opl3_reset(opl3);
down(&opl3->access_mutex);
mutex_lock(&opl3->access_mutex);
opl3->used--;
up(&opl3->access_mutex);
mutex_unlock(&opl3->access_mutex);
}

static int snd_opl3_synth_use(void *private_data, struct snd_seq_port_subscribe * info)
Expand Down
10 changes: 5 additions & 5 deletions sound/drivers/opl3/opl3_synth.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ int snd_opl3_open(struct snd_hwdep * hw, struct file *file)
{
struct snd_opl3 *opl3 = hw->private_data;

down(&opl3->access_mutex);
mutex_lock(&opl3->access_mutex);
if (opl3->used) {
up(&opl3->access_mutex);
mutex_unlock(&opl3->access_mutex);
return -EAGAIN;
}
opl3->used++;
up(&opl3->access_mutex);
mutex_unlock(&opl3->access_mutex);

return 0;
}
Expand Down Expand Up @@ -179,9 +179,9 @@ int snd_opl3_release(struct snd_hwdep * hw, struct file *file)
struct snd_opl3 *opl3 = hw->private_data;

snd_opl3_reset(opl3);
down(&opl3->access_mutex);
mutex_lock(&opl3->access_mutex);
opl3->used--;
up(&opl3->access_mutex);
mutex_unlock(&opl3->access_mutex);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion sound/drivers/opl4/opl4_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ int snd_opl4_create(struct snd_card *card,
opl4->fm_port = fm_port;
opl4->pcm_port = pcm_port;
spin_lock_init(&opl4->reg_lock);
init_MUTEX(&opl4->access_mutex);
mutex_init(&opl4->access_mutex);

err = snd_opl4_detect(opl4);
if (err < 0) {
Expand Down
2 changes: 1 addition & 1 deletion sound/drivers/opl4/opl4_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ struct snd_opl4 {
struct snd_info_entry *proc_entry;
int memory_access;
#endif
struct semaphore access_mutex;
struct mutex access_mutex;

#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
int used;
Expand Down
10 changes: 5 additions & 5 deletions sound/drivers/opl4/opl4_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ static int snd_opl4_mem_proc_open(struct snd_info_entry *entry,
{
struct snd_opl4 *opl4 = entry->private_data;

down(&opl4->access_mutex);
mutex_lock(&opl4->access_mutex);
if (opl4->memory_access) {
up(&opl4->access_mutex);
mutex_unlock(&opl4->access_mutex);
return -EBUSY;
}
opl4->memory_access++;
up(&opl4->access_mutex);
mutex_unlock(&opl4->access_mutex);
return 0;
}

Expand All @@ -43,9 +43,9 @@ static int snd_opl4_mem_proc_release(struct snd_info_entry *entry,
{
struct snd_opl4 *opl4 = entry->private_data;

down(&opl4->access_mutex);
mutex_lock(&opl4->access_mutex);
opl4->memory_access--;
up(&opl4->access_mutex);
mutex_unlock(&opl4->access_mutex);
return 0;
}

Expand Down
12 changes: 6 additions & 6 deletions sound/drivers/opl4/opl4_seq.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,23 @@ static int snd_opl4_seq_use(void *private_data, struct snd_seq_port_subscribe *i
struct snd_opl4 *opl4 = private_data;
int err;

down(&opl4->access_mutex);
mutex_lock(&opl4->access_mutex);

if (opl4->used) {
up(&opl4->access_mutex);
mutex_unlock(&opl4->access_mutex);
return -EBUSY;
}
opl4->used++;

if (info->sender.client != SNDRV_SEQ_CLIENT_SYSTEM) {
err = snd_opl4_seq_use_inc(opl4);
if (err < 0) {
up(&opl4->access_mutex);
mutex_unlock(&opl4->access_mutex);
return err;
}
}

up(&opl4->access_mutex);
mutex_unlock(&opl4->access_mutex);

snd_opl4_synth_reset(opl4);
return 0;
Expand All @@ -90,9 +90,9 @@ static int snd_opl4_seq_unuse(void *private_data, struct snd_seq_port_subscribe

snd_opl4_synth_shutdown(opl4);

down(&opl4->access_mutex);
mutex_lock(&opl4->access_mutex);
opl4->used--;
up(&opl4->access_mutex);
mutex_unlock(&opl4->access_mutex);

if (info->sender.client != SNDRV_SEQ_CLIENT_SYSTEM)
snd_opl4_seq_use_dec(opl4);
Expand Down
2 changes: 1 addition & 1 deletion sound/drivers/vx/vx_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ struct vx_core *snd_vx_create(struct snd_card *card, struct snd_vx_hardware *hw,
chip->type = hw->type;
chip->ops = ops;
tasklet_init(&chip->tq, vx_interrupt, (unsigned long)chip);
init_MUTEX(&chip->mixer_mutex);
mutex_init(&chip->mixer_mutex);

chip->card = card;
card->private_data = chip;
Expand Down
Loading

0 comments on commit ef9f0a4

Please sign in to comment.