aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/rawmidi.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core/rawmidi.c')
-rw-r--r--sound/core/rawmidi.c49
1 files changed, 34 insertions, 15 deletions
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index f6c12a2b019c..801c86133937 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -56,6 +56,13 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device);
56static LIST_HEAD(snd_rawmidi_devices); 56static LIST_HEAD(snd_rawmidi_devices);
57static DEFINE_MUTEX(register_mutex); 57static DEFINE_MUTEX(register_mutex);
58 58
59#define rmidi_err(rmidi, fmt, args...) \
60 dev_err((rmidi)->card->dev, fmt, ##args)
61#define rmidi_warn(rmidi, fmt, args...) \
62 dev_warn((rmidi)->card->dev, fmt, ##args)
63#define rmidi_dbg(rmidi, fmt, args...) \
64 dev_dbg((rmidi)->card->dev, fmt, ##args)
65
59static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device) 66static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device)
60{ 67{
61 struct snd_rawmidi *rawmidi; 68 struct snd_rawmidi *rawmidi;
@@ -180,7 +187,9 @@ int snd_rawmidi_drain_output(struct snd_rawmidi_substream *substream)
180 if (signal_pending(current)) 187 if (signal_pending(current))
181 err = -ERESTARTSYS; 188 err = -ERESTARTSYS;
182 if (runtime->avail < runtime->buffer_size && !timeout) { 189 if (runtime->avail < runtime->buffer_size && !timeout) {
183 snd_printk(KERN_WARNING "rawmidi drain error (avail = %li, buffer_size = %li)\n", (long)runtime->avail, (long)runtime->buffer_size); 190 rmidi_warn(substream->rmidi,
191 "rawmidi drain error (avail = %li, buffer_size = %li)\n",
192 (long)runtime->avail, (long)runtime->buffer_size);
184 err = -EIO; 193 err = -EIO;
185 } 194 }
186 runtime->drain = 0; 195 runtime->drain = 0;
@@ -802,10 +811,9 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long
802 return -EINVAL; 811 return -EINVAL;
803 } 812 }
804 } 813 }
805#ifdef CONFIG_SND_DEBUG
806 default: 814 default:
807 snd_printk(KERN_WARNING "rawmidi: unknown command = 0x%x\n", cmd); 815 rmidi_dbg(rfile->rmidi,
808#endif 816 "rawmidi: unknown command = 0x%x\n", cmd);
809 } 817 }
810 return -ENOTTY; 818 return -ENOTTY;
811} 819}
@@ -875,7 +883,8 @@ int snd_rawmidi_receive(struct snd_rawmidi_substream *substream,
875 if (!substream->opened) 883 if (!substream->opened)
876 return -EBADFD; 884 return -EBADFD;
877 if (runtime->buffer == NULL) { 885 if (runtime->buffer == NULL) {
878 snd_printd("snd_rawmidi_receive: input is not active!!!\n"); 886 rmidi_dbg(substream->rmidi,
887 "snd_rawmidi_receive: input is not active!!!\n");
879 return -EINVAL; 888 return -EINVAL;
880 } 889 }
881 spin_lock_irqsave(&runtime->lock, flags); 890 spin_lock_irqsave(&runtime->lock, flags);
@@ -1034,7 +1043,8 @@ int snd_rawmidi_transmit_empty(struct snd_rawmidi_substream *substream)
1034 unsigned long flags; 1043 unsigned long flags;
1035 1044
1036 if (runtime->buffer == NULL) { 1045 if (runtime->buffer == NULL) {
1037 snd_printd("snd_rawmidi_transmit_empty: output is not active!!!\n"); 1046 rmidi_dbg(substream->rmidi,
1047 "snd_rawmidi_transmit_empty: output is not active!!!\n");
1038 return 1; 1048 return 1;
1039 } 1049 }
1040 spin_lock_irqsave(&runtime->lock, flags); 1050 spin_lock_irqsave(&runtime->lock, flags);
@@ -1065,7 +1075,8 @@ int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream,
1065 struct snd_rawmidi_runtime *runtime = substream->runtime; 1075 struct snd_rawmidi_runtime *runtime = substream->runtime;
1066 1076
1067 if (runtime->buffer == NULL) { 1077 if (runtime->buffer == NULL) {
1068 snd_printd("snd_rawmidi_transmit_peek: output is not active!!!\n"); 1078 rmidi_dbg(substream->rmidi,
1079 "snd_rawmidi_transmit_peek: output is not active!!!\n");
1069 return -EINVAL; 1080 return -EINVAL;
1070 } 1081 }
1071 result = 0; 1082 result = 0;
@@ -1115,7 +1126,8 @@ int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count)
1115 struct snd_rawmidi_runtime *runtime = substream->runtime; 1126 struct snd_rawmidi_runtime *runtime = substream->runtime;
1116 1127
1117 if (runtime->buffer == NULL) { 1128 if (runtime->buffer == NULL) {
1118 snd_printd("snd_rawmidi_transmit_ack: output is not active!!!\n"); 1129 rmidi_dbg(substream->rmidi,
1130 "snd_rawmidi_transmit_ack: output is not active!!!\n");
1119 return -EINVAL; 1131 return -EINVAL;
1120 } 1132 }
1121 spin_lock_irqsave(&runtime->lock, flags); 1133 spin_lock_irqsave(&runtime->lock, flags);
@@ -1413,7 +1425,7 @@ static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi,
1413 for (idx = 0; idx < count; idx++) { 1425 for (idx = 0; idx < count; idx++) {
1414 substream = kzalloc(sizeof(*substream), GFP_KERNEL); 1426 substream = kzalloc(sizeof(*substream), GFP_KERNEL);
1415 if (substream == NULL) { 1427 if (substream == NULL) {
1416 snd_printk(KERN_ERR "rawmidi: cannot allocate substream\n"); 1428 rmidi_err(rmidi, "rawmidi: cannot allocate substream\n");
1417 return -ENOMEM; 1429 return -ENOMEM;
1418 } 1430 }
1419 substream->stream = direction; 1431 substream->stream = direction;
@@ -1458,7 +1470,7 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device,
1458 *rrawmidi = NULL; 1470 *rrawmidi = NULL;
1459 rmidi = kzalloc(sizeof(*rmidi), GFP_KERNEL); 1471 rmidi = kzalloc(sizeof(*rmidi), GFP_KERNEL);
1460 if (rmidi == NULL) { 1472 if (rmidi == NULL) {
1461 snd_printk(KERN_ERR "rawmidi: cannot allocate\n"); 1473 dev_err(card->dev, "rawmidi: cannot allocate\n");
1462 return -ENOMEM; 1474 return -ENOMEM;
1463 } 1475 }
1464 rmidi->card = card; 1476 rmidi->card = card;
@@ -1557,7 +1569,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
1557 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI, 1569 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI,
1558 rmidi->card, rmidi->device, 1570 rmidi->card, rmidi->device,
1559 &snd_rawmidi_f_ops, rmidi, name)) < 0) { 1571 &snd_rawmidi_f_ops, rmidi, name)) < 0) {
1560 snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device); 1572 rmidi_err(rmidi, "unable to register rawmidi device %i:%i\n",
1573 rmidi->card->number, rmidi->device);
1561 list_del(&rmidi->list); 1574 list_del(&rmidi->list);
1562 mutex_unlock(&register_mutex); 1575 mutex_unlock(&register_mutex);
1563 return err; 1576 return err;
@@ -1575,7 +1588,9 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
1575 if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, 1588 if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI,
1576 rmidi->card, 0, &snd_rawmidi_f_ops, 1589 rmidi->card, 0, &snd_rawmidi_f_ops,
1577 rmidi) < 0) { 1590 rmidi) < 0) {
1578 snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 0); 1591 rmidi_err(rmidi,
1592 "unable to register OSS rawmidi device %i:%i\n",
1593 rmidi->card->number, 0);
1579 } else { 1594 } else {
1580 rmidi->ossreg++; 1595 rmidi->ossreg++;
1581#ifdef SNDRV_OSS_INFO_DEV_MIDI 1596#ifdef SNDRV_OSS_INFO_DEV_MIDI
@@ -1587,7 +1602,9 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
1587 if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, 1602 if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI,
1588 rmidi->card, 1, &snd_rawmidi_f_ops, 1603 rmidi->card, 1, &snd_rawmidi_f_ops,
1589 rmidi) < 0) { 1604 rmidi) < 0) {
1590 snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 1); 1605 rmidi_err(rmidi,
1606 "unable to register OSS rawmidi device %i:%i\n",
1607 rmidi->card->number, 1);
1591 } else { 1608 } else {
1592 rmidi->ossreg++; 1609 rmidi->ossreg++;
1593 } 1610 }
@@ -1685,11 +1702,13 @@ static int __init alsa_rawmidi_init(void)
1685 /* check device map table */ 1702 /* check device map table */
1686 for (i = 0; i < SNDRV_CARDS; i++) { 1703 for (i = 0; i < SNDRV_CARDS; i++) {
1687 if (midi_map[i] < 0 || midi_map[i] >= SNDRV_RAWMIDI_DEVICES) { 1704 if (midi_map[i] < 0 || midi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
1688 snd_printk(KERN_ERR "invalid midi_map[%d] = %d\n", i, midi_map[i]); 1705 pr_err("ALSA: rawmidi: invalid midi_map[%d] = %d\n",
1706 i, midi_map[i]);
1689 midi_map[i] = 0; 1707 midi_map[i] = 0;
1690 } 1708 }
1691 if (amidi_map[i] < 0 || amidi_map[i] >= SNDRV_RAWMIDI_DEVICES) { 1709 if (amidi_map[i] < 0 || amidi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
1692 snd_printk(KERN_ERR "invalid amidi_map[%d] = %d\n", i, amidi_map[i]); 1710 pr_err("ALSA: rawmidi: invalid amidi_map[%d] = %d\n",
1711 i, amidi_map[i]);
1693 amidi_map[i] = 1; 1712 amidi_map[i] = 1;
1694 } 1713 }
1695 } 1714 }