Commit f1f6b8f65ff08afed4532b88de1a3bbea773787f

Authored by Daniel Mack
Committed by Takashi Iwai
1 parent 1c8470ce31

ALSA: snd-usb-caiaq: switch to dev_*() logging

Get rid of the proprietary functions log() and debug() and use the
generic dev_*() approach. A macro is needed to cast a cdev to a struct
device *.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

Showing 6 changed files with 75 additions and 56 deletions Side-by-side Diff

sound/usb/caiaq/audio.c
... ... @@ -16,6 +16,7 @@
16 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 17 */
18 18  
  19 +#include <linux/device.h>
19 20 #include <linux/spinlock.h>
20 21 #include <linux/slab.h>
21 22 #include <linux/init.h>
22 23  
... ... @@ -101,8 +102,9 @@
101 102 static int stream_start(struct snd_usb_caiaqdev *cdev)
102 103 {
103 104 int i, ret;
  105 + struct device *dev = caiaqdev_to_dev(cdev);
104 106  
105   - debug("%s(%p)\n", __func__, cdev);
  107 + dev_dbg(dev, "%s(%p)\n", __func__, cdev);
106 108  
107 109 if (cdev->streaming)
108 110 return -EINVAL;
... ... @@ -118,7 +120,8 @@
118 120 for (i = 0; i < N_URBS; i++) {
119 121 ret = usb_submit_urb(cdev->data_urbs_in[i], GFP_ATOMIC);
120 122 if (ret) {
121   - log("unable to trigger read #%d! (ret %d)\n", i, ret);
  123 + dev_err(dev, "unable to trigger read #%d! (ret %d)\n",
  124 + i, ret);
122 125 cdev->streaming = 0;
123 126 return -EPIPE;
124 127 }
125 128  
... ... @@ -130,8 +133,9 @@
130 133 static void stream_stop(struct snd_usb_caiaqdev *cdev)
131 134 {
132 135 int i;
  136 + struct device *dev = caiaqdev_to_dev(cdev);
133 137  
134   - debug("%s(%p)\n", __func__, cdev);
  138 + dev_dbg(dev, "%s(%p)\n", __func__, cdev);
135 139 if (!cdev->streaming)
136 140 return;
137 141  
138 142  
139 143  
140 144  
... ... @@ -150,17 +154,21 @@
150 154 static int snd_usb_caiaq_substream_open(struct snd_pcm_substream *substream)
151 155 {
152 156 struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream);
153   - debug("%s(%p)\n", __func__, substream);
  157 + struct device *dev = caiaqdev_to_dev(cdev);
  158 +
  159 + dev_dbg(dev, "%s(%p)\n", __func__, substream);
154 160 substream->runtime->hw = cdev->pcm_info;
155 161 snd_pcm_limit_hw_rates(substream->runtime);
  162 +
156 163 return 0;
157 164 }
158 165  
159 166 static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream)
160 167 {
161 168 struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream);
  169 + struct device *dev = caiaqdev_to_dev(cdev);
162 170  
163   - debug("%s(%p)\n", __func__, substream);
  171 + dev_dbg(dev, "%s(%p)\n", __func__, substream);
164 172 if (all_substreams_zero(cdev->sub_playback) &&
165 173 all_substreams_zero(cdev->sub_capture)) {
166 174 /* when the last client has stopped streaming,
167 175  
... ... @@ -175,14 +183,12 @@
175 183 static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub,
176 184 struct snd_pcm_hw_params *hw_params)
177 185 {
178   - debug("%s(%p)\n", __func__, sub);
179 186 return snd_pcm_lib_malloc_pages(sub, params_buffer_bytes(hw_params));
180 187 }
181 188  
182 189 static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub)
183 190 {
184 191 struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub);
185   - debug("%s(%p)\n", __func__, sub);
186 192 deactivate_substream(cdev, sub);
187 193 return snd_pcm_lib_free_pages(sub);
188 194 }
189 195  
... ... @@ -201,8 +207,9 @@
201 207 int index = substream->number;
202 208 struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream);
203 209 struct snd_pcm_runtime *runtime = substream->runtime;
  210 + struct device *dev = caiaqdev_to_dev(cdev);
204 211  
205   - debug("%s(%p)\n", __func__, substream);
  212 + dev_dbg(dev, "%s(%p)\n", __func__, substream);
206 213  
207 214 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
208 215 int out_pos;
209 216  
... ... @@ -283,8 +290,9 @@
283 290 static int snd_usb_caiaq_pcm_trigger(struct snd_pcm_substream *sub, int cmd)
284 291 {
285 292 struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub);
  293 + struct device *dev = caiaqdev_to_dev(cdev);
286 294  
287   - debug("%s(%p) cmd %d\n", __func__, sub, cmd);
  295 + dev_dbg(dev, "%s(%p) cmd %d\n", __func__, sub, cmd);
288 296  
289 297 switch (cmd) {
290 298 case SNDRV_PCM_TRIGGER_START:
... ... @@ -443,6 +451,7 @@
443 451 const struct usb_iso_packet_descriptor *iso)
444 452 {
445 453 unsigned char *usb_buf = urb->transfer_buffer + iso->offset;
  454 + struct device *dev = caiaqdev_to_dev(cdev);
446 455 int stream, i;
447 456  
448 457 /* paranoia check */
... ... @@ -479,8 +488,8 @@
479 488 if (usb_buf[i] != ((stream << 1) | c) &&
480 489 !cdev->first_packet) {
481 490 if (!cdev->input_panic)
482   - printk(" EXPECTED: %02x got %02x, c %d, stream %d, i %d\n",
483   - ((stream << 1) | c), usb_buf[i], c, stream, i);
  491 + dev_warn(dev, " EXPECTED: %02x got %02x, c %d, stream %d, i %d\n",
  492 + ((stream << 1) | c), usb_buf[i], c, stream, i);
484 493 cdev->input_panic = 1;
485 494 }
486 495  
... ... @@ -497,6 +506,8 @@
497 506 const struct urb *urb,
498 507 const struct usb_iso_packet_descriptor *iso)
499 508 {
  509 + struct device *dev = caiaqdev_to_dev(cdev);
  510 +
500 511 if (!cdev->streaming)
501 512 return;
502 513  
... ... @@ -516,7 +527,7 @@
516 527 }
517 528  
518 529 if ((cdev->input_panic || cdev->output_panic) && !cdev->warned) {
519   - debug("streaming error detected %s %s\n",
  530 + dev_warn(dev, "streaming error detected %s %s\n",
520 531 cdev->input_panic ? "(input)" : "",
521 532 cdev->output_panic ? "(output)" : "");
522 533 cdev->warned = 1;
... ... @@ -619,6 +630,7 @@
619 630 {
620 631 struct snd_usb_caiaq_cb_info *info = urb->context;
621 632 struct snd_usb_caiaqdev *cdev;
  633 + struct device *dev;
622 634 struct urb *out = NULL;
623 635 int i, frame, len, send_it = 0, outframe = 0;
624 636 size_t offset = 0;
... ... @@ -627,6 +639,7 @@
627 639 return;
628 640  
629 641 cdev = info->cdev;
  642 + dev = caiaqdev_to_dev(cdev);
630 643  
631 644 if (!cdev->streaming)
632 645 return;
... ... @@ -639,7 +652,7 @@
639 652 }
640 653  
641 654 if (!out) {
642   - log("Unable to find an output urb to use\n");
  655 + dev_err(dev, "Unable to find an output urb to use\n");
643 656 goto requeue;
644 657 }
645 658  
... ... @@ -708,6 +721,7 @@
708 721 int i, frame;
709 722 struct urb **urbs;
710 723 struct usb_device *usb_dev = cdev->chip.dev;
  724 + struct device *dev = caiaqdev_to_dev(cdev);
711 725 unsigned int pipe;
712 726  
713 727 pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ?
... ... @@ -716,7 +730,7 @@
716 730  
717 731 urbs = kmalloc(N_URBS * sizeof(*urbs), GFP_KERNEL);
718 732 if (!urbs) {
719   - log("unable to kmalloc() urbs, OOM!?\n");
  733 + dev_err(dev, "unable to kmalloc() urbs, OOM!?\n");
720 734 *ret = -ENOMEM;
721 735 return NULL;
722 736 }
... ... @@ -724,7 +738,7 @@
724 738 for (i = 0; i < N_URBS; i++) {
725 739 urbs[i] = usb_alloc_urb(FRAMES_PER_URB, GFP_KERNEL);
726 740 if (!urbs[i]) {
727   - log("unable to usb_alloc_urb(), OOM!?\n");
  741 + dev_err(dev, "unable to usb_alloc_urb(), OOM!?\n");
728 742 *ret = -ENOMEM;
729 743 return urbs;
730 744 }
... ... @@ -732,7 +746,7 @@
732 746 urbs[i]->transfer_buffer =
733 747 kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL);
734 748 if (!urbs[i]->transfer_buffer) {
735   - log("unable to kmalloc() transfer buffer, OOM!?\n");
  749 + dev_err(dev, "unable to kmalloc() transfer buffer, OOM!?\n");
736 750 *ret = -ENOMEM;
737 751 return urbs;
738 752 }
... ... @@ -783,6 +797,7 @@
783 797 int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev)
784 798 {
785 799 int i, ret;
  800 + struct device *dev = caiaqdev_to_dev(cdev);
786 801  
787 802 cdev->n_audio_in = max(cdev->spec.num_analog_audio_in,
788 803 cdev->spec.num_digital_audio_in) /
789 804  
... ... @@ -792,12 +807,12 @@
792 807 CHANNELS_PER_STREAM;
793 808 cdev->n_streams = max(cdev->n_audio_in, cdev->n_audio_out);
794 809  
795   - debug("cdev->n_audio_in = %d\n", cdev->n_audio_in);
796   - debug("cdev->n_audio_out = %d\n", cdev->n_audio_out);
797   - debug("cdev->n_streams = %d\n", cdev->n_streams);
  810 + dev_dbg(dev, "cdev->n_audio_in = %d\n", cdev->n_audio_in);
  811 + dev_dbg(dev, "cdev->n_audio_out = %d\n", cdev->n_audio_out);
  812 + dev_dbg(dev, "cdev->n_streams = %d\n", cdev->n_streams);
798 813  
799 814 if (cdev->n_streams > MAX_STREAMS) {
800   - log("unable to initialize device, too many streams.\n");
  815 + dev_err(dev, "unable to initialize device, too many streams.\n");
801 816 return -EINVAL;
802 817 }
803 818  
... ... @@ -805,7 +820,7 @@
805 820 cdev->n_audio_out, cdev->n_audio_in, &cdev->pcm);
806 821  
807 822 if (ret < 0) {
808   - log("snd_pcm_new() returned %d\n", ret);
  823 + dev_err(dev, "snd_pcm_new() returned %d\n", ret);
809 824 return ret;
810 825 }
811 826  
... ... @@ -880,7 +895,9 @@
880 895  
881 896 void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *cdev)
882 897 {
883   - debug("%s(%p)\n", __func__, cdev);
  898 + struct device *dev = caiaqdev_to_dev(cdev);
  899 +
  900 + dev_dbg(dev, "%s(%p)\n", __func__, cdev);
884 901 stream_stop(cdev);
885 902 free_urbs(cdev->data_urbs_in);
886 903 free_urbs(cdev->data_urbs_out);
sound/usb/caiaq/control.c
... ... @@ -17,6 +17,7 @@
17 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 */
19 19  
  20 +#include <linux/device.h>
20 21 #include <linux/init.h>
21 22 #include <linux/usb.h>
22 23 #include <sound/control.h>
sound/usb/caiaq/device.c
... ... @@ -20,6 +20,7 @@
20 20 */
21 21  
22 22 #include <linux/moduleparam.h>
  23 +#include <linux/device.h>
23 24 #include <linux/interrupt.h>
24 25 #include <linux/module.h>
25 26 #include <linux/init.h>
26 27  
... ... @@ -159,10 +160,11 @@
159 160 {
160 161 int ret;
161 162 struct snd_usb_caiaqdev *cdev = urb->context;
  163 + struct device *dev = caiaqdev_to_dev(cdev);
162 164 unsigned char *buf = urb->transfer_buffer;
163 165  
164 166 if (urb->status || !cdev) {
165   - log("received EP1 urb->status = %i\n", urb->status);
  167 + dev_warn(dev, "received EP1 urb->status = %i\n", urb->status);
166 168 return;
167 169 }
168 170  
... ... @@ -170,7 +172,7 @@
170 172 case EP1_CMD_GET_DEVICE_INFO:
171 173 memcpy(&cdev->spec, buf+1, sizeof(struct caiaq_device_spec));
172 174 cdev->spec.fw_version = le16_to_cpu(cdev->spec.fw_version);
173   - debug("device spec (firmware %d): audio: %d in, %d out, "
  175 + dev_dbg(dev, "device spec (firmware %d): audio: %d in, %d out, "
174 176 "MIDI: %d in, %d out, data alignment %d\n",
175 177 cdev->spec.fw_version,
176 178 cdev->spec.num_analog_audio_in,
... ... @@ -209,7 +211,7 @@
209 211 cdev->ep1_in_urb.actual_length = 0;
210 212 ret = usb_submit_urb(&cdev->ep1_in_urb, GFP_ATOMIC);
211 213 if (ret < 0)
212   - log("unable to submit urb. OOM!?\n");
  214 + dev_err(dev, "unable to submit urb. OOM!?\n");
213 215 }
214 216  
215 217 int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev,
... ... @@ -239,6 +241,7 @@
239 241 {
240 242 int ret;
241 243 char tmp[5];
  244 + struct device *dev = caiaqdev_to_dev(cdev);
242 245  
243 246 switch (rate) {
244 247 case 44100: tmp[0] = SAMPLERATE_44100; break;
... ... @@ -259,7 +262,7 @@
259 262 tmp[3] = bpp >> 8;
260 263 tmp[4] = 1; /* packets per microframe */
261 264  
262   - debug("setting audio params: %d Hz, %d bits, %d bpp\n",
  265 + dev_dbg(dev, "setting audio params: %d Hz, %d bits, %d bpp\n",
263 266 rate, depth, bpp);
264 267  
265 268 cdev->audio_parm_answer = -1;
... ... @@ -274,7 +277,7 @@
274 277 return -EPIPE;
275 278  
276 279 if (cdev->audio_parm_answer != 1)
277   - debug("unable to set the device's audio params\n");
  280 + dev_dbg(dev, "unable to set the device's audio params\n");
278 281 else
279 282 cdev->bpp = bpp;
280 283  
... ... @@ -293,6 +296,7 @@
293 296 {
294 297 int ret;
295 298 char val[4];
  299 + struct device *dev = caiaqdev_to_dev(cdev);
296 300  
297 301 /* device-specific startup specials */
298 302 switch (cdev->chip.usb_id) {
299 303  
300 304  
301 305  
302 306  
... ... @@ -346,32 +350,32 @@
346 350 cdev->spec.num_digital_audio_in > 0) {
347 351 ret = snd_usb_caiaq_audio_init(cdev);
348 352 if (ret < 0)
349   - log("Unable to set up audio system (ret=%d)\n", ret);
  353 + dev_err(dev, "Unable to set up audio system (ret=%d)\n", ret);
350 354 }
351 355  
352 356 if (cdev->spec.num_midi_in +
353 357 cdev->spec.num_midi_out > 0) {
354 358 ret = snd_usb_caiaq_midi_init(cdev);
355 359 if (ret < 0)
356   - log("Unable to set up MIDI system (ret=%d)\n", ret);
  360 + dev_err(dev, "Unable to set up MIDI system (ret=%d)\n", ret);
357 361 }
358 362  
359 363 #ifdef CONFIG_SND_USB_CAIAQ_INPUT
360 364 ret = snd_usb_caiaq_input_init(cdev);
361 365 if (ret < 0)
362   - log("Unable to set up input system (ret=%d)\n", ret);
  366 + dev_err(dev, "Unable to set up input system (ret=%d)\n", ret);
363 367 #endif
364 368  
365 369 /* finally, register the card and all its sub-instances */
366 370 ret = snd_card_register(cdev->chip.card);
367 371 if (ret < 0) {
368   - log("snd_card_register() returned %d\n", ret);
  372 + dev_err(dev, "snd_card_register() returned %d\n", ret);
369 373 snd_card_free(cdev->chip.card);
370 374 }
371 375  
372 376 ret = snd_usb_caiaq_control_init(cdev);
373 377 if (ret < 0)
374   - log("Unable to set up control system (ret=%d)\n", ret);
  378 + dev_err(dev, "Unable to set up control system (ret=%d)\n", ret);
375 379 }
376 380  
377 381 static int create_card(struct usb_device *usb_dev,
378 382  
... ... @@ -412,10 +416,11 @@
412 416 char *c, usbpath[32];
413 417 struct usb_device *usb_dev = cdev->chip.dev;
414 418 struct snd_card *card = cdev->chip.card;
  419 + struct device *dev = caiaqdev_to_dev(cdev);
415 420 int err, len;
416 421  
417 422 if (usb_set_interface(usb_dev, 0, 1) != 0) {
418   - log("can't set alt interface.\n");
  423 + dev_err(dev, "can't set alt interface.\n");
419 424 return -EIO;
420 425 }
421 426  
... ... @@ -473,8 +478,7 @@
473 478 }
474 479  
475 480 usb_make_path(usb_dev, usbpath, sizeof(usbpath));
476   - snprintf(card->longname, sizeof(card->longname),
477   - "%s %s (%s)",
  481 + snprintf(card->longname, sizeof(card->longname), "%s %s (%s)",
478 482 cdev->vendor_name, cdev->product_name, usbpath);
479 483  
480 484 setup_card(cdev);
... ... @@ -496,7 +500,7 @@
496 500 usb_set_intfdata(intf, card);
497 501 ret = init_card(caiaqdev(card));
498 502 if (ret < 0) {
499   - log("unable to init card! (ret=%d)\n", ret);
  503 + dev_err(&usb_dev->dev, "unable to init card! (ret=%d)\n", ret);
500 504 snd_card_free(card);
501 505 return ret;
502 506 }
503 507  
504 508  
505 509  
... ... @@ -506,15 +510,16 @@
506 510  
507 511 static void snd_disconnect(struct usb_interface *intf)
508 512 {
509   - struct snd_usb_caiaqdev *cdev;
510 513 struct snd_card *card = usb_get_intfdata(intf);
  514 + struct snd_usb_caiaqdev *cdev = caiaqdev(card);
  515 + struct device *dev;
511 516  
512   - debug("%s(%p)\n", __func__, intf);
513   -
514 517 if (!card)
515 518 return;
516 519  
517   - cdev = caiaqdev(card);
  520 + dev = caiaqdev_to_dev(cdev);
  521 + dev_dbg(dev, "%s(%p)\n", __func__, intf);
  522 +
518 523 snd_card_disconnect(card);
519 524  
520 525 #ifdef CONFIG_SND_USB_CAIAQ_INPUT
sound/usb/caiaq/device.h
... ... @@ -25,17 +25,8 @@
25 25 #define CAIAQ_USB_STR_LEN 0xff
26 26 #define MAX_STREAMS 32
27 27  
28   -//#define SND_USB_CAIAQ_DEBUG
29   -
30 28 #define MODNAME "snd-usb-caiaq"
31   -#define log(x...) snd_printk(KERN_WARNING MODNAME" log: " x)
32 29  
33   -#ifdef SND_USB_CAIAQ_DEBUG
34   -#define debug(x...) snd_printk(KERN_WARNING MODNAME " debug: " x)
35   -#else
36   -#define debug(x...) do { } while(0)
37   -#endif
38   -
39 30 #define EP1_CMD_GET_DEVICE_INFO 0x1
40 31 #define EP1_CMD_READ_ERP 0x2
41 32 #define EP1_CMD_READ_ANALOG 0x3
... ... @@ -129,6 +120,7 @@
129 120 };
130 121  
131 122 #define caiaqdev(c) ((struct snd_usb_caiaqdev*)(c)->private_data)
  123 +#define caiaqdev_to_dev(d) (d->chip.card->dev)
132 124  
133 125 int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev, int rate, int depth, int bbp);
134 126 int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *cdev, int digital, int analog, int erp);
sound/usb/caiaq/input.c
... ... @@ -16,6 +16,7 @@
16 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 17 */
18 18  
  19 +#include <linux/device.h>
19 20 #include <linux/gfp.h>
20 21 #include <linux/init.h>
21 22 #include <linux/usb.h>
... ... @@ -340,6 +341,8 @@
340 341 const unsigned char *buf,
341 342 unsigned int len)
342 343 {
  344 + struct device *dev = caiaqdev_to_dev(cdev);
  345 +
343 346 while (len) {
344 347 unsigned int i, block_id = (buf[0] << 8) | buf[1];
345 348  
... ... @@ -466,7 +469,7 @@
466 469 break;
467 470  
468 471 default:
469   - debug("%s(): bogus block (id %d)\n",
  472 + dev_dbg(dev, "%s(): bogus block (id %d)\n",
470 473 __func__, block_id);
471 474 return;
472 475 }
... ... @@ -500,6 +503,7 @@
500 503 static void snd_usb_caiaq_ep4_reply_dispatch(struct urb *urb)
501 504 {
502 505 struct snd_usb_caiaqdev *cdev = urb->context;
  506 + struct device *dev = caiaqdev_to_dev(cdev);
503 507 unsigned char *buf = urb->transfer_buffer;
504 508 int ret;
505 509  
... ... @@ -535,7 +539,7 @@
535 539 cdev->ep4_in_urb->actual_length = 0;
536 540 ret = usb_submit_urb(cdev->ep4_in_urb, GFP_ATOMIC);
537 541 if (ret < 0)
538   - log("unable to submit urb. OOM!?\n");
  542 + dev_err(dev, "unable to submit urb. OOM!?\n");
539 543 }
540 544  
541 545 static int snd_usb_caiaq_input_open(struct input_dev *idev)
sound/usb/caiaq/midi.c
... ... @@ -16,6 +16,7 @@
16 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 17 */
18 18  
  19 +#include <linux/device.h>
19 20 #include <linux/usb.h>
20 21 #include <linux/gfp.h>
21 22 #include <sound/rawmidi.h>
... ... @@ -65,6 +66,7 @@
65 66 struct snd_rawmidi_substream *substream)
66 67 {
67 68 int len, ret;
  69 + struct device *dev = caiaqdev_to_dev(cdev);
68 70  
69 71 cdev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
70 72 cdev->midi_out_buf[1] = 0; /* port */
... ... @@ -79,9 +81,9 @@
79 81  
80 82 ret = usb_submit_urb(&cdev->midi_out_urb, GFP_ATOMIC);
81 83 if (ret < 0)
82   - log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,"
83   - "ret=%d, len=%d\n",
84   - substream, ret, len);
  84 + dev_err(dev,
  85 + "snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,"
  86 + "ret=%d, len=%d\n", substream, ret, len);
85 87 else
86 88 cdev->midi_out_active = 1;
87 89 }