Commit f823b8a7 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: seq: Remove superfluous irqsave flags

spin_lock_irqsave() is used unnecessarily in various places in
sequencer core code although it's pretty obvious that the context is
sleepable.  Remove irqsave and use the plain spin_lock_irq() in such
places for simplicity.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 4b24b960
...@@ -203,7 +203,6 @@ int __init client_init_data(void) ...@@ -203,7 +203,6 @@ int __init client_init_data(void)
static struct snd_seq_client *seq_create_client1(int client_index, int poolsize) static struct snd_seq_client *seq_create_client1(int client_index, int poolsize)
{ {
unsigned long flags;
int c; int c;
struct snd_seq_client *client; struct snd_seq_client *client;
...@@ -224,7 +223,7 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize) ...@@ -224,7 +223,7 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize)
mutex_init(&client->ioctl_mutex); mutex_init(&client->ioctl_mutex);
/* find free slot in the client table */ /* find free slot in the client table */
spin_lock_irqsave(&clients_lock, flags); spin_lock_irq(&clients_lock);
if (client_index < 0) { if (client_index < 0) {
for (c = SNDRV_SEQ_DYNAMIC_CLIENTS_BEGIN; for (c = SNDRV_SEQ_DYNAMIC_CLIENTS_BEGIN;
c < SNDRV_SEQ_MAX_CLIENTS; c < SNDRV_SEQ_MAX_CLIENTS;
...@@ -232,17 +231,17 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize) ...@@ -232,17 +231,17 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize)
if (clienttab[c] || clienttablock[c]) if (clienttab[c] || clienttablock[c])
continue; continue;
clienttab[client->number = c] = client; clienttab[client->number = c] = client;
spin_unlock_irqrestore(&clients_lock, flags); spin_unlock_irq(&clients_lock);
return client; return client;
} }
} else { } else {
if (clienttab[client_index] == NULL && !clienttablock[client_index]) { if (clienttab[client_index] == NULL && !clienttablock[client_index]) {
clienttab[client->number = client_index] = client; clienttab[client->number = client_index] = client;
spin_unlock_irqrestore(&clients_lock, flags); spin_unlock_irq(&clients_lock);
return client; return client;
} }
} }
spin_unlock_irqrestore(&clients_lock, flags); spin_unlock_irq(&clients_lock);
snd_seq_pool_delete(&client->pool); snd_seq_pool_delete(&client->pool);
kfree(client); kfree(client);
return NULL; /* no free slot found or busy, return failure code */ return NULL; /* no free slot found or busy, return failure code */
...@@ -251,23 +250,21 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize) ...@@ -251,23 +250,21 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize)
static int seq_free_client1(struct snd_seq_client *client) static int seq_free_client1(struct snd_seq_client *client)
{ {
unsigned long flags;
if (!client) if (!client)
return 0; return 0;
spin_lock_irqsave(&clients_lock, flags); spin_lock_irq(&clients_lock);
clienttablock[client->number] = 1; clienttablock[client->number] = 1;
clienttab[client->number] = NULL; clienttab[client->number] = NULL;
spin_unlock_irqrestore(&clients_lock, flags); spin_unlock_irq(&clients_lock);
snd_seq_delete_all_ports(client); snd_seq_delete_all_ports(client);
snd_seq_queue_client_leave(client->number); snd_seq_queue_client_leave(client->number);
snd_use_lock_sync(&client->use_lock); snd_use_lock_sync(&client->use_lock);
snd_seq_queue_client_termination(client->number); snd_seq_queue_client_termination(client->number);
if (client->pool) if (client->pool)
snd_seq_pool_delete(&client->pool); snd_seq_pool_delete(&client->pool);
spin_lock_irqsave(&clients_lock, flags); spin_lock_irq(&clients_lock);
clienttablock[client->number] = 0; clienttablock[client->number] = 0;
spin_unlock_irqrestore(&clients_lock, flags); spin_unlock_irq(&clients_lock);
return 0; return 0;
} }
......
...@@ -98,18 +98,17 @@ static struct snd_seq_event_cell *fifo_cell_out(struct snd_seq_fifo *f); ...@@ -98,18 +98,17 @@ static struct snd_seq_event_cell *fifo_cell_out(struct snd_seq_fifo *f);
void snd_seq_fifo_clear(struct snd_seq_fifo *f) void snd_seq_fifo_clear(struct snd_seq_fifo *f)
{ {
struct snd_seq_event_cell *cell; struct snd_seq_event_cell *cell;
unsigned long flags;
/* clear overflow flag */ /* clear overflow flag */
atomic_set(&f->overflow, 0); atomic_set(&f->overflow, 0);
snd_use_lock_sync(&f->use_lock); snd_use_lock_sync(&f->use_lock);
spin_lock_irqsave(&f->lock, flags); spin_lock_irq(&f->lock);
/* drain the fifo */ /* drain the fifo */
while ((cell = fifo_cell_out(f)) != NULL) { while ((cell = fifo_cell_out(f)) != NULL) {
snd_seq_cell_free(cell); snd_seq_cell_free(cell);
} }
spin_unlock_irqrestore(&f->lock, flags); spin_unlock_irq(&f->lock);
} }
...@@ -239,7 +238,6 @@ int snd_seq_fifo_poll_wait(struct snd_seq_fifo *f, struct file *file, ...@@ -239,7 +238,6 @@ int snd_seq_fifo_poll_wait(struct snd_seq_fifo *f, struct file *file,
/* change the size of pool; all old events are removed */ /* change the size of pool; all old events are removed */
int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize) int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize)
{ {
unsigned long flags;
struct snd_seq_pool *newpool, *oldpool; struct snd_seq_pool *newpool, *oldpool;
struct snd_seq_event_cell *cell, *next, *oldhead; struct snd_seq_event_cell *cell, *next, *oldhead;
...@@ -255,7 +253,7 @@ int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize) ...@@ -255,7 +253,7 @@ int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize)
return -ENOMEM; return -ENOMEM;
} }
spin_lock_irqsave(&f->lock, flags); spin_lock_irq(&f->lock);
/* remember old pool */ /* remember old pool */
oldpool = f->pool; oldpool = f->pool;
oldhead = f->head; oldhead = f->head;
...@@ -265,7 +263,7 @@ int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize) ...@@ -265,7 +263,7 @@ int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize)
f->tail = NULL; f->tail = NULL;
f->cells = 0; f->cells = 0;
/* NOTE: overflow flag is not cleared */ /* NOTE: overflow flag is not cleared */
spin_unlock_irqrestore(&f->lock, flags); spin_unlock_irq(&f->lock);
/* close the old pool and wait until all users are gone */ /* close the old pool and wait until all users are gone */
snd_seq_pool_mark_closing(oldpool); snd_seq_pool_mark_closing(oldpool);
......
...@@ -384,7 +384,6 @@ int snd_seq_pool_init(struct snd_seq_pool *pool) ...@@ -384,7 +384,6 @@ int snd_seq_pool_init(struct snd_seq_pool *pool)
{ {
int cell; int cell;
struct snd_seq_event_cell *cellptr; struct snd_seq_event_cell *cellptr;
unsigned long flags;
if (snd_BUG_ON(!pool)) if (snd_BUG_ON(!pool))
return -EINVAL; return -EINVAL;
...@@ -395,9 +394,9 @@ int snd_seq_pool_init(struct snd_seq_pool *pool) ...@@ -395,9 +394,9 @@ int snd_seq_pool_init(struct snd_seq_pool *pool)
return -ENOMEM; return -ENOMEM;
/* add new cells to the free cell list */ /* add new cells to the free cell list */
spin_lock_irqsave(&pool->lock, flags); spin_lock_irq(&pool->lock);
if (pool->ptr) { if (pool->ptr) {
spin_unlock_irqrestore(&pool->lock, flags); spin_unlock_irq(&pool->lock);
kvfree(cellptr); kvfree(cellptr);
return 0; return 0;
} }
...@@ -416,7 +415,7 @@ int snd_seq_pool_init(struct snd_seq_pool *pool) ...@@ -416,7 +415,7 @@ int snd_seq_pool_init(struct snd_seq_pool *pool)
/* init statistics */ /* init statistics */
pool->max_used = 0; pool->max_used = 0;
pool->total_elements = pool->size; pool->total_elements = pool->size;
spin_unlock_irqrestore(&pool->lock, flags); spin_unlock_irq(&pool->lock);
return 0; return 0;
} }
...@@ -435,7 +434,6 @@ void snd_seq_pool_mark_closing(struct snd_seq_pool *pool) ...@@ -435,7 +434,6 @@ void snd_seq_pool_mark_closing(struct snd_seq_pool *pool)
/* remove events */ /* remove events */
int snd_seq_pool_done(struct snd_seq_pool *pool) int snd_seq_pool_done(struct snd_seq_pool *pool)
{ {
unsigned long flags;
struct snd_seq_event_cell *ptr; struct snd_seq_event_cell *ptr;
if (snd_BUG_ON(!pool)) if (snd_BUG_ON(!pool))
...@@ -449,18 +447,18 @@ int snd_seq_pool_done(struct snd_seq_pool *pool) ...@@ -449,18 +447,18 @@ int snd_seq_pool_done(struct snd_seq_pool *pool)
schedule_timeout_uninterruptible(1); schedule_timeout_uninterruptible(1);
/* release all resources */ /* release all resources */
spin_lock_irqsave(&pool->lock, flags); spin_lock_irq(&pool->lock);
ptr = pool->ptr; ptr = pool->ptr;
pool->ptr = NULL; pool->ptr = NULL;
pool->free = NULL; pool->free = NULL;
pool->total_elements = 0; pool->total_elements = 0;
spin_unlock_irqrestore(&pool->lock, flags); spin_unlock_irq(&pool->lock);
kvfree(ptr); kvfree(ptr);
spin_lock_irqsave(&pool->lock, flags); spin_lock_irq(&pool->lock);
pool->closing = 0; pool->closing = 0;
spin_unlock_irqrestore(&pool->lock, flags); spin_unlock_irq(&pool->lock);
return 0; return 0;
} }
......
...@@ -128,7 +128,6 @@ static void port_subs_info_init(struct snd_seq_port_subs_info *grp) ...@@ -128,7 +128,6 @@ static void port_subs_info_init(struct snd_seq_port_subs_info *grp)
struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client, struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
int port) int port)
{ {
unsigned long flags;
struct snd_seq_client_port *new_port, *p; struct snd_seq_client_port *new_port, *p;
int num = -1; int num = -1;
...@@ -157,7 +156,7 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client, ...@@ -157,7 +156,7 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
num = port >= 0 ? port : 0; num = port >= 0 ? port : 0;
mutex_lock(&client->ports_mutex); mutex_lock(&client->ports_mutex);
write_lock_irqsave(&client->ports_lock, flags); write_lock_irq(&client->ports_lock);
list_for_each_entry(p, &client->ports_list_head, list) { list_for_each_entry(p, &client->ports_list_head, list) {
if (p->addr.port > num) if (p->addr.port > num)
break; break;
...@@ -169,7 +168,7 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client, ...@@ -169,7 +168,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 */
sprintf(new_port->name, "port-%d", num); sprintf(new_port->name, "port-%d", num);
write_unlock_irqrestore(&client->ports_lock, flags); write_unlock_irq(&client->ports_lock);
mutex_unlock(&client->ports_mutex); mutex_unlock(&client->ports_mutex);
return new_port; return new_port;
...@@ -283,11 +282,10 @@ static int port_delete(struct snd_seq_client *client, ...@@ -283,11 +282,10 @@ static int port_delete(struct snd_seq_client *client,
/* delete a port with the given port id */ /* delete a port with the given port id */
int snd_seq_delete_port(struct snd_seq_client *client, int port) int snd_seq_delete_port(struct snd_seq_client *client, int port)
{ {
unsigned long flags;
struct snd_seq_client_port *found = NULL, *p; struct snd_seq_client_port *found = NULL, *p;
mutex_lock(&client->ports_mutex); mutex_lock(&client->ports_mutex);
write_lock_irqsave(&client->ports_lock, flags); write_lock_irq(&client->ports_lock);
list_for_each_entry(p, &client->ports_list_head, list) { list_for_each_entry(p, &client->ports_list_head, list) {
if (p->addr.port == port) { if (p->addr.port == port) {
/* ok found. delete from the list at first */ /* ok found. delete from the list at first */
...@@ -297,7 +295,7 @@ int snd_seq_delete_port(struct snd_seq_client *client, int port) ...@@ -297,7 +295,7 @@ int snd_seq_delete_port(struct snd_seq_client *client, int port)
break; break;
} }
} }
write_unlock_irqrestore(&client->ports_lock, flags); write_unlock_irq(&client->ports_lock);
mutex_unlock(&client->ports_mutex); mutex_unlock(&client->ports_mutex);
if (found) if (found)
return port_delete(client, found); return port_delete(client, found);
...@@ -308,7 +306,6 @@ int snd_seq_delete_port(struct snd_seq_client *client, int port) ...@@ -308,7 +306,6 @@ int snd_seq_delete_port(struct snd_seq_client *client, int port)
/* delete the all ports belonging to the given client */ /* delete the all ports belonging to the given client */
int snd_seq_delete_all_ports(struct snd_seq_client *client) int snd_seq_delete_all_ports(struct snd_seq_client *client)
{ {
unsigned long flags;
struct list_head deleted_list; struct list_head deleted_list;
struct snd_seq_client_port *port, *tmp; struct snd_seq_client_port *port, *tmp;
...@@ -316,7 +313,7 @@ int snd_seq_delete_all_ports(struct snd_seq_client *client) ...@@ -316,7 +313,7 @@ int snd_seq_delete_all_ports(struct snd_seq_client *client)
* clear the port list in the client data. * clear the port list in the client data.
*/ */
mutex_lock(&client->ports_mutex); mutex_lock(&client->ports_mutex);
write_lock_irqsave(&client->ports_lock, flags); write_lock_irq(&client->ports_lock);
if (! list_empty(&client->ports_list_head)) { if (! list_empty(&client->ports_list_head)) {
list_add(&deleted_list, &client->ports_list_head); list_add(&deleted_list, &client->ports_list_head);
list_del_init(&client->ports_list_head); list_del_init(&client->ports_list_head);
...@@ -324,7 +321,7 @@ int snd_seq_delete_all_ports(struct snd_seq_client *client) ...@@ -324,7 +321,7 @@ int snd_seq_delete_all_ports(struct snd_seq_client *client)
INIT_LIST_HEAD(&deleted_list); INIT_LIST_HEAD(&deleted_list);
} }
client->num_ports = 0; client->num_ports = 0;
write_unlock_irqrestore(&client->ports_lock, flags); write_unlock_irq(&client->ports_lock);
/* remove each port in deleted_list */ /* remove each port in deleted_list */
list_for_each_entry_safe(port, tmp, &deleted_list, list) { list_for_each_entry_safe(port, tmp, &deleted_list, list) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment