diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-02-26 07:02:17 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-02-26 10:45:34 -0500 |
commit | 0ba41d917eeb87f608cf147f870ff2f4c1056bab (patch) | |
tree | e848ad3bb355ec92150b7f22eab66e88d7eee34b /sound/usb/pcm.c | |
parent | 6436bcf6a4a35ae83af9ff3c250435e5fd001205 (diff) |
ALSA: usb-audio: Use standard printk helpers
Convert with dev_err() and co from snd_printk(), etc.
As there are too deep indirections (e.g. ep->chip->dev->dev),
a few new local macros, usb_audio_err() & co, are introduced.
Also, the device numbers in some messages are dropped, as they are
shown in the prefix automatically.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/pcm.c')
-rw-r--r-- | sound/usb/pcm.c | 83 |
1 files changed, 49 insertions, 34 deletions
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index ca3256d6fde3..49de5c1284f6 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c | |||
@@ -166,8 +166,8 @@ static int init_pitch_v1(struct snd_usb_audio *chip, int iface, | |||
166 | USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, | 166 | USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, |
167 | UAC_EP_CS_ATTR_PITCH_CONTROL << 8, ep, | 167 | UAC_EP_CS_ATTR_PITCH_CONTROL << 8, ep, |
168 | data, sizeof(data))) < 0) { | 168 | data, sizeof(data))) < 0) { |
169 | snd_printk(KERN_ERR "%d:%d:%d: cannot set enable PITCH\n", | 169 | usb_audio_err(chip, "%d:%d: cannot set enable PITCH\n", |
170 | dev->devnum, iface, ep); | 170 | iface, ep); |
171 | return err; | 171 | return err; |
172 | } | 172 | } |
173 | 173 | ||
@@ -187,8 +187,8 @@ static int init_pitch_v2(struct snd_usb_audio *chip, int iface, | |||
187 | USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_OUT, | 187 | USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_OUT, |
188 | UAC2_EP_CS_PITCH << 8, 0, | 188 | UAC2_EP_CS_PITCH << 8, 0, |
189 | data, sizeof(data))) < 0) { | 189 | data, sizeof(data))) < 0) { |
190 | snd_printk(KERN_ERR "%d:%d:%d: cannot set enable PITCH (v2)\n", | 190 | usb_audio_err(chip, "%d:%d: cannot set enable PITCH (v2)\n", |
191 | dev->devnum, iface, fmt->altsetting); | 191 | iface, fmt->altsetting); |
192 | return err; | 192 | return err; |
193 | } | 193 | } |
194 | 194 | ||
@@ -226,7 +226,7 @@ static int start_endpoints(struct snd_usb_substream *subs, bool can_sleep) | |||
226 | if (!test_and_set_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags)) { | 226 | if (!test_and_set_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags)) { |
227 | struct snd_usb_endpoint *ep = subs->data_endpoint; | 227 | struct snd_usb_endpoint *ep = subs->data_endpoint; |
228 | 228 | ||
229 | snd_printdd(KERN_DEBUG "Starting data EP @%p\n", ep); | 229 | dev_dbg(&subs->dev->dev, "Starting data EP @%p\n", ep); |
230 | 230 | ||
231 | ep->data_subs = subs; | 231 | ep->data_subs = subs; |
232 | err = snd_usb_endpoint_start(ep, can_sleep); | 232 | err = snd_usb_endpoint_start(ep, can_sleep); |
@@ -247,16 +247,15 @@ static int start_endpoints(struct snd_usb_substream *subs, bool can_sleep) | |||
247 | subs->sync_endpoint->altsetting); | 247 | subs->sync_endpoint->altsetting); |
248 | if (err < 0) { | 248 | if (err < 0) { |
249 | clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags); | 249 | clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags); |
250 | snd_printk(KERN_ERR | 250 | dev_err(&subs->dev->dev, |
251 | "%d:%d:%d: cannot set interface (%d)\n", | 251 | "%d:%d: cannot set interface (%d)\n", |
252 | subs->dev->devnum, | ||
253 | subs->sync_endpoint->iface, | 252 | subs->sync_endpoint->iface, |
254 | subs->sync_endpoint->altsetting, err); | 253 | subs->sync_endpoint->altsetting, err); |
255 | return -EIO; | 254 | return -EIO; |
256 | } | 255 | } |
257 | } | 256 | } |
258 | 257 | ||
259 | snd_printdd(KERN_DEBUG "Starting sync EP @%p\n", ep); | 258 | dev_dbg(&subs->dev->dev, "Starting sync EP @%p\n", ep); |
260 | 259 | ||
261 | ep->sync_slave = subs->data_endpoint; | 260 | ep->sync_slave = subs->data_endpoint; |
262 | err = snd_usb_endpoint_start(ep, can_sleep); | 261 | err = snd_usb_endpoint_start(ep, can_sleep); |
@@ -410,8 +409,9 @@ static int set_sync_endpoint(struct snd_usb_substream *subs, | |||
410 | if ((get_endpoint(alts, 1)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_ISOC || | 409 | if ((get_endpoint(alts, 1)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_ISOC || |
411 | (get_endpoint(alts, 1)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE && | 410 | (get_endpoint(alts, 1)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE && |
412 | get_endpoint(alts, 1)->bSynchAddress != 0)) { | 411 | get_endpoint(alts, 1)->bSynchAddress != 0)) { |
413 | snd_printk(KERN_ERR "%d:%d:%d : invalid sync pipe. bmAttributes %02x, bLength %d, bSynchAddress %02x\n", | 412 | dev_err(&dev->dev, |
414 | dev->devnum, fmt->iface, fmt->altsetting, | 413 | "%d:%d : invalid sync pipe. bmAttributes %02x, bLength %d, bSynchAddress %02x\n", |
414 | fmt->iface, fmt->altsetting, | ||
415 | get_endpoint(alts, 1)->bmAttributes, | 415 | get_endpoint(alts, 1)->bmAttributes, |
416 | get_endpoint(alts, 1)->bLength, | 416 | get_endpoint(alts, 1)->bLength, |
417 | get_endpoint(alts, 1)->bSynchAddress); | 417 | get_endpoint(alts, 1)->bSynchAddress); |
@@ -421,8 +421,9 @@ static int set_sync_endpoint(struct snd_usb_substream *subs, | |||
421 | if (get_endpoint(alts, 0)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE && | 421 | if (get_endpoint(alts, 0)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE && |
422 | ((is_playback && ep != (unsigned int)(get_endpoint(alts, 0)->bSynchAddress | USB_DIR_IN)) || | 422 | ((is_playback && ep != (unsigned int)(get_endpoint(alts, 0)->bSynchAddress | USB_DIR_IN)) || |
423 | (!is_playback && ep != (unsigned int)(get_endpoint(alts, 0)->bSynchAddress & ~USB_DIR_IN)))) { | 423 | (!is_playback && ep != (unsigned int)(get_endpoint(alts, 0)->bSynchAddress & ~USB_DIR_IN)))) { |
424 | snd_printk(KERN_ERR "%d:%d:%d : invalid sync pipe. is_playback %d, ep %02x, bSynchAddress %02x\n", | 424 | dev_err(&dev->dev, |
425 | dev->devnum, fmt->iface, fmt->altsetting, | 425 | "%d:%d : invalid sync pipe. is_playback %d, ep %02x, bSynchAddress %02x\n", |
426 | fmt->iface, fmt->altsetting, | ||
426 | is_playback, ep, get_endpoint(alts, 0)->bSynchAddress); | 427 | is_playback, ep, get_endpoint(alts, 0)->bSynchAddress); |
427 | return -EINVAL; | 428 | return -EINVAL; |
428 | } | 429 | } |
@@ -469,8 +470,9 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) | |||
469 | if (subs->interface >= 0 && subs->interface != fmt->iface) { | 470 | if (subs->interface >= 0 && subs->interface != fmt->iface) { |
470 | err = usb_set_interface(subs->dev, subs->interface, 0); | 471 | err = usb_set_interface(subs->dev, subs->interface, 0); |
471 | if (err < 0) { | 472 | if (err < 0) { |
472 | snd_printk(KERN_ERR "%d:%d:%d: return to setting 0 failed (%d)\n", | 473 | dev_err(&dev->dev, |
473 | dev->devnum, fmt->iface, fmt->altsetting, err); | 474 | "%d:%d: return to setting 0 failed (%d)\n", |
475 | fmt->iface, fmt->altsetting, err); | ||
474 | return -EIO; | 476 | return -EIO; |
475 | } | 477 | } |
476 | subs->interface = -1; | 478 | subs->interface = -1; |
@@ -482,12 +484,13 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) | |||
482 | subs->altset_idx != fmt->altset_idx) { | 484 | subs->altset_idx != fmt->altset_idx) { |
483 | err = usb_set_interface(dev, fmt->iface, fmt->altsetting); | 485 | err = usb_set_interface(dev, fmt->iface, fmt->altsetting); |
484 | if (err < 0) { | 486 | if (err < 0) { |
485 | snd_printk(KERN_ERR "%d:%d:%d: usb_set_interface failed (%d)\n", | 487 | dev_err(&dev->dev, |
486 | dev->devnum, fmt->iface, fmt->altsetting, err); | 488 | "%d:%d: usb_set_interface failed (%d)\n", |
489 | fmt->iface, fmt->altsetting, err); | ||
487 | return -EIO; | 490 | return -EIO; |
488 | } | 491 | } |
489 | snd_printdd(KERN_INFO "setting usb interface %d:%d\n", | 492 | dev_dbg(&dev->dev, "setting usb interface %d:%d\n", |
490 | fmt->iface, fmt->altsetting); | 493 | fmt->iface, fmt->altsetting); |
491 | subs->interface = fmt->iface; | 494 | subs->interface = fmt->iface; |
492 | subs->altset_idx = fmt->altset_idx; | 495 | subs->altset_idx = fmt->altset_idx; |
493 | 496 | ||
@@ -523,20 +526,23 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) | |||
523 | * - Requested PCM format is not supported. | 526 | * - Requested PCM format is not supported. |
524 | * - Requested sample rate is not supported. | 527 | * - Requested sample rate is not supported. |
525 | */ | 528 | */ |
526 | static int match_endpoint_audioformats(struct audioformat *fp, | 529 | static int match_endpoint_audioformats(struct snd_usb_substream *subs, |
527 | struct audioformat *match, int rate, | 530 | struct audioformat *fp, |
528 | snd_pcm_format_t pcm_format) | 531 | struct audioformat *match, int rate, |
532 | snd_pcm_format_t pcm_format) | ||
529 | { | 533 | { |
530 | int i; | 534 | int i; |
531 | int score = 0; | 535 | int score = 0; |
532 | 536 | ||
533 | if (fp->channels < 1) { | 537 | if (fp->channels < 1) { |
534 | snd_printdd("%s: (fmt @%p) no channels\n", __func__, fp); | 538 | dev_dbg(&subs->dev->dev, |
539 | "%s: (fmt @%p) no channels\n", __func__, fp); | ||
535 | return 0; | 540 | return 0; |
536 | } | 541 | } |
537 | 542 | ||
538 | if (!(fp->formats & pcm_format_to_bits(pcm_format))) { | 543 | if (!(fp->formats & pcm_format_to_bits(pcm_format))) { |
539 | snd_printdd("%s: (fmt @%p) no match for format %d\n", __func__, | 544 | dev_dbg(&subs->dev->dev, |
545 | "%s: (fmt @%p) no match for format %d\n", __func__, | ||
540 | fp, pcm_format); | 546 | fp, pcm_format); |
541 | return 0; | 547 | return 0; |
542 | } | 548 | } |
@@ -548,7 +554,8 @@ static int match_endpoint_audioformats(struct audioformat *fp, | |||
548 | } | 554 | } |
549 | } | 555 | } |
550 | if (!score) { | 556 | if (!score) { |
551 | snd_printdd("%s: (fmt @%p) no match for rate %d\n", __func__, | 557 | dev_dbg(&subs->dev->dev, |
558 | "%s: (fmt @%p) no match for rate %d\n", __func__, | ||
552 | fp, rate); | 559 | fp, rate); |
553 | return 0; | 560 | return 0; |
554 | } | 561 | } |
@@ -556,7 +563,8 @@ static int match_endpoint_audioformats(struct audioformat *fp, | |||
556 | if (fp->channels == match->channels) | 563 | if (fp->channels == match->channels) |
557 | score++; | 564 | score++; |
558 | 565 | ||
559 | snd_printdd("%s: (fmt @%p) score %d\n", __func__, fp, score); | 566 | dev_dbg(&subs->dev->dev, |
567 | "%s: (fmt @%p) score %d\n", __func__, fp, score); | ||
560 | 568 | ||
561 | return score; | 569 | return score; |
562 | } | 570 | } |
@@ -587,7 +595,8 @@ static int configure_sync_endpoint(struct snd_usb_substream *subs) | |||
587 | 595 | ||
588 | /* Try to find the best matching audioformat. */ | 596 | /* Try to find the best matching audioformat. */ |
589 | list_for_each_entry(fp, &sync_subs->fmt_list, list) { | 597 | list_for_each_entry(fp, &sync_subs->fmt_list, list) { |
590 | int score = match_endpoint_audioformats(fp, subs->cur_audiofmt, | 598 | int score = match_endpoint_audioformats(subs, |
599 | fp, subs->cur_audiofmt, | ||
591 | subs->cur_rate, subs->pcm_format); | 600 | subs->cur_rate, subs->pcm_format); |
592 | 601 | ||
593 | if (score > cur_score) { | 602 | if (score > cur_score) { |
@@ -597,7 +606,8 @@ static int configure_sync_endpoint(struct snd_usb_substream *subs) | |||
597 | } | 606 | } |
598 | 607 | ||
599 | if (unlikely(sync_fp == NULL)) { | 608 | if (unlikely(sync_fp == NULL)) { |
600 | snd_printk(KERN_ERR "%s: no valid audioformat for sync ep %x found\n", | 609 | dev_err(&subs->dev->dev, |
610 | "%s: no valid audioformat for sync ep %x found\n", | ||
601 | __func__, sync_subs->ep_num); | 611 | __func__, sync_subs->ep_num); |
602 | return -EINVAL; | 612 | return -EINVAL; |
603 | } | 613 | } |
@@ -609,7 +619,8 @@ static int configure_sync_endpoint(struct snd_usb_substream *subs) | |||
609 | if (sync_fp->channels != subs->channels) { | 619 | if (sync_fp->channels != subs->channels) { |
610 | sync_period_bytes = (subs->period_bytes / subs->channels) * | 620 | sync_period_bytes = (subs->period_bytes / subs->channels) * |
611 | sync_fp->channels; | 621 | sync_fp->channels; |
612 | snd_printdd("%s: adjusted sync ep period bytes (%d -> %d)\n", | 622 | dev_dbg(&subs->dev->dev, |
623 | "%s: adjusted sync ep period bytes (%d -> %d)\n", | ||
613 | __func__, subs->period_bytes, sync_period_bytes); | 624 | __func__, subs->period_bytes, sync_period_bytes); |
614 | } | 625 | } |
615 | 626 | ||
@@ -685,7 +696,8 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream, | |||
685 | 696 | ||
686 | fmt = find_format(subs); | 697 | fmt = find_format(subs); |
687 | if (!fmt) { | 698 | if (!fmt) { |
688 | snd_printd(KERN_DEBUG "cannot set format: format = %#x, rate = %d, channels = %d\n", | 699 | dev_dbg(&subs->dev->dev, |
700 | "cannot set format: format = %#x, rate = %d, channels = %d\n", | ||
689 | subs->pcm_format, subs->cur_rate, subs->channels); | 701 | subs->pcm_format, subs->cur_rate, subs->channels); |
690 | return -EINVAL; | 702 | return -EINVAL; |
691 | } | 703 | } |
@@ -742,7 +754,7 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) | |||
742 | int ret; | 754 | int ret; |
743 | 755 | ||
744 | if (! subs->cur_audiofmt) { | 756 | if (! subs->cur_audiofmt) { |
745 | snd_printk(KERN_ERR "usbaudio: no format is specified!\n"); | 757 | dev_err(&subs->dev->dev, "no format is specified!\n"); |
746 | return -ENXIO; | 758 | return -ENXIO; |
747 | } | 759 | } |
748 | 760 | ||
@@ -1235,7 +1247,8 @@ static void retire_capture_urb(struct snd_usb_substream *subs, | |||
1235 | for (i = 0; i < urb->number_of_packets; i++) { | 1247 | for (i = 0; i < urb->number_of_packets; i++) { |
1236 | cp = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset + subs->pkt_offset_adj; | 1248 | cp = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset + subs->pkt_offset_adj; |
1237 | if (urb->iso_frame_desc[i].status && printk_ratelimit()) { | 1249 | if (urb->iso_frame_desc[i].status && printk_ratelimit()) { |
1238 | snd_printdd(KERN_ERR "frame %d active: %d\n", i, urb->iso_frame_desc[i].status); | 1250 | dev_dbg(&subs->dev->dev, "frame %d active: %d\n", |
1251 | i, urb->iso_frame_desc[i].status); | ||
1239 | // continue; | 1252 | // continue; |
1240 | } | 1253 | } |
1241 | bytes = urb->iso_frame_desc[i].actual_length; | 1254 | bytes = urb->iso_frame_desc[i].actual_length; |
@@ -1245,7 +1258,8 @@ static void retire_capture_urb(struct snd_usb_substream *subs, | |||
1245 | if (bytes % (runtime->sample_bits >> 3) != 0) { | 1258 | if (bytes % (runtime->sample_bits >> 3) != 0) { |
1246 | int oldbytes = bytes; | 1259 | int oldbytes = bytes; |
1247 | bytes = frames * stride; | 1260 | bytes = frames * stride; |
1248 | snd_printdd(KERN_ERR "Corrected urb data len. %d->%d\n", | 1261 | dev_warn(&subs->dev->dev, |
1262 | "Corrected urb data len. %d->%d\n", | ||
1249 | oldbytes, bytes); | 1263 | oldbytes, bytes); |
1250 | } | 1264 | } |
1251 | /* update the current pointer */ | 1265 | /* update the current pointer */ |
@@ -1488,7 +1502,8 @@ static void retire_playback_urb(struct snd_usb_substream *subs, | |||
1488 | * on two reads of a counter updated every ms. | 1502 | * on two reads of a counter updated every ms. |
1489 | */ | 1503 | */ |
1490 | if (abs(est_delay - subs->last_delay) * 1000 > runtime->rate * 2) | 1504 | if (abs(est_delay - subs->last_delay) * 1000 > runtime->rate * 2) |
1491 | snd_printk(KERN_DEBUG "delay: estimated %d, actual %d\n", | 1505 | dev_dbg(&subs->dev->dev, |
1506 | "delay: estimated %d, actual %d\n", | ||
1492 | est_delay, subs->last_delay); | 1507 | est_delay, subs->last_delay); |
1493 | 1508 | ||
1494 | if (!subs->running) { | 1509 | if (!subs->running) { |