aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/seq/seq_clientmgr.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core/seq/seq_clientmgr.c')
-rw-r--r--sound/core/seq/seq_clientmgr.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index fd2032eae214..bb15d9ee8842 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -67,7 +67,7 @@
67#define SNDRV_SEQ_LFLG_OPEN (SNDRV_SEQ_LFLG_INPUT|SNDRV_SEQ_LFLG_OUTPUT) 67#define SNDRV_SEQ_LFLG_OPEN (SNDRV_SEQ_LFLG_INPUT|SNDRV_SEQ_LFLG_OUTPUT)
68 68
69static DEFINE_SPINLOCK(clients_lock); 69static DEFINE_SPINLOCK(clients_lock);
70static DECLARE_MUTEX(register_mutex); 70static DEFINE_MUTEX(register_mutex);
71 71
72/* 72/*
73 * client table 73 * client table
@@ -237,7 +237,7 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize)
237 client->type = NO_CLIENT; 237 client->type = NO_CLIENT;
238 snd_use_lock_init(&client->use_lock); 238 snd_use_lock_init(&client->use_lock);
239 rwlock_init(&client->ports_lock); 239 rwlock_init(&client->ports_lock);
240 init_MUTEX(&client->ports_mutex); 240 mutex_init(&client->ports_mutex);
241 INIT_LIST_HEAD(&client->ports_list_head); 241 INIT_LIST_HEAD(&client->ports_list_head);
242 242
243 /* find free slot in the client table */ 243 /* find free slot in the client table */
@@ -290,7 +290,7 @@ static int seq_free_client1(struct snd_seq_client *client)
290 290
291static void seq_free_client(struct snd_seq_client * client) 291static void seq_free_client(struct snd_seq_client * client)
292{ 292{
293 down(&register_mutex); 293 mutex_lock(&register_mutex);
294 switch (client->type) { 294 switch (client->type) {
295 case NO_CLIENT: 295 case NO_CLIENT:
296 snd_printk(KERN_WARNING "Seq: Trying to free unused client %d\n", 296 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 snd_printk(KERN_ERR "Seq: Trying to free client %d with undefined type = %d\n", 306 snd_printk(KERN_ERR "Seq: Trying to free client %d with undefined type = %d\n",
307 client->number, client->type); 307 client->number, client->type);
308 } 308 }
309 up(&register_mutex); 309 mutex_unlock(&register_mutex);
310 310
311 snd_seq_system_client_ev_client_exit(client->number); 311 snd_seq_system_client_ev_client_exit(client->number);
312} 312}
@@ -322,11 +322,11 @@ static int snd_seq_open(struct inode *inode, struct file *file)
322 struct snd_seq_client *client; 322 struct snd_seq_client *client;
323 struct snd_seq_user_client *user; 323 struct snd_seq_user_client *user;
324 324
325 if (down_interruptible(&register_mutex)) 325 if (mutex_lock_interruptible(&register_mutex))
326 return -ERESTARTSYS; 326 return -ERESTARTSYS;
327 client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS); 327 client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS);
328 if (client == NULL) { 328 if (client == NULL) {
329 up(&register_mutex); 329 mutex_unlock(&register_mutex);
330 return -ENOMEM; /* failure code */ 330 return -ENOMEM; /* failure code */
331 } 331 }
332 332
@@ -346,14 +346,14 @@ static int snd_seq_open(struct inode *inode, struct file *file)
346 if (user->fifo == NULL) { 346 if (user->fifo == NULL) {
347 seq_free_client1(client); 347 seq_free_client1(client);
348 kfree(client); 348 kfree(client);
349 up(&register_mutex); 349 mutex_unlock(&register_mutex);
350 return -ENOMEM; 350 return -ENOMEM;
351 } 351 }
352 } 352 }
353 353
354 usage_alloc(&client_usage, 1); 354 usage_alloc(&client_usage, 1);
355 client->type = USER_CLIENT; 355 client->type = USER_CLIENT;
356 up(&register_mutex); 356 mutex_unlock(&register_mutex);
357 357
358 c = client->number; 358 c = client->number;
359 file->private_data = client; 359 file->private_data = client;
@@ -1743,7 +1743,7 @@ static int snd_seq_ioctl_get_queue_timer(struct snd_seq_client *client,
1743 if (queue == NULL) 1743 if (queue == NULL)
1744 return -EINVAL; 1744 return -EINVAL;
1745 1745
1746 if (down_interruptible(&queue->timer_mutex)) { 1746 if (mutex_lock_interruptible(&queue->timer_mutex)) {
1747 queuefree(queue); 1747 queuefree(queue);
1748 return -ERESTARTSYS; 1748 return -ERESTARTSYS;
1749 } 1749 }
@@ -1756,7 +1756,7 @@ static int snd_seq_ioctl_get_queue_timer(struct snd_seq_client *client,
1756 timer.u.alsa.id = tmr->alsa_id; 1756 timer.u.alsa.id = tmr->alsa_id;
1757 timer.u.alsa.resolution = tmr->preferred_resolution; 1757 timer.u.alsa.resolution = tmr->preferred_resolution;
1758 } 1758 }
1759 up(&queue->timer_mutex); 1759 mutex_unlock(&queue->timer_mutex);
1760 queuefree(queue); 1760 queuefree(queue);
1761 1761
1762 if (copy_to_user(arg, &timer, sizeof(timer))) 1762 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 q = queueptr(timer.queue); 1785 q = queueptr(timer.queue);
1786 if (q == NULL) 1786 if (q == NULL)
1787 return -ENXIO; 1787 return -ENXIO;
1788 if (down_interruptible(&q->timer_mutex)) { 1788 if (mutex_lock_interruptible(&q->timer_mutex)) {
1789 queuefree(q); 1789 queuefree(q);
1790 return -ERESTARTSYS; 1790 return -ERESTARTSYS;
1791 } 1791 }
@@ -1797,7 +1797,7 @@ static int snd_seq_ioctl_set_queue_timer(struct snd_seq_client *client,
1797 tmr->preferred_resolution = timer.u.alsa.resolution; 1797 tmr->preferred_resolution = timer.u.alsa.resolution;
1798 } 1798 }
1799 result = snd_seq_queue_timer_open(timer.queue); 1799 result = snd_seq_queue_timer_open(timer.queue);
1800 up(&q->timer_mutex); 1800 mutex_unlock(&q->timer_mutex);
1801 queuefree(q); 1801 queuefree(q);
1802 } else { 1802 } else {
1803 return -EPERM; 1803 return -EPERM;
@@ -1866,8 +1866,7 @@ static int snd_seq_ioctl_get_client_pool(struct snd_seq_client *client,
1866 info.output_pool = cptr->pool->size; 1866 info.output_pool = cptr->pool->size;
1867 info.output_room = cptr->pool->room; 1867 info.output_room = cptr->pool->room;
1868 info.output_free = info.output_pool; 1868 info.output_free = info.output_pool;
1869 if (cptr->pool) 1869 info.output_free = snd_seq_unused_cells(cptr->pool);
1870 info.output_free = snd_seq_unused_cells(cptr->pool);
1871 if (cptr->type == USER_CLIENT) { 1870 if (cptr->type == USER_CLIENT) {
1872 info.input_pool = cptr->data.user.fifo_pool_size; 1871 info.input_pool = cptr->data.user.fifo_pool_size;
1873 info.input_free = info.input_pool; 1872 info.input_free = info.input_pool;
@@ -2230,7 +2229,7 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
2230 if (card == NULL && client_index >= SNDRV_SEQ_GLOBAL_CLIENTS) 2229 if (card == NULL && client_index >= SNDRV_SEQ_GLOBAL_CLIENTS)
2231 return -EINVAL; 2230 return -EINVAL;
2232 2231
2233 if (down_interruptible(&register_mutex)) 2232 if (mutex_lock_interruptible(&register_mutex))
2234 return -ERESTARTSYS; 2233 return -ERESTARTSYS;
2235 2234
2236 if (card) { 2235 if (card) {
@@ -2243,7 +2242,7 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
2243 /* empty write queue as default */ 2242 /* empty write queue as default */
2244 client = seq_create_client1(client_index, 0); 2243 client = seq_create_client1(client_index, 0);
2245 if (client == NULL) { 2244 if (client == NULL) {
2246 up(&register_mutex); 2245 mutex_unlock(&register_mutex);
2247 return -EBUSY; /* failure code */ 2246 return -EBUSY; /* failure code */
2248 } 2247 }
2249 usage_alloc(&client_usage, 1); 2248 usage_alloc(&client_usage, 1);
@@ -2256,7 +2255,7 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
2256 va_end(args); 2255 va_end(args);
2257 2256
2258 client->type = KERNEL_CLIENT; 2257 client->type = KERNEL_CLIENT;
2259 up(&register_mutex); 2258 mutex_unlock(&register_mutex);
2260 2259
2261 /* make others aware this new client */ 2260 /* make others aware this new client */
2262 snd_seq_system_client_ev_client_start(client->number); 2261 snd_seq_system_client_ev_client_start(client->number);
@@ -2464,7 +2463,7 @@ static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer,
2464{ 2463{
2465 struct list_head *l; 2464 struct list_head *l;
2466 2465
2467 down(&client->ports_mutex); 2466 mutex_lock(&client->ports_mutex);
2468 list_for_each(l, &client->ports_list_head) { 2467 list_for_each(l, &client->ports_list_head) {
2469 struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list); 2468 struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
2470 snd_iprintf(buffer, " Port %3d : \"%s\" (%c%c%c%c)\n", 2469 snd_iprintf(buffer, " Port %3d : \"%s\" (%c%c%c%c)\n",
@@ -2476,7 +2475,7 @@ static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer,
2476 snd_seq_info_dump_subscribers(buffer, &p->c_src, 1, " Connecting To: "); 2475 snd_seq_info_dump_subscribers(buffer, &p->c_src, 1, " Connecting To: ");
2477 snd_seq_info_dump_subscribers(buffer, &p->c_dest, 0, " Connected From: "); 2476 snd_seq_info_dump_subscribers(buffer, &p->c_dest, 0, " Connected From: ");
2478 } 2477 }
2479 up(&client->ports_mutex); 2478 mutex_unlock(&client->ports_mutex);
2480} 2479}
2481 2480
2482 2481
@@ -2550,16 +2549,16 @@ int __init snd_sequencer_device_init(void)
2550{ 2549{
2551 int err; 2550 int err;
2552 2551
2553 if (down_interruptible(&register_mutex)) 2552 if (mutex_lock_interruptible(&register_mutex))
2554 return -ERESTARTSYS; 2553 return -ERESTARTSYS;
2555 2554
2556 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0, 2555 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0,
2557 &snd_seq_f_ops, NULL, "seq")) < 0) { 2556 &snd_seq_f_ops, NULL, "seq")) < 0) {
2558 up(&register_mutex); 2557 mutex_unlock(&register_mutex);
2559 return err; 2558 return err;
2560 } 2559 }
2561 2560
2562 up(&register_mutex); 2561 mutex_unlock(&register_mutex);
2563 2562
2564 return 0; 2563 return 0;
2565} 2564}