diff options
author | Takashi Iwai <tiwai@suse.de> | 2015-01-19 08:41:57 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-01-20 02:14:55 -0500 |
commit | b45a7c565473d29bd7e02ac8ca86232a24ca247f (patch) | |
tree | 91debcffbe4be26cd475406cb5496d546fc3af7f /sound/usb/line6 | |
parent | 075587b723ec5d90d1788b9cdba3034f524a64c9 (diff) |
ALSA: line6: Drop superfluous snd_device for PCM
Instead of handling the card-specific resource in snd_device, attach
it into pcm->private_data and release it directly in private_free.
This simplifies the code and structure.
Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/line6')
-rw-r--r-- | sound/usb/line6/pcm.c | 53 |
1 files changed, 19 insertions, 34 deletions
diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 626b6c158023..520cf540e83c 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c | |||
@@ -351,24 +351,21 @@ static void line6_cleanup_pcm(struct snd_pcm *pcm) | |||
351 | usb_free_urb(line6pcm->urb_audio_in[i]); | 351 | usb_free_urb(line6pcm->urb_audio_in[i]); |
352 | } | 352 | } |
353 | } | 353 | } |
354 | kfree(line6pcm); | ||
354 | } | 355 | } |
355 | 356 | ||
356 | /* create a PCM device */ | 357 | /* create a PCM device */ |
357 | static int snd_line6_new_pcm(struct snd_line6_pcm *line6pcm) | 358 | static int snd_line6_new_pcm(struct usb_line6 *line6, struct snd_pcm **pcm_ret) |
358 | { | 359 | { |
359 | struct snd_pcm *pcm; | 360 | struct snd_pcm *pcm; |
360 | int err; | 361 | int err; |
361 | 362 | ||
362 | err = snd_pcm_new(line6pcm->line6->card, | 363 | err = snd_pcm_new(line6->card, (char *)line6->properties->name, |
363 | (char *)line6pcm->line6->properties->name, | 364 | 0, 1, 1, pcm_ret); |
364 | 0, 1, 1, &pcm); | ||
365 | if (err < 0) | 365 | if (err < 0) |
366 | return err; | 366 | return err; |
367 | 367 | pcm = *pcm_ret; | |
368 | pcm->private_data = line6pcm; | 368 | strcpy(pcm->name, line6->properties->name); |
369 | pcm->private_free = line6_cleanup_pcm; | ||
370 | line6pcm->pcm = pcm; | ||
371 | strcpy(pcm->name, line6pcm->line6->properties->name); | ||
372 | 369 | ||
373 | /* set operators */ | 370 | /* set operators */ |
374 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, | 371 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, |
@@ -380,13 +377,6 @@ static int snd_line6_new_pcm(struct snd_line6_pcm *line6pcm) | |||
380 | snd_dma_continuous_data | 377 | snd_dma_continuous_data |
381 | (GFP_KERNEL), 64 * 1024, | 378 | (GFP_KERNEL), 64 * 1024, |
382 | 128 * 1024); | 379 | 128 * 1024); |
383 | |||
384 | return 0; | ||
385 | } | ||
386 | |||
387 | /* PCM device destructor */ | ||
388 | static int snd_line6_pcm_free(struct snd_device *device) | ||
389 | { | ||
390 | return 0; | 380 | return 0; |
391 | } | 381 | } |
392 | 382 | ||
@@ -423,23 +413,25 @@ EXPORT_SYMBOL_GPL(line6_pcm_disconnect); | |||
423 | int line6_init_pcm(struct usb_line6 *line6, | 413 | int line6_init_pcm(struct usb_line6 *line6, |
424 | struct line6_pcm_properties *properties) | 414 | struct line6_pcm_properties *properties) |
425 | { | 415 | { |
426 | static struct snd_device_ops pcm_ops = { | ||
427 | .dev_free = snd_line6_pcm_free, | ||
428 | }; | ||
429 | |||
430 | int i, err; | 416 | int i, err; |
431 | unsigned ep_read = line6->properties->ep_audio_r; | 417 | unsigned ep_read = line6->properties->ep_audio_r; |
432 | unsigned ep_write = line6->properties->ep_audio_w; | 418 | unsigned ep_write = line6->properties->ep_audio_w; |
419 | struct snd_pcm *pcm; | ||
433 | struct snd_line6_pcm *line6pcm; | 420 | struct snd_line6_pcm *line6pcm; |
434 | 421 | ||
435 | if (!(line6->properties->capabilities & LINE6_CAP_PCM)) | 422 | if (!(line6->properties->capabilities & LINE6_CAP_PCM)) |
436 | return 0; /* skip PCM initialization and report success */ | 423 | return 0; /* skip PCM initialization and report success */ |
437 | 424 | ||
438 | line6pcm = kzalloc(sizeof(*line6pcm), GFP_KERNEL); | 425 | err = snd_line6_new_pcm(line6, &pcm); |
426 | if (err < 0) | ||
427 | return err; | ||
439 | 428 | ||
440 | if (line6pcm == NULL) | 429 | line6pcm = kzalloc(sizeof(*line6pcm), GFP_KERNEL); |
430 | if (!line6pcm) | ||
441 | return -ENOMEM; | 431 | return -ENOMEM; |
442 | 432 | ||
433 | line6pcm->pcm = pcm; | ||
434 | line6pcm->properties = properties; | ||
443 | line6pcm->volume_playback[0] = line6pcm->volume_playback[1] = 255; | 435 | line6pcm->volume_playback[0] = line6pcm->volume_playback[1] = 255; |
444 | line6pcm->volume_monitor = 255; | 436 | line6pcm->volume_monitor = 255; |
445 | line6pcm->line6 = line6; | 437 | line6pcm->line6 = line6; |
@@ -451,23 +443,16 @@ int line6_init_pcm(struct usb_line6 *line6, | |||
451 | usb_maxpacket(line6->usbdev, | 443 | usb_maxpacket(line6->usbdev, |
452 | usb_sndisocpipe(line6->usbdev, ep_write), 1)); | 444 | usb_sndisocpipe(line6->usbdev, ep_write), 1)); |
453 | 445 | ||
454 | line6pcm->properties = properties; | ||
455 | line6->line6pcm = line6pcm; | ||
456 | |||
457 | /* PCM device: */ | ||
458 | err = snd_device_new(line6->card, SNDRV_DEV_PCM, line6, &pcm_ops); | ||
459 | if (err < 0) | ||
460 | return err; | ||
461 | |||
462 | err = snd_line6_new_pcm(line6pcm); | ||
463 | if (err < 0) | ||
464 | return err; | ||
465 | |||
466 | spin_lock_init(&line6pcm->lock_audio_out); | 446 | spin_lock_init(&line6pcm->lock_audio_out); |
467 | spin_lock_init(&line6pcm->lock_audio_in); | 447 | spin_lock_init(&line6pcm->lock_audio_in); |
468 | spin_lock_init(&line6pcm->lock_trigger); | 448 | spin_lock_init(&line6pcm->lock_trigger); |
469 | line6pcm->impulse_period = LINE6_IMPULSE_DEFAULT_PERIOD; | 449 | line6pcm->impulse_period = LINE6_IMPULSE_DEFAULT_PERIOD; |
470 | 450 | ||
451 | line6->line6pcm = line6pcm; | ||
452 | |||
453 | pcm->private_data = line6pcm; | ||
454 | pcm->private_free = line6_cleanup_pcm; | ||
455 | |||
471 | err = line6_create_audio_out_urbs(line6pcm); | 456 | err = line6_create_audio_out_urbs(line6pcm); |
472 | if (err < 0) | 457 | if (err < 0) |
473 | return err; | 458 | return err; |