diff options
| author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-03-23 23:44:19 -0500 |
|---|---|---|
| committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-03-23 23:44:19 -0500 |
| commit | 1ebbe2b20091d306453a5cf480a87e6cd28ae76f (patch) | |
| tree | f5cd7a0fa69b8b1938cb5a0faed2e7b0628072a5 /sound/core/rawmidi.c | |
| parent | ac58c9059da8886b5e8cde012a80266b18ca146e (diff) | |
| parent | 674a396c6d2ba0341ebdd7c1c9950f32f018e2dd (diff) | |
Merge branch 'linus'
Diffstat (limited to 'sound/core/rawmidi.c')
| -rw-r--r-- | sound/core/rawmidi.c | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index d4d124e21924..6b7a36774298 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
| 29 | #include <linux/time.h> | 29 | #include <linux/time.h> |
| 30 | #include <linux/wait.h> | 30 | #include <linux/wait.h> |
| 31 | #include <linux/mutex.h> | ||
| 31 | #include <linux/moduleparam.h> | 32 | #include <linux/moduleparam.h> |
| 32 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
| 33 | #include <linux/wait.h> | 34 | #include <linux/wait.h> |
| @@ -57,7 +58,7 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device); | |||
| 57 | static int snd_rawmidi_dev_unregister(struct snd_device *device); | 58 | static int snd_rawmidi_dev_unregister(struct snd_device *device); |
| 58 | 59 | ||
| 59 | static LIST_HEAD(snd_rawmidi_devices); | 60 | static LIST_HEAD(snd_rawmidi_devices); |
| 60 | static DECLARE_MUTEX(register_mutex); | 61 | static DEFINE_MUTEX(register_mutex); |
| 61 | 62 | ||
| 62 | static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device) | 63 | static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device) |
| 63 | { | 64 | { |
| @@ -237,9 +238,9 @@ int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice, | |||
| 237 | 238 | ||
| 238 | if (rfile) | 239 | if (rfile) |
| 239 | rfile->input = rfile->output = NULL; | 240 | rfile->input = rfile->output = NULL; |
| 240 | down(®ister_mutex); | 241 | mutex_lock(®ister_mutex); |
| 241 | rmidi = snd_rawmidi_search(card, device); | 242 | rmidi = snd_rawmidi_search(card, device); |
| 242 | up(®ister_mutex); | 243 | mutex_unlock(®ister_mutex); |
| 243 | if (rmidi == NULL) { | 244 | if (rmidi == NULL) { |
| 244 | err = -ENODEV; | 245 | err = -ENODEV; |
| 245 | goto __error1; | 246 | goto __error1; |
| @@ -249,7 +250,7 @@ int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice, | |||
| 249 | goto __error1; | 250 | goto __error1; |
| 250 | } | 251 | } |
| 251 | if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK)) | 252 | if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK)) |
| 252 | down(&rmidi->open_mutex); | 253 | mutex_lock(&rmidi->open_mutex); |
| 253 | if (mode & SNDRV_RAWMIDI_LFLG_INPUT) { | 254 | if (mode & SNDRV_RAWMIDI_LFLG_INPUT) { |
| 254 | if (!(rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT)) { | 255 | if (!(rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT)) { |
| 255 | err = -ENXIO; | 256 | err = -ENXIO; |
| @@ -359,7 +360,7 @@ int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice, | |||
| 359 | soutput = NULL; | 360 | soutput = NULL; |
| 360 | } | 361 | } |
| 361 | if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK)) | 362 | if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK)) |
| 362 | up(&rmidi->open_mutex); | 363 | mutex_unlock(&rmidi->open_mutex); |
| 363 | if (rfile) { | 364 | if (rfile) { |
| 364 | rfile->rmidi = rmidi; | 365 | rfile->rmidi = rmidi; |
| 365 | rfile->input = sinput; | 366 | rfile->input = sinput; |
| @@ -374,7 +375,7 @@ int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice, | |||
| 374 | snd_rawmidi_runtime_free(soutput); | 375 | snd_rawmidi_runtime_free(soutput); |
| 375 | module_put(rmidi->card->module); | 376 | module_put(rmidi->card->module); |
| 376 | if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK)) | 377 | if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK)) |
| 377 | up(&rmidi->open_mutex); | 378 | mutex_unlock(&rmidi->open_mutex); |
| 378 | __error1: | 379 | __error1: |
| 379 | return err; | 380 | return err; |
| 380 | } | 381 | } |
| @@ -422,7 +423,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) | |||
| 422 | } | 423 | } |
| 423 | init_waitqueue_entry(&wait, current); | 424 | init_waitqueue_entry(&wait, current); |
| 424 | add_wait_queue(&rmidi->open_wait, &wait); | 425 | add_wait_queue(&rmidi->open_wait, &wait); |
| 425 | down(&rmidi->open_mutex); | 426 | mutex_lock(&rmidi->open_mutex); |
| 426 | while (1) { | 427 | while (1) { |
| 427 | subdevice = -1; | 428 | subdevice = -1; |
| 428 | down_read(&card->controls_rwsem); | 429 | down_read(&card->controls_rwsem); |
| @@ -446,9 +447,9 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) | |||
| 446 | } else | 447 | } else |
| 447 | break; | 448 | break; |
| 448 | set_current_state(TASK_INTERRUPTIBLE); | 449 | set_current_state(TASK_INTERRUPTIBLE); |
| 449 | up(&rmidi->open_mutex); | 450 | mutex_unlock(&rmidi->open_mutex); |
| 450 | schedule(); | 451 | schedule(); |
| 451 | down(&rmidi->open_mutex); | 452 | mutex_lock(&rmidi->open_mutex); |
| 452 | if (signal_pending(current)) { | 453 | if (signal_pending(current)) { |
| 453 | err = -ERESTARTSYS; | 454 | err = -ERESTARTSYS; |
| 454 | break; | 455 | break; |
| @@ -467,7 +468,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) | |||
| 467 | snd_card_file_remove(card, file); | 468 | snd_card_file_remove(card, file); |
| 468 | kfree(rawmidi_file); | 469 | kfree(rawmidi_file); |
| 469 | } | 470 | } |
| 470 | up(&rmidi->open_mutex); | 471 | mutex_unlock(&rmidi->open_mutex); |
| 471 | return err; | 472 | return err; |
| 472 | } | 473 | } |
| 473 | 474 | ||
| @@ -480,7 +481,7 @@ int snd_rawmidi_kernel_release(struct snd_rawmidi_file * rfile) | |||
| 480 | snd_assert(rfile != NULL, return -ENXIO); | 481 | snd_assert(rfile != NULL, return -ENXIO); |
| 481 | snd_assert(rfile->input != NULL || rfile->output != NULL, return -ENXIO); | 482 | snd_assert(rfile->input != NULL || rfile->output != NULL, return -ENXIO); |
| 482 | rmidi = rfile->rmidi; | 483 | rmidi = rfile->rmidi; |
| 483 | down(&rmidi->open_mutex); | 484 | mutex_lock(&rmidi->open_mutex); |
| 484 | if (rfile->input != NULL) { | 485 | if (rfile->input != NULL) { |
| 485 | substream = rfile->input; | 486 | substream = rfile->input; |
| 486 | rfile->input = NULL; | 487 | rfile->input = NULL; |
| @@ -514,7 +515,7 @@ int snd_rawmidi_kernel_release(struct snd_rawmidi_file * rfile) | |||
| 514 | } | 515 | } |
| 515 | rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_opened--; | 516 | rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_opened--; |
| 516 | } | 517 | } |
| 517 | up(&rmidi->open_mutex); | 518 | mutex_unlock(&rmidi->open_mutex); |
| 518 | module_put(rmidi->card->module); | 519 | module_put(rmidi->card->module); |
| 519 | return 0; | 520 | return 0; |
| 520 | } | 521 | } |
| @@ -576,9 +577,9 @@ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info | |||
| 576 | struct snd_rawmidi_substream *substream; | 577 | struct snd_rawmidi_substream *substream; |
| 577 | struct list_head *list; | 578 | struct list_head *list; |
| 578 | 579 | ||
| 579 | down(®ister_mutex); | 580 | mutex_lock(®ister_mutex); |
| 580 | rmidi = snd_rawmidi_search(card, info->device); | 581 | rmidi = snd_rawmidi_search(card, info->device); |
| 581 | up(®ister_mutex); | 582 | mutex_unlock(®ister_mutex); |
| 582 | if (!rmidi) | 583 | if (!rmidi) |
| 583 | return -ENXIO; | 584 | return -ENXIO; |
| 584 | if (info->stream < 0 || info->stream > 1) | 585 | if (info->stream < 0 || info->stream > 1) |
| @@ -818,7 +819,7 @@ static int snd_rawmidi_control_ioctl(struct snd_card *card, | |||
| 818 | 819 | ||
| 819 | if (get_user(device, (int __user *)argp)) | 820 | if (get_user(device, (int __user *)argp)) |
| 820 | return -EFAULT; | 821 | return -EFAULT; |
| 821 | down(®ister_mutex); | 822 | mutex_lock(®ister_mutex); |
| 822 | device = device < 0 ? 0 : device + 1; | 823 | device = device < 0 ? 0 : device + 1; |
| 823 | while (device < SNDRV_RAWMIDI_DEVICES) { | 824 | while (device < SNDRV_RAWMIDI_DEVICES) { |
| 824 | if (snd_rawmidi_search(card, device)) | 825 | if (snd_rawmidi_search(card, device)) |
| @@ -827,7 +828,7 @@ static int snd_rawmidi_control_ioctl(struct snd_card *card, | |||
| 827 | } | 828 | } |
| 828 | if (device == SNDRV_RAWMIDI_DEVICES) | 829 | if (device == SNDRV_RAWMIDI_DEVICES) |
| 829 | device = -1; | 830 | device = -1; |
| 830 | up(®ister_mutex); | 831 | mutex_unlock(®ister_mutex); |
| 831 | if (put_user(device, (int __user *)argp)) | 832 | if (put_user(device, (int __user *)argp)) |
| 832 | return -EFAULT; | 833 | return -EFAULT; |
| 833 | return 0; | 834 | return 0; |
| @@ -1314,7 +1315,7 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry, | |||
| 1314 | 1315 | ||
| 1315 | rmidi = entry->private_data; | 1316 | rmidi = entry->private_data; |
| 1316 | snd_iprintf(buffer, "%s\n\n", rmidi->name); | 1317 | snd_iprintf(buffer, "%s\n\n", rmidi->name); |
| 1317 | down(&rmidi->open_mutex); | 1318 | mutex_lock(&rmidi->open_mutex); |
| 1318 | if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) { | 1319 | if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) { |
| 1319 | list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) { | 1320 | list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) { |
| 1320 | substream = list_entry(list, struct snd_rawmidi_substream, list); | 1321 | 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 | } | 1356 | } |
| 1356 | } | 1357 | } |
| 1357 | } | 1358 | } |
| 1358 | up(&rmidi->open_mutex); | 1359 | mutex_unlock(&rmidi->open_mutex); |
| 1359 | } | 1360 | } |
| 1360 | 1361 | ||
| 1361 | /* | 1362 | /* |
| @@ -1436,7 +1437,7 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device, | |||
| 1436 | } | 1437 | } |
| 1437 | rmidi->card = card; | 1438 | rmidi->card = card; |
| 1438 | rmidi->device = device; | 1439 | rmidi->device = device; |
| 1439 | init_MUTEX(&rmidi->open_mutex); | 1440 | mutex_init(&rmidi->open_mutex); |
| 1440 | init_waitqueue_head(&rmidi->open_wait); | 1441 | init_waitqueue_head(&rmidi->open_wait); |
| 1441 | if (id != NULL) | 1442 | if (id != NULL) |
| 1442 | strlcpy(rmidi->id, id, sizeof(rmidi->id)); | 1443 | strlcpy(rmidi->id, id, sizeof(rmidi->id)); |
| @@ -1507,9 +1508,9 @@ static int snd_rawmidi_dev_register(struct snd_device *device) | |||
| 1507 | 1508 | ||
| 1508 | if (rmidi->device >= SNDRV_RAWMIDI_DEVICES) | 1509 | if (rmidi->device >= SNDRV_RAWMIDI_DEVICES) |
| 1509 | return -ENOMEM; | 1510 | return -ENOMEM; |
| 1510 | down(®ister_mutex); | 1511 | mutex_lock(®ister_mutex); |
| 1511 | if (snd_rawmidi_search(rmidi->card, rmidi->device)) { | 1512 | if (snd_rawmidi_search(rmidi->card, rmidi->device)) { |
| 1512 | up(®ister_mutex); | 1513 | mutex_unlock(®ister_mutex); |
| 1513 | return -EBUSY; | 1514 | return -EBUSY; |
| 1514 | } | 1515 | } |
| 1515 | list_add_tail(&rmidi->list, &snd_rawmidi_devices); | 1516 | list_add_tail(&rmidi->list, &snd_rawmidi_devices); |
| @@ -1519,14 +1520,14 @@ static int snd_rawmidi_dev_register(struct snd_device *device) | |||
| 1519 | &snd_rawmidi_f_ops, rmidi, name)) < 0) { | 1520 | &snd_rawmidi_f_ops, rmidi, name)) < 0) { |
| 1520 | snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device); | 1521 | snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device); |
| 1521 | list_del(&rmidi->list); | 1522 | list_del(&rmidi->list); |
| 1522 | up(®ister_mutex); | 1523 | mutex_unlock(®ister_mutex); |
| 1523 | return err; | 1524 | return err; |
| 1524 | } | 1525 | } |
| 1525 | if (rmidi->ops && rmidi->ops->dev_register && | 1526 | if (rmidi->ops && rmidi->ops->dev_register && |
| 1526 | (err = rmidi->ops->dev_register(rmidi)) < 0) { | 1527 | (err = rmidi->ops->dev_register(rmidi)) < 0) { |
| 1527 | snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device); | 1528 | snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device); |
| 1528 | list_del(&rmidi->list); | 1529 | list_del(&rmidi->list); |
| 1529 | up(®ister_mutex); | 1530 | mutex_unlock(®ister_mutex); |
| 1530 | return err; | 1531 | return err; |
| 1531 | } | 1532 | } |
| 1532 | #ifdef CONFIG_SND_OSSEMUL | 1533 | #ifdef CONFIG_SND_OSSEMUL |
| @@ -1553,7 +1554,7 @@ static int snd_rawmidi_dev_register(struct snd_device *device) | |||
| 1553 | } | 1554 | } |
| 1554 | } | 1555 | } |
| 1555 | #endif /* CONFIG_SND_OSSEMUL */ | 1556 | #endif /* CONFIG_SND_OSSEMUL */ |
| 1556 | up(®ister_mutex); | 1557 | mutex_unlock(®ister_mutex); |
| 1557 | sprintf(name, "midi%d", rmidi->device); | 1558 | sprintf(name, "midi%d", rmidi->device); |
| 1558 | entry = snd_info_create_card_entry(rmidi->card, name, rmidi->card->proc_root); | 1559 | entry = snd_info_create_card_entry(rmidi->card, name, rmidi->card->proc_root); |
| 1559 | if (entry) { | 1560 | if (entry) { |
| @@ -1583,9 +1584,9 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device) | |||
| 1583 | { | 1584 | { |
| 1584 | struct snd_rawmidi *rmidi = device->device_data; | 1585 | struct snd_rawmidi *rmidi = device->device_data; |
| 1585 | 1586 | ||
| 1586 | down(®ister_mutex); | 1587 | mutex_lock(®ister_mutex); |
| 1587 | list_del_init(&rmidi->list); | 1588 | list_del_init(&rmidi->list); |
| 1588 | up(®ister_mutex); | 1589 | mutex_unlock(®ister_mutex); |
| 1589 | return 0; | 1590 | return 0; |
| 1590 | } | 1591 | } |
| 1591 | 1592 | ||
| @@ -1594,7 +1595,7 @@ static int snd_rawmidi_dev_unregister(struct snd_device *device) | |||
| 1594 | struct snd_rawmidi *rmidi = device->device_data; | 1595 | struct snd_rawmidi *rmidi = device->device_data; |
| 1595 | 1596 | ||
| 1596 | snd_assert(rmidi != NULL, return -ENXIO); | 1597 | snd_assert(rmidi != NULL, return -ENXIO); |
| 1597 | down(®ister_mutex); | 1598 | mutex_lock(®ister_mutex); |
| 1598 | list_del(&rmidi->list); | 1599 | list_del(&rmidi->list); |
| 1599 | if (rmidi->proc_entry) { | 1600 | if (rmidi->proc_entry) { |
| 1600 | snd_info_unregister(rmidi->proc_entry); | 1601 | snd_info_unregister(rmidi->proc_entry); |
| @@ -1616,7 +1617,7 @@ static int snd_rawmidi_dev_unregister(struct snd_device *device) | |||
| 1616 | if (rmidi->ops && rmidi->ops->dev_unregister) | 1617 | if (rmidi->ops && rmidi->ops->dev_unregister) |
| 1617 | rmidi->ops->dev_unregister(rmidi); | 1618 | rmidi->ops->dev_unregister(rmidi); |
| 1618 | snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device); | 1619 | snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device); |
| 1619 | up(®ister_mutex); | 1620 | mutex_unlock(®ister_mutex); |
| 1620 | #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) | 1621 | #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) |
| 1621 | if (rmidi->seq_dev) { | 1622 | if (rmidi->seq_dev) { |
| 1622 | snd_device_free(rmidi->card, rmidi->seq_dev); | 1623 | snd_device_free(rmidi->card, rmidi->seq_dev); |
