aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb
diff options
context:
space:
mode:
authorDaniel Mack <zonque@gmail.com>2013-03-03 14:46:22 -0500
committerTakashi Iwai <tiwai@suse.de>2013-03-04 03:57:26 -0500
commitf1f6b8f65ff08afed4532b88de1a3bbea773787f (patch)
tree239b592c8d087738c05d0ebe1d192330d4fa69db /sound/usb
parent1c8470ce311c6b2b49a71a02961c360d04ed28b2 (diff)
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>
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/caiaq/audio.c61
-rw-r--r--sound/usb/caiaq/control.c1
-rw-r--r--sound/usb/caiaq/device.c42
-rw-r--r--sound/usb/caiaq/device.h10
-rw-r--r--sound/usb/caiaq/input.c8
-rw-r--r--sound/usb/caiaq/midi.c9
6 files changed, 75 insertions, 56 deletions
diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c
index 75d8ba9143f6..67330af21b0e 100644
--- a/sound/usb/caiaq/audio.c
+++ b/sound/usb/caiaq/audio.c
@@ -16,6 +16,7 @@
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/ 17*/
18 18
19#include <linux/device.h>
19#include <linux/spinlock.h> 20#include <linux/spinlock.h>
20#include <linux/slab.h> 21#include <linux/slab.h>
21#include <linux/init.h> 22#include <linux/init.h>
@@ -101,8 +102,9 @@ all_substreams_zero(struct snd_pcm_substream **subs)
101static int stream_start(struct snd_usb_caiaqdev *cdev) 102static int stream_start(struct snd_usb_caiaqdev *cdev)
102{ 103{
103 int i, ret; 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 if (cdev->streaming) 109 if (cdev->streaming)
108 return -EINVAL; 110 return -EINVAL;
@@ -118,7 +120,8 @@ static int stream_start(struct snd_usb_caiaqdev *cdev)
118 for (i = 0; i < N_URBS; i++) { 120 for (i = 0; i < N_URBS; i++) {
119 ret = usb_submit_urb(cdev->data_urbs_in[i], GFP_ATOMIC); 121 ret = usb_submit_urb(cdev->data_urbs_in[i], GFP_ATOMIC);
120 if (ret) { 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 cdev->streaming = 0; 125 cdev->streaming = 0;
123 return -EPIPE; 126 return -EPIPE;
124 } 127 }
@@ -130,8 +133,9 @@ static int stream_start(struct snd_usb_caiaqdev *cdev)
130static void stream_stop(struct snd_usb_caiaqdev *cdev) 133static void stream_stop(struct snd_usb_caiaqdev *cdev)
131{ 134{
132 int i; 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 if (!cdev->streaming) 139 if (!cdev->streaming)
136 return; 140 return;
137 141
@@ -150,17 +154,21 @@ static void stream_stop(struct snd_usb_caiaqdev *cdev)
150static int snd_usb_caiaq_substream_open(struct snd_pcm_substream *substream) 154static int snd_usb_caiaq_substream_open(struct snd_pcm_substream *substream)
151{ 155{
152 struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream); 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 substream->runtime->hw = cdev->pcm_info; 160 substream->runtime->hw = cdev->pcm_info;
155 snd_pcm_limit_hw_rates(substream->runtime); 161 snd_pcm_limit_hw_rates(substream->runtime);
162
156 return 0; 163 return 0;
157} 164}
158 165
159static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream) 166static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream)
160{ 167{
161 struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream); 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 if (all_substreams_zero(cdev->sub_playback) && 172 if (all_substreams_zero(cdev->sub_playback) &&
165 all_substreams_zero(cdev->sub_capture)) { 173 all_substreams_zero(cdev->sub_capture)) {
166 /* when the last client has stopped streaming, 174 /* when the last client has stopped streaming,
@@ -175,14 +183,12 @@ static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream)
175static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub, 183static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub,
176 struct snd_pcm_hw_params *hw_params) 184 struct snd_pcm_hw_params *hw_params)
177{ 185{
178 debug("%s(%p)\n", __func__, sub);
179 return snd_pcm_lib_malloc_pages(sub, params_buffer_bytes(hw_params)); 186 return snd_pcm_lib_malloc_pages(sub, params_buffer_bytes(hw_params));
180} 187}
181 188
182static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub) 189static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub)
183{ 190{
184 struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub); 191 struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub);
185 debug("%s(%p)\n", __func__, sub);
186 deactivate_substream(cdev, sub); 192 deactivate_substream(cdev, sub);
187 return snd_pcm_lib_free_pages(sub); 193 return snd_pcm_lib_free_pages(sub);
188} 194}
@@ -201,8 +207,9 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
201 int index = substream->number; 207 int index = substream->number;
202 struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream); 208 struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream);
203 struct snd_pcm_runtime *runtime = substream->runtime; 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 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 214 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
208 int out_pos; 215 int out_pos;
@@ -283,8 +290,9 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
283static int snd_usb_caiaq_pcm_trigger(struct snd_pcm_substream *sub, int cmd) 290static int snd_usb_caiaq_pcm_trigger(struct snd_pcm_substream *sub, int cmd)
284{ 291{
285 struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub); 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 switch (cmd) { 297 switch (cmd) {
290 case SNDRV_PCM_TRIGGER_START: 298 case SNDRV_PCM_TRIGGER_START:
@@ -443,6 +451,7 @@ static void read_in_urb_mode3(struct snd_usb_caiaqdev *cdev,
443 const struct usb_iso_packet_descriptor *iso) 451 const struct usb_iso_packet_descriptor *iso)
444{ 452{
445 unsigned char *usb_buf = urb->transfer_buffer + iso->offset; 453 unsigned char *usb_buf = urb->transfer_buffer + iso->offset;
454 struct device *dev = caiaqdev_to_dev(cdev);
446 int stream, i; 455 int stream, i;
447 456
448 /* paranoia check */ 457 /* paranoia check */
@@ -479,8 +488,8 @@ static void read_in_urb_mode3(struct snd_usb_caiaqdev *cdev,
479 if (usb_buf[i] != ((stream << 1) | c) && 488 if (usb_buf[i] != ((stream << 1) | c) &&
480 !cdev->first_packet) { 489 !cdev->first_packet) {
481 if (!cdev->input_panic) 490 if (!cdev->input_panic)
482 printk(" EXPECTED: %02x got %02x, c %d, stream %d, i %d\n", 491 dev_warn(dev, " EXPECTED: %02x got %02x, c %d, stream %d, i %d\n",
483 ((stream << 1) | c), usb_buf[i], c, stream, i); 492 ((stream << 1) | c), usb_buf[i], c, stream, i);
484 cdev->input_panic = 1; 493 cdev->input_panic = 1;
485 } 494 }
486 495
@@ -497,6 +506,8 @@ static void read_in_urb(struct snd_usb_caiaqdev *cdev,
497 const struct urb *urb, 506 const struct urb *urb,
498 const struct usb_iso_packet_descriptor *iso) 507 const struct usb_iso_packet_descriptor *iso)
499{ 508{
509 struct device *dev = caiaqdev_to_dev(cdev);
510
500 if (!cdev->streaming) 511 if (!cdev->streaming)
501 return; 512 return;
502 513
@@ -516,7 +527,7 @@ static void read_in_urb(struct snd_usb_caiaqdev *cdev,
516 } 527 }
517 528
518 if ((cdev->input_panic || cdev->output_panic) && !cdev->warned) { 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 cdev->input_panic ? "(input)" : "", 531 cdev->input_panic ? "(input)" : "",
521 cdev->output_panic ? "(output)" : ""); 532 cdev->output_panic ? "(output)" : "");
522 cdev->warned = 1; 533 cdev->warned = 1;
@@ -619,6 +630,7 @@ static void read_completed(struct urb *urb)
619{ 630{
620 struct snd_usb_caiaq_cb_info *info = urb->context; 631 struct snd_usb_caiaq_cb_info *info = urb->context;
621 struct snd_usb_caiaqdev *cdev; 632 struct snd_usb_caiaqdev *cdev;
633 struct device *dev;
622 struct urb *out = NULL; 634 struct urb *out = NULL;
623 int i, frame, len, send_it = 0, outframe = 0; 635 int i, frame, len, send_it = 0, outframe = 0;
624 size_t offset = 0; 636 size_t offset = 0;
@@ -627,6 +639,7 @@ static void read_completed(struct urb *urb)
627 return; 639 return;
628 640
629 cdev = info->cdev; 641 cdev = info->cdev;
642 dev = caiaqdev_to_dev(cdev);
630 643
631 if (!cdev->streaming) 644 if (!cdev->streaming)
632 return; 645 return;
@@ -639,7 +652,7 @@ static void read_completed(struct urb *urb)
639 } 652 }
640 653
641 if (!out) { 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 goto requeue; 656 goto requeue;
644 } 657 }
645 658
@@ -708,6 +721,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret)
708 int i, frame; 721 int i, frame;
709 struct urb **urbs; 722 struct urb **urbs;
710 struct usb_device *usb_dev = cdev->chip.dev; 723 struct usb_device *usb_dev = cdev->chip.dev;
724 struct device *dev = caiaqdev_to_dev(cdev);
711 unsigned int pipe; 725 unsigned int pipe;
712 726
713 pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ? 727 pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ?
@@ -716,7 +730,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret)
716 730
717 urbs = kmalloc(N_URBS * sizeof(*urbs), GFP_KERNEL); 731 urbs = kmalloc(N_URBS * sizeof(*urbs), GFP_KERNEL);
718 if (!urbs) { 732 if (!urbs) {
719 log("unable to kmalloc() urbs, OOM!?\n"); 733 dev_err(dev, "unable to kmalloc() urbs, OOM!?\n");
720 *ret = -ENOMEM; 734 *ret = -ENOMEM;
721 return NULL; 735 return NULL;
722 } 736 }
@@ -724,7 +738,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret)
724 for (i = 0; i < N_URBS; i++) { 738 for (i = 0; i < N_URBS; i++) {
725 urbs[i] = usb_alloc_urb(FRAMES_PER_URB, GFP_KERNEL); 739 urbs[i] = usb_alloc_urb(FRAMES_PER_URB, GFP_KERNEL);
726 if (!urbs[i]) { 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 *ret = -ENOMEM; 742 *ret = -ENOMEM;
729 return urbs; 743 return urbs;
730 } 744 }
@@ -732,7 +746,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret)
732 urbs[i]->transfer_buffer = 746 urbs[i]->transfer_buffer =
733 kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL); 747 kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL);
734 if (!urbs[i]->transfer_buffer) { 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 *ret = -ENOMEM; 750 *ret = -ENOMEM;
737 return urbs; 751 return urbs;
738 } 752 }
@@ -783,6 +797,7 @@ static void free_urbs(struct urb **urbs)
783int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev) 797int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev)
784{ 798{
785 int i, ret; 799 int i, ret;
800 struct device *dev = caiaqdev_to_dev(cdev);
786 801
787 cdev->n_audio_in = max(cdev->spec.num_analog_audio_in, 802 cdev->n_audio_in = max(cdev->spec.num_analog_audio_in,
788 cdev->spec.num_digital_audio_in) / 803 cdev->spec.num_digital_audio_in) /
@@ -792,12 +807,12 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev)
792 CHANNELS_PER_STREAM; 807 CHANNELS_PER_STREAM;
793 cdev->n_streams = max(cdev->n_audio_in, cdev->n_audio_out); 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); 810 dev_dbg(dev, "cdev->n_audio_in = %d\n", cdev->n_audio_in);
796 debug("cdev->n_audio_out = %d\n", cdev->n_audio_out); 811 dev_dbg(dev, "cdev->n_audio_out = %d\n", cdev->n_audio_out);
797 debug("cdev->n_streams = %d\n", cdev->n_streams); 812 dev_dbg(dev, "cdev->n_streams = %d\n", cdev->n_streams);
798 813
799 if (cdev->n_streams > MAX_STREAMS) { 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 return -EINVAL; 816 return -EINVAL;
802 } 817 }
803 818
@@ -805,7 +820,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev)
805 cdev->n_audio_out, cdev->n_audio_in, &cdev->pcm); 820 cdev->n_audio_out, cdev->n_audio_in, &cdev->pcm);
806 821
807 if (ret < 0) { 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 return ret; 824 return ret;
810 } 825 }
811 826
@@ -880,7 +895,9 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev)
880 895
881void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *cdev) 896void 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 stream_stop(cdev); 901 stream_stop(cdev);
885 free_urbs(cdev->data_urbs_in); 902 free_urbs(cdev->data_urbs_in);
886 free_urbs(cdev->data_urbs_out); 903 free_urbs(cdev->data_urbs_out);
diff --git a/sound/usb/caiaq/control.c b/sound/usb/caiaq/control.c
index 2c5195948b2c..ae6b50f9ed56 100644
--- a/sound/usb/caiaq/control.c
+++ b/sound/usb/caiaq/control.c
@@ -17,6 +17,7 @@
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 18 */
19 19
20#include <linux/device.h>
20#include <linux/init.h> 21#include <linux/init.h>
21#include <linux/usb.h> 22#include <linux/usb.h>
22#include <sound/control.h> 23#include <sound/control.h>
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
index 45c3853b2a65..d898f737c07e 100644
--- a/sound/usb/caiaq/device.c
+++ b/sound/usb/caiaq/device.c
@@ -20,6 +20,7 @@
20*/ 20*/
21 21
22#include <linux/moduleparam.h> 22#include <linux/moduleparam.h>
23#include <linux/device.h>
23#include <linux/interrupt.h> 24#include <linux/interrupt.h>
24#include <linux/module.h> 25#include <linux/module.h>
25#include <linux/init.h> 26#include <linux/init.h>
@@ -159,10 +160,11 @@ static void usb_ep1_command_reply_dispatch (struct urb* urb)
159{ 160{
160 int ret; 161 int ret;
161 struct snd_usb_caiaqdev *cdev = urb->context; 162 struct snd_usb_caiaqdev *cdev = urb->context;
163 struct device *dev = caiaqdev_to_dev(cdev);
162 unsigned char *buf = urb->transfer_buffer; 164 unsigned char *buf = urb->transfer_buffer;
163 165
164 if (urb->status || !cdev) { 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 return; 168 return;
167 } 169 }
168 170
@@ -170,7 +172,7 @@ static void usb_ep1_command_reply_dispatch (struct urb* urb)
170 case EP1_CMD_GET_DEVICE_INFO: 172 case EP1_CMD_GET_DEVICE_INFO:
171 memcpy(&cdev->spec, buf+1, sizeof(struct caiaq_device_spec)); 173 memcpy(&cdev->spec, buf+1, sizeof(struct caiaq_device_spec));
172 cdev->spec.fw_version = le16_to_cpu(cdev->spec.fw_version); 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 "MIDI: %d in, %d out, data alignment %d\n", 176 "MIDI: %d in, %d out, data alignment %d\n",
175 cdev->spec.fw_version, 177 cdev->spec.fw_version,
176 cdev->spec.num_analog_audio_in, 178 cdev->spec.num_analog_audio_in,
@@ -209,7 +211,7 @@ static void usb_ep1_command_reply_dispatch (struct urb* urb)
209 cdev->ep1_in_urb.actual_length = 0; 211 cdev->ep1_in_urb.actual_length = 0;
210 ret = usb_submit_urb(&cdev->ep1_in_urb, GFP_ATOMIC); 212 ret = usb_submit_urb(&cdev->ep1_in_urb, GFP_ATOMIC);
211 if (ret < 0) 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
215int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev, 217int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev,
@@ -239,6 +241,7 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev,
239{ 241{
240 int ret; 242 int ret;
241 char tmp[5]; 243 char tmp[5];
244 struct device *dev = caiaqdev_to_dev(cdev);
242 245
243 switch (rate) { 246 switch (rate) {
244 case 44100: tmp[0] = SAMPLERATE_44100; break; 247 case 44100: tmp[0] = SAMPLERATE_44100; break;
@@ -259,7 +262,7 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev,
259 tmp[3] = bpp >> 8; 262 tmp[3] = bpp >> 8;
260 tmp[4] = 1; /* packets per microframe */ 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 rate, depth, bpp); 266 rate, depth, bpp);
264 267
265 cdev->audio_parm_answer = -1; 268 cdev->audio_parm_answer = -1;
@@ -274,7 +277,7 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev,
274 return -EPIPE; 277 return -EPIPE;
275 278
276 if (cdev->audio_parm_answer != 1) 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 else 281 else
279 cdev->bpp = bpp; 282 cdev->bpp = bpp;
280 283
@@ -293,6 +296,7 @@ static void setup_card(struct snd_usb_caiaqdev *cdev)
293{ 296{
294 int ret; 297 int ret;
295 char val[4]; 298 char val[4];
299 struct device *dev = caiaqdev_to_dev(cdev);
296 300
297 /* device-specific startup specials */ 301 /* device-specific startup specials */
298 switch (cdev->chip.usb_id) { 302 switch (cdev->chip.usb_id) {
@@ -346,32 +350,32 @@ static void setup_card(struct snd_usb_caiaqdev *cdev)
346 cdev->spec.num_digital_audio_in > 0) { 350 cdev->spec.num_digital_audio_in > 0) {
347 ret = snd_usb_caiaq_audio_init(cdev); 351 ret = snd_usb_caiaq_audio_init(cdev);
348 if (ret < 0) 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 if (cdev->spec.num_midi_in + 356 if (cdev->spec.num_midi_in +
353 cdev->spec.num_midi_out > 0) { 357 cdev->spec.num_midi_out > 0) {
354 ret = snd_usb_caiaq_midi_init(cdev); 358 ret = snd_usb_caiaq_midi_init(cdev);
355 if (ret < 0) 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#ifdef CONFIG_SND_USB_CAIAQ_INPUT 363#ifdef CONFIG_SND_USB_CAIAQ_INPUT
360 ret = snd_usb_caiaq_input_init(cdev); 364 ret = snd_usb_caiaq_input_init(cdev);
361 if (ret < 0) 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#endif 367#endif
364 368
365 /* finally, register the card and all its sub-instances */ 369 /* finally, register the card and all its sub-instances */
366 ret = snd_card_register(cdev->chip.card); 370 ret = snd_card_register(cdev->chip.card);
367 if (ret < 0) { 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 snd_card_free(cdev->chip.card); 373 snd_card_free(cdev->chip.card);
370 } 374 }
371 375
372 ret = snd_usb_caiaq_control_init(cdev); 376 ret = snd_usb_caiaq_control_init(cdev);
373 if (ret < 0) 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
377static int create_card(struct usb_device *usb_dev, 381static int create_card(struct usb_device *usb_dev,
@@ -412,10 +416,11 @@ static int init_card(struct snd_usb_caiaqdev *cdev)
412 char *c, usbpath[32]; 416 char *c, usbpath[32];
413 struct usb_device *usb_dev = cdev->chip.dev; 417 struct usb_device *usb_dev = cdev->chip.dev;
414 struct snd_card *card = cdev->chip.card; 418 struct snd_card *card = cdev->chip.card;
419 struct device *dev = caiaqdev_to_dev(cdev);
415 int err, len; 420 int err, len;
416 421
417 if (usb_set_interface(usb_dev, 0, 1) != 0) { 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 return -EIO; 424 return -EIO;
420 } 425 }
421 426
@@ -473,8 +478,7 @@ static int init_card(struct snd_usb_caiaqdev *cdev)
473 } 478 }
474 479
475 usb_make_path(usb_dev, usbpath, sizeof(usbpath)); 480 usb_make_path(usb_dev, usbpath, sizeof(usbpath));
476 snprintf(card->longname, sizeof(card->longname), 481 snprintf(card->longname, sizeof(card->longname), "%s %s (%s)",
477 "%s %s (%s)",
478 cdev->vendor_name, cdev->product_name, usbpath); 482 cdev->vendor_name, cdev->product_name, usbpath);
479 483
480 setup_card(cdev); 484 setup_card(cdev);
@@ -496,7 +500,7 @@ static int snd_probe(struct usb_interface *intf,
496 usb_set_intfdata(intf, card); 500 usb_set_intfdata(intf, card);
497 ret = init_card(caiaqdev(card)); 501 ret = init_card(caiaqdev(card));
498 if (ret < 0) { 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 snd_card_free(card); 504 snd_card_free(card);
501 return ret; 505 return ret;
502 } 506 }
@@ -506,15 +510,16 @@ static int snd_probe(struct usb_interface *intf,
506 510
507static void snd_disconnect(struct usb_interface *intf) 511static void snd_disconnect(struct usb_interface *intf)
508{ 512{
509 struct snd_usb_caiaqdev *cdev;
510 struct snd_card *card = usb_get_intfdata(intf); 513 struct snd_card *card = usb_get_intfdata(intf);
511 514 struct snd_usb_caiaqdev *cdev = caiaqdev(card);
512 debug("%s(%p)\n", __func__, intf); 515 struct device *dev;
513 516
514 if (!card) 517 if (!card)
515 return; 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 snd_card_disconnect(card); 523 snd_card_disconnect(card);
519 524
520#ifdef CONFIG_SND_USB_CAIAQ_INPUT 525#ifdef CONFIG_SND_USB_CAIAQ_INPUT
@@ -539,4 +544,3 @@ static struct usb_driver snd_usb_driver = {
539}; 544};
540 545
541module_usb_driver(snd_usb_driver); 546module_usb_driver(snd_usb_driver);
542
diff --git a/sound/usb/caiaq/device.h b/sound/usb/caiaq/device.h
index 7176a0ec950b..ad102fac6942 100644
--- a/sound/usb/caiaq/device.h
+++ b/sound/usb/caiaq/device.h
@@ -25,16 +25,7 @@
25#define CAIAQ_USB_STR_LEN 0xff 25#define CAIAQ_USB_STR_LEN 0xff
26#define MAX_STREAMS 32 26#define MAX_STREAMS 32
27 27
28//#define SND_USB_CAIAQ_DEBUG
29
30#define MODNAME "snd-usb-caiaq" 28#define MODNAME "snd-usb-caiaq"
31#define log(x...) snd_printk(KERN_WARNING MODNAME" log: " x)
32
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 29
39#define EP1_CMD_GET_DEVICE_INFO 0x1 30#define EP1_CMD_GET_DEVICE_INFO 0x1
40#define EP1_CMD_READ_ERP 0x2 31#define EP1_CMD_READ_ERP 0x2
@@ -129,6 +120,7 @@ struct snd_usb_caiaq_cb_info {
129}; 120};
130 121
131#define caiaqdev(c) ((struct snd_usb_caiaqdev*)(c)->private_data) 122#define caiaqdev(c) ((struct snd_usb_caiaqdev*)(c)->private_data)
123#define caiaqdev_to_dev(d) (d->chip.card->dev)
132 124
133int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev, int rate, int depth, int bbp); 125int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev, int rate, int depth, int bbp);
134int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *cdev, int digital, int analog, int erp); 126int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *cdev, int digital, int analog, int erp);
diff --git a/sound/usb/caiaq/input.c b/sound/usb/caiaq/input.c
index a32ad7cd76f9..fe8f4b4fd369 100644
--- a/sound/usb/caiaq/input.c
+++ b/sound/usb/caiaq/input.c
@@ -16,6 +16,7 @@
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/ 17*/
18 18
19#include <linux/device.h>
19#include <linux/gfp.h> 20#include <linux/gfp.h>
20#include <linux/init.h> 21#include <linux/init.h>
21#include <linux/usb.h> 22#include <linux/usb.h>
@@ -340,6 +341,8 @@ static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *cdev,
340 const unsigned char *buf, 341 const unsigned char *buf,
341 unsigned int len) 342 unsigned int len)
342{ 343{
344 struct device *dev = caiaqdev_to_dev(cdev);
345
343 while (len) { 346 while (len) {
344 unsigned int i, block_id = (buf[0] << 8) | buf[1]; 347 unsigned int i, block_id = (buf[0] << 8) | buf[1];
345 348
@@ -466,7 +469,7 @@ static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *cdev,
466 break; 469 break;
467 470
468 default: 471 default:
469 debug("%s(): bogus block (id %d)\n", 472 dev_dbg(dev, "%s(): bogus block (id %d)\n",
470 __func__, block_id); 473 __func__, block_id);
471 return; 474 return;
472 } 475 }
@@ -500,6 +503,7 @@ static void snd_usb_caiaq_maschine_dispatch(struct snd_usb_caiaqdev *cdev,
500static void snd_usb_caiaq_ep4_reply_dispatch(struct urb *urb) 503static void snd_usb_caiaq_ep4_reply_dispatch(struct urb *urb)
501{ 504{
502 struct snd_usb_caiaqdev *cdev = urb->context; 505 struct snd_usb_caiaqdev *cdev = urb->context;
506 struct device *dev = caiaqdev_to_dev(cdev);
503 unsigned char *buf = urb->transfer_buffer; 507 unsigned char *buf = urb->transfer_buffer;
504 int ret; 508 int ret;
505 509
@@ -535,7 +539,7 @@ requeue:
535 cdev->ep4_in_urb->actual_length = 0; 539 cdev->ep4_in_urb->actual_length = 0;
536 ret = usb_submit_urb(cdev->ep4_in_urb, GFP_ATOMIC); 540 ret = usb_submit_urb(cdev->ep4_in_urb, GFP_ATOMIC);
537 if (ret < 0) 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
541static int snd_usb_caiaq_input_open(struct input_dev *idev) 545static int snd_usb_caiaq_input_open(struct input_dev *idev)
diff --git a/sound/usb/caiaq/midi.c b/sound/usb/caiaq/midi.c
index 63c5a2caa0ad..2d7588461b33 100644
--- a/sound/usb/caiaq/midi.c
+++ b/sound/usb/caiaq/midi.c
@@ -16,6 +16,7 @@
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/ 17*/
18 18
19#include <linux/device.h>
19#include <linux/usb.h> 20#include <linux/usb.h>
20#include <linux/gfp.h> 21#include <linux/gfp.h>
21#include <sound/rawmidi.h> 22#include <sound/rawmidi.h>
@@ -65,6 +66,7 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *cdev,
65 struct snd_rawmidi_substream *substream) 66 struct snd_rawmidi_substream *substream)
66{ 67{
67 int len, ret; 68 int len, ret;
69 struct device *dev = caiaqdev_to_dev(cdev);
68 70
69 cdev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE; 71 cdev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
70 cdev->midi_out_buf[1] = 0; /* port */ 72 cdev->midi_out_buf[1] = 0; /* port */
@@ -79,9 +81,9 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *cdev,
79 81
80 ret = usb_submit_urb(&cdev->midi_out_urb, GFP_ATOMIC); 82 ret = usb_submit_urb(&cdev->midi_out_urb, GFP_ATOMIC);
81 if (ret < 0) 83 if (ret < 0)
82 log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed," 84 dev_err(dev,
83 "ret=%d, len=%d\n", 85 "snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,"
84 substream, ret, len); 86 "ret=%d, len=%d\n", substream, ret, len);
85 else 87 else
86 cdev->midi_out_active = 1; 88 cdev->midi_out_active = 1;
87} 89}
@@ -171,4 +173,3 @@ void snd_usb_caiaq_midi_output_done(struct urb* urb)
171 173
172 snd_usb_caiaq_midi_send(cdev, cdev->midi_out_substream); 174 snd_usb_caiaq_midi_send(cdev, cdev->midi_out_substream);
173} 175}
174