Commit ca20d292 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: rawmidi: Use standard printk helpers

Use dev_err() & co as much as possible.  If not available (no device
assigned at the calling point), use pr_xxx() helpers instead.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent f2f9307a
...@@ -56,6 +56,13 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device); ...@@ -56,6 +56,13 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device);
static LIST_HEAD(snd_rawmidi_devices); static LIST_HEAD(snd_rawmidi_devices);
static DEFINE_MUTEX(register_mutex); static DEFINE_MUTEX(register_mutex);
#define rmidi_err(rmidi, fmt, args...) \
dev_err((rmidi)->card->dev, fmt, ##args)
#define rmidi_warn(rmidi, fmt, args...) \
dev_warn((rmidi)->card->dev, fmt, ##args)
#define rmidi_dbg(rmidi, fmt, args...) \
dev_dbg((rmidi)->card->dev, fmt, ##args)
static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device) static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device)
{ {
struct snd_rawmidi *rawmidi; struct snd_rawmidi *rawmidi;
...@@ -180,7 +187,9 @@ int snd_rawmidi_drain_output(struct snd_rawmidi_substream *substream) ...@@ -180,7 +187,9 @@ int snd_rawmidi_drain_output(struct snd_rawmidi_substream *substream)
if (signal_pending(current)) if (signal_pending(current))
err = -ERESTARTSYS; err = -ERESTARTSYS;
if (runtime->avail < runtime->buffer_size && !timeout) { if (runtime->avail < runtime->buffer_size && !timeout) {
snd_printk(KERN_WARNING "rawmidi drain error (avail = %li, buffer_size = %li)\n", (long)runtime->avail, (long)runtime->buffer_size); rmidi_warn(substream->rmidi,
"rawmidi drain error (avail = %li, buffer_size = %li)\n",
(long)runtime->avail, (long)runtime->buffer_size);
err = -EIO; err = -EIO;
} }
runtime->drain = 0; runtime->drain = 0;
...@@ -802,10 +811,9 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long ...@@ -802,10 +811,9 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long
return -EINVAL; return -EINVAL;
} }
} }
#ifdef CONFIG_SND_DEBUG
default: default:
snd_printk(KERN_WARNING "rawmidi: unknown command = 0x%x\n", cmd); rmidi_dbg(rfile->rmidi,
#endif "rawmidi: unknown command = 0x%x\n", cmd);
} }
return -ENOTTY; return -ENOTTY;
} }
...@@ -875,7 +883,8 @@ int snd_rawmidi_receive(struct snd_rawmidi_substream *substream, ...@@ -875,7 +883,8 @@ int snd_rawmidi_receive(struct snd_rawmidi_substream *substream,
if (!substream->opened) if (!substream->opened)
return -EBADFD; return -EBADFD;
if (runtime->buffer == NULL) { if (runtime->buffer == NULL) {
snd_printd("snd_rawmidi_receive: input is not active!!!\n"); rmidi_dbg(substream->rmidi,
"snd_rawmidi_receive: input is not active!!!\n");
return -EINVAL; return -EINVAL;
} }
spin_lock_irqsave(&runtime->lock, flags); spin_lock_irqsave(&runtime->lock, flags);
...@@ -1034,7 +1043,8 @@ int snd_rawmidi_transmit_empty(struct snd_rawmidi_substream *substream) ...@@ -1034,7 +1043,8 @@ int snd_rawmidi_transmit_empty(struct snd_rawmidi_substream *substream)
unsigned long flags; unsigned long flags;
if (runtime->buffer == NULL) { if (runtime->buffer == NULL) {
snd_printd("snd_rawmidi_transmit_empty: output is not active!!!\n"); rmidi_dbg(substream->rmidi,
"snd_rawmidi_transmit_empty: output is not active!!!\n");
return 1; return 1;
} }
spin_lock_irqsave(&runtime->lock, flags); spin_lock_irqsave(&runtime->lock, flags);
...@@ -1065,7 +1075,8 @@ int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream, ...@@ -1065,7 +1075,8 @@ int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream,
struct snd_rawmidi_runtime *runtime = substream->runtime; struct snd_rawmidi_runtime *runtime = substream->runtime;
if (runtime->buffer == NULL) { if (runtime->buffer == NULL) {
snd_printd("snd_rawmidi_transmit_peek: output is not active!!!\n"); rmidi_dbg(substream->rmidi,
"snd_rawmidi_transmit_peek: output is not active!!!\n");
return -EINVAL; return -EINVAL;
} }
result = 0; result = 0;
...@@ -1115,7 +1126,8 @@ int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count) ...@@ -1115,7 +1126,8 @@ int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count)
struct snd_rawmidi_runtime *runtime = substream->runtime; struct snd_rawmidi_runtime *runtime = substream->runtime;
if (runtime->buffer == NULL) { if (runtime->buffer == NULL) {
snd_printd("snd_rawmidi_transmit_ack: output is not active!!!\n"); rmidi_dbg(substream->rmidi,
"snd_rawmidi_transmit_ack: output is not active!!!\n");
return -EINVAL; return -EINVAL;
} }
spin_lock_irqsave(&runtime->lock, flags); spin_lock_irqsave(&runtime->lock, flags);
...@@ -1413,7 +1425,7 @@ static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi, ...@@ -1413,7 +1425,7 @@ static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi,
for (idx = 0; idx < count; idx++) { for (idx = 0; idx < count; idx++) {
substream = kzalloc(sizeof(*substream), GFP_KERNEL); substream = kzalloc(sizeof(*substream), GFP_KERNEL);
if (substream == NULL) { if (substream == NULL) {
snd_printk(KERN_ERR "rawmidi: cannot allocate substream\n"); rmidi_err(rmidi, "rawmidi: cannot allocate substream\n");
return -ENOMEM; return -ENOMEM;
} }
substream->stream = direction; substream->stream = direction;
...@@ -1458,7 +1470,7 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device, ...@@ -1458,7 +1470,7 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device,
*rrawmidi = NULL; *rrawmidi = NULL;
rmidi = kzalloc(sizeof(*rmidi), GFP_KERNEL); rmidi = kzalloc(sizeof(*rmidi), GFP_KERNEL);
if (rmidi == NULL) { if (rmidi == NULL) {
snd_printk(KERN_ERR "rawmidi: cannot allocate\n"); dev_err(card->dev, "rawmidi: cannot allocate\n");
return -ENOMEM; return -ENOMEM;
} }
rmidi->card = card; rmidi->card = card;
...@@ -1557,7 +1569,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device) ...@@ -1557,7 +1569,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
if ((err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI, if ((err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI,
rmidi->card, rmidi->device, rmidi->card, rmidi->device,
&snd_rawmidi_f_ops, rmidi, name)) < 0) { &snd_rawmidi_f_ops, rmidi, name)) < 0) {
snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device); rmidi_err(rmidi, "unable to register rawmidi device %i:%i\n",
rmidi->card->number, rmidi->device);
list_del(&rmidi->list); list_del(&rmidi->list);
mutex_unlock(&register_mutex); mutex_unlock(&register_mutex);
return err; return err;
...@@ -1575,7 +1588,9 @@ static int snd_rawmidi_dev_register(struct snd_device *device) ...@@ -1575,7 +1588,9 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI,
rmidi->card, 0, &snd_rawmidi_f_ops, rmidi->card, 0, &snd_rawmidi_f_ops,
rmidi) < 0) { rmidi) < 0) {
snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 0); rmidi_err(rmidi,
"unable to register OSS rawmidi device %i:%i\n",
rmidi->card->number, 0);
} else { } else {
rmidi->ossreg++; rmidi->ossreg++;
#ifdef SNDRV_OSS_INFO_DEV_MIDI #ifdef SNDRV_OSS_INFO_DEV_MIDI
...@@ -1587,7 +1602,9 @@ static int snd_rawmidi_dev_register(struct snd_device *device) ...@@ -1587,7 +1602,9 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI,
rmidi->card, 1, &snd_rawmidi_f_ops, rmidi->card, 1, &snd_rawmidi_f_ops,
rmidi) < 0) { rmidi) < 0) {
snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 1); rmidi_err(rmidi,
"unable to register OSS rawmidi device %i:%i\n",
rmidi->card->number, 1);
} else { } else {
rmidi->ossreg++; rmidi->ossreg++;
} }
...@@ -1685,11 +1702,13 @@ static int __init alsa_rawmidi_init(void) ...@@ -1685,11 +1702,13 @@ static int __init alsa_rawmidi_init(void)
/* check device map table */ /* check device map table */
for (i = 0; i < SNDRV_CARDS; i++) { for (i = 0; i < SNDRV_CARDS; i++) {
if (midi_map[i] < 0 || midi_map[i] >= SNDRV_RAWMIDI_DEVICES) { if (midi_map[i] < 0 || midi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
snd_printk(KERN_ERR "invalid midi_map[%d] = %d\n", i, midi_map[i]); pr_err("ALSA: rawmidi: invalid midi_map[%d] = %d\n",
i, midi_map[i]);
midi_map[i] = 0; midi_map[i] = 0;
} }
if (amidi_map[i] < 0 || amidi_map[i] >= SNDRV_RAWMIDI_DEVICES) { if (amidi_map[i] < 0 || amidi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
snd_printk(KERN_ERR "invalid amidi_map[%d] = %d\n", i, amidi_map[i]); pr_err("ALSA: rawmidi: invalid amidi_map[%d] = %d\n",
i, amidi_map[i]);
amidi_map[i] = 1; amidi_map[i] = 1;
} }
} }
......
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