Skip to content

Commit f823b8a

Browse files
committed
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: Takashi Iwai <tiwai@suse.de>
1 parent 4b24b96 commit f823b8a

4 files changed

Lines changed: 25 additions & 35 deletions

File tree

‎sound/core/seq/seq_clientmgr.c‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ int __init client_init_data(void)
203203

204204
static struct snd_seq_client *seq_create_client1(int client_index, int poolsize)
205205
{
206-
unsigned long flags;
207206
int c;
208207
struct snd_seq_client *client;
209208

@@ -224,25 +223,25 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize)
224223
mutex_init(&client->ioctl_mutex);
225224

226225
/* find free slot in the client table */
227-
spin_lock_irqsave(&clients_lock, flags);
226+
spin_lock_irq(&clients_lock);
228227
if (client_index < 0) {
229228
for (c = SNDRV_SEQ_DYNAMIC_CLIENTS_BEGIN;
230229
c < SNDRV_SEQ_MAX_CLIENTS;
231230
c++) {
232231
if (clienttab[c] || clienttablock[c])
233232
continue;
234233
clienttab[client->number = c] = client;
235-
spin_unlock_irqrestore(&clients_lock, flags);
234+
spin_unlock_irq(&clients_lock);
236235
return client;
237236
}
238237
} else {
239238
if (clienttab[client_index] == NULL && !clienttablock[client_index]) {
240239
clienttab[client->number = client_index] = client;
241-
spin_unlock_irqrestore(&clients_lock, flags);
240+
spin_unlock_irq(&clients_lock);
242241
return client;
243242
}
244243
}
245-
spin_unlock_irqrestore(&clients_lock, flags);
244+
spin_unlock_irq(&clients_lock);
246245
snd_seq_pool_delete(&client->pool);
247246
kfree(client);
248247
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)
251250

252251
static int seq_free_client1(struct snd_seq_client *client)
253252
{
254-
unsigned long flags;
255-
256253
if (!client)
257254
return 0;
258-
spin_lock_irqsave(&clients_lock, flags);
255+
spin_lock_irq(&clients_lock);
259256
clienttablock[client->number] = 1;
260257
clienttab[client->number] = NULL;
261-
spin_unlock_irqrestore(&clients_lock, flags);
258+
spin_unlock_irq(&clients_lock);
262259
snd_seq_delete_all_ports(client);
263260
snd_seq_queue_client_leave(client->number);
264261
snd_use_lock_sync(&client->use_lock);
265262
snd_seq_queue_client_termination(client->number);
266263
if (client->pool)
267264
snd_seq_pool_delete(&client->pool);
268-
spin_lock_irqsave(&clients_lock, flags);
265+
spin_lock_irq(&clients_lock);
269266
clienttablock[client->number] = 0;
270-
spin_unlock_irqrestore(&clients_lock, flags);
267+
spin_unlock_irq(&clients_lock);
271268
return 0;
272269
}
273270

‎sound/core/seq/seq_fifo.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,17 @@ static struct snd_seq_event_cell *fifo_cell_out(struct snd_seq_fifo *f);
9898
void snd_seq_fifo_clear(struct snd_seq_fifo *f)
9999
{
100100
struct snd_seq_event_cell *cell;
101-
unsigned long flags;
102101

103102
/* clear overflow flag */
104103
atomic_set(&f->overflow, 0);
105104

106105
snd_use_lock_sync(&f->use_lock);
107-
spin_lock_irqsave(&f->lock, flags);
106+
spin_lock_irq(&f->lock);
108107
/* drain the fifo */
109108
while ((cell = fifo_cell_out(f)) != NULL) {
110109
snd_seq_cell_free(cell);
111110
}
112-
spin_unlock_irqrestore(&f->lock, flags);
111+
spin_unlock_irq(&f->lock);
113112
}
114113

115114

@@ -239,7 +238,6 @@ int snd_seq_fifo_poll_wait(struct snd_seq_fifo *f, struct file *file,
239238
/* change the size of pool; all old events are removed */
240239
int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize)
241240
{
242-
unsigned long flags;
243241
struct snd_seq_pool *newpool, *oldpool;
244242
struct snd_seq_event_cell *cell, *next, *oldhead;
245243

@@ -255,7 +253,7 @@ int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize)
255253
return -ENOMEM;
256254
}
257255

258-
spin_lock_irqsave(&f->lock, flags);
256+
spin_lock_irq(&f->lock);
259257
/* remember old pool */
260258
oldpool = f->pool;
261259
oldhead = f->head;
@@ -265,7 +263,7 @@ int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize)
265263
f->tail = NULL;
266264
f->cells = 0;
267265
/* NOTE: overflow flag is not cleared */
268-
spin_unlock_irqrestore(&f->lock, flags);
266+
spin_unlock_irq(&f->lock);
269267

270268
/* close the old pool and wait until all users are gone */
271269
snd_seq_pool_mark_closing(oldpool);

‎sound/core/seq/seq_memory.c‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@ int snd_seq_pool_init(struct snd_seq_pool *pool)
384384
{
385385
int cell;
386386
struct snd_seq_event_cell *cellptr;
387-
unsigned long flags;
388387

389388
if (snd_BUG_ON(!pool))
390389
return -EINVAL;
@@ -395,9 +394,9 @@ int snd_seq_pool_init(struct snd_seq_pool *pool)
395394
return -ENOMEM;
396395

397396
/* add new cells to the free cell list */
398-
spin_lock_irqsave(&pool->lock, flags);
397+
spin_lock_irq(&pool->lock);
399398
if (pool->ptr) {
400-
spin_unlock_irqrestore(&pool->lock, flags);
399+
spin_unlock_irq(&pool->lock);
401400
kvfree(cellptr);
402401
return 0;
403402
}
@@ -416,7 +415,7 @@ int snd_seq_pool_init(struct snd_seq_pool *pool)
416415
/* init statistics */
417416
pool->max_used = 0;
418417
pool->total_elements = pool->size;
419-
spin_unlock_irqrestore(&pool->lock, flags);
418+
spin_unlock_irq(&pool->lock);
420419
return 0;
421420
}
422421

@@ -435,7 +434,6 @@ void snd_seq_pool_mark_closing(struct snd_seq_pool *pool)
435434
/* remove events */
436435
int snd_seq_pool_done(struct snd_seq_pool *pool)
437436
{
438-
unsigned long flags;
439437
struct snd_seq_event_cell *ptr;
440438

441439
if (snd_BUG_ON(!pool))
@@ -449,18 +447,18 @@ int snd_seq_pool_done(struct snd_seq_pool *pool)
449447
schedule_timeout_uninterruptible(1);
450448

451449
/* release all resources */
452-
spin_lock_irqsave(&pool->lock, flags);
450+
spin_lock_irq(&pool->lock);
453451
ptr = pool->ptr;
454452
pool->ptr = NULL;
455453
pool->free = NULL;
456454
pool->total_elements = 0;
457-
spin_unlock_irqrestore(&pool->lock, flags);
455+
spin_unlock_irq(&pool->lock);
458456

459457
kvfree(ptr);
460458

461-
spin_lock_irqsave(&pool->lock, flags);
459+
spin_lock_irq(&pool->lock);
462460
pool->closing = 0;
463-
spin_unlock_irqrestore(&pool->lock, flags);
461+
spin_unlock_irq(&pool->lock);
464462

465463
return 0;
466464
}

‎sound/core/seq/seq_ports.c‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ static void port_subs_info_init(struct snd_seq_port_subs_info *grp)
128128
struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
129129
int port)
130130
{
131-
unsigned long flags;
132131
struct snd_seq_client_port *new_port, *p;
133132
int num = -1;
134133

@@ -157,7 +156,7 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
157156

158157
num = port >= 0 ? port : 0;
159158
mutex_lock(&client->ports_mutex);
160-
write_lock_irqsave(&client->ports_lock, flags);
159+
write_lock_irq(&client->ports_lock);
161160
list_for_each_entry(p, &client->ports_list_head, list) {
162161
if (p->addr.port > num)
163162
break;
@@ -169,7 +168,7 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
169168
client->num_ports++;
170169
new_port->addr.port = num; /* store the port number in the port */
171170
sprintf(new_port->name, "port-%d", num);
172-
write_unlock_irqrestore(&client->ports_lock, flags);
171+
write_unlock_irq(&client->ports_lock);
173172
mutex_unlock(&client->ports_mutex);
174173

175174
return new_port;
@@ -283,11 +282,10 @@ static int port_delete(struct snd_seq_client *client,
283282
/* delete a port with the given port id */
284283
int snd_seq_delete_port(struct snd_seq_client *client, int port)
285284
{
286-
unsigned long flags;
287285
struct snd_seq_client_port *found = NULL, *p;
288286

289287
mutex_lock(&client->ports_mutex);
290-
write_lock_irqsave(&client->ports_lock, flags);
288+
write_lock_irq(&client->ports_lock);
291289
list_for_each_entry(p, &client->ports_list_head, list) {
292290
if (p->addr.port == port) {
293291
/* ok found. delete from the list at first */
@@ -297,7 +295,7 @@ int snd_seq_delete_port(struct snd_seq_client *client, int port)
297295
break;
298296
}
299297
}
300-
write_unlock_irqrestore(&client->ports_lock, flags);
298+
write_unlock_irq(&client->ports_lock);
301299
mutex_unlock(&client->ports_mutex);
302300
if (found)
303301
return port_delete(client, found);
@@ -308,23 +306,22 @@ int snd_seq_delete_port(struct snd_seq_client *client, int port)
308306
/* delete the all ports belonging to the given client */
309307
int snd_seq_delete_all_ports(struct snd_seq_client *client)
310308
{
311-
unsigned long flags;
312309
struct list_head deleted_list;
313310
struct snd_seq_client_port *port, *tmp;
314311

315312
/* move the port list to deleted_list, and
316313
* clear the port list in the client data.
317314
*/
318315
mutex_lock(&client->ports_mutex);
319-
write_lock_irqsave(&client->ports_lock, flags);
316+
write_lock_irq(&client->ports_lock);
320317
if (! list_empty(&client->ports_list_head)) {
321318
list_add(&deleted_list, &client->ports_list_head);
322319
list_del_init(&client->ports_list_head);
323320
} else {
324321
INIT_LIST_HEAD(&deleted_list);
325322
}
326323
client->num_ports = 0;
327-
write_unlock_irqrestore(&client->ports_lock, flags);
324+
write_unlock_irq(&client->ports_lock);
328325

329326
/* remove each port in deleted_list */
330327
list_for_each_entry_safe(port, tmp, &deleted_list, list) {

0 commit comments

Comments
 (0)