diff options
Diffstat (limited to 'sound/drivers/dummy.c')
-rw-r--r-- | sound/drivers/dummy.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 4e4c69e6cb4c..e5e749f3e0ef 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c | |||
@@ -47,9 +47,11 @@ MODULE_SUPPORTED_DEVICE("{{ALSA,Dummy soundcard}}"); | |||
47 | static int emu10k1_playback_constraints(struct snd_pcm_runtime *runtime) | 47 | static int emu10k1_playback_constraints(struct snd_pcm_runtime *runtime) |
48 | { | 48 | { |
49 | int err; | 49 | int err; |
50 | if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) | 50 | err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); |
51 | if (err < 0) | ||
51 | return err; | 52 | return err; |
52 | if ((err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256, UINT_MAX)) < 0) | 53 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256, UINT_MAX); |
54 | if (err) < 0) | ||
53 | return err; | 55 | return err; |
54 | return 0; | 56 | return 0; |
55 | } | 57 | } |
@@ -354,6 +356,7 @@ static int snd_card_dummy_playback_open(struct snd_pcm_substream *substream) | |||
354 | if ((dpcm = new_pcm_stream(substream)) == NULL) | 356 | if ((dpcm = new_pcm_stream(substream)) == NULL) |
355 | return -ENOMEM; | 357 | return -ENOMEM; |
356 | runtime->private_data = dpcm; | 358 | runtime->private_data = dpcm; |
359 | /* makes the infrastructure responsible for freeing dpcm */ | ||
357 | runtime->private_free = snd_card_dummy_runtime_free; | 360 | runtime->private_free = snd_card_dummy_runtime_free; |
358 | runtime->hw = snd_card_dummy_playback; | 361 | runtime->hw = snd_card_dummy_playback; |
359 | if (substream->pcm->device & 1) { | 362 | if (substream->pcm->device & 1) { |
@@ -362,10 +365,9 @@ static int snd_card_dummy_playback_open(struct snd_pcm_substream *substream) | |||
362 | } | 365 | } |
363 | if (substream->pcm->device & 2) | 366 | if (substream->pcm->device & 2) |
364 | runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID); | 367 | runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID); |
365 | if ((err = add_playback_constraints(runtime)) < 0) { | 368 | err = add_playback_constraints(runtime); |
366 | kfree(dpcm); | 369 | if (err < 0) |
367 | return err; | 370 | return err; |
368 | } | ||
369 | 371 | ||
370 | return 0; | 372 | return 0; |
371 | } | 373 | } |
@@ -379,6 +381,7 @@ static int snd_card_dummy_capture_open(struct snd_pcm_substream *substream) | |||
379 | if ((dpcm = new_pcm_stream(substream)) == NULL) | 381 | if ((dpcm = new_pcm_stream(substream)) == NULL) |
380 | return -ENOMEM; | 382 | return -ENOMEM; |
381 | runtime->private_data = dpcm; | 383 | runtime->private_data = dpcm; |
384 | /* makes the infrastructure responsible for freeing dpcm */ | ||
382 | runtime->private_free = snd_card_dummy_runtime_free; | 385 | runtime->private_free = snd_card_dummy_runtime_free; |
383 | runtime->hw = snd_card_dummy_capture; | 386 | runtime->hw = snd_card_dummy_capture; |
384 | if (substream->pcm->device == 1) { | 387 | if (substream->pcm->device == 1) { |
@@ -387,10 +390,9 @@ static int snd_card_dummy_capture_open(struct snd_pcm_substream *substream) | |||
387 | } | 390 | } |
388 | if (substream->pcm->device & 2) | 391 | if (substream->pcm->device & 2) |
389 | runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID); | 392 | runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID); |
390 | if ((err = add_capture_constraints(runtime)) < 0) { | 393 | err = add_capture_constraints(runtime); |
391 | kfree(dpcm); | 394 | if (err < 0) |
392 | return err; | 395 | return err; |
393 | } | ||
394 | 396 | ||
395 | return 0; | 397 | return 0; |
396 | } | 398 | } |
@@ -433,8 +435,9 @@ static int __devinit snd_card_dummy_pcm(struct snd_dummy *dummy, int device, | |||
433 | struct snd_pcm *pcm; | 435 | struct snd_pcm *pcm; |
434 | int err; | 436 | int err; |
435 | 437 | ||
436 | if ((err = snd_pcm_new(dummy->card, "Dummy PCM", device, | 438 | err = snd_pcm_new(dummy->card, "Dummy PCM", device, |
437 | substreams, substreams, &pcm)) < 0) | 439 | substreams, substreams, &pcm); |
440 | if (err < 0) | ||
438 | return err; | 441 | return err; |
439 | dummy->pcm = pcm; | 442 | dummy->pcm = pcm; |
440 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_card_dummy_playback_ops); | 443 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_card_dummy_playback_ops); |
@@ -565,12 +568,14 @@ static int __devinit snd_card_dummy_new_mixer(struct snd_dummy *dummy) | |||
565 | unsigned int idx; | 568 | unsigned int idx; |
566 | int err; | 569 | int err; |
567 | 570 | ||
568 | snd_assert(dummy != NULL, return -EINVAL); | 571 | if (snd_BUG_ON(!dummy)) |
572 | return -EINVAL; | ||
569 | spin_lock_init(&dummy->mixer_lock); | 573 | spin_lock_init(&dummy->mixer_lock); |
570 | strcpy(card->mixername, "Dummy Mixer"); | 574 | strcpy(card->mixername, "Dummy Mixer"); |
571 | 575 | ||
572 | for (idx = 0; idx < ARRAY_SIZE(snd_dummy_controls); idx++) { | 576 | for (idx = 0; idx < ARRAY_SIZE(snd_dummy_controls); idx++) { |
573 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_dummy_controls[idx], dummy))) < 0) | 577 | err = snd_ctl_add(card, snd_ctl_new1(&snd_dummy_controls[idx], dummy)); |
578 | if (err < 0) | ||
574 | return err; | 579 | return err; |
575 | } | 580 | } |
576 | return 0; | 581 | return 0; |
@@ -594,10 +599,12 @@ static int __devinit snd_dummy_probe(struct platform_device *devptr) | |||
594 | pcm_substreams[dev] = 1; | 599 | pcm_substreams[dev] = 1; |
595 | if (pcm_substreams[dev] > MAX_PCM_SUBSTREAMS) | 600 | if (pcm_substreams[dev] > MAX_PCM_SUBSTREAMS) |
596 | pcm_substreams[dev] = MAX_PCM_SUBSTREAMS; | 601 | pcm_substreams[dev] = MAX_PCM_SUBSTREAMS; |
597 | if ((err = snd_card_dummy_pcm(dummy, idx, pcm_substreams[dev])) < 0) | 602 | err = snd_card_dummy_pcm(dummy, idx, pcm_substreams[dev]); |
603 | if (err < 0) | ||
598 | goto __nodev; | 604 | goto __nodev; |
599 | } | 605 | } |
600 | if ((err = snd_card_dummy_new_mixer(dummy)) < 0) | 606 | err = snd_card_dummy_new_mixer(dummy); |
607 | if (err < 0) | ||
601 | goto __nodev; | 608 | goto __nodev; |
602 | strcpy(card->driver, "Dummy"); | 609 | strcpy(card->driver, "Dummy"); |
603 | strcpy(card->shortname, "Dummy"); | 610 | strcpy(card->shortname, "Dummy"); |
@@ -605,7 +612,8 @@ static int __devinit snd_dummy_probe(struct platform_device *devptr) | |||
605 | 612 | ||
606 | snd_card_set_dev(card, &devptr->dev); | 613 | snd_card_set_dev(card, &devptr->dev); |
607 | 614 | ||
608 | if ((err = snd_card_register(card)) == 0) { | 615 | err = snd_card_register(card); |
616 | if (err == 0) { | ||
609 | platform_set_drvdata(devptr, card); | 617 | platform_set_drvdata(devptr, card); |
610 | return 0; | 618 | return 0; |
611 | } | 619 | } |
@@ -668,7 +676,8 @@ static int __init alsa_card_dummy_init(void) | |||
668 | { | 676 | { |
669 | int i, cards, err; | 677 | int i, cards, err; |
670 | 678 | ||
671 | if ((err = platform_driver_register(&snd_dummy_driver)) < 0) | 679 | err = platform_driver_register(&snd_dummy_driver); |
680 | if (err < 0) | ||
672 | return err; | 681 | return err; |
673 | 682 | ||
674 | cards = 0; | 683 | cards = 0; |