提交 1a60d4c5 编写于 作者: I Ingo Molnar 提交者: Jaroslav Kysela

[ALSA] semaphore -> mutex (core 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: NIngo Molnar <mingo@elte.hu>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 f0283f45
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
*/ */
#include <linux/sched.h> /* wake_up() */ #include <linux/sched.h> /* wake_up() */
#include <asm/semaphore.h> /* struct semaphore */ #include <linux/mutex.h> /* struct mutex */
#include <linux/rwsem.h> /* struct rw_semaphore */ #include <linux/rwsem.h> /* struct rw_semaphore */
#include <linux/workqueue.h> /* struct workqueue_struct */ #include <linux/workqueue.h> /* struct workqueue_struct */
#include <linux/pm.h> /* pm_message_t */ #include <linux/pm.h> /* pm_message_t */
...@@ -137,7 +137,7 @@ struct snd_card { ...@@ -137,7 +137,7 @@ struct snd_card {
#ifdef CONFIG_PM #ifdef CONFIG_PM
unsigned int power_state; /* power state */ unsigned int power_state; /* power state */
struct semaphore power_lock; /* power lock */ struct mutex power_lock; /* power lock */
wait_queue_head_t power_sleep; wait_queue_head_t power_sleep;
#endif #endif
...@@ -150,12 +150,12 @@ struct snd_card { ...@@ -150,12 +150,12 @@ struct snd_card {
#ifdef CONFIG_PM #ifdef CONFIG_PM
static inline void snd_power_lock(struct snd_card *card) static inline void snd_power_lock(struct snd_card *card)
{ {
down(&card->power_lock); mutex_lock(&card->power_lock);
} }
static inline void snd_power_unlock(struct snd_card *card) static inline void snd_power_unlock(struct snd_card *card)
{ {
up(&card->power_lock); mutex_unlock(&card->power_lock);
} }
static inline unsigned int snd_power_get_state(struct snd_card *card) static inline unsigned int snd_power_get_state(struct snd_card *card)
......
...@@ -60,7 +60,7 @@ struct snd_hwdep { ...@@ -60,7 +60,7 @@ struct snd_hwdep {
void *private_data; void *private_data;
void (*private_free) (struct snd_hwdep *hwdep); void (*private_free) (struct snd_hwdep *hwdep);
struct semaphore open_mutex; struct mutex open_mutex;
int used; int used;
unsigned int dsp_loaded; unsigned int dsp_loaded;
unsigned int exclusive: 1; unsigned int exclusive: 1;
......
...@@ -84,7 +84,7 @@ struct snd_info_entry { ...@@ -84,7 +84,7 @@ struct snd_info_entry {
void *private_data; void *private_data;
void (*private_free)(struct snd_info_entry *entry); void (*private_free)(struct snd_info_entry *entry);
struct proc_dir_entry *p; struct proc_dir_entry *p;
struct semaphore access; struct mutex access;
}; };
#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS) #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
......
...@@ -61,7 +61,7 @@ struct snd_mixer_oss { ...@@ -61,7 +61,7 @@ struct snd_mixer_oss {
unsigned int active_index); unsigned int active_index);
void *private_data_recsrc; void *private_data_recsrc;
void (*private_free_recsrc)(struct snd_mixer_oss *mixer); void (*private_free_recsrc)(struct snd_mixer_oss *mixer);
struct semaphore reg_mutex; struct mutex reg_mutex;
struct snd_info_entry *proc_entry; struct snd_info_entry *proc_entry;
int oss_dev_alloc; int oss_dev_alloc;
/* --- */ /* --- */
......
...@@ -420,7 +420,7 @@ struct snd_pcm { ...@@ -420,7 +420,7 @@ struct snd_pcm {
char id[64]; char id[64];
char name[80]; char name[80];
struct snd_pcm_str streams[2]; struct snd_pcm_str streams[2];
struct semaphore open_mutex; struct mutex open_mutex;
wait_queue_head_t open_wait; wait_queue_head_t open_wait;
void *private_data; void *private_data;
void (*private_free) (struct snd_pcm *pcm); void (*private_free) (struct snd_pcm *pcm);
......
...@@ -75,7 +75,7 @@ struct snd_pcm_oss_substream { ...@@ -75,7 +75,7 @@ struct snd_pcm_oss_substream {
struct snd_pcm_oss_stream { struct snd_pcm_oss_stream {
struct snd_pcm_oss_setup *setup_list; /* setup list */ struct snd_pcm_oss_setup *setup_list; /* setup list */
struct semaphore setup_mutex; struct mutex setup_mutex;
struct snd_info_entry *proc_entry; struct snd_info_entry *proc_entry;
}; };
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <asm/semaphore.h> #include <linux/mutex.h>
#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE) #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
#include "seq_device.h" #include "seq_device.h"
...@@ -130,7 +130,7 @@ struct snd_rawmidi { ...@@ -130,7 +130,7 @@ struct snd_rawmidi {
void *private_data; void *private_data;
void (*private_free) (struct snd_rawmidi *rmidi); void (*private_free) (struct snd_rawmidi *rmidi);
struct semaphore open_mutex; struct mutex open_mutex;
wait_queue_head_t open_wait; wait_queue_head_t open_wait;
struct snd_info_entry *dev; struct snd_info_entry *dev;
......
...@@ -64,7 +64,7 @@ struct snd_seq_kinstr_list { ...@@ -64,7 +64,7 @@ struct snd_seq_kinstr_list {
spinlock_t lock; spinlock_t lock;
spinlock_t ops_lock; spinlock_t ops_lock;
struct semaphore ops_mutex; struct mutex ops_mutex;
unsigned long ops_flags; unsigned long ops_flags;
}; };
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/mutex.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/control.h> #include <sound/control.h>
#include <sound/minors.h> #include <sound/minors.h>
...@@ -36,7 +37,7 @@ MODULE_DESCRIPTION("Hardware dependent layer"); ...@@ -36,7 +37,7 @@ MODULE_DESCRIPTION("Hardware dependent layer");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static LIST_HEAD(snd_hwdep_devices); static LIST_HEAD(snd_hwdep_devices);
static DECLARE_MUTEX(register_mutex); static DEFINE_MUTEX(register_mutex);
static int snd_hwdep_free(struct snd_hwdep *hwdep); static int snd_hwdep_free(struct snd_hwdep *hwdep);
static int snd_hwdep_dev_free(struct snd_device *device); static int snd_hwdep_dev_free(struct snd_device *device);
...@@ -111,7 +112,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file) ...@@ -111,7 +112,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
init_waitqueue_entry(&wait, current); init_waitqueue_entry(&wait, current);
add_wait_queue(&hw->open_wait, &wait); add_wait_queue(&hw->open_wait, &wait);
down(&hw->open_mutex); mutex_lock(&hw->open_mutex);
while (1) { while (1) {
if (hw->exclusive && hw->used > 0) { if (hw->exclusive && hw->used > 0) {
err = -EBUSY; err = -EBUSY;
...@@ -128,9 +129,9 @@ static int snd_hwdep_open(struct inode *inode, struct file * file) ...@@ -128,9 +129,9 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
} else } else
break; break;
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
up(&hw->open_mutex); mutex_unlock(&hw->open_mutex);
schedule(); schedule();
down(&hw->open_mutex); mutex_lock(&hw->open_mutex);
if (signal_pending(current)) { if (signal_pending(current)) {
err = -ERESTARTSYS; err = -ERESTARTSYS;
break; break;
...@@ -147,7 +148,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file) ...@@ -147,7 +148,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
hw->ops.release(hw, file); hw->ops.release(hw, file);
} }
} }
up(&hw->open_mutex); mutex_unlock(&hw->open_mutex);
if (err < 0) if (err < 0)
module_put(hw->card->module); module_put(hw->card->module);
return err; return err;
...@@ -157,7 +158,7 @@ static int snd_hwdep_release(struct inode *inode, struct file * file) ...@@ -157,7 +158,7 @@ static int snd_hwdep_release(struct inode *inode, struct file * file)
{ {
int err = -ENXIO; int err = -ENXIO;
struct snd_hwdep *hw = file->private_data; struct snd_hwdep *hw = file->private_data;
down(&hw->open_mutex); mutex_lock(&hw->open_mutex);
if (hw->ops.release) { if (hw->ops.release) {
err = hw->ops.release(hw, file); err = hw->ops.release(hw, file);
wake_up(&hw->open_wait); wake_up(&hw->open_wait);
...@@ -165,7 +166,7 @@ static int snd_hwdep_release(struct inode *inode, struct file * file) ...@@ -165,7 +166,7 @@ static int snd_hwdep_release(struct inode *inode, struct file * file)
if (hw->used > 0) if (hw->used > 0)
hw->used--; hw->used--;
snd_card_file_remove(hw->card, file); snd_card_file_remove(hw->card, file);
up(&hw->open_mutex); mutex_unlock(&hw->open_mutex);
module_put(hw->card->module); module_put(hw->card->module);
return err; return err;
} }
...@@ -272,7 +273,7 @@ static int snd_hwdep_control_ioctl(struct snd_card *card, ...@@ -272,7 +273,7 @@ static int snd_hwdep_control_ioctl(struct snd_card *card,
if (get_user(device, (int __user *)arg)) if (get_user(device, (int __user *)arg))
return -EFAULT; return -EFAULT;
down(&register_mutex); mutex_lock(&register_mutex);
device = device < 0 ? 0 : device + 1; device = device < 0 ? 0 : device + 1;
while (device < SNDRV_MINOR_HWDEPS) { while (device < SNDRV_MINOR_HWDEPS) {
if (snd_hwdep_search(card, device)) if (snd_hwdep_search(card, device))
...@@ -281,7 +282,7 @@ static int snd_hwdep_control_ioctl(struct snd_card *card, ...@@ -281,7 +282,7 @@ static int snd_hwdep_control_ioctl(struct snd_card *card,
} }
if (device >= SNDRV_MINOR_HWDEPS) if (device >= SNDRV_MINOR_HWDEPS)
device = -1; device = -1;
up(&register_mutex); mutex_unlock(&register_mutex);
if (put_user(device, (int __user *)arg)) if (put_user(device, (int __user *)arg))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -294,13 +295,13 @@ static int snd_hwdep_control_ioctl(struct snd_card *card, ...@@ -294,13 +295,13 @@ static int snd_hwdep_control_ioctl(struct snd_card *card,
if (get_user(device, &info->device)) if (get_user(device, &info->device))
return -EFAULT; return -EFAULT;
down(&register_mutex); mutex_lock(&register_mutex);
hwdep = snd_hwdep_search(card, device); hwdep = snd_hwdep_search(card, device);
if (hwdep) if (hwdep)
err = snd_hwdep_info(hwdep, info); err = snd_hwdep_info(hwdep, info);
else else
err = -ENXIO; err = -ENXIO;
up(&register_mutex); mutex_unlock(&register_mutex);
return err; return err;
} }
} }
...@@ -375,7 +376,7 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device, ...@@ -375,7 +376,7 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device,
return err; return err;
} }
init_waitqueue_head(&hwdep->open_wait); init_waitqueue_head(&hwdep->open_wait);
init_MUTEX(&hwdep->open_mutex); mutex_init(&hwdep->open_mutex);
*rhwdep = hwdep; *rhwdep = hwdep;
return 0; return 0;
} }
...@@ -401,9 +402,9 @@ static int snd_hwdep_dev_register(struct snd_device *device) ...@@ -401,9 +402,9 @@ static int snd_hwdep_dev_register(struct snd_device *device)
int err; int err;
char name[32]; char name[32];
down(&register_mutex); mutex_lock(&register_mutex);
if (snd_hwdep_search(hwdep->card, hwdep->device)) { if (snd_hwdep_search(hwdep->card, hwdep->device)) {
up(&register_mutex); mutex_unlock(&register_mutex);
return -EBUSY; return -EBUSY;
} }
list_add_tail(&hwdep->list, &snd_hwdep_devices); list_add_tail(&hwdep->list, &snd_hwdep_devices);
...@@ -414,7 +415,7 @@ static int snd_hwdep_dev_register(struct snd_device *device) ...@@ -414,7 +415,7 @@ static int snd_hwdep_dev_register(struct snd_device *device)
snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n", snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n",
hwdep->card->number, hwdep->device); hwdep->card->number, hwdep->device);
list_del(&hwdep->list); list_del(&hwdep->list);
up(&register_mutex); mutex_unlock(&register_mutex);
return err; return err;
} }
#ifdef CONFIG_SND_OSSEMUL #ifdef CONFIG_SND_OSSEMUL
...@@ -434,7 +435,7 @@ static int snd_hwdep_dev_register(struct snd_device *device) ...@@ -434,7 +435,7 @@ static int snd_hwdep_dev_register(struct snd_device *device)
} }
} }
#endif #endif
up(&register_mutex); mutex_unlock(&register_mutex);
return 0; return 0;
} }
...@@ -443,9 +444,9 @@ static int snd_hwdep_dev_unregister(struct snd_device *device) ...@@ -443,9 +444,9 @@ static int snd_hwdep_dev_unregister(struct snd_device *device)
struct snd_hwdep *hwdep = device->device_data; struct snd_hwdep *hwdep = device->device_data;
snd_assert(hwdep != NULL, return -ENXIO); snd_assert(hwdep != NULL, return -ENXIO);
down(&register_mutex); mutex_lock(&register_mutex);
if (snd_hwdep_search(hwdep->card, hwdep->device) != hwdep) { if (snd_hwdep_search(hwdep->card, hwdep->device) != hwdep) {
up(&register_mutex); mutex_unlock(&register_mutex);
return -EINVAL; return -EINVAL;
} }
#ifdef CONFIG_SND_OSSEMUL #ifdef CONFIG_SND_OSSEMUL
...@@ -454,7 +455,7 @@ static int snd_hwdep_dev_unregister(struct snd_device *device) ...@@ -454,7 +455,7 @@ static int snd_hwdep_dev_unregister(struct snd_device *device)
#endif #endif
snd_unregister_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device); snd_unregister_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device);
list_del(&hwdep->list); list_del(&hwdep->list);
up(&register_mutex); mutex_unlock(&register_mutex);
return snd_hwdep_free(hwdep); return snd_hwdep_free(hwdep);
} }
...@@ -469,13 +470,13 @@ static void snd_hwdep_proc_read(struct snd_info_entry *entry, ...@@ -469,13 +470,13 @@ static void snd_hwdep_proc_read(struct snd_info_entry *entry,
struct list_head *p; struct list_head *p;
struct snd_hwdep *hwdep; struct snd_hwdep *hwdep;
down(&register_mutex); mutex_lock(&register_mutex);
list_for_each(p, &snd_hwdep_devices) { list_for_each(p, &snd_hwdep_devices) {
hwdep = list_entry(p, struct snd_hwdep, list); hwdep = list_entry(p, struct snd_hwdep, list);
snd_iprintf(buffer, "%02i-%02i: %s\n", snd_iprintf(buffer, "%02i-%02i: %s\n",
hwdep->card->number, hwdep->device, hwdep->name); hwdep->card->number, hwdep->device, hwdep->name);
} }
up(&register_mutex); mutex_unlock(&register_mutex);
} }
static struct snd_info_entry *snd_hwdep_proc_entry; static struct snd_info_entry *snd_hwdep_proc_entry;
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <sound/version.h> #include <sound/version.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/devfs_fs_kernel.h> #include <linux/devfs_fs_kernel.h>
#include <linux/mutex.h>
#include <stdarg.h> #include <stdarg.h>
/* /*
...@@ -68,7 +69,7 @@ int snd_info_check_reserved_words(const char *str) ...@@ -68,7 +69,7 @@ int snd_info_check_reserved_words(const char *str)
return 1; return 1;
} }
static DECLARE_MUTEX(info_mutex); static DEFINE_MUTEX(info_mutex);
struct snd_info_private_data { struct snd_info_private_data {
struct snd_info_buffer *rbuffer; struct snd_info_buffer *rbuffer;
...@@ -265,11 +266,11 @@ static int snd_info_entry_open(struct inode *inode, struct file *file) ...@@ -265,11 +266,11 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
struct proc_dir_entry *p; struct proc_dir_entry *p;
int mode, err; int mode, err;
down(&info_mutex); mutex_lock(&info_mutex);
p = PDE(inode); p = PDE(inode);
entry = p == NULL ? NULL : (struct snd_info_entry *)p->data; entry = p == NULL ? NULL : (struct snd_info_entry *)p->data;
if (entry == NULL || entry->disconnected) { if (entry == NULL || entry->disconnected) {
up(&info_mutex); mutex_unlock(&info_mutex);
return -ENODEV; return -ENODEV;
} }
if (!try_module_get(entry->module)) { if (!try_module_get(entry->module)) {
...@@ -361,13 +362,13 @@ static int snd_info_entry_open(struct inode *inode, struct file *file) ...@@ -361,13 +362,13 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
break; break;
} }
file->private_data = data; file->private_data = data;
up(&info_mutex); mutex_unlock(&info_mutex);
if (entry->content == SNDRV_INFO_CONTENT_TEXT && if (entry->content == SNDRV_INFO_CONTENT_TEXT &&
(mode == O_RDONLY || mode == O_RDWR)) { (mode == O_RDONLY || mode == O_RDWR)) {
if (entry->c.text.read) { if (entry->c.text.read) {
down(&entry->access); mutex_lock(&entry->access);
entry->c.text.read(entry, data->rbuffer); entry->c.text.read(entry, data->rbuffer);
up(&entry->access); mutex_unlock(&entry->access);
} }
} }
return 0; return 0;
...@@ -375,7 +376,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file) ...@@ -375,7 +376,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
__error: __error:
module_put(entry->module); module_put(entry->module);
__error1: __error1:
up(&info_mutex); mutex_unlock(&info_mutex);
return err; return err;
} }
...@@ -747,7 +748,7 @@ static struct snd_info_entry *snd_info_create_entry(const char *name) ...@@ -747,7 +748,7 @@ static struct snd_info_entry *snd_info_create_entry(const char *name)
} }
entry->mode = S_IFREG | S_IRUGO; entry->mode = S_IFREG | S_IRUGO;
entry->content = SNDRV_INFO_CONTENT_TEXT; entry->content = SNDRV_INFO_CONTENT_TEXT;
init_MUTEX(&entry->access); mutex_init(&entry->access);
return entry; return entry;
} }
...@@ -896,10 +897,10 @@ int snd_info_register(struct snd_info_entry * entry) ...@@ -896,10 +897,10 @@ int snd_info_register(struct snd_info_entry * entry)
snd_assert(entry != NULL, return -ENXIO); snd_assert(entry != NULL, return -ENXIO);
root = entry->parent == NULL ? snd_proc_root : entry->parent->p; root = entry->parent == NULL ? snd_proc_root : entry->parent->p;
down(&info_mutex); mutex_lock(&info_mutex);
p = snd_create_proc_entry(entry->name, entry->mode, root); p = snd_create_proc_entry(entry->name, entry->mode, root);
if (!p) { if (!p) {
up(&info_mutex); mutex_unlock(&info_mutex);
return -ENOMEM; return -ENOMEM;
} }
p->owner = entry->module; p->owner = entry->module;
...@@ -908,7 +909,7 @@ int snd_info_register(struct snd_info_entry * entry) ...@@ -908,7 +909,7 @@ int snd_info_register(struct snd_info_entry * entry)
p->size = entry->size; p->size = entry->size;
p->data = entry; p->data = entry;
entry->p = p; entry->p = p;
up(&info_mutex); mutex_unlock(&info_mutex);
return 0; return 0;
} }
...@@ -929,9 +930,9 @@ int snd_info_unregister(struct snd_info_entry * entry) ...@@ -929,9 +930,9 @@ int snd_info_unregister(struct snd_info_entry * entry)
snd_assert(entry->p != NULL, return -ENXIO); snd_assert(entry->p != NULL, return -ENXIO);
root = entry->parent == NULL ? snd_proc_root : entry->parent->p; root = entry->parent == NULL ? snd_proc_root : entry->parent->p;
snd_assert(root, return -ENXIO); snd_assert(root, return -ENXIO);
down(&info_mutex); mutex_lock(&info_mutex);
snd_remove_proc_entry(root, entry->p); snd_remove_proc_entry(root, entry->p);
up(&info_mutex); mutex_unlock(&info_mutex);
snd_info_free_entry(entry); snd_info_free_entry(entry);
return 0; return 0;
} }
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <sound/info.h> #include <sound/info.h>
#include <sound/version.h> #include <sound/version.h>
#include <linux/utsname.h> #include <linux/utsname.h>
#include <linux/mutex.h>
#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS) #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
...@@ -35,7 +36,7 @@ ...@@ -35,7 +36,7 @@
* OSS compatible part * OSS compatible part
*/ */
static DECLARE_MUTEX(strings); static DEFINE_MUTEX(strings);
static char *snd_sndstat_strings[SNDRV_CARDS][SNDRV_OSS_INFO_DEV_COUNT]; static char *snd_sndstat_strings[SNDRV_CARDS][SNDRV_OSS_INFO_DEV_COUNT];
static struct snd_info_entry *snd_sndstat_proc_entry; static struct snd_info_entry *snd_sndstat_proc_entry;
...@@ -45,7 +46,7 @@ int snd_oss_info_register(int dev, int num, char *string) ...@@ -45,7 +46,7 @@ int snd_oss_info_register(int dev, int num, char *string)
snd_assert(dev >= 0 && dev < SNDRV_OSS_INFO_DEV_COUNT, return -ENXIO); snd_assert(dev >= 0 && dev < SNDRV_OSS_INFO_DEV_COUNT, return -ENXIO);
snd_assert(num >= 0 && num < SNDRV_CARDS, return -ENXIO); snd_assert(num >= 0 && num < SNDRV_CARDS, return -ENXIO);
down(&strings); mutex_lock(&strings);
if (string == NULL) { if (string == NULL) {
if ((x = snd_sndstat_strings[num][dev]) != NULL) { if ((x = snd_sndstat_strings[num][dev]) != NULL) {
kfree(x); kfree(x);
...@@ -54,12 +55,12 @@ int snd_oss_info_register(int dev, int num, char *string) ...@@ -54,12 +55,12 @@ int snd_oss_info_register(int dev, int num, char *string)
} else { } else {
x = kstrdup(string, GFP_KERNEL); x = kstrdup(string, GFP_KERNEL);
if (x == NULL) { if (x == NULL) {
up(&strings); mutex_unlock(&strings);
return -ENOMEM; return -ENOMEM;
} }
} }
snd_sndstat_strings[num][dev] = x; snd_sndstat_strings[num][dev] = x;
up(&strings); mutex_unlock(&strings);
return 0; return 0;
} }
...@@ -71,7 +72,7 @@ static int snd_sndstat_show_strings(struct snd_info_buffer *buf, char *id, int d ...@@ -71,7 +72,7 @@ static int snd_sndstat_show_strings(struct snd_info_buffer *buf, char *id, int d
char *str; char *str;
snd_iprintf(buf, "\n%s:", id); snd_iprintf(buf, "\n%s:", id);
down(&strings); mutex_lock(&strings);
for (idx = 0; idx < SNDRV_CARDS; idx++) { for (idx = 0; idx < SNDRV_CARDS; idx++) {
str = snd_sndstat_strings[idx][dev]; str = snd_sndstat_strings[idx][dev];
if (str) { if (str) {
...@@ -82,7 +83,7 @@ static int snd_sndstat_show_strings(struct snd_info_buffer *buf, char *id, int d ...@@ -82,7 +83,7 @@ static int snd_sndstat_show_strings(struct snd_info_buffer *buf, char *id, int d
snd_iprintf(buf, "%i: %s\n", idx, str); snd_iprintf(buf, "%i: %s\n", idx, str);
} }
} }
up(&strings); mutex_unlock(&strings);
if (ok < 0) if (ok < 0)
snd_iprintf(buf, " NOT ENABLED IN CONFIG\n"); snd_iprintf(buf, " NOT ENABLED IN CONFIG\n");
return ok; return ok;
......
...@@ -145,7 +145,7 @@ struct snd_card *snd_card_new(int idx, const char *xid, ...@@ -145,7 +145,7 @@ struct snd_card *snd_card_new(int idx, const char *xid,
init_waitqueue_head(&card->shutdown_sleep); init_waitqueue_head(&card->shutdown_sleep);
INIT_WORK(&card->free_workq, snd_card_free_thread, card); INIT_WORK(&card->free_workq, snd_card_free_thread, card);
#ifdef CONFIG_PM #ifdef CONFIG_PM
init_MUTEX(&card->power_lock); mutex_init(&card->power_lock);
init_waitqueue_head(&card->power_sleep); init_waitqueue_head(&card->power_sleep);
#endif #endif
/* the control interface cannot be accessed from the user space until */ /* the control interface cannot be accessed from the user space until */
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <asm/semaphore.h> #include <linux/mutex.h>
#include <sound/memalloc.h> #include <sound/memalloc.h>
#ifdef CONFIG_SBUS #ifdef CONFIG_SBUS
#include <asm/sbus.h> #include <asm/sbus.h>
...@@ -54,7 +54,7 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab); ...@@ -54,7 +54,7 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab);
/* /*
*/ */
static DECLARE_MUTEX(list_mutex); static DEFINE_MUTEX(list_mutex);
static LIST_HEAD(mem_list_head); static LIST_HEAD(mem_list_head);
/* buffer preservation list */ /* buffer preservation list */
...@@ -440,7 +440,7 @@ size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id) ...@@ -440,7 +440,7 @@ size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id)
snd_assert(dmab, return 0); snd_assert(dmab, return 0);
down(&list_mutex); mutex_lock(&list_mutex);
list_for_each(p, &mem_list_head) { list_for_each(p, &mem_list_head) {
mem = list_entry(p, struct snd_mem_list, list); mem = list_entry(p, struct snd_mem_list, list);
if (mem->id == id && if (mem->id == id &&
...@@ -452,11 +452,11 @@ size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id) ...@@ -452,11 +452,11 @@ size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id)
if (dmab->dev.dev == NULL) if (dmab->dev.dev == NULL)
dmab->dev.dev = dev; dmab->dev.dev = dev;
kfree(mem); kfree(mem);
up(&list_mutex); mutex_unlock(&list_mutex);
return dmab->bytes; return dmab->bytes;
} }
} }
up(&list_mutex); mutex_unlock(&list_mutex);
return 0; return 0;
} }
...@@ -477,11 +477,11 @@ int snd_dma_reserve_buf(struct snd_dma_buffer *dmab, unsigned int id) ...@@ -477,11 +477,11 @@ int snd_dma_reserve_buf(struct snd_dma_buffer *dmab, unsigned int id)
mem = kmalloc(sizeof(*mem), GFP_KERNEL); mem = kmalloc(sizeof(*mem), GFP_KERNEL);
if (! mem) if (! mem)
return -ENOMEM; return -ENOMEM;
down(&list_mutex); mutex_lock(&list_mutex);
mem->buffer = *dmab; mem->buffer = *dmab;
mem->id = id; mem->id = id;
list_add_tail(&mem->list, &mem_list_head); list_add_tail(&mem->list, &mem_list_head);
up(&list_mutex); mutex_unlock(&list_mutex);
return 0; return 0;
} }
...@@ -493,7 +493,7 @@ static void free_all_reserved_pages(void) ...@@ -493,7 +493,7 @@ static void free_all_reserved_pages(void)
struct list_head *p; struct list_head *p;
struct snd_mem_list *mem; struct snd_mem_list *mem;
down(&list_mutex); mutex_lock(&list_mutex);
while (! list_empty(&mem_list_head)) { while (! list_empty(&mem_list_head)) {
p = mem_list_head.next; p = mem_list_head.next;
mem = list_entry(p, struct snd_mem_list, list); mem = list_entry(p, struct snd_mem_list, list);
...@@ -501,7 +501,7 @@ static void free_all_reserved_pages(void) ...@@ -501,7 +501,7 @@ static void free_all_reserved_pages(void)
snd_dma_free_pages(&mem->buffer); snd_dma_free_pages(&mem->buffer);
kfree(mem); kfree(mem);
} }
up(&list_mutex); mutex_unlock(&list_mutex);
} }
...@@ -522,7 +522,7 @@ static int snd_mem_proc_read(char *page, char **start, off_t off, ...@@ -522,7 +522,7 @@ static int snd_mem_proc_read(char *page, char **start, off_t off,
int devno; int devno;
static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG", "SBUS" }; static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG", "SBUS" };
down(&list_mutex); mutex_lock(&list_mutex);
len += snprintf(page + len, count - len, len += snprintf(page + len, count - len,
"pages : %li bytes (%li pages per %likB)\n", "pages : %li bytes (%li pages per %likB)\n",
pages * PAGE_SIZE, pages, PAGE_SIZE / 1024); pages * PAGE_SIZE, pages, PAGE_SIZE / 1024);
...@@ -537,7 +537,7 @@ static int snd_mem_proc_read(char *page, char **start, off_t off, ...@@ -537,7 +537,7 @@ static int snd_mem_proc_read(char *page, char **start, off_t off,
" addr = 0x%lx, size = %d bytes\n", " addr = 0x%lx, size = %d bytes\n",
(unsigned long)mem->buffer.addr, (int)mem->buffer.bytes); (unsigned long)mem->buffer.addr, (int)mem->buffer.bytes);
} }
up(&list_mutex); mutex_unlock(&list_mutex);
return len; return len;
} }
......
...@@ -1095,7 +1095,7 @@ static void snd_mixer_oss_proc_read(struct snd_info_entry *entry, ...@@ -1095,7 +1095,7 @@ static void snd_mixer_oss_proc_read(struct snd_info_entry *entry,
struct snd_mixer_oss *mixer = entry->private_data; struct snd_mixer_oss *mixer = entry->private_data;
int i; int i;
down(&mixer->reg_mutex); mutex_lock(&mixer->reg_mutex);
for (i = 0; i < SNDRV_OSS_MAX_MIXERS; i++) { for (i = 0; i < SNDRV_OSS_MAX_MIXERS; i++) {
struct slot *p; struct slot *p;
...@@ -1110,7 +1110,7 @@ static void snd_mixer_oss_proc_read(struct snd_info_entry *entry, ...@@ -1110,7 +1110,7 @@ static void snd_mixer_oss_proc_read(struct snd_info_entry *entry,
else else
snd_iprintf(buffer, "\"\" 0\n"); snd_iprintf(buffer, "\"\" 0\n");
} }
up(&mixer->reg_mutex); mutex_unlock(&mixer->reg_mutex);
} }
static void snd_mixer_oss_proc_write(struct snd_info_entry *entry, static void snd_mixer_oss_proc_write(struct snd_info_entry *entry,
...@@ -1134,9 +1134,9 @@ static void snd_mixer_oss_proc_write(struct snd_info_entry *entry, ...@@ -1134,9 +1134,9 @@ static void snd_mixer_oss_proc_write(struct snd_info_entry *entry,
cptr = snd_info_get_str(str, cptr, sizeof(str)); cptr = snd_info_get_str(str, cptr, sizeof(str));
if (! *str) { if (! *str) {
/* remove the entry */ /* remove the entry */
down(&mixer->reg_mutex); mutex_lock(&mixer->reg_mutex);
mixer_slot_clear(&mixer->slots[ch]); mixer_slot_clear(&mixer->slots[ch]);
up(&mixer->reg_mutex); mutex_unlock(&mixer->reg_mutex);
continue; continue;
} }
snd_info_get_str(idxstr, cptr, sizeof(idxstr)); snd_info_get_str(idxstr, cptr, sizeof(idxstr));
...@@ -1145,7 +1145,7 @@ static void snd_mixer_oss_proc_write(struct snd_info_entry *entry, ...@@ -1145,7 +1145,7 @@ static void snd_mixer_oss_proc_write(struct snd_info_entry *entry,
snd_printk(KERN_ERR "mixer_oss: invalid index %d\n", idx); snd_printk(KERN_ERR "mixer_oss: invalid index %d\n", idx);
continue; continue;
} }
down(&mixer->reg_mutex); mutex_lock(&mixer->reg_mutex);
slot = (struct slot *)mixer->slots[ch].private_data; slot = (struct slot *)mixer->slots[ch].private_data;
if (slot && slot->assigned && if (slot && slot->assigned &&
slot->assigned->index == idx && ! strcmp(slot->assigned->name, str)) slot->assigned->index == idx && ! strcmp(slot->assigned->name, str))
...@@ -1168,7 +1168,7 @@ static void snd_mixer_oss_proc_write(struct snd_info_entry *entry, ...@@ -1168,7 +1168,7 @@ static void snd_mixer_oss_proc_write(struct snd_info_entry *entry,
kfree(tbl); kfree(tbl);
} }
__unlock: __unlock:
up(&mixer->reg_mutex); mutex_unlock(&mixer->reg_mutex);
} }
} }
...@@ -1288,7 +1288,7 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd) ...@@ -1288,7 +1288,7 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd)
mixer = kcalloc(2, sizeof(*mixer), GFP_KERNEL); mixer = kcalloc(2, sizeof(*mixer), GFP_KERNEL);
if (mixer == NULL) if (mixer == NULL)
return -ENOMEM; return -ENOMEM;
init_MUTEX(&mixer->reg_mutex); mutex_init(&mixer->reg_mutex);
sprintf(name, "mixer%i%i", card->number, 0); sprintf(name, "mixer%i%i", card->number, 0);
if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER, if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER,
card, 0, card, 0,
......
...@@ -1643,10 +1643,10 @@ static struct snd_pcm_oss_setup *snd_pcm_oss_look_for_setup(struct snd_pcm *pcm, ...@@ -1643,10 +1643,10 @@ static struct snd_pcm_oss_setup *snd_pcm_oss_look_for_setup(struct snd_pcm *pcm,
const char *ptr, *ptrl; const char *ptr, *ptrl;
struct snd_pcm_oss_setup *setup; struct snd_pcm_oss_setup *setup;
down(&pcm->streams[stream].oss.setup_mutex); mutex_lock(&pcm->streams[stream].oss.setup_mutex);
for (setup = pcm->streams[stream].oss.setup_list; setup; setup = setup->next) { for (setup = pcm->streams[stream].oss.setup_list; setup; setup = setup->next) {
if (!strcmp(setup->task_name, task_name)) { if (!strcmp(setup->task_name, task_name)) {
up(&pcm->streams[stream].oss.setup_mutex); mutex_unlock(&pcm->streams[stream].oss.setup_mutex);
return setup; return setup;
} }
} }
...@@ -1662,12 +1662,12 @@ static struct snd_pcm_oss_setup *snd_pcm_oss_look_for_setup(struct snd_pcm *pcm, ...@@ -1662,12 +1662,12 @@ static struct snd_pcm_oss_setup *snd_pcm_oss_look_for_setup(struct snd_pcm *pcm,
} }
for (setup = pcm->streams[stream].oss.setup_list; setup; setup = setup->next) { for (setup = pcm->streams[stream].oss.setup_list; setup; setup = setup->next) {
if (!strcmp(setup->task_name, ptrl)) { if (!strcmp(setup->task_name, ptrl)) {
up(&pcm->streams[stream].oss.setup_mutex); mutex_unlock(&pcm->streams[stream].oss.setup_mutex);
return setup; return setup;
} }
} }
__not_found: __not_found:
up(&pcm->streams[stream].oss.setup_mutex); mutex_unlock(&pcm->streams[stream].oss.setup_mutex);
return NULL; return NULL;
} }
...@@ -1895,7 +1895,7 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) ...@@ -1895,7 +1895,7 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file)
init_waitqueue_entry(&wait, current); init_waitqueue_entry(&wait, current);
add_wait_queue(&pcm->open_wait, &wait); add_wait_queue(&pcm->open_wait, &wait);
down(&pcm->open_mutex); mutex_lock(&pcm->open_mutex);
while (1) { while (1) {
err = snd_pcm_oss_open_file(file, pcm, &pcm_oss_file, err = snd_pcm_oss_open_file(file, pcm, &pcm_oss_file,
iminor(inode), psetup, csetup); iminor(inode), psetup, csetup);
...@@ -1909,16 +1909,16 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) ...@@ -1909,16 +1909,16 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file)
} else } else
break; break;
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
up(&pcm->open_mutex); mutex_unlock(&pcm->open_mutex);
schedule(); schedule();
down(&pcm->open_mutex); mutex_lock(&pcm->open_mutex);
if (signal_pending(current)) { if (signal_pending(current)) {
err = -ERESTARTSYS; err = -ERESTARTSYS;
break; break;
} }
} }
remove_wait_queue(&pcm->open_wait, &wait); remove_wait_queue(&pcm->open_wait, &wait);
up(&pcm->open_mutex); mutex_unlock(&pcm->open_mutex);
if (err < 0) if (err < 0)
goto __error; goto __error;
return err; return err;
...@@ -1944,9 +1944,9 @@ static int snd_pcm_oss_release(struct inode *inode, struct file *file) ...@@ -1944,9 +1944,9 @@ static int snd_pcm_oss_release(struct inode *inode, struct file *file)
snd_assert(substream != NULL, return -ENXIO); snd_assert(substream != NULL, return -ENXIO);
pcm = substream->pcm; pcm = substream->pcm;
snd_pcm_oss_sync(pcm_oss_file); snd_pcm_oss_sync(pcm_oss_file);
down(&pcm->open_mutex); mutex_lock(&pcm->open_mutex);
snd_pcm_oss_release_file(pcm_oss_file); snd_pcm_oss_release_file(pcm_oss_file);
up(&pcm->open_mutex); mutex_unlock(&pcm->open_mutex);
wake_up(&pcm->open_wait); wake_up(&pcm->open_wait);
module_put(pcm->card->module); module_put(pcm->card->module);
snd_card_file_remove(pcm->card, file); snd_card_file_remove(pcm->card, file);
...@@ -2293,7 +2293,7 @@ static void snd_pcm_oss_proc_read(struct snd_info_entry *entry, ...@@ -2293,7 +2293,7 @@ static void snd_pcm_oss_proc_read(struct snd_info_entry *entry,
{ {
struct snd_pcm_str *pstr = entry->private_data; struct snd_pcm_str *pstr = entry->private_data;
struct snd_pcm_oss_setup *setup = pstr->oss.setup_list; struct snd_pcm_oss_setup *setup = pstr->oss.setup_list;
down(&pstr->oss.setup_mutex); mutex_lock(&pstr->oss.setup_mutex);
while (setup) { while (setup) {
snd_iprintf(buffer, "%s %u %u%s%s%s%s%s%s\n", snd_iprintf(buffer, "%s %u %u%s%s%s%s%s%s\n",
setup->task_name, setup->task_name,
...@@ -2307,7 +2307,7 @@ static void snd_pcm_oss_proc_read(struct snd_info_entry *entry, ...@@ -2307,7 +2307,7 @@ static void snd_pcm_oss_proc_read(struct snd_info_entry *entry,
setup->nosilence ? " no-silence" : ""); setup->nosilence ? " no-silence" : "");
setup = setup->next; setup = setup->next;
} }
up(&pstr->oss.setup_mutex); mutex_unlock(&pstr->oss.setup_mutex);
} }
static void snd_pcm_oss_proc_free_setup_list(struct snd_pcm_str * pstr) static void snd_pcm_oss_proc_free_setup_list(struct snd_pcm_str * pstr)
...@@ -2337,12 +2337,12 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry, ...@@ -2337,12 +2337,12 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry,
struct snd_pcm_oss_setup *setup, *setup1, template; struct snd_pcm_oss_setup *setup, *setup1, template;
while (!snd_info_get_line(buffer, line, sizeof(line))) { while (!snd_info_get_line(buffer, line, sizeof(line))) {
down(&pstr->oss.setup_mutex); mutex_lock(&pstr->oss.setup_mutex);
memset(&template, 0, sizeof(template)); memset(&template, 0, sizeof(template));
ptr = snd_info_get_str(task_name, line, sizeof(task_name)); ptr = snd_info_get_str(task_name, line, sizeof(task_name));
if (!strcmp(task_name, "clear") || !strcmp(task_name, "erase")) { if (!strcmp(task_name, "clear") || !strcmp(task_name, "erase")) {
snd_pcm_oss_proc_free_setup_list(pstr); snd_pcm_oss_proc_free_setup_list(pstr);
up(&pstr->oss.setup_mutex); mutex_unlock(&pstr->oss.setup_mutex);
continue; continue;
} }
for (setup = pstr->oss.setup_list; setup; setup = setup->next) { for (setup = pstr->oss.setup_list; setup; setup = setup->next) {
...@@ -2394,7 +2394,7 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry, ...@@ -2394,7 +2394,7 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry,
} }
if (setup) if (setup)
*setup = template; *setup = template;
up(&pstr->oss.setup_mutex); mutex_unlock(&pstr->oss.setup_mutex);
} }
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/mutex.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/minors.h> #include <sound/minors.h>
#include <sound/pcm.h> #include <sound/pcm.h>
...@@ -35,7 +36,7 @@ MODULE_LICENSE("GPL"); ...@@ -35,7 +36,7 @@ MODULE_LICENSE("GPL");
static LIST_HEAD(snd_pcm_devices); static LIST_HEAD(snd_pcm_devices);
static LIST_HEAD(snd_pcm_notify_list); static LIST_HEAD(snd_pcm_notify_list);
static DECLARE_MUTEX(register_mutex); static DEFINE_MUTEX(register_mutex);
static int snd_pcm_free(struct snd_pcm *pcm); static int snd_pcm_free(struct snd_pcm *pcm);
static int snd_pcm_dev_free(struct snd_device *device); static int snd_pcm_dev_free(struct snd_device *device);
...@@ -67,7 +68,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card, ...@@ -67,7 +68,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card,
if (get_user(device, (int __user *)arg)) if (get_user(device, (int __user *)arg))
return -EFAULT; return -EFAULT;
down(&register_mutex); mutex_lock(&register_mutex);
device = device < 0 ? 0 : device + 1; device = device < 0 ? 0 : device + 1;
while (device < SNDRV_PCM_DEVICES) { while (device < SNDRV_PCM_DEVICES) {
if (snd_pcm_search(card, device)) if (snd_pcm_search(card, device))
...@@ -76,7 +77,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card, ...@@ -76,7 +77,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card,
} }
if (device == SNDRV_PCM_DEVICES) if (device == SNDRV_PCM_DEVICES)
device = -1; device = -1;
up(&register_mutex); mutex_unlock(&register_mutex);
if (put_user(device, (int __user *)arg)) if (put_user(device, (int __user *)arg))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -100,7 +101,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card, ...@@ -100,7 +101,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card,
return -EINVAL; return -EINVAL;
if (get_user(subdevice, &info->subdevice)) if (get_user(subdevice, &info->subdevice))
return -EFAULT; return -EFAULT;
down(&register_mutex); mutex_lock(&register_mutex);
pcm = snd_pcm_search(card, device); pcm = snd_pcm_search(card, device);
if (pcm == NULL) { if (pcm == NULL) {
err = -ENXIO; err = -ENXIO;
...@@ -125,7 +126,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card, ...@@ -125,7 +126,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card,
} }
err = snd_pcm_info_user(substream, info); err = snd_pcm_info_user(substream, info);
_error: _error:
up(&register_mutex); mutex_unlock(&register_mutex);
return err; return err;
} }
case SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE: case SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE:
...@@ -262,6 +263,7 @@ static const char *snd_pcm_state_name(snd_pcm_state_t state) ...@@ -262,6 +263,7 @@ static const char *snd_pcm_state_name(snd_pcm_state_t state)
#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
#include <linux/soundcard.h> #include <linux/soundcard.h>
static const char *snd_pcm_oss_format_name(int format) static const char *snd_pcm_oss_format_name(int format)
{ {
switch (format) { switch (format) {
...@@ -624,7 +626,7 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) ...@@ -624,7 +626,7 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
struct snd_pcm_substream *substream, *prev; struct snd_pcm_substream *substream, *prev;
#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
init_MUTEX(&pstr->oss.setup_mutex); mutex_init(&pstr->oss.setup_mutex);
#endif #endif
pstr->stream = stream; pstr->stream = stream;
pstr->pcm = pcm; pstr->pcm = pcm;
...@@ -718,7 +720,7 @@ int snd_pcm_new(struct snd_card *card, char *id, int device, ...@@ -718,7 +720,7 @@ int snd_pcm_new(struct snd_card *card, char *id, int device,
snd_pcm_free(pcm); snd_pcm_free(pcm);
return err; return err;
} }
init_MUTEX(&pcm->open_mutex); mutex_init(&pcm->open_mutex);
init_waitqueue_head(&pcm->open_wait); init_waitqueue_head(&pcm->open_wait);
if ((err = snd_device_new(card, SNDRV_DEV_PCM, pcm, &ops)) < 0) { if ((err = snd_device_new(card, SNDRV_DEV_PCM, pcm, &ops)) < 0) {
snd_pcm_free(pcm); snd_pcm_free(pcm);
...@@ -904,9 +906,9 @@ static int snd_pcm_dev_register(struct snd_device *device) ...@@ -904,9 +906,9 @@ static int snd_pcm_dev_register(struct snd_device *device)
struct snd_pcm *pcm = device->device_data; struct snd_pcm *pcm = device->device_data;
snd_assert(pcm != NULL && device != NULL, return -ENXIO); snd_assert(pcm != NULL && device != NULL, return -ENXIO);
down(&register_mutex); mutex_lock(&register_mutex);
if (snd_pcm_search(pcm->card, pcm->device)) { if (snd_pcm_search(pcm->card, pcm->device)) {
up(&register_mutex); mutex_unlock(&register_mutex);
return -EBUSY; return -EBUSY;
} }
list_add_tail(&pcm->list, &snd_pcm_devices); list_add_tail(&pcm->list, &snd_pcm_devices);
...@@ -930,7 +932,7 @@ static int snd_pcm_dev_register(struct snd_device *device) ...@@ -930,7 +932,7 @@ static int snd_pcm_dev_register(struct snd_device *device)
pcm, str)) < 0) pcm, str)) < 0)
{ {
list_del(&pcm->list); list_del(&pcm->list);
up(&register_mutex); mutex_unlock(&register_mutex);
return err; return err;
} }
for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
...@@ -941,7 +943,7 @@ static int snd_pcm_dev_register(struct snd_device *device) ...@@ -941,7 +943,7 @@ static int snd_pcm_dev_register(struct snd_device *device)
notify = list_entry(list, struct snd_pcm_notify, list); notify = list_entry(list, struct snd_pcm_notify, list);
notify->n_register(pcm); notify->n_register(pcm);
} }
up(&register_mutex); mutex_unlock(&register_mutex);
return 0; return 0;
} }
...@@ -952,7 +954,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) ...@@ -952,7 +954,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device)
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
int cidx; int cidx;
down(&register_mutex); mutex_lock(&register_mutex);
list_del_init(&pcm->list); list_del_init(&pcm->list);
for (cidx = 0; cidx < 2; cidx++) for (cidx = 0; cidx < 2; cidx++)
for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
...@@ -963,7 +965,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) ...@@ -963,7 +965,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device)
notify = list_entry(list, struct snd_pcm_notify, list); notify = list_entry(list, struct snd_pcm_notify, list);
notify->n_disconnect(pcm); notify->n_disconnect(pcm);
} }
up(&register_mutex); mutex_unlock(&register_mutex);
return 0; return 0;
} }
...@@ -975,7 +977,7 @@ static int snd_pcm_dev_unregister(struct snd_device *device) ...@@ -975,7 +977,7 @@ static int snd_pcm_dev_unregister(struct snd_device *device)
struct snd_pcm *pcm = device->device_data; struct snd_pcm *pcm = device->device_data;
snd_assert(pcm != NULL, return -ENXIO); snd_assert(pcm != NULL, return -ENXIO);
down(&register_mutex); mutex_lock(&register_mutex);
list_del(&pcm->list); list_del(&pcm->list);
for (cidx = 0; cidx < 2; cidx++) { for (cidx = 0; cidx < 2; cidx++) {
devtype = -1; devtype = -1;
...@@ -996,7 +998,7 @@ static int snd_pcm_dev_unregister(struct snd_device *device) ...@@ -996,7 +998,7 @@ static int snd_pcm_dev_unregister(struct snd_device *device)
notify = list_entry(list, struct snd_pcm_notify, list); notify = list_entry(list, struct snd_pcm_notify, list);
notify->n_unregister(pcm); notify->n_unregister(pcm);
} }
up(&register_mutex); mutex_unlock(&register_mutex);
return snd_pcm_free(pcm); return snd_pcm_free(pcm);
} }
...@@ -1005,7 +1007,7 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree) ...@@ -1005,7 +1007,7 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
struct list_head *p; struct list_head *p;
snd_assert(notify != NULL && notify->n_register != NULL && notify->n_unregister != NULL, return -EINVAL); snd_assert(notify != NULL && notify->n_register != NULL && notify->n_unregister != NULL, return -EINVAL);
down(&register_mutex); mutex_lock(&register_mutex);
if (nfree) { if (nfree) {
list_del(&notify->list); list_del(&notify->list);
list_for_each(p, &snd_pcm_devices) list_for_each(p, &snd_pcm_devices)
...@@ -1016,7 +1018,7 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree) ...@@ -1016,7 +1018,7 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
list_for_each(p, &snd_pcm_devices) list_for_each(p, &snd_pcm_devices)
notify->n_register(list_entry(p, struct snd_pcm, list)); notify->n_register(list_entry(p, struct snd_pcm, list));
} }
up(&register_mutex); mutex_unlock(&register_mutex);
return 0; return 0;
} }
...@@ -1031,7 +1033,7 @@ static void snd_pcm_proc_read(struct snd_info_entry *entry, ...@@ -1031,7 +1033,7 @@ static void snd_pcm_proc_read(struct snd_info_entry *entry,
struct list_head *p; struct list_head *p;
struct snd_pcm *pcm; struct snd_pcm *pcm;
down(&register_mutex); mutex_lock(&register_mutex);
list_for_each(p, &snd_pcm_devices) { list_for_each(p, &snd_pcm_devices) {
pcm = list_entry(p, struct snd_pcm, list); pcm = list_entry(p, struct snd_pcm, list);
snd_iprintf(buffer, "%02i-%02i: %s : %s", snd_iprintf(buffer, "%02i-%02i: %s : %s",
...@@ -1044,7 +1046,7 @@ static void snd_pcm_proc_read(struct snd_info_entry *entry, ...@@ -1044,7 +1046,7 @@ static void snd_pcm_proc_read(struct snd_info_entry *entry,
pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream_count); pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream_count);
snd_iprintf(buffer, "\n"); snd_iprintf(buffer, "\n");
} }
up(&register_mutex); mutex_unlock(&register_mutex);
} }
static struct snd_info_entry *snd_pcm_proc_entry = NULL; static struct snd_info_entry *snd_pcm_proc_entry = NULL;
......
...@@ -2112,7 +2112,7 @@ static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream) ...@@ -2112,7 +2112,7 @@ static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream)
} }
init_waitqueue_entry(&wait, current); init_waitqueue_entry(&wait, current);
add_wait_queue(&pcm->open_wait, &wait); add_wait_queue(&pcm->open_wait, &wait);
down(&pcm->open_mutex); mutex_lock(&pcm->open_mutex);
while (1) { while (1) {
err = snd_pcm_open_file(file, pcm, stream, &pcm_file); err = snd_pcm_open_file(file, pcm, stream, &pcm_file);
if (err >= 0) if (err >= 0)
...@@ -2125,16 +2125,16 @@ static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream) ...@@ -2125,16 +2125,16 @@ static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream)
} else } else
break; break;
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
up(&pcm->open_mutex); mutex_unlock(&pcm->open_mutex);
schedule(); schedule();
down(&pcm->open_mutex); mutex_lock(&pcm->open_mutex);
if (signal_pending(current)) { if (signal_pending(current)) {
err = -ERESTARTSYS; err = -ERESTARTSYS;
break; break;
} }
} }
remove_wait_queue(&pcm->open_wait, &wait); remove_wait_queue(&pcm->open_wait, &wait);
up(&pcm->open_mutex); mutex_unlock(&pcm->open_mutex);
if (err < 0) if (err < 0)
goto __error; goto __error;
return err; return err;
...@@ -2160,9 +2160,9 @@ static int snd_pcm_release(struct inode *inode, struct file *file) ...@@ -2160,9 +2160,9 @@ static int snd_pcm_release(struct inode *inode, struct file *file)
pcm = substream->pcm; pcm = substream->pcm;
snd_pcm_drop(substream); snd_pcm_drop(substream);
fasync_helper(-1, file, 0, &substream->runtime->fasync); fasync_helper(-1, file, 0, &substream->runtime->fasync);
down(&pcm->open_mutex); mutex_lock(&pcm->open_mutex);
snd_pcm_release_file(pcm_file); snd_pcm_release_file(pcm_file);
up(&pcm->open_mutex); mutex_unlock(&pcm->open_mutex);
wake_up(&pcm->open_wait); wake_up(&pcm->open_wait);
module_put(pcm->card->module); module_put(pcm->card->module);
snd_card_file_remove(pcm->card, file); snd_card_file_remove(pcm->card, file);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/mutex.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/wait.h> #include <linux/wait.h>
...@@ -57,7 +58,7 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device); ...@@ -57,7 +58,7 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device);
static int snd_rawmidi_dev_unregister(struct snd_device *device); static int snd_rawmidi_dev_unregister(struct snd_device *device);
static LIST_HEAD(snd_rawmidi_devices); static LIST_HEAD(snd_rawmidi_devices);
static DECLARE_MUTEX(register_mutex); static DEFINE_MUTEX(register_mutex);
static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device) static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device)
{ {
...@@ -237,9 +238,9 @@ int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice, ...@@ -237,9 +238,9 @@ int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice,
if (rfile) if (rfile)
rfile->input = rfile->output = NULL; rfile->input = rfile->output = NULL;
down(&register_mutex); mutex_lock(&register_mutex);
rmidi = snd_rawmidi_search(card, device); rmidi = snd_rawmidi_search(card, device);
up(&register_mutex); mutex_unlock(&register_mutex);
if (rmidi == NULL) { if (rmidi == NULL) {
err = -ENODEV; err = -ENODEV;
goto __error1; goto __error1;
...@@ -249,7 +250,7 @@ int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice, ...@@ -249,7 +250,7 @@ int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice,
goto __error1; goto __error1;
} }
if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK)) if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK))
down(&rmidi->open_mutex); mutex_lock(&rmidi->open_mutex);
if (mode & SNDRV_RAWMIDI_LFLG_INPUT) { if (mode & SNDRV_RAWMIDI_LFLG_INPUT) {
if (!(rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT)) { if (!(rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT)) {
err = -ENXIO; err = -ENXIO;
...@@ -359,7 +360,7 @@ int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice, ...@@ -359,7 +360,7 @@ int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice,
soutput = NULL; soutput = NULL;
} }
if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK)) if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK))
up(&rmidi->open_mutex); mutex_unlock(&rmidi->open_mutex);
if (rfile) { if (rfile) {
rfile->rmidi = rmidi; rfile->rmidi = rmidi;
rfile->input = sinput; rfile->input = sinput;
...@@ -374,7 +375,7 @@ int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice, ...@@ -374,7 +375,7 @@ int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice,
snd_rawmidi_runtime_free(soutput); snd_rawmidi_runtime_free(soutput);
module_put(rmidi->card->module); module_put(rmidi->card->module);
if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK)) if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK))
up(&rmidi->open_mutex); mutex_unlock(&rmidi->open_mutex);
__error1: __error1:
return err; return err;
} }
...@@ -422,7 +423,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) ...@@ -422,7 +423,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
} }
init_waitqueue_entry(&wait, current); init_waitqueue_entry(&wait, current);
add_wait_queue(&rmidi->open_wait, &wait); add_wait_queue(&rmidi->open_wait, &wait);
down(&rmidi->open_mutex); mutex_lock(&rmidi->open_mutex);
while (1) { while (1) {
subdevice = -1; subdevice = -1;
down_read(&card->controls_rwsem); down_read(&card->controls_rwsem);
...@@ -446,9 +447,9 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) ...@@ -446,9 +447,9 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
} else } else
break; break;
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
up(&rmidi->open_mutex); mutex_unlock(&rmidi->open_mutex);
schedule(); schedule();
down(&rmidi->open_mutex); mutex_lock(&rmidi->open_mutex);
if (signal_pending(current)) { if (signal_pending(current)) {
err = -ERESTARTSYS; err = -ERESTARTSYS;
break; break;
...@@ -467,7 +468,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) ...@@ -467,7 +468,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
snd_card_file_remove(card, file); snd_card_file_remove(card, file);
kfree(rawmidi_file); kfree(rawmidi_file);
} }
up(&rmidi->open_mutex); mutex_unlock(&rmidi->open_mutex);
return err; return err;
} }
...@@ -480,7 +481,7 @@ int snd_rawmidi_kernel_release(struct snd_rawmidi_file * rfile) ...@@ -480,7 +481,7 @@ int snd_rawmidi_kernel_release(struct snd_rawmidi_file * rfile)
snd_assert(rfile != NULL, return -ENXIO); snd_assert(rfile != NULL, return -ENXIO);
snd_assert(rfile->input != NULL || rfile->output != NULL, return -ENXIO); snd_assert(rfile->input != NULL || rfile->output != NULL, return -ENXIO);
rmidi = rfile->rmidi; rmidi = rfile->rmidi;
down(&rmidi->open_mutex); mutex_lock(&rmidi->open_mutex);
if (rfile->input != NULL) { if (rfile->input != NULL) {
substream = rfile->input; substream = rfile->input;
rfile->input = NULL; rfile->input = NULL;
...@@ -514,7 +515,7 @@ int snd_rawmidi_kernel_release(struct snd_rawmidi_file * rfile) ...@@ -514,7 +515,7 @@ int snd_rawmidi_kernel_release(struct snd_rawmidi_file * rfile)
} }
rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_opened--; rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_opened--;
} }
up(&rmidi->open_mutex); mutex_unlock(&rmidi->open_mutex);
module_put(rmidi->card->module); module_put(rmidi->card->module);
return 0; return 0;
} }
...@@ -576,9 +577,9 @@ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info ...@@ -576,9 +577,9 @@ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info
struct snd_rawmidi_substream *substream; struct snd_rawmidi_substream *substream;
struct list_head *list; struct list_head *list;
down(&register_mutex); mutex_lock(&register_mutex);
rmidi = snd_rawmidi_search(card, info->device); rmidi = snd_rawmidi_search(card, info->device);
up(&register_mutex); mutex_unlock(&register_mutex);
if (!rmidi) if (!rmidi)
return -ENXIO; return -ENXIO;
if (info->stream < 0 || info->stream > 1) if (info->stream < 0 || info->stream > 1)
...@@ -818,7 +819,7 @@ static int snd_rawmidi_control_ioctl(struct snd_card *card, ...@@ -818,7 +819,7 @@ static int snd_rawmidi_control_ioctl(struct snd_card *card,
if (get_user(device, (int __user *)argp)) if (get_user(device, (int __user *)argp))
return -EFAULT; return -EFAULT;
down(&register_mutex); mutex_lock(&register_mutex);
device = device < 0 ? 0 : device + 1; device = device < 0 ? 0 : device + 1;
while (device < SNDRV_RAWMIDI_DEVICES) { while (device < SNDRV_RAWMIDI_DEVICES) {
if (snd_rawmidi_search(card, device)) if (snd_rawmidi_search(card, device))
...@@ -827,7 +828,7 @@ static int snd_rawmidi_control_ioctl(struct snd_card *card, ...@@ -827,7 +828,7 @@ static int snd_rawmidi_control_ioctl(struct snd_card *card,
} }
if (device == SNDRV_RAWMIDI_DEVICES) if (device == SNDRV_RAWMIDI_DEVICES)
device = -1; device = -1;
up(&register_mutex); mutex_unlock(&register_mutex);
if (put_user(device, (int __user *)argp)) if (put_user(device, (int __user *)argp))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -1314,7 +1315,7 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry, ...@@ -1314,7 +1315,7 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
rmidi = entry->private_data; rmidi = entry->private_data;
snd_iprintf(buffer, "%s\n\n", rmidi->name); snd_iprintf(buffer, "%s\n\n", rmidi->name);
down(&rmidi->open_mutex); mutex_lock(&rmidi->open_mutex);
if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) { if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) {
list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) { list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) {
substream = list_entry(list, struct snd_rawmidi_substream, list); substream = list_entry(list, struct snd_rawmidi_substream, list);
...@@ -1355,7 +1356,7 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry, ...@@ -1355,7 +1356,7 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
} }
} }
} }
up(&rmidi->open_mutex); mutex_unlock(&rmidi->open_mutex);
} }
/* /*
...@@ -1436,7 +1437,7 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device, ...@@ -1436,7 +1437,7 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device,
} }
rmidi->card = card; rmidi->card = card;
rmidi->device = device; rmidi->device = device;
init_MUTEX(&rmidi->open_mutex); mutex_init(&rmidi->open_mutex);
init_waitqueue_head(&rmidi->open_wait); init_waitqueue_head(&rmidi->open_wait);
if (id != NULL) if (id != NULL)
strlcpy(rmidi->id, id, sizeof(rmidi->id)); strlcpy(rmidi->id, id, sizeof(rmidi->id));
...@@ -1507,9 +1508,9 @@ static int snd_rawmidi_dev_register(struct snd_device *device) ...@@ -1507,9 +1508,9 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
if (rmidi->device >= SNDRV_RAWMIDI_DEVICES) if (rmidi->device >= SNDRV_RAWMIDI_DEVICES)
return -ENOMEM; return -ENOMEM;
down(&register_mutex); mutex_lock(&register_mutex);
if (snd_rawmidi_search(rmidi->card, rmidi->device)) { if (snd_rawmidi_search(rmidi->card, rmidi->device)) {
up(&register_mutex); mutex_unlock(&register_mutex);
return -EBUSY; return -EBUSY;
} }
list_add_tail(&rmidi->list, &snd_rawmidi_devices); list_add_tail(&rmidi->list, &snd_rawmidi_devices);
...@@ -1519,14 +1520,14 @@ static int snd_rawmidi_dev_register(struct snd_device *device) ...@@ -1519,14 +1520,14 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
&snd_rawmidi_f_ops, rmidi, name)) < 0) { &snd_rawmidi_f_ops, rmidi, name)) < 0) {
snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device); snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device);
list_del(&rmidi->list); list_del(&rmidi->list);
up(&register_mutex); mutex_unlock(&register_mutex);
return err; return err;
} }
if (rmidi->ops && rmidi->ops->dev_register && if (rmidi->ops && rmidi->ops->dev_register &&
(err = rmidi->ops->dev_register(rmidi)) < 0) { (err = rmidi->ops->dev_register(rmidi)) < 0) {
snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device); snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device);
list_del(&rmidi->list); list_del(&rmidi->list);
up(&register_mutex); mutex_unlock(&register_mutex);
return err; return err;
} }
#ifdef CONFIG_SND_OSSEMUL #ifdef CONFIG_SND_OSSEMUL
...@@ -1553,7 +1554,7 @@ static int snd_rawmidi_dev_register(struct snd_device *device) ...@@ -1553,7 +1554,7 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
} }
} }
#endif /* CONFIG_SND_OSSEMUL */ #endif /* CONFIG_SND_OSSEMUL */
up(&register_mutex); mutex_unlock(&register_mutex);
sprintf(name, "midi%d", rmidi->device); sprintf(name, "midi%d", rmidi->device);
entry = snd_info_create_card_entry(rmidi->card, name, rmidi->card->proc_root); entry = snd_info_create_card_entry(rmidi->card, name, rmidi->card->proc_root);
if (entry) { if (entry) {
...@@ -1583,9 +1584,9 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device) ...@@ -1583,9 +1584,9 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device)
{ {
struct snd_rawmidi *rmidi = device->device_data; struct snd_rawmidi *rmidi = device->device_data;
down(&register_mutex); mutex_lock(&register_mutex);
list_del_init(&rmidi->list); list_del_init(&rmidi->list);
up(&register_mutex); mutex_unlock(&register_mutex);
return 0; return 0;
} }
...@@ -1594,7 +1595,7 @@ static int snd_rawmidi_dev_unregister(struct snd_device *device) ...@@ -1594,7 +1595,7 @@ static int snd_rawmidi_dev_unregister(struct snd_device *device)
struct snd_rawmidi *rmidi = device->device_data; struct snd_rawmidi *rmidi = device->device_data;
snd_assert(rmidi != NULL, return -ENXIO); snd_assert(rmidi != NULL, return -ENXIO);
down(&register_mutex); mutex_lock(&register_mutex);
list_del(&rmidi->list); list_del(&rmidi->list);
if (rmidi->proc_entry) { if (rmidi->proc_entry) {
snd_info_unregister(rmidi->proc_entry); snd_info_unregister(rmidi->proc_entry);
...@@ -1616,7 +1617,7 @@ static int snd_rawmidi_dev_unregister(struct snd_device *device) ...@@ -1616,7 +1617,7 @@ static int snd_rawmidi_dev_unregister(struct snd_device *device)
if (rmidi->ops && rmidi->ops->dev_unregister) if (rmidi->ops && rmidi->ops->dev_unregister)
rmidi->ops->dev_unregister(rmidi); rmidi->ops->dev_unregister(rmidi);
snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device); snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device);
up(&register_mutex); mutex_unlock(&register_mutex);
#if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE))
if (rmidi->seq_dev) { if (rmidi->seq_dev) {
snd_device_free(rmidi->card, rmidi->seq_dev); snd_device_free(rmidi->card, rmidi->seq_dev);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/mutex.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/minors.h> #include <sound/minors.h>
#include <sound/initval.h> #include <sound/initval.h>
...@@ -124,7 +125,7 @@ module_exit(alsa_seq_oss_exit) ...@@ -124,7 +125,7 @@ module_exit(alsa_seq_oss_exit)
* ALSA minor device interface * ALSA minor device interface
*/ */
static DECLARE_MUTEX(register_mutex); static DEFINE_MUTEX(register_mutex);
static int static int
odev_open(struct inode *inode, struct file *file) odev_open(struct inode *inode, struct file *file)
...@@ -136,9 +137,9 @@ odev_open(struct inode *inode, struct file *file) ...@@ -136,9 +137,9 @@ odev_open(struct inode *inode, struct file *file)
else else
level = SNDRV_SEQ_OSS_MODE_SYNTH; level = SNDRV_SEQ_OSS_MODE_SYNTH;
down(&register_mutex); mutex_lock(&register_mutex);
rc = snd_seq_oss_open(file, level); rc = snd_seq_oss_open(file, level);
up(&register_mutex); mutex_unlock(&register_mutex);
return rc; return rc;
} }
...@@ -153,9 +154,9 @@ odev_release(struct inode *inode, struct file *file) ...@@ -153,9 +154,9 @@ odev_release(struct inode *inode, struct file *file)
snd_seq_oss_drain_write(dp); snd_seq_oss_drain_write(dp);
down(&register_mutex); mutex_lock(&register_mutex);
snd_seq_oss_release(dp); snd_seq_oss_release(dp);
up(&register_mutex); mutex_unlock(&register_mutex);
return 0; return 0;
} }
...@@ -224,13 +225,13 @@ register_device(void) ...@@ -224,13 +225,13 @@ register_device(void)
{ {
int rc; int rc;
down(&register_mutex); mutex_lock(&register_mutex);
if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER,
NULL, 0, NULL, 0,
&seq_oss_f_ops, NULL, &seq_oss_f_ops, NULL,
SNDRV_SEQ_OSS_DEVNAME)) < 0) { SNDRV_SEQ_OSS_DEVNAME)) < 0) {
snd_printk(KERN_ERR "can't register device seq\n"); snd_printk(KERN_ERR "can't register device seq\n");
up(&register_mutex); mutex_unlock(&register_mutex);
return rc; return rc;
} }
if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC, if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC,
...@@ -239,24 +240,24 @@ register_device(void) ...@@ -239,24 +240,24 @@ register_device(void)
SNDRV_SEQ_OSS_DEVNAME)) < 0) { SNDRV_SEQ_OSS_DEVNAME)) < 0) {
snd_printk(KERN_ERR "can't register device music\n"); snd_printk(KERN_ERR "can't register device music\n");
snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0); snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0);
up(&register_mutex); mutex_unlock(&register_mutex);
return rc; return rc;
} }
debug_printk(("device registered\n")); debug_printk(("device registered\n"));
up(&register_mutex); mutex_unlock(&register_mutex);
return 0; return 0;
} }
static void static void
unregister_device(void) unregister_device(void)
{ {
down(&register_mutex); mutex_lock(&register_mutex);
debug_printk(("device unregistered\n")); debug_printk(("device unregistered\n"));
if (snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC, NULL, 0) < 0) if (snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC, NULL, 0) < 0)
snd_printk(KERN_ERR "error unregister device music\n"); snd_printk(KERN_ERR "error unregister device music\n");
if (snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0) < 0) if (snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0) < 0)
snd_printk(KERN_ERR "error unregister device seq\n"); snd_printk(KERN_ERR "error unregister device seq\n");
up(&register_mutex); mutex_unlock(&register_mutex);
} }
/* /*
...@@ -270,12 +271,12 @@ static struct snd_info_entry *info_entry; ...@@ -270,12 +271,12 @@ static struct snd_info_entry *info_entry;
static void static void
info_read(struct snd_info_entry *entry, struct snd_info_buffer *buf) info_read(struct snd_info_entry *entry, struct snd_info_buffer *buf)
{ {
down(&register_mutex); mutex_lock(&register_mutex);
snd_iprintf(buf, "OSS sequencer emulation version %s\n", SNDRV_SEQ_OSS_VERSION_STR); snd_iprintf(buf, "OSS sequencer emulation version %s\n", SNDRV_SEQ_OSS_VERSION_STR);
snd_seq_oss_system_info_read(buf); snd_seq_oss_system_info_read(buf);
snd_seq_oss_synth_info_read(buf); snd_seq_oss_synth_info_read(buf);
snd_seq_oss_midi_info_read(buf); snd_seq_oss_midi_info_read(buf);
up(&register_mutex); mutex_unlock(&register_mutex);
} }
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
#define SNDRV_SEQ_LFLG_OPEN (SNDRV_SEQ_LFLG_INPUT|SNDRV_SEQ_LFLG_OUTPUT) #define SNDRV_SEQ_LFLG_OPEN (SNDRV_SEQ_LFLG_INPUT|SNDRV_SEQ_LFLG_OUTPUT)
static DEFINE_SPINLOCK(clients_lock); static DEFINE_SPINLOCK(clients_lock);
static DECLARE_MUTEX(register_mutex); static DEFINE_MUTEX(register_mutex);
/* /*
* client table * client table
...@@ -237,7 +237,7 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize) ...@@ -237,7 +237,7 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize)
client->type = NO_CLIENT; client->type = NO_CLIENT;
snd_use_lock_init(&client->use_lock); snd_use_lock_init(&client->use_lock);
rwlock_init(&client->ports_lock); rwlock_init(&client->ports_lock);
init_MUTEX(&client->ports_mutex); mutex_init(&client->ports_mutex);
INIT_LIST_HEAD(&client->ports_list_head); INIT_LIST_HEAD(&client->ports_list_head);
/* find free slot in the client table */ /* find free slot in the client table */
...@@ -290,7 +290,7 @@ static int seq_free_client1(struct snd_seq_client *client) ...@@ -290,7 +290,7 @@ static int seq_free_client1(struct snd_seq_client *client)
static void seq_free_client(struct snd_seq_client * client) static void seq_free_client(struct snd_seq_client * client)
{ {
down(&register_mutex); mutex_lock(&register_mutex);
switch (client->type) { switch (client->type) {
case NO_CLIENT: case NO_CLIENT:
snd_printk(KERN_WARNING "Seq: Trying to free unused client %d\n", snd_printk(KERN_WARNING "Seq: Trying to free unused client %d\n",
...@@ -306,7 +306,7 @@ static void seq_free_client(struct snd_seq_client * client) ...@@ -306,7 +306,7 @@ static void seq_free_client(struct snd_seq_client * client)
snd_printk(KERN_ERR "Seq: Trying to free client %d with undefined type = %d\n", snd_printk(KERN_ERR "Seq: Trying to free client %d with undefined type = %d\n",
client->number, client->type); client->number, client->type);
} }
up(&register_mutex); mutex_unlock(&register_mutex);
snd_seq_system_client_ev_client_exit(client->number); snd_seq_system_client_ev_client_exit(client->number);
} }
...@@ -322,11 +322,11 @@ static int snd_seq_open(struct inode *inode, struct file *file) ...@@ -322,11 +322,11 @@ static int snd_seq_open(struct inode *inode, struct file *file)
struct snd_seq_client *client; struct snd_seq_client *client;
struct snd_seq_user_client *user; struct snd_seq_user_client *user;
if (down_interruptible(&register_mutex)) if (mutex_lock_interruptible(&register_mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS); client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS);
if (client == NULL) { if (client == NULL) {
up(&register_mutex); mutex_unlock(&register_mutex);
return -ENOMEM; /* failure code */ return -ENOMEM; /* failure code */
} }
...@@ -346,14 +346,14 @@ static int snd_seq_open(struct inode *inode, struct file *file) ...@@ -346,14 +346,14 @@ static int snd_seq_open(struct inode *inode, struct file *file)
if (user->fifo == NULL) { if (user->fifo == NULL) {
seq_free_client1(client); seq_free_client1(client);
kfree(client); kfree(client);
up(&register_mutex); mutex_unlock(&register_mutex);
return -ENOMEM; return -ENOMEM;
} }
} }
usage_alloc(&client_usage, 1); usage_alloc(&client_usage, 1);
client->type = USER_CLIENT; client->type = USER_CLIENT;
up(&register_mutex); mutex_unlock(&register_mutex);
c = client->number; c = client->number;
file->private_data = client; file->private_data = client;
...@@ -1743,7 +1743,7 @@ static int snd_seq_ioctl_get_queue_timer(struct snd_seq_client *client, ...@@ -1743,7 +1743,7 @@ static int snd_seq_ioctl_get_queue_timer(struct snd_seq_client *client,
if (queue == NULL) if (queue == NULL)
return -EINVAL; return -EINVAL;
if (down_interruptible(&queue->timer_mutex)) { if (mutex_lock_interruptible(&queue->timer_mutex)) {
queuefree(queue); queuefree(queue);
return -ERESTARTSYS; return -ERESTARTSYS;
} }
...@@ -1756,7 +1756,7 @@ static int snd_seq_ioctl_get_queue_timer(struct snd_seq_client *client, ...@@ -1756,7 +1756,7 @@ static int snd_seq_ioctl_get_queue_timer(struct snd_seq_client *client,
timer.u.alsa.id = tmr->alsa_id; timer.u.alsa.id = tmr->alsa_id;
timer.u.alsa.resolution = tmr->preferred_resolution; timer.u.alsa.resolution = tmr->preferred_resolution;
} }
up(&queue->timer_mutex); mutex_unlock(&queue->timer_mutex);
queuefree(queue); queuefree(queue);
if (copy_to_user(arg, &timer, sizeof(timer))) if (copy_to_user(arg, &timer, sizeof(timer)))
...@@ -1785,7 +1785,7 @@ static int snd_seq_ioctl_set_queue_timer(struct snd_seq_client *client, ...@@ -1785,7 +1785,7 @@ static int snd_seq_ioctl_set_queue_timer(struct snd_seq_client *client,
q = queueptr(timer.queue); q = queueptr(timer.queue);
if (q == NULL) if (q == NULL)
return -ENXIO; return -ENXIO;
if (down_interruptible(&q->timer_mutex)) { if (mutex_lock_interruptible(&q->timer_mutex)) {
queuefree(q); queuefree(q);
return -ERESTARTSYS; return -ERESTARTSYS;
} }
...@@ -1797,7 +1797,7 @@ static int snd_seq_ioctl_set_queue_timer(struct snd_seq_client *client, ...@@ -1797,7 +1797,7 @@ static int snd_seq_ioctl_set_queue_timer(struct snd_seq_client *client,
tmr->preferred_resolution = timer.u.alsa.resolution; tmr->preferred_resolution = timer.u.alsa.resolution;
} }
result = snd_seq_queue_timer_open(timer.queue); result = snd_seq_queue_timer_open(timer.queue);
up(&q->timer_mutex); mutex_unlock(&q->timer_mutex);
queuefree(q); queuefree(q);
} else { } else {
return -EPERM; return -EPERM;
...@@ -2230,7 +2230,7 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index, ...@@ -2230,7 +2230,7 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
if (card == NULL && client_index >= SNDRV_SEQ_GLOBAL_CLIENTS) if (card == NULL && client_index >= SNDRV_SEQ_GLOBAL_CLIENTS)
return -EINVAL; return -EINVAL;
if (down_interruptible(&register_mutex)) if (mutex_lock_interruptible(&register_mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (card) { if (card) {
...@@ -2243,7 +2243,7 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index, ...@@ -2243,7 +2243,7 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
/* empty write queue as default */ /* empty write queue as default */
client = seq_create_client1(client_index, 0); client = seq_create_client1(client_index, 0);
if (client == NULL) { if (client == NULL) {
up(&register_mutex); mutex_unlock(&register_mutex);
return -EBUSY; /* failure code */ return -EBUSY; /* failure code */
} }
usage_alloc(&client_usage, 1); usage_alloc(&client_usage, 1);
...@@ -2256,7 +2256,7 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index, ...@@ -2256,7 +2256,7 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
va_end(args); va_end(args);
client->type = KERNEL_CLIENT; client->type = KERNEL_CLIENT;
up(&register_mutex); mutex_unlock(&register_mutex);
/* make others aware this new client */ /* make others aware this new client */
snd_seq_system_client_ev_client_start(client->number); snd_seq_system_client_ev_client_start(client->number);
...@@ -2464,7 +2464,7 @@ static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer, ...@@ -2464,7 +2464,7 @@ static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer,
{ {
struct list_head *l; struct list_head *l;
down(&client->ports_mutex); mutex_lock(&client->ports_mutex);
list_for_each(l, &client->ports_list_head) { list_for_each(l, &client->ports_list_head) {
struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list); struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
snd_iprintf(buffer, " Port %3d : \"%s\" (%c%c%c%c)\n", snd_iprintf(buffer, " Port %3d : \"%s\" (%c%c%c%c)\n",
...@@ -2476,7 +2476,7 @@ static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer, ...@@ -2476,7 +2476,7 @@ static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer,
snd_seq_info_dump_subscribers(buffer, &p->c_src, 1, " Connecting To: "); snd_seq_info_dump_subscribers(buffer, &p->c_src, 1, " Connecting To: ");
snd_seq_info_dump_subscribers(buffer, &p->c_dest, 0, " Connected From: "); snd_seq_info_dump_subscribers(buffer, &p->c_dest, 0, " Connected From: ");
} }
up(&client->ports_mutex); mutex_unlock(&client->ports_mutex);
} }
...@@ -2550,16 +2550,16 @@ int __init snd_sequencer_device_init(void) ...@@ -2550,16 +2550,16 @@ int __init snd_sequencer_device_init(void)
{ {
int err; int err;
if (down_interruptible(&register_mutex)) if (mutex_lock_interruptible(&register_mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0, if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0,
&snd_seq_f_ops, NULL, "seq")) < 0) { &snd_seq_f_ops, NULL, "seq")) < 0) {
up(&register_mutex); mutex_unlock(&register_mutex);
return err; return err;
} }
up(&register_mutex); mutex_unlock(&register_mutex);
return 0; return 0;
} }
......
...@@ -58,7 +58,7 @@ struct snd_seq_client { ...@@ -58,7 +58,7 @@ struct snd_seq_client {
int num_ports; /* number of ports */ int num_ports; /* number of ports */
struct list_head ports_list_head; struct list_head ports_list_head;
rwlock_t ports_lock; rwlock_t ports_lock;
struct semaphore ports_mutex; struct mutex ports_mutex;
int convert32; /* convert 32->64bit */ int convert32; /* convert 32->64bit */
/* output pool */ /* output pool */
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <sound/initval.h> #include <sound/initval.h>
#include <linux/kmod.h> #include <linux/kmod.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/mutex.h>
MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>"); MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
MODULE_DESCRIPTION("ALSA sequencer device management"); MODULE_DESCRIPTION("ALSA sequencer device management");
...@@ -69,7 +70,7 @@ struct ops_list { ...@@ -69,7 +70,7 @@ struct ops_list {
struct list_head dev_list; /* list of devices */ struct list_head dev_list; /* list of devices */
int num_devices; /* number of associated devices */ int num_devices; /* number of associated devices */
int num_init_devices; /* number of initialized devices */ int num_init_devices; /* number of initialized devices */
struct semaphore reg_mutex; struct mutex reg_mutex;
struct list_head list; /* next driver */ struct list_head list; /* next driver */
}; };
...@@ -77,7 +78,7 @@ struct ops_list { ...@@ -77,7 +78,7 @@ struct ops_list {
static LIST_HEAD(opslist); static LIST_HEAD(opslist);
static int num_ops; static int num_ops;
static DECLARE_MUTEX(ops_mutex); static DEFINE_MUTEX(ops_mutex);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
static struct snd_info_entry *info_entry = NULL; static struct snd_info_entry *info_entry = NULL;
#endif #endif
...@@ -108,7 +109,7 @@ static void snd_seq_device_info(struct snd_info_entry *entry, ...@@ -108,7 +109,7 @@ static void snd_seq_device_info(struct snd_info_entry *entry,
{ {
struct list_head *head; struct list_head *head;
down(&ops_mutex); mutex_lock(&ops_mutex);
list_for_each(head, &opslist) { list_for_each(head, &opslist) {
struct ops_list *ops = list_entry(head, struct ops_list, list); struct ops_list *ops = list_entry(head, struct ops_list, list);
snd_iprintf(buffer, "snd-%s%s%s%s,%d\n", snd_iprintf(buffer, "snd-%s%s%s%s,%d\n",
...@@ -118,7 +119,7 @@ static void snd_seq_device_info(struct snd_info_entry *entry, ...@@ -118,7 +119,7 @@ static void snd_seq_device_info(struct snd_info_entry *entry,
ops->driver & DRIVER_LOCKED ? ",locked" : "", ops->driver & DRIVER_LOCKED ? ",locked" : "",
ops->num_devices); ops->num_devices);
} }
up(&ops_mutex); mutex_unlock(&ops_mutex);
} }
#endif #endif
...@@ -154,20 +155,20 @@ void snd_seq_device_load_drivers(void) ...@@ -154,20 +155,20 @@ void snd_seq_device_load_drivers(void)
if (! current->fs->root) if (! current->fs->root)
return; return;
down(&ops_mutex); mutex_lock(&ops_mutex);
list_for_each(head, &opslist) { list_for_each(head, &opslist) {
struct ops_list *ops = list_entry(head, struct ops_list, list); struct ops_list *ops = list_entry(head, struct ops_list, list);
if (! (ops->driver & DRIVER_LOADED) && if (! (ops->driver & DRIVER_LOADED) &&
! (ops->driver & DRIVER_REQUESTED)) { ! (ops->driver & DRIVER_REQUESTED)) {
ops->used++; ops->used++;
up(&ops_mutex); mutex_unlock(&ops_mutex);
ops->driver |= DRIVER_REQUESTED; ops->driver |= DRIVER_REQUESTED;
request_module("snd-%s", ops->id); request_module("snd-%s", ops->id);
down(&ops_mutex); mutex_lock(&ops_mutex);
ops->used--; ops->used--;
} }
} }
up(&ops_mutex); mutex_unlock(&ops_mutex);
#endif #endif
} }
...@@ -214,10 +215,10 @@ int snd_seq_device_new(struct snd_card *card, int device, char *id, int argsize, ...@@ -214,10 +215,10 @@ int snd_seq_device_new(struct snd_card *card, int device, char *id, int argsize,
dev->status = SNDRV_SEQ_DEVICE_FREE; dev->status = SNDRV_SEQ_DEVICE_FREE;
/* add this device to the list */ /* add this device to the list */
down(&ops->reg_mutex); mutex_lock(&ops->reg_mutex);
list_add_tail(&dev->list, &ops->dev_list); list_add_tail(&dev->list, &ops->dev_list);
ops->num_devices++; ops->num_devices++;
up(&ops->reg_mutex); mutex_unlock(&ops->reg_mutex);
unlock_driver(ops); unlock_driver(ops);
...@@ -246,10 +247,10 @@ static int snd_seq_device_free(struct snd_seq_device *dev) ...@@ -246,10 +247,10 @@ static int snd_seq_device_free(struct snd_seq_device *dev)
return -ENXIO; return -ENXIO;
/* remove the device from the list */ /* remove the device from the list */
down(&ops->reg_mutex); mutex_lock(&ops->reg_mutex);
list_del(&dev->list); list_del(&dev->list);
ops->num_devices--; ops->num_devices--;
up(&ops->reg_mutex); mutex_unlock(&ops->reg_mutex);
free_device(dev, ops); free_device(dev, ops);
if (dev->private_free) if (dev->private_free)
...@@ -344,7 +345,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry, ...@@ -344,7 +345,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
return -EBUSY; return -EBUSY;
} }
down(&ops->reg_mutex); mutex_lock(&ops->reg_mutex);
/* copy driver operators */ /* copy driver operators */
ops->ops = *entry; ops->ops = *entry;
ops->driver |= DRIVER_LOADED; ops->driver |= DRIVER_LOADED;
...@@ -355,7 +356,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry, ...@@ -355,7 +356,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list); struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list);
init_device(dev, ops); init_device(dev, ops);
} }
up(&ops->reg_mutex); mutex_unlock(&ops->reg_mutex);
unlock_driver(ops); unlock_driver(ops);
snd_seq_autoload_unlock(); snd_seq_autoload_unlock();
...@@ -378,17 +379,17 @@ static struct ops_list * create_driver(char *id) ...@@ -378,17 +379,17 @@ static struct ops_list * create_driver(char *id)
/* set up driver entry */ /* set up driver entry */
strlcpy(ops->id, id, sizeof(ops->id)); strlcpy(ops->id, id, sizeof(ops->id));
init_MUTEX(&ops->reg_mutex); mutex_init(&ops->reg_mutex);
ops->driver = DRIVER_EMPTY; ops->driver = DRIVER_EMPTY;
INIT_LIST_HEAD(&ops->dev_list); INIT_LIST_HEAD(&ops->dev_list);
/* lock this instance */ /* lock this instance */
ops->used = 1; ops->used = 1;
/* register driver entry */ /* register driver entry */
down(&ops_mutex); mutex_lock(&ops_mutex);
list_add_tail(&ops->list, &opslist); list_add_tail(&ops->list, &opslist);
num_ops++; num_ops++;
up(&ops_mutex); mutex_unlock(&ops_mutex);
return ops; return ops;
} }
...@@ -414,7 +415,7 @@ int snd_seq_device_unregister_driver(char *id) ...@@ -414,7 +415,7 @@ int snd_seq_device_unregister_driver(char *id)
} }
/* close and release all devices associated with this driver */ /* close and release all devices associated with this driver */
down(&ops->reg_mutex); mutex_lock(&ops->reg_mutex);
ops->driver |= DRIVER_LOCKED; /* do not remove this driver recursively */ ops->driver |= DRIVER_LOCKED; /* do not remove this driver recursively */
list_for_each(head, &ops->dev_list) { list_for_each(head, &ops->dev_list) {
struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list); struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list);
...@@ -425,7 +426,7 @@ int snd_seq_device_unregister_driver(char *id) ...@@ -425,7 +426,7 @@ int snd_seq_device_unregister_driver(char *id)
if (ops->num_init_devices > 0) if (ops->num_init_devices > 0)
snd_printk(KERN_ERR "free_driver: init_devices > 0!! (%d)\n", snd_printk(KERN_ERR "free_driver: init_devices > 0!! (%d)\n",
ops->num_init_devices); ops->num_init_devices);
up(&ops->reg_mutex); mutex_unlock(&ops->reg_mutex);
unlock_driver(ops); unlock_driver(ops);
...@@ -443,7 +444,7 @@ static void remove_drivers(void) ...@@ -443,7 +444,7 @@ static void remove_drivers(void)
{ {
struct list_head *head; struct list_head *head;
down(&ops_mutex); mutex_lock(&ops_mutex);
head = opslist.next; head = opslist.next;
while (head != &opslist) { while (head != &opslist) {
struct ops_list *ops = list_entry(head, struct ops_list, list); struct ops_list *ops = list_entry(head, struct ops_list, list);
...@@ -456,7 +457,7 @@ static void remove_drivers(void) ...@@ -456,7 +457,7 @@ static void remove_drivers(void)
} else } else
head = head->next; head = head->next;
} }
up(&ops_mutex); mutex_unlock(&ops_mutex);
} }
/* /*
...@@ -519,16 +520,16 @@ static struct ops_list * find_driver(char *id, int create_if_empty) ...@@ -519,16 +520,16 @@ static struct ops_list * find_driver(char *id, int create_if_empty)
{ {
struct list_head *head; struct list_head *head;
down(&ops_mutex); mutex_lock(&ops_mutex);
list_for_each(head, &opslist) { list_for_each(head, &opslist) {
struct ops_list *ops = list_entry(head, struct ops_list, list); struct ops_list *ops = list_entry(head, struct ops_list, list);
if (strcmp(ops->id, id) == 0) { if (strcmp(ops->id, id) == 0) {
ops->used++; ops->used++;
up(&ops_mutex); mutex_unlock(&ops_mutex);
return ops; return ops;
} }
} }
up(&ops_mutex); mutex_unlock(&ops_mutex);
if (create_if_empty) if (create_if_empty)
return create_driver(id); return create_driver(id);
return NULL; return NULL;
...@@ -536,9 +537,9 @@ static struct ops_list * find_driver(char *id, int create_if_empty) ...@@ -536,9 +537,9 @@ static struct ops_list * find_driver(char *id, int create_if_empty)
static void unlock_driver(struct ops_list *ops) static void unlock_driver(struct ops_list *ops)
{ {
down(&ops_mutex); mutex_lock(&ops_mutex);
ops->used--; ops->used--;
up(&ops_mutex); mutex_unlock(&ops_mutex);
} }
......
...@@ -36,7 +36,7 @@ static void snd_instr_lock_ops(struct snd_seq_kinstr_list *list) ...@@ -36,7 +36,7 @@ static void snd_instr_lock_ops(struct snd_seq_kinstr_list *list)
if (!(list->flags & SNDRV_SEQ_INSTR_FLG_DIRECT)) { if (!(list->flags & SNDRV_SEQ_INSTR_FLG_DIRECT)) {
spin_lock_irqsave(&list->ops_lock, list->ops_flags); spin_lock_irqsave(&list->ops_lock, list->ops_flags);
} else { } else {
down(&list->ops_mutex); mutex_lock(&list->ops_mutex);
} }
} }
...@@ -45,7 +45,7 @@ static void snd_instr_unlock_ops(struct snd_seq_kinstr_list *list) ...@@ -45,7 +45,7 @@ static void snd_instr_unlock_ops(struct snd_seq_kinstr_list *list)
if (!(list->flags & SNDRV_SEQ_INSTR_FLG_DIRECT)) { if (!(list->flags & SNDRV_SEQ_INSTR_FLG_DIRECT)) {
spin_unlock_irqrestore(&list->ops_lock, list->ops_flags); spin_unlock_irqrestore(&list->ops_lock, list->ops_flags);
} else { } else {
up(&list->ops_mutex); mutex_unlock(&list->ops_mutex);
} }
} }
...@@ -82,7 +82,7 @@ struct snd_seq_kinstr_list *snd_seq_instr_list_new(void) ...@@ -82,7 +82,7 @@ struct snd_seq_kinstr_list *snd_seq_instr_list_new(void)
return NULL; return NULL;
spin_lock_init(&list->lock); spin_lock_init(&list->lock);
spin_lock_init(&list->ops_lock); spin_lock_init(&list->ops_lock);
init_MUTEX(&list->ops_mutex); mutex_init(&list->ops_mutex);
list->owner = -1; list->owner = -1;
return list; return list;
} }
......
...@@ -32,7 +32,7 @@ Possible options for midisynth module: ...@@ -32,7 +32,7 @@ Possible options for midisynth module:
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <asm/semaphore.h> #include <linux/mutex.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/rawmidi.h> #include <sound/rawmidi.h>
#include <sound/seq_kernel.h> #include <sound/seq_kernel.h>
...@@ -70,7 +70,7 @@ struct seq_midisynth_client { ...@@ -70,7 +70,7 @@ struct seq_midisynth_client {
}; };
static struct seq_midisynth_client *synths[SNDRV_CARDS]; static struct seq_midisynth_client *synths[SNDRV_CARDS];
static DECLARE_MUTEX(register_mutex); static DEFINE_MUTEX(register_mutex);
/* handle rawmidi input event (MIDI v1.0 stream) */ /* handle rawmidi input event (MIDI v1.0 stream) */
static void snd_midi_input_event(struct snd_rawmidi_substream *substream) static void snd_midi_input_event(struct snd_rawmidi_substream *substream)
...@@ -308,13 +308,13 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev) ...@@ -308,13 +308,13 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev)
if (ports > (256 / SNDRV_RAWMIDI_DEVICES)) if (ports > (256 / SNDRV_RAWMIDI_DEVICES))
ports = 256 / SNDRV_RAWMIDI_DEVICES; ports = 256 / SNDRV_RAWMIDI_DEVICES;
down(&register_mutex); mutex_lock(&register_mutex);
client = synths[card->number]; client = synths[card->number];
if (client == NULL) { if (client == NULL) {
newclient = 1; newclient = 1;
client = kzalloc(sizeof(*client), GFP_KERNEL); client = kzalloc(sizeof(*client), GFP_KERNEL);
if (client == NULL) { if (client == NULL) {
up(&register_mutex); mutex_unlock(&register_mutex);
kfree(info); kfree(info);
return -ENOMEM; return -ENOMEM;
} }
...@@ -324,7 +324,7 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev) ...@@ -324,7 +324,7 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev)
(const char *)info->name : "External MIDI"); (const char *)info->name : "External MIDI");
if (client->seq_client < 0) { if (client->seq_client < 0) {
kfree(client); kfree(client);
up(&register_mutex); mutex_unlock(&register_mutex);
kfree(info); kfree(info);
return -ENOMEM; return -ENOMEM;
} }
...@@ -397,7 +397,7 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev) ...@@ -397,7 +397,7 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev)
client->num_ports++; client->num_ports++;
if (newclient) if (newclient)
synths[card->number] = client; synths[card->number] = client;
up(&register_mutex); mutex_unlock(&register_mutex);
kfree(info); kfree(info);
kfree(port); kfree(port);
return 0; /* success */ return 0; /* success */
...@@ -414,7 +414,7 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev) ...@@ -414,7 +414,7 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev)
} }
kfree(info); kfree(info);
kfree(port); kfree(port);
up(&register_mutex); mutex_unlock(&register_mutex);
return -ENOMEM; return -ENOMEM;
} }
...@@ -427,10 +427,10 @@ snd_seq_midisynth_unregister_port(struct snd_seq_device *dev) ...@@ -427,10 +427,10 @@ snd_seq_midisynth_unregister_port(struct snd_seq_device *dev)
struct snd_card *card = dev->card; struct snd_card *card = dev->card;
int device = dev->device, p, ports; int device = dev->device, p, ports;
down(&register_mutex); mutex_lock(&register_mutex);
client = synths[card->number]; client = synths[card->number];
if (client == NULL || client->ports[device] == NULL) { if (client == NULL || client->ports[device] == NULL) {
up(&register_mutex); mutex_unlock(&register_mutex);
return -ENODEV; return -ENODEV;
} }
ports = client->ports_per_device[device]; ports = client->ports_per_device[device];
...@@ -446,7 +446,7 @@ snd_seq_midisynth_unregister_port(struct snd_seq_device *dev) ...@@ -446,7 +446,7 @@ snd_seq_midisynth_unregister_port(struct snd_seq_device *dev)
synths[card->number] = NULL; synths[card->number] = NULL;
kfree(client); kfree(client);
} }
up(&register_mutex); mutex_unlock(&register_mutex);
return 0; return 0;
} }
......
...@@ -159,7 +159,7 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client, ...@@ -159,7 +159,7 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
port_subs_info_init(&new_port->c_dest); port_subs_info_init(&new_port->c_dest);
num = port >= 0 ? port : 0; num = port >= 0 ? port : 0;
down(&client->ports_mutex); mutex_lock(&client->ports_mutex);
write_lock_irqsave(&client->ports_lock, flags); write_lock_irqsave(&client->ports_lock, flags);
list_for_each(l, &client->ports_list_head) { list_for_each(l, &client->ports_list_head) {
struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list); struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
...@@ -173,7 +173,7 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client, ...@@ -173,7 +173,7 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
client->num_ports++; client->num_ports++;
new_port->addr.port = num; /* store the port number in the port */ new_port->addr.port = num; /* store the port number in the port */
write_unlock_irqrestore(&client->ports_lock, flags); write_unlock_irqrestore(&client->ports_lock, flags);
up(&client->ports_mutex); mutex_unlock(&client->ports_mutex);
sprintf(new_port->name, "port-%d", num); sprintf(new_port->name, "port-%d", num);
return new_port; return new_port;
...@@ -292,7 +292,7 @@ int snd_seq_delete_port(struct snd_seq_client *client, int port) ...@@ -292,7 +292,7 @@ int snd_seq_delete_port(struct snd_seq_client *client, int port)
struct list_head *l; struct list_head *l;
struct snd_seq_client_port *found = NULL; struct snd_seq_client_port *found = NULL;
down(&client->ports_mutex); mutex_lock(&client->ports_mutex);
write_lock_irqsave(&client->ports_lock, flags); write_lock_irqsave(&client->ports_lock, flags);
list_for_each(l, &client->ports_list_head) { list_for_each(l, &client->ports_list_head) {
struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list); struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
...@@ -305,7 +305,7 @@ int snd_seq_delete_port(struct snd_seq_client *client, int port) ...@@ -305,7 +305,7 @@ int snd_seq_delete_port(struct snd_seq_client *client, int port)
} }
} }
write_unlock_irqrestore(&client->ports_lock, flags); write_unlock_irqrestore(&client->ports_lock, flags);
up(&client->ports_mutex); mutex_unlock(&client->ports_mutex);
if (found) if (found)
return port_delete(client, found); return port_delete(client, found);
else else
...@@ -321,7 +321,7 @@ int snd_seq_delete_all_ports(struct snd_seq_client *client) ...@@ -321,7 +321,7 @@ int snd_seq_delete_all_ports(struct snd_seq_client *client)
/* move the port list to deleted_list, and /* move the port list to deleted_list, and
* clear the port list in the client data. * clear the port list in the client data.
*/ */
down(&client->ports_mutex); mutex_lock(&client->ports_mutex);
write_lock_irqsave(&client->ports_lock, flags); write_lock_irqsave(&client->ports_lock, flags);
if (! list_empty(&client->ports_list_head)) { if (! list_empty(&client->ports_list_head)) {
__list_add(&deleted_list, __list_add(&deleted_list,
...@@ -341,7 +341,7 @@ int snd_seq_delete_all_ports(struct snd_seq_client *client) ...@@ -341,7 +341,7 @@ int snd_seq_delete_all_ports(struct snd_seq_client *client)
snd_seq_system_client_ev_port_exit(port->addr.client, port->addr.port); snd_seq_system_client_ev_port_exit(port->addr.client, port->addr.port);
port_delete(client, port); port_delete(client, port);
} }
up(&client->ports_mutex); mutex_unlock(&client->ports_mutex);
return 0; return 0;
} }
......
...@@ -119,7 +119,7 @@ static struct snd_seq_queue *queue_new(int owner, int locked) ...@@ -119,7 +119,7 @@ static struct snd_seq_queue *queue_new(int owner, int locked)
spin_lock_init(&q->owner_lock); spin_lock_init(&q->owner_lock);
spin_lock_init(&q->check_lock); spin_lock_init(&q->check_lock);
init_MUTEX(&q->timer_mutex); mutex_init(&q->timer_mutex);
snd_use_lock_init(&q->use_lock); snd_use_lock_init(&q->use_lock);
q->queue = -1; q->queue = -1;
...@@ -516,7 +516,7 @@ int snd_seq_queue_use(int queueid, int client, int use) ...@@ -516,7 +516,7 @@ int snd_seq_queue_use(int queueid, int client, int use)
queue = queueptr(queueid); queue = queueptr(queueid);
if (queue == NULL) if (queue == NULL)
return -EINVAL; return -EINVAL;
down(&queue->timer_mutex); mutex_lock(&queue->timer_mutex);
if (use) { if (use) {
if (!test_and_set_bit(client, queue->clients_bitmap)) if (!test_and_set_bit(client, queue->clients_bitmap))
queue->clients++; queue->clients++;
...@@ -531,7 +531,7 @@ int snd_seq_queue_use(int queueid, int client, int use) ...@@ -531,7 +531,7 @@ int snd_seq_queue_use(int queueid, int client, int use)
} else { } else {
snd_seq_timer_close(queue); snd_seq_timer_close(queue);
} }
up(&queue->timer_mutex); mutex_unlock(&queue->timer_mutex);
queuefree(queue); queuefree(queue);
return 0; return 0;
} }
......
...@@ -54,7 +54,7 @@ struct snd_seq_queue { ...@@ -54,7 +54,7 @@ struct snd_seq_queue {
/* clients which uses this queue (bitmap) */ /* clients which uses this queue (bitmap) */
DECLARE_BITMAP(clients_bitmap, SNDRV_SEQ_MAX_CLIENTS); DECLARE_BITMAP(clients_bitmap, SNDRV_SEQ_MAX_CLIENTS);
unsigned int clients; /* users of this queue */ unsigned int clients; /* users of this queue */
struct semaphore timer_mutex; struct mutex timer_mutex;
snd_use_lock_t use_lock; snd_use_lock_t use_lock;
}; };
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <sound/initval.h> #include <sound/initval.h>
#include <linux/kmod.h> #include <linux/kmod.h>
#include <linux/devfs_fs_kernel.h> #include <linux/devfs_fs_kernel.h>
#include <linux/mutex.h>
#define SNDRV_OS_MINORS 256 #define SNDRV_OS_MINORS 256
...@@ -61,7 +62,7 @@ MODULE_ALIAS_CHARDEV_MAJOR(CONFIG_SND_MAJOR); ...@@ -61,7 +62,7 @@ MODULE_ALIAS_CHARDEV_MAJOR(CONFIG_SND_MAJOR);
int snd_ecards_limit; int snd_ecards_limit;
static struct snd_minor *snd_minors[SNDRV_OS_MINORS]; static struct snd_minor *snd_minors[SNDRV_OS_MINORS];
static DECLARE_MUTEX(sound_mutex); static DEFINE_MUTEX(sound_mutex);
extern struct class *sound_class; extern struct class *sound_class;
...@@ -122,13 +123,13 @@ void *snd_lookup_minor_data(unsigned int minor, int type) ...@@ -122,13 +123,13 @@ void *snd_lookup_minor_data(unsigned int minor, int type)
if (minor > ARRAY_SIZE(snd_minors)) if (minor > ARRAY_SIZE(snd_minors))
return NULL; return NULL;
down(&sound_mutex); mutex_lock(&sound_mutex);
mreg = snd_minors[minor]; mreg = snd_minors[minor];
if (mreg && mreg->type == type) if (mreg && mreg->type == type)
private_data = mreg->private_data; private_data = mreg->private_data;
else else
private_data = NULL; private_data = NULL;
up(&sound_mutex); mutex_unlock(&sound_mutex);
return private_data; return private_data;
} }
...@@ -256,7 +257,7 @@ int snd_register_device(int type, struct snd_card *card, int dev, ...@@ -256,7 +257,7 @@ int snd_register_device(int type, struct snd_card *card, int dev,
preg->f_ops = f_ops; preg->f_ops = f_ops;
preg->private_data = private_data; preg->private_data = private_data;
strcpy(preg->name, name); strcpy(preg->name, name);
down(&sound_mutex); mutex_lock(&sound_mutex);
#ifdef CONFIG_SND_DYNAMIC_MINORS #ifdef CONFIG_SND_DYNAMIC_MINORS
minor = snd_find_free_minor(); minor = snd_find_free_minor();
#else #else
...@@ -265,7 +266,7 @@ int snd_register_device(int type, struct snd_card *card, int dev, ...@@ -265,7 +266,7 @@ int snd_register_device(int type, struct snd_card *card, int dev,
minor = -EBUSY; minor = -EBUSY;
#endif #endif
if (minor < 0) { if (minor < 0) {
up(&sound_mutex); mutex_unlock(&sound_mutex);
kfree(preg); kfree(preg);
return minor; return minor;
} }
...@@ -276,7 +277,7 @@ int snd_register_device(int type, struct snd_card *card, int dev, ...@@ -276,7 +277,7 @@ int snd_register_device(int type, struct snd_card *card, int dev,
device = card->dev; device = card->dev;
class_device_create(sound_class, NULL, MKDEV(major, minor), device, "%s", name); class_device_create(sound_class, NULL, MKDEV(major, minor), device, "%s", name);
up(&sound_mutex); mutex_unlock(&sound_mutex);
return 0; return 0;
} }
...@@ -297,7 +298,7 @@ int snd_unregister_device(int type, struct snd_card *card, int dev) ...@@ -297,7 +298,7 @@ int snd_unregister_device(int type, struct snd_card *card, int dev)
struct snd_minor *mptr; struct snd_minor *mptr;
cardnum = card ? card->number : -1; cardnum = card ? card->number : -1;
down(&sound_mutex); mutex_lock(&sound_mutex);
for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor) for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor)
if ((mptr = snd_minors[minor]) != NULL && if ((mptr = snd_minors[minor]) != NULL &&
mptr->type == type && mptr->type == type &&
...@@ -305,7 +306,7 @@ int snd_unregister_device(int type, struct snd_card *card, int dev) ...@@ -305,7 +306,7 @@ int snd_unregister_device(int type, struct snd_card *card, int dev)
mptr->device == dev) mptr->device == dev)
break; break;
if (minor == ARRAY_SIZE(snd_minors)) { if (minor == ARRAY_SIZE(snd_minors)) {
up(&sound_mutex); mutex_unlock(&sound_mutex);
return -EINVAL; return -EINVAL;
} }
...@@ -315,7 +316,7 @@ int snd_unregister_device(int type, struct snd_card *card, int dev) ...@@ -315,7 +316,7 @@ int snd_unregister_device(int type, struct snd_card *card, int dev)
class_device_destroy(sound_class, MKDEV(major, minor)); class_device_destroy(sound_class, MKDEV(major, minor));
snd_minors[minor] = NULL; snd_minors[minor] = NULL;
up(&sound_mutex); mutex_unlock(&sound_mutex);
kfree(mptr); kfree(mptr);
return 0; return 0;
} }
...@@ -354,7 +355,7 @@ static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_bu ...@@ -354,7 +355,7 @@ static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_bu
int minor; int minor;
struct snd_minor *mptr; struct snd_minor *mptr;
down(&sound_mutex); mutex_lock(&sound_mutex);
for (minor = 0; minor < SNDRV_OS_MINORS; ++minor) { for (minor = 0; minor < SNDRV_OS_MINORS; ++minor) {
if (!(mptr = snd_minors[minor])) if (!(mptr = snd_minors[minor]))
continue; continue;
...@@ -371,7 +372,7 @@ static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_bu ...@@ -371,7 +372,7 @@ static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_bu
snd_iprintf(buffer, "%3i: : %s\n", minor, snd_iprintf(buffer, "%3i: : %s\n", minor,
snd_device_type_name(mptr->type)); snd_device_type_name(mptr->type));
} }
up(&sound_mutex); mutex_unlock(&sound_mutex);
} }
int __init snd_minor_info_init(void) int __init snd_minor_info_init(void)
......
...@@ -34,11 +34,12 @@ ...@@ -34,11 +34,12 @@
#include <sound/minors.h> #include <sound/minors.h>
#include <sound/info.h> #include <sound/info.h>
#include <linux/sound.h> #include <linux/sound.h>
#include <linux/mutex.h>
#define SNDRV_OSS_MINORS 128 #define SNDRV_OSS_MINORS 128
static struct snd_minor *snd_oss_minors[SNDRV_OSS_MINORS]; static struct snd_minor *snd_oss_minors[SNDRV_OSS_MINORS];
static DECLARE_MUTEX(sound_oss_mutex); static DEFINE_MUTEX(sound_oss_mutex);
void *snd_lookup_oss_minor_data(unsigned int minor, int type) void *snd_lookup_oss_minor_data(unsigned int minor, int type)
{ {
...@@ -47,13 +48,13 @@ void *snd_lookup_oss_minor_data(unsigned int minor, int type) ...@@ -47,13 +48,13 @@ void *snd_lookup_oss_minor_data(unsigned int minor, int type)
if (minor > ARRAY_SIZE(snd_oss_minors)) if (minor > ARRAY_SIZE(snd_oss_minors))
return NULL; return NULL;
down(&sound_oss_mutex); mutex_lock(&sound_oss_mutex);
mreg = snd_oss_minors[minor]; mreg = snd_oss_minors[minor];
if (mreg && mreg->type == type) if (mreg && mreg->type == type)
private_data = mreg->private_data; private_data = mreg->private_data;
else else
private_data = NULL; private_data = NULL;
up(&sound_oss_mutex); mutex_unlock(&sound_oss_mutex);
return private_data; return private_data;
} }
...@@ -117,7 +118,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, ...@@ -117,7 +118,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
preg->device = dev; preg->device = dev;
preg->f_ops = f_ops; preg->f_ops = f_ops;
preg->private_data = private_data; preg->private_data = private_data;
down(&sound_oss_mutex); mutex_lock(&sound_oss_mutex);
snd_oss_minors[minor] = preg; snd_oss_minors[minor] = preg;
minor_unit = SNDRV_MINOR_OSS_DEVICE(minor); minor_unit = SNDRV_MINOR_OSS_DEVICE(minor);
switch (minor_unit) { switch (minor_unit) {
...@@ -143,7 +144,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, ...@@ -143,7 +144,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
goto __end; goto __end;
snd_oss_minors[track2] = preg; snd_oss_minors[track2] = preg;
} }
up(&sound_oss_mutex); mutex_unlock(&sound_oss_mutex);
return 0; return 0;
__end: __end:
...@@ -152,7 +153,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, ...@@ -152,7 +153,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
if (register1 >= 0) if (register1 >= 0)
unregister_sound_special(register1); unregister_sound_special(register1);
snd_oss_minors[minor] = NULL; snd_oss_minors[minor] = NULL;
up(&sound_oss_mutex); mutex_unlock(&sound_oss_mutex);
kfree(preg); kfree(preg);
return -EBUSY; return -EBUSY;
} }
...@@ -168,10 +169,10 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev) ...@@ -168,10 +169,10 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev)
return 0; return 0;
if (minor < 0) if (minor < 0)
return minor; return minor;
down(&sound_oss_mutex); mutex_lock(&sound_oss_mutex);
mptr = snd_oss_minors[minor]; mptr = snd_oss_minors[minor];
if (mptr == NULL) { if (mptr == NULL) {
up(&sound_oss_mutex); mutex_unlock(&sound_oss_mutex);
return -ENOENT; return -ENOENT;
} }
unregister_sound_special(minor); unregister_sound_special(minor);
...@@ -191,7 +192,7 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev) ...@@ -191,7 +192,7 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev)
snd_oss_minors[track2] = NULL; snd_oss_minors[track2] = NULL;
} }
snd_oss_minors[minor] = NULL; snd_oss_minors[minor] = NULL;
up(&sound_oss_mutex); mutex_unlock(&sound_oss_mutex);
kfree(mptr); kfree(mptr);
return 0; return 0;
} }
...@@ -229,7 +230,7 @@ static void snd_minor_info_oss_read(struct snd_info_entry *entry, ...@@ -229,7 +230,7 @@ static void snd_minor_info_oss_read(struct snd_info_entry *entry,
int minor; int minor;
struct snd_minor *mptr; struct snd_minor *mptr;
down(&sound_oss_mutex); mutex_lock(&sound_oss_mutex);
for (minor = 0; minor < SNDRV_OSS_MINORS; ++minor) { for (minor = 0; minor < SNDRV_OSS_MINORS; ++minor) {
if (!(mptr = snd_oss_minors[minor])) if (!(mptr = snd_oss_minors[minor]))
continue; continue;
...@@ -241,7 +242,7 @@ static void snd_minor_info_oss_read(struct snd_info_entry *entry, ...@@ -241,7 +242,7 @@ static void snd_minor_info_oss_read(struct snd_info_entry *entry,
snd_iprintf(buffer, "%3i: : %s\n", minor, snd_iprintf(buffer, "%3i: : %s\n", minor,
snd_oss_device_type_name(mptr->type)); snd_oss_device_type_name(mptr->type));
} }
up(&sound_oss_mutex); mutex_unlock(&sound_oss_mutex);
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/mutex.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/string.h> #include <linux/string.h>
#include <sound/core.h> #include <sound/core.h>
...@@ -70,7 +71,7 @@ struct snd_timer_user { ...@@ -70,7 +71,7 @@ struct snd_timer_user {
struct timespec tstamp; /* trigger tstamp */ struct timespec tstamp; /* trigger tstamp */
wait_queue_head_t qchange_sleep; wait_queue_head_t qchange_sleep;
struct fasync_struct *fasync; struct fasync_struct *fasync;
struct semaphore tread_sem; struct mutex tread_sem;
}; };
/* list of timers */ /* list of timers */
...@@ -82,7 +83,7 @@ static LIST_HEAD(snd_timer_slave_list); ...@@ -82,7 +83,7 @@ static LIST_HEAD(snd_timer_slave_list);
/* lock for slave active lists */ /* lock for slave active lists */
static DEFINE_SPINLOCK(slave_active_lock); static DEFINE_SPINLOCK(slave_active_lock);
static DECLARE_MUTEX(register_mutex); static DEFINE_MUTEX(register_mutex);
static int snd_timer_free(struct snd_timer *timer); static int snd_timer_free(struct snd_timer *timer);
static int snd_timer_dev_free(struct snd_device *device); static int snd_timer_dev_free(struct snd_device *device);
...@@ -252,10 +253,10 @@ int snd_timer_open(struct snd_timer_instance **ti, ...@@ -252,10 +253,10 @@ int snd_timer_open(struct snd_timer_instance **ti,
snd_printd("invalid slave class %i\n", tid->dev_sclass); snd_printd("invalid slave class %i\n", tid->dev_sclass);
return -EINVAL; return -EINVAL;
} }
down(&register_mutex); mutex_lock(&register_mutex);
timeri = snd_timer_instance_new(owner, NULL); timeri = snd_timer_instance_new(owner, NULL);
if (!timeri) { if (!timeri) {
up(&register_mutex); mutex_unlock(&register_mutex);
return -ENOMEM; return -ENOMEM;
} }
timeri->slave_class = tid->dev_sclass; timeri->slave_class = tid->dev_sclass;
...@@ -263,37 +264,37 @@ int snd_timer_open(struct snd_timer_instance **ti, ...@@ -263,37 +264,37 @@ int snd_timer_open(struct snd_timer_instance **ti,
timeri->flags |= SNDRV_TIMER_IFLG_SLAVE; timeri->flags |= SNDRV_TIMER_IFLG_SLAVE;
list_add_tail(&timeri->open_list, &snd_timer_slave_list); list_add_tail(&timeri->open_list, &snd_timer_slave_list);
snd_timer_check_slave(timeri); snd_timer_check_slave(timeri);
up(&register_mutex); mutex_unlock(&register_mutex);
*ti = timeri; *ti = timeri;
return 0; return 0;
} }
/* open a master instance */ /* open a master instance */
down(&register_mutex); mutex_lock(&register_mutex);
timer = snd_timer_find(tid); timer = snd_timer_find(tid);
#ifdef CONFIG_KMOD #ifdef CONFIG_KMOD
if (timer == NULL) { if (timer == NULL) {
up(&register_mutex); mutex_unlock(&register_mutex);
snd_timer_request(tid); snd_timer_request(tid);
down(&register_mutex); mutex_lock(&register_mutex);
timer = snd_timer_find(tid); timer = snd_timer_find(tid);
} }
#endif #endif
if (!timer) { if (!timer) {
up(&register_mutex); mutex_unlock(&register_mutex);
return -ENODEV; return -ENODEV;
} }
if (!list_empty(&timer->open_list_head)) { if (!list_empty(&timer->open_list_head)) {
timeri = list_entry(timer->open_list_head.next, timeri = list_entry(timer->open_list_head.next,
struct snd_timer_instance, open_list); struct snd_timer_instance, open_list);
if (timeri->flags & SNDRV_TIMER_IFLG_EXCLUSIVE) { if (timeri->flags & SNDRV_TIMER_IFLG_EXCLUSIVE) {
up(&register_mutex); mutex_unlock(&register_mutex);
return -EBUSY; return -EBUSY;
} }
} }
timeri = snd_timer_instance_new(owner, timer); timeri = snd_timer_instance_new(owner, timer);
if (!timeri) { if (!timeri) {
up(&register_mutex); mutex_unlock(&register_mutex);
return -ENOMEM; return -ENOMEM;
} }
timeri->slave_class = tid->dev_sclass; timeri->slave_class = tid->dev_sclass;
...@@ -302,7 +303,7 @@ int snd_timer_open(struct snd_timer_instance **ti, ...@@ -302,7 +303,7 @@ int snd_timer_open(struct snd_timer_instance **ti,
timer->hw.open(timer); timer->hw.open(timer);
list_add_tail(&timeri->open_list, &timer->open_list_head); list_add_tail(&timeri->open_list, &timer->open_list_head);
snd_timer_check_master(timeri); snd_timer_check_master(timeri);
up(&register_mutex); mutex_unlock(&register_mutex);
*ti = timeri; *ti = timeri;
return 0; return 0;
} }
...@@ -333,9 +334,9 @@ int snd_timer_close(struct snd_timer_instance *timeri) ...@@ -333,9 +334,9 @@ int snd_timer_close(struct snd_timer_instance *timeri)
spin_lock_irq(&slave_active_lock); spin_lock_irq(&slave_active_lock);
} }
spin_unlock_irq(&slave_active_lock); spin_unlock_irq(&slave_active_lock);
down(&register_mutex); mutex_lock(&register_mutex);
list_del(&timeri->open_list); list_del(&timeri->open_list);
up(&register_mutex); mutex_unlock(&register_mutex);
} else { } else {
timer = timeri->timer; timer = timeri->timer;
/* wait, until the active callback is finished */ /* wait, until the active callback is finished */
...@@ -346,7 +347,7 @@ int snd_timer_close(struct snd_timer_instance *timeri) ...@@ -346,7 +347,7 @@ int snd_timer_close(struct snd_timer_instance *timeri)
spin_lock_irq(&timer->lock); spin_lock_irq(&timer->lock);
} }
spin_unlock_irq(&timer->lock); spin_unlock_irq(&timer->lock);
down(&register_mutex); mutex_lock(&register_mutex);
list_del(&timeri->open_list); list_del(&timeri->open_list);
if (timer && list_empty(&timer->open_list_head) && if (timer && list_empty(&timer->open_list_head) &&
timer->hw.close) timer->hw.close)
...@@ -362,7 +363,7 @@ int snd_timer_close(struct snd_timer_instance *timeri) ...@@ -362,7 +363,7 @@ int snd_timer_close(struct snd_timer_instance *timeri)
slave->timer = NULL; slave->timer = NULL;
spin_unlock_irq(&slave_active_lock); spin_unlock_irq(&slave_active_lock);
} }
up(&register_mutex); mutex_unlock(&register_mutex);
} }
if (timeri->private_free) if (timeri->private_free)
timeri->private_free(timeri); timeri->private_free(timeri);
...@@ -835,7 +836,7 @@ static int snd_timer_dev_register(struct snd_device *dev) ...@@ -835,7 +836,7 @@ static int snd_timer_dev_register(struct snd_device *dev)
!timer->hw.resolution && timer->hw.c_resolution == NULL) !timer->hw.resolution && timer->hw.c_resolution == NULL)
return -EINVAL; return -EINVAL;
down(&register_mutex); mutex_lock(&register_mutex);
list_for_each(p, &snd_timer_list) { list_for_each(p, &snd_timer_list) {
timer1 = list_entry(p, struct snd_timer, device_list); timer1 = list_entry(p, struct snd_timer, device_list);
if (timer1->tmr_class > timer->tmr_class) if (timer1->tmr_class > timer->tmr_class)
...@@ -857,11 +858,11 @@ static int snd_timer_dev_register(struct snd_device *dev) ...@@ -857,11 +858,11 @@ static int snd_timer_dev_register(struct snd_device *dev)
if (timer1->tmr_subdevice < timer->tmr_subdevice) if (timer1->tmr_subdevice < timer->tmr_subdevice)
continue; continue;
/* conflicts.. */ /* conflicts.. */
up(&register_mutex); mutex_unlock(&register_mutex);
return -EBUSY; return -EBUSY;
} }
list_add_tail(&timer->device_list, p); list_add_tail(&timer->device_list, p);
up(&register_mutex); mutex_unlock(&register_mutex);
return 0; return 0;
} }
...@@ -871,7 +872,7 @@ static int snd_timer_unregister(struct snd_timer *timer) ...@@ -871,7 +872,7 @@ static int snd_timer_unregister(struct snd_timer *timer)
struct snd_timer_instance *ti; struct snd_timer_instance *ti;
snd_assert(timer != NULL, return -ENXIO); snd_assert(timer != NULL, return -ENXIO);
down(&register_mutex); mutex_lock(&register_mutex);
if (! list_empty(&timer->open_list_head)) { if (! list_empty(&timer->open_list_head)) {
snd_printk(KERN_WARNING "timer 0x%lx is busy?\n", (long)timer); snd_printk(KERN_WARNING "timer 0x%lx is busy?\n", (long)timer);
list_for_each_safe(p, n, &timer->open_list_head) { list_for_each_safe(p, n, &timer->open_list_head) {
...@@ -881,7 +882,7 @@ static int snd_timer_unregister(struct snd_timer *timer) ...@@ -881,7 +882,7 @@ static int snd_timer_unregister(struct snd_timer *timer)
} }
} }
list_del(&timer->device_list); list_del(&timer->device_list);
up(&register_mutex); mutex_unlock(&register_mutex);
return snd_timer_free(timer); return snd_timer_free(timer);
} }
...@@ -1065,7 +1066,7 @@ static void snd_timer_proc_read(struct snd_info_entry *entry, ...@@ -1065,7 +1066,7 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
struct snd_timer_instance *ti; struct snd_timer_instance *ti;
struct list_head *p, *q; struct list_head *p, *q;
down(&register_mutex); mutex_lock(&register_mutex);
list_for_each(p, &snd_timer_list) { list_for_each(p, &snd_timer_list) {
timer = list_entry(p, struct snd_timer, device_list); timer = list_entry(p, struct snd_timer, device_list);
switch (timer->tmr_class) { switch (timer->tmr_class) {
...@@ -1105,7 +1106,7 @@ static void snd_timer_proc_read(struct snd_info_entry *entry, ...@@ -1105,7 +1106,7 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
} }
spin_unlock_irqrestore(&timer->lock, flags); spin_unlock_irqrestore(&timer->lock, flags);
} }
up(&register_mutex); mutex_unlock(&register_mutex);
} }
static struct snd_info_entry *snd_timer_proc_entry = NULL; static struct snd_info_entry *snd_timer_proc_entry = NULL;
...@@ -1269,7 +1270,7 @@ static int snd_timer_user_open(struct inode *inode, struct file *file) ...@@ -1269,7 +1270,7 @@ static int snd_timer_user_open(struct inode *inode, struct file *file)
return -ENOMEM; return -ENOMEM;
spin_lock_init(&tu->qlock); spin_lock_init(&tu->qlock);
init_waitqueue_head(&tu->qchange_sleep); init_waitqueue_head(&tu->qchange_sleep);
init_MUTEX(&tu->tread_sem); mutex_init(&tu->tread_sem);
tu->ticks = 1; tu->ticks = 1;
tu->queue_size = 128; tu->queue_size = 128;
tu->queue = kmalloc(tu->queue_size * sizeof(struct snd_timer_read), tu->queue = kmalloc(tu->queue_size * sizeof(struct snd_timer_read),
...@@ -1325,7 +1326,7 @@ static int snd_timer_user_next_device(struct snd_timer_id __user *_tid) ...@@ -1325,7 +1326,7 @@ static int snd_timer_user_next_device(struct snd_timer_id __user *_tid)
if (copy_from_user(&id, _tid, sizeof(id))) if (copy_from_user(&id, _tid, sizeof(id)))
return -EFAULT; return -EFAULT;
down(&register_mutex); mutex_lock(&register_mutex);
if (id.dev_class < 0) { /* first item */ if (id.dev_class < 0) { /* first item */
if (list_empty(&snd_timer_list)) if (list_empty(&snd_timer_list))
snd_timer_user_zero_id(&id); snd_timer_user_zero_id(&id);
...@@ -1407,7 +1408,7 @@ static int snd_timer_user_next_device(struct snd_timer_id __user *_tid) ...@@ -1407,7 +1408,7 @@ static int snd_timer_user_next_device(struct snd_timer_id __user *_tid)
snd_timer_user_zero_id(&id); snd_timer_user_zero_id(&id);
} }
} }
up(&register_mutex); mutex_unlock(&register_mutex);
if (copy_to_user(_tid, &id, sizeof(*_tid))) if (copy_to_user(_tid, &id, sizeof(*_tid)))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -1432,7 +1433,7 @@ static int snd_timer_user_ginfo(struct file *file, ...@@ -1432,7 +1433,7 @@ static int snd_timer_user_ginfo(struct file *file,
tid = ginfo->tid; tid = ginfo->tid;
memset(ginfo, 0, sizeof(*ginfo)); memset(ginfo, 0, sizeof(*ginfo));
ginfo->tid = tid; ginfo->tid = tid;
down(&register_mutex); mutex_lock(&register_mutex);
t = snd_timer_find(&tid); t = snd_timer_find(&tid);
if (t != NULL) { if (t != NULL) {
ginfo->card = t->card ? t->card->number : -1; ginfo->card = t->card ? t->card->number : -1;
...@@ -1451,7 +1452,7 @@ static int snd_timer_user_ginfo(struct file *file, ...@@ -1451,7 +1452,7 @@ static int snd_timer_user_ginfo(struct file *file,
} else { } else {
err = -ENODEV; err = -ENODEV;
} }
up(&register_mutex); mutex_unlock(&register_mutex);
if (err >= 0 && copy_to_user(_ginfo, ginfo, sizeof(*ginfo))) if (err >= 0 && copy_to_user(_ginfo, ginfo, sizeof(*ginfo)))
err = -EFAULT; err = -EFAULT;
kfree(ginfo); kfree(ginfo);
...@@ -1467,7 +1468,7 @@ static int snd_timer_user_gparams(struct file *file, ...@@ -1467,7 +1468,7 @@ static int snd_timer_user_gparams(struct file *file,
if (copy_from_user(&gparams, _gparams, sizeof(gparams))) if (copy_from_user(&gparams, _gparams, sizeof(gparams)))
return -EFAULT; return -EFAULT;
down(&register_mutex); mutex_lock(&register_mutex);
t = snd_timer_find(&gparams.tid); t = snd_timer_find(&gparams.tid);
if (!t) { if (!t) {
err = -ENODEV; err = -ENODEV;
...@@ -1483,7 +1484,7 @@ static int snd_timer_user_gparams(struct file *file, ...@@ -1483,7 +1484,7 @@ static int snd_timer_user_gparams(struct file *file,
} }
err = t->hw.set_period(t, gparams.period_num, gparams.period_den); err = t->hw.set_period(t, gparams.period_num, gparams.period_den);
_error: _error:
up(&register_mutex); mutex_unlock(&register_mutex);
return err; return err;
} }
...@@ -1500,7 +1501,7 @@ static int snd_timer_user_gstatus(struct file *file, ...@@ -1500,7 +1501,7 @@ static int snd_timer_user_gstatus(struct file *file,
tid = gstatus.tid; tid = gstatus.tid;
memset(&gstatus, 0, sizeof(gstatus)); memset(&gstatus, 0, sizeof(gstatus));
gstatus.tid = tid; gstatus.tid = tid;
down(&register_mutex); mutex_lock(&register_mutex);
t = snd_timer_find(&tid); t = snd_timer_find(&tid);
if (t != NULL) { if (t != NULL) {
if (t->hw.c_resolution) if (t->hw.c_resolution)
...@@ -1517,7 +1518,7 @@ static int snd_timer_user_gstatus(struct file *file, ...@@ -1517,7 +1518,7 @@ static int snd_timer_user_gstatus(struct file *file,
} else { } else {
err = -ENODEV; err = -ENODEV;
} }
up(&register_mutex); mutex_unlock(&register_mutex);
if (err >= 0 && copy_to_user(_gstatus, &gstatus, sizeof(gstatus))) if (err >= 0 && copy_to_user(_gstatus, &gstatus, sizeof(gstatus)))
err = -EFAULT; err = -EFAULT;
return err; return err;
...@@ -1532,7 +1533,7 @@ static int snd_timer_user_tselect(struct file *file, ...@@ -1532,7 +1533,7 @@ static int snd_timer_user_tselect(struct file *file,
int err = 0; int err = 0;
tu = file->private_data; tu = file->private_data;
down(&tu->tread_sem); mutex_lock(&tu->tread_sem);
if (tu->timeri) { if (tu->timeri) {
snd_timer_close(tu->timeri); snd_timer_close(tu->timeri);
tu->timeri = NULL; tu->timeri = NULL;
...@@ -1576,7 +1577,7 @@ static int snd_timer_user_tselect(struct file *file, ...@@ -1576,7 +1577,7 @@ static int snd_timer_user_tselect(struct file *file,
} }
__err: __err:
up(&tu->tread_sem); mutex_unlock(&tu->tread_sem);
return err; return err;
} }
...@@ -1797,17 +1798,17 @@ static long snd_timer_user_ioctl(struct file *file, unsigned int cmd, ...@@ -1797,17 +1798,17 @@ static long snd_timer_user_ioctl(struct file *file, unsigned int cmd,
{ {
int xarg; int xarg;
down(&tu->tread_sem); mutex_lock(&tu->tread_sem);
if (tu->timeri) { /* too late */ if (tu->timeri) { /* too late */
up(&tu->tread_sem); mutex_unlock(&tu->tread_sem);
return -EBUSY; return -EBUSY;
} }
if (get_user(xarg, p)) { if (get_user(xarg, p)) {
up(&tu->tread_sem); mutex_unlock(&tu->tread_sem);
return -EFAULT; return -EFAULT;
} }
tu->tread = xarg ? 1 : 0; tu->tread = xarg ? 1 : 0;
up(&tu->tread_sem); mutex_unlock(&tu->tread_sem);
return 0; return 0;
} }
case SNDRV_TIMER_IOCTL_GINFO: case SNDRV_TIMER_IOCTL_GINFO:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册