ALSA: seq: Use no intrruptible mutex_lock

All usages of mutex in ALSA sequencer core would take too long, hence
we don't have to care about the user interruption that makes things
complicated.  Let's replace them with simpler mutex_lock().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2018-08-01 16:42:29 +02:00
parent 00976ad527
commit 04702e8d00
1 changed files with 7 additions and 19 deletions

View File

@ -311,10 +311,9 @@ static int snd_seq_open(struct inode *inode, struct file *file)
if (err < 0) if (err < 0)
return err; return err;
if (mutex_lock_interruptible(&register_mutex)) mutex_lock(&register_mutex);
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) {
mutex_unlock(&register_mutex); mutex_unlock(&register_mutex);
return -ENOMEM; /* failure code */ return -ENOMEM; /* failure code */
} }
@ -1704,10 +1703,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 (mutex_lock_interruptible(&queue->timer_mutex)) { mutex_lock(&queue->timer_mutex);
queuefree(queue);
return -ERESTARTSYS;
}
tmr = queue->timer; tmr = queue->timer;
memset(timer, 0, sizeof(*timer)); memset(timer, 0, sizeof(*timer));
timer->queue = queue->queue; timer->queue = queue->queue;
@ -1741,10 +1737,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 (mutex_lock_interruptible(&q->timer_mutex)) { mutex_lock(&q->timer_mutex);
queuefree(q);
return -ERESTARTSYS;
}
tmr = q->timer; tmr = q->timer;
snd_seq_queue_timer_close(timer->queue); snd_seq_queue_timer_close(timer->queue);
tmr->type = timer->type; tmr->type = timer->type;
@ -2180,8 +2173,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 (mutex_lock_interruptible(&register_mutex)) mutex_lock(&register_mutex);
return -ERESTARTSYS;
if (card) { if (card) {
client_index += SNDRV_SEQ_GLOBAL_CLIENTS client_index += SNDRV_SEQ_GLOBAL_CLIENTS
@ -2522,19 +2514,15 @@ int __init snd_sequencer_device_init(void)
snd_device_initialize(&seq_dev, NULL); snd_device_initialize(&seq_dev, NULL);
dev_set_name(&seq_dev, "seq"); dev_set_name(&seq_dev, "seq");
if (mutex_lock_interruptible(&register_mutex)) mutex_lock(&register_mutex);
return -ERESTARTSYS;
err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0, err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0,
&snd_seq_f_ops, NULL, &seq_dev); &snd_seq_f_ops, NULL, &seq_dev);
mutex_unlock(&register_mutex);
if (err < 0) { if (err < 0) {
mutex_unlock(&register_mutex);
put_device(&seq_dev); put_device(&seq_dev);
return err; return err;
} }
mutex_unlock(&register_mutex);
return 0; return 0;
} }