aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/pcm_native.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-08-08 11:09:09 -0400
committerJaroslav Kysela <perex@perex.cz>2008-08-13 05:46:35 -0400
commit7eaa943c8ed8e91e05d0f5d0dc7a18e3319b45cf (patch)
tree51d86a4cb01cf5735b18c36ca62471f8c759a041 /sound/core/pcm_native.c
parent5ef03460a6ffc1d3ee6b6f2abc6765d3e224cf89 (diff)
ALSA: Kill snd_assert() in sound/core/*
Kill snd_assert() in sound/core/*, either removed or replaced with if () with snd_BUG_ON(). Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/core/pcm_native.c')
-rw-r--r--sound/core/pcm_native.c127
1 files changed, 64 insertions, 63 deletions
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index c487025d3457..df2299a8cefd 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -95,7 +95,6 @@ int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info)
95 struct snd_pcm *pcm = substream->pcm; 95 struct snd_pcm *pcm = substream->pcm;
96 struct snd_pcm_str *pstr = substream->pstr; 96 struct snd_pcm_str *pstr = substream->pstr;
97 97
98 snd_assert(substream != NULL, return -ENXIO);
99 memset(info, 0, sizeof(*info)); 98 memset(info, 0, sizeof(*info));
100 info->card = pcm->card->number; 99 info->card = pcm->card->number;
101 info->device = pcm->device; 100 info->device = pcm->device;
@@ -370,9 +369,9 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
370 unsigned int bits; 369 unsigned int bits;
371 snd_pcm_uframes_t frames; 370 snd_pcm_uframes_t frames;
372 371
373 snd_assert(substream != NULL, return -ENXIO); 372 if (PCM_RUNTIME_CHECK(substream))
373 return -ENXIO;
374 runtime = substream->runtime; 374 runtime = substream->runtime;
375 snd_assert(runtime != NULL, return -ENXIO);
376 snd_pcm_stream_lock_irq(substream); 375 snd_pcm_stream_lock_irq(substream);
377 switch (runtime->status->state) { 376 switch (runtime->status->state) {
378 case SNDRV_PCM_STATE_OPEN: 377 case SNDRV_PCM_STATE_OPEN:
@@ -490,9 +489,9 @@ static int snd_pcm_hw_free(struct snd_pcm_substream *substream)
490 struct snd_pcm_runtime *runtime; 489 struct snd_pcm_runtime *runtime;
491 int result = 0; 490 int result = 0;
492 491
493 snd_assert(substream != NULL, return -ENXIO); 492 if (PCM_RUNTIME_CHECK(substream))
493 return -ENXIO;
494 runtime = substream->runtime; 494 runtime = substream->runtime;
495 snd_assert(runtime != NULL, return -ENXIO);
496 snd_pcm_stream_lock_irq(substream); 495 snd_pcm_stream_lock_irq(substream);
497 switch (runtime->status->state) { 496 switch (runtime->status->state) {
498 case SNDRV_PCM_STATE_SETUP: 497 case SNDRV_PCM_STATE_SETUP:
@@ -518,9 +517,9 @@ static int snd_pcm_sw_params(struct snd_pcm_substream *substream,
518{ 517{
519 struct snd_pcm_runtime *runtime; 518 struct snd_pcm_runtime *runtime;
520 519
521 snd_assert(substream != NULL, return -ENXIO); 520 if (PCM_RUNTIME_CHECK(substream))
521 return -ENXIO;
522 runtime = substream->runtime; 522 runtime = substream->runtime;
523 snd_assert(runtime != NULL, return -ENXIO);
524 snd_pcm_stream_lock_irq(substream); 523 snd_pcm_stream_lock_irq(substream);
525 if (runtime->status->state == SNDRV_PCM_STATE_OPEN) { 524 if (runtime->status->state == SNDRV_PCM_STATE_OPEN) {
526 snd_pcm_stream_unlock_irq(substream); 525 snd_pcm_stream_unlock_irq(substream);
@@ -622,11 +621,8 @@ static int snd_pcm_status_user(struct snd_pcm_substream *substream,
622 struct snd_pcm_status __user * _status) 621 struct snd_pcm_status __user * _status)
623{ 622{
624 struct snd_pcm_status status; 623 struct snd_pcm_status status;
625 struct snd_pcm_runtime *runtime;
626 int res; 624 int res;
627 625
628 snd_assert(substream != NULL, return -ENXIO);
629 runtime = substream->runtime;
630 memset(&status, 0, sizeof(status)); 626 memset(&status, 0, sizeof(status));
631 res = snd_pcm_status(substream, &status); 627 res = snd_pcm_status(substream, &status);
632 if (res < 0) 628 if (res < 0)
@@ -642,7 +638,6 @@ static int snd_pcm_channel_info(struct snd_pcm_substream *substream,
642 struct snd_pcm_runtime *runtime; 638 struct snd_pcm_runtime *runtime;
643 unsigned int channel; 639 unsigned int channel;
644 640
645 snd_assert(substream != NULL, return -ENXIO);
646 channel = info->channel; 641 channel = info->channel;
647 runtime = substream->runtime; 642 runtime = substream->runtime;
648 snd_pcm_stream_lock_irq(substream); 643 snd_pcm_stream_lock_irq(substream);
@@ -1250,7 +1245,6 @@ static int snd_pcm_do_reset(struct snd_pcm_substream *substream, int state)
1250 int err = substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); 1245 int err = substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL);
1251 if (err < 0) 1246 if (err < 0)
1252 return err; 1247 return err;
1253 // snd_assert(runtime->status->hw_ptr < runtime->buffer_size, );
1254 runtime->hw_ptr_base = 0; 1248 runtime->hw_ptr_base = 0;
1255 runtime->hw_ptr_interrupt = runtime->status->hw_ptr - 1249 runtime->hw_ptr_interrupt = runtime->status->hw_ptr -
1256 runtime->status->hw_ptr % runtime->period_size; 1250 runtime->status->hw_ptr % runtime->period_size;
@@ -1421,7 +1415,6 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream)
1421 int i, num_drecs; 1415 int i, num_drecs;
1422 struct drain_rec *drec, drec_tmp, *d; 1416 struct drain_rec *drec, drec_tmp, *d;
1423 1417
1424 snd_assert(substream != NULL, return -ENXIO);
1425 card = substream->pcm->card; 1418 card = substream->pcm->card;
1426 runtime = substream->runtime; 1419 runtime = substream->runtime;
1427 1420
@@ -1541,7 +1534,8 @@ static int snd_pcm_drop(struct snd_pcm_substream *substream)
1541 struct snd_card *card; 1534 struct snd_card *card;
1542 int result = 0; 1535 int result = 0;
1543 1536
1544 snd_assert(substream != NULL, return -ENXIO); 1537 if (PCM_RUNTIME_CHECK(substream))
1538 return -ENXIO;
1545 runtime = substream->runtime; 1539 runtime = substream->runtime;
1546 card = substream->pcm->card; 1540 card = substream->pcm->card;
1547 1541
@@ -1934,33 +1928,41 @@ int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream)
1934 mask |= 1 << SNDRV_PCM_ACCESS_MMAP_COMPLEX; 1928 mask |= 1 << SNDRV_PCM_ACCESS_MMAP_COMPLEX;
1935 } 1929 }
1936 err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_ACCESS, mask); 1930 err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_ACCESS, mask);
1937 snd_assert(err >= 0, return -EINVAL); 1931 if (err < 0)
1932 return err;
1938 1933
1939 err = snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT, hw->formats); 1934 err = snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT, hw->formats);
1940 snd_assert(err >= 0, return -EINVAL); 1935 if (err < 0)
1936 return err;
1941 1937
1942 err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_SUBFORMAT, 1 << SNDRV_PCM_SUBFORMAT_STD); 1938 err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_SUBFORMAT, 1 << SNDRV_PCM_SUBFORMAT_STD);
1943 snd_assert(err >= 0, return -EINVAL); 1939 if (err < 0)
1940 return err;
1944 1941
1945 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, 1942 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS,
1946 hw->channels_min, hw->channels_max); 1943 hw->channels_min, hw->channels_max);
1947 snd_assert(err >= 0, return -EINVAL); 1944 if (err < 0)
1945 return err;
1948 1946
1949 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, 1947 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE,
1950 hw->rate_min, hw->rate_max); 1948 hw->rate_min, hw->rate_max);
1951 snd_assert(err >= 0, return -EINVAL); 1949 if (err < 0)
1950 return err;
1952 1951
1953 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 1952 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
1954 hw->period_bytes_min, hw->period_bytes_max); 1953 hw->period_bytes_min, hw->period_bytes_max);
1955 snd_assert(err >= 0, return -EINVAL); 1954 if (err < 0)
1955 return err;
1956 1956
1957 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS, 1957 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS,
1958 hw->periods_min, hw->periods_max); 1958 hw->periods_min, hw->periods_max);
1959 snd_assert(err >= 0, return -EINVAL); 1959 if (err < 0)
1960 return err;
1960 1961
1961 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 1962 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
1962 hw->period_bytes_min, hw->buffer_bytes_max); 1963 hw->period_bytes_min, hw->buffer_bytes_max);
1963 snd_assert(err >= 0, return -EINVAL); 1964 if (err < 0)
1965 return err;
1964 1966
1965 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 1967 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
1966 snd_pcm_hw_rule_buffer_bytes_max, substream, 1968 snd_pcm_hw_rule_buffer_bytes_max, substream,
@@ -1971,7 +1973,8 @@ int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream)
1971 /* FIXME: remove */ 1973 /* FIXME: remove */
1972 if (runtime->dma_bytes) { 1974 if (runtime->dma_bytes) {
1973 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 0, runtime->dma_bytes); 1975 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 0, runtime->dma_bytes);
1974 snd_assert(err >= 0, return -EINVAL); 1976 if (err < 0)
1977 return -EINVAL;
1975 } 1978 }
1976 1979
1977 if (!(hw->rates & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))) { 1980 if (!(hw->rates & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))) {
@@ -2067,8 +2070,8 @@ static int snd_pcm_open_file(struct file *file,
2067 struct snd_pcm_str *str; 2070 struct snd_pcm_str *str;
2068 int err; 2071 int err;
2069 2072
2070 snd_assert(rpcm_file != NULL, return -EINVAL); 2073 if (rpcm_file)
2071 *rpcm_file = NULL; 2074 *rpcm_file = NULL;
2072 2075
2073 err = snd_pcm_open_substream(pcm, stream, file, &substream); 2076 err = snd_pcm_open_substream(pcm, stream, file, &substream);
2074 if (err < 0) 2077 if (err < 0)
@@ -2086,7 +2089,8 @@ static int snd_pcm_open_file(struct file *file,
2086 substream->pcm_release = pcm_release_private; 2089 substream->pcm_release = pcm_release_private;
2087 } 2090 }
2088 file->private_data = pcm_file; 2091 file->private_data = pcm_file;
2089 *rpcm_file = pcm_file; 2092 if (rpcm_file)
2093 *rpcm_file = pcm_file;
2090 return 0; 2094 return 0;
2091} 2095}
2092 2096
@@ -2170,7 +2174,8 @@ static int snd_pcm_release(struct inode *inode, struct file *file)
2170 2174
2171 pcm_file = file->private_data; 2175 pcm_file = file->private_data;
2172 substream = pcm_file->substream; 2176 substream = pcm_file->substream;
2173 snd_assert(substream != NULL, return -ENXIO); 2177 if (snd_BUG_ON(!substream))
2178 return -ENXIO;
2174 pcm = substream->pcm; 2179 pcm = substream->pcm;
2175 fasync_helper(-1, file, 0, &substream->runtime->fasync); 2180 fasync_helper(-1, file, 0, &substream->runtime->fasync);
2176 mutex_lock(&pcm->open_mutex); 2181 mutex_lock(&pcm->open_mutex);
@@ -2493,8 +2498,6 @@ static int snd_pcm_common_ioctl1(struct file *file,
2493 struct snd_pcm_substream *substream, 2498 struct snd_pcm_substream *substream,
2494 unsigned int cmd, void __user *arg) 2499 unsigned int cmd, void __user *arg)
2495{ 2500{
2496 snd_assert(substream != NULL, return -ENXIO);
2497
2498 switch (cmd) { 2501 switch (cmd) {
2499 case SNDRV_PCM_IOCTL_PVERSION: 2502 case SNDRV_PCM_IOCTL_PVERSION:
2500 return put_user(SNDRV_PCM_VERSION, (int __user *)arg) ? -EFAULT : 0; 2503 return put_user(SNDRV_PCM_VERSION, (int __user *)arg) ? -EFAULT : 0;
@@ -2563,8 +2566,10 @@ static int snd_pcm_playback_ioctl1(struct file *file,
2563 struct snd_pcm_substream *substream, 2566 struct snd_pcm_substream *substream,
2564 unsigned int cmd, void __user *arg) 2567 unsigned int cmd, void __user *arg)
2565{ 2568{
2566 snd_assert(substream != NULL, return -ENXIO); 2569 if (snd_BUG_ON(!substream))
2567 snd_assert(substream->stream == SNDRV_PCM_STREAM_PLAYBACK, return -EINVAL); 2570 return -ENXIO;
2571 if (snd_BUG_ON(substream->stream != SNDRV_PCM_STREAM_PLAYBACK))
2572 return -EINVAL;
2568 switch (cmd) { 2573 switch (cmd) {
2569 case SNDRV_PCM_IOCTL_WRITEI_FRAMES: 2574 case SNDRV_PCM_IOCTL_WRITEI_FRAMES:
2570 { 2575 {
@@ -2643,8 +2648,10 @@ static int snd_pcm_capture_ioctl1(struct file *file,
2643 struct snd_pcm_substream *substream, 2648 struct snd_pcm_substream *substream,
2644 unsigned int cmd, void __user *arg) 2649 unsigned int cmd, void __user *arg)
2645{ 2650{
2646 snd_assert(substream != NULL, return -ENXIO); 2651 if (snd_BUG_ON(!substream))
2647 snd_assert(substream->stream == SNDRV_PCM_STREAM_CAPTURE, return -EINVAL); 2652 return -ENXIO;
2653 if (snd_BUG_ON(substream->stream != SNDRV_PCM_STREAM_CAPTURE))
2654 return -EINVAL;
2648 switch (cmd) { 2655 switch (cmd) {
2649 case SNDRV_PCM_IOCTL_READI_FRAMES: 2656 case SNDRV_PCM_IOCTL_READI_FRAMES:
2650 { 2657 {
@@ -2783,7 +2790,8 @@ static ssize_t snd_pcm_read(struct file *file, char __user *buf, size_t count,
2783 2790
2784 pcm_file = file->private_data; 2791 pcm_file = file->private_data;
2785 substream = pcm_file->substream; 2792 substream = pcm_file->substream;
2786 snd_assert(substream != NULL, return -ENXIO); 2793 if (PCM_RUNTIME_CHECK(substream))
2794 return -ENXIO;
2787 runtime = substream->runtime; 2795 runtime = substream->runtime;
2788 if (runtime->status->state == SNDRV_PCM_STATE_OPEN) 2796 if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
2789 return -EBADFD; 2797 return -EBADFD;
@@ -2806,21 +2814,17 @@ static ssize_t snd_pcm_write(struct file *file, const char __user *buf,
2806 2814
2807 pcm_file = file->private_data; 2815 pcm_file = file->private_data;
2808 substream = pcm_file->substream; 2816 substream = pcm_file->substream;
2809 snd_assert(substream != NULL, result = -ENXIO; goto end); 2817 if (PCM_RUNTIME_CHECK(substream))
2818 return -ENXIO;
2810 runtime = substream->runtime; 2819 runtime = substream->runtime;
2811 if (runtime->status->state == SNDRV_PCM_STATE_OPEN) { 2820 if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
2812 result = -EBADFD; 2821 return -EBADFD;
2813 goto end; 2822 if (!frame_aligned(runtime, count))
2814 } 2823 return -EINVAL;
2815 if (!frame_aligned(runtime, count)) {
2816 result = -EINVAL;
2817 goto end;
2818 }
2819 count = bytes_to_frames(runtime, count); 2824 count = bytes_to_frames(runtime, count);
2820 result = snd_pcm_lib_write(substream, buf, count); 2825 result = snd_pcm_lib_write(substream, buf, count);
2821 if (result > 0) 2826 if (result > 0)
2822 result = frames_to_bytes(runtime, result); 2827 result = frames_to_bytes(runtime, result);
2823 end:
2824 return result; 2828 return result;
2825} 2829}
2826 2830
@@ -2838,7 +2842,8 @@ static ssize_t snd_pcm_aio_read(struct kiocb *iocb, const struct iovec *iov,
2838 2842
2839 pcm_file = iocb->ki_filp->private_data; 2843 pcm_file = iocb->ki_filp->private_data;
2840 substream = pcm_file->substream; 2844 substream = pcm_file->substream;
2841 snd_assert(substream != NULL, return -ENXIO); 2845 if (PCM_RUNTIME_CHECK(substream))
2846 return -ENXIO;
2842 runtime = substream->runtime; 2847 runtime = substream->runtime;
2843 if (runtime->status->state == SNDRV_PCM_STATE_OPEN) 2848 if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
2844 return -EBADFD; 2849 return -EBADFD;
@@ -2872,17 +2877,14 @@ static ssize_t snd_pcm_aio_write(struct kiocb *iocb, const struct iovec *iov,
2872 2877
2873 pcm_file = iocb->ki_filp->private_data; 2878 pcm_file = iocb->ki_filp->private_data;
2874 substream = pcm_file->substream; 2879 substream = pcm_file->substream;
2875 snd_assert(substream != NULL, result = -ENXIO; goto end); 2880 if (PCM_RUNTIME_CHECK(substream))
2881 return -ENXIO;
2876 runtime = substream->runtime; 2882 runtime = substream->runtime;
2877 if (runtime->status->state == SNDRV_PCM_STATE_OPEN) { 2883 if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
2878 result = -EBADFD; 2884 return -EBADFD;
2879 goto end;
2880 }
2881 if (nr_segs > 128 || nr_segs != runtime->channels || 2885 if (nr_segs > 128 || nr_segs != runtime->channels ||
2882 !frame_aligned(runtime, iov->iov_len)) { 2886 !frame_aligned(runtime, iov->iov_len))
2883 result = -EINVAL; 2887 return -EINVAL;
2884 goto end;
2885 }
2886 frames = bytes_to_samples(runtime, iov->iov_len); 2888 frames = bytes_to_samples(runtime, iov->iov_len);
2887 bufs = kmalloc(sizeof(void *) * nr_segs, GFP_KERNEL); 2889 bufs = kmalloc(sizeof(void *) * nr_segs, GFP_KERNEL);
2888 if (bufs == NULL) 2890 if (bufs == NULL)
@@ -2893,7 +2895,6 @@ static ssize_t snd_pcm_aio_write(struct kiocb *iocb, const struct iovec *iov,
2893 if (result > 0) 2895 if (result > 0)
2894 result = frames_to_bytes(runtime, result); 2896 result = frames_to_bytes(runtime, result);
2895 kfree(bufs); 2897 kfree(bufs);
2896 end:
2897 return result; 2898 return result;
2898} 2899}
2899 2900
@@ -2908,7 +2909,8 @@ static unsigned int snd_pcm_playback_poll(struct file *file, poll_table * wait)
2908 pcm_file = file->private_data; 2909 pcm_file = file->private_data;
2909 2910
2910 substream = pcm_file->substream; 2911 substream = pcm_file->substream;
2911 snd_assert(substream != NULL, return -ENXIO); 2912 if (PCM_RUNTIME_CHECK(substream))
2913 return -ENXIO;
2912 runtime = substream->runtime; 2914 runtime = substream->runtime;
2913 2915
2914 poll_wait(file, &runtime->sleep, wait); 2916 poll_wait(file, &runtime->sleep, wait);
@@ -2946,7 +2948,8 @@ static unsigned int snd_pcm_capture_poll(struct file *file, poll_table * wait)
2946 pcm_file = file->private_data; 2948 pcm_file = file->private_data;
2947 2949
2948 substream = pcm_file->substream; 2950 substream = pcm_file->substream;
2949 snd_assert(substream != NULL, return -ENXIO); 2951 if (PCM_RUNTIME_CHECK(substream))
2952 return -ENXIO;
2950 runtime = substream->runtime; 2953 runtime = substream->runtime;
2951 2954
2952 poll_wait(file, &runtime->sleep, wait); 2955 poll_wait(file, &runtime->sleep, wait);
@@ -3016,7 +3019,6 @@ static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file
3016 if (!(area->vm_flags & VM_READ)) 3019 if (!(area->vm_flags & VM_READ))
3017 return -EINVAL; 3020 return -EINVAL;
3018 runtime = substream->runtime; 3021 runtime = substream->runtime;
3019 snd_assert(runtime != NULL, return -EAGAIN);
3020 size = area->vm_end - area->vm_start; 3022 size = area->vm_end - area->vm_start;
3021 if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status))) 3023 if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status)))
3022 return -EINVAL; 3024 return -EINVAL;
@@ -3056,7 +3058,6 @@ static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file
3056 if (!(area->vm_flags & VM_READ)) 3058 if (!(area->vm_flags & VM_READ))
3057 return -EINVAL; 3059 return -EINVAL;
3058 runtime = substream->runtime; 3060 runtime = substream->runtime;
3059 snd_assert(runtime != NULL, return -EAGAIN);
3060 size = area->vm_end - area->vm_start; 3061 size = area->vm_end - area->vm_start;
3061 if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control))) 3062 if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control)))
3062 return -EINVAL; 3063 return -EINVAL;
@@ -3188,7 +3189,6 @@ int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file,
3188 return -EINVAL; 3189 return -EINVAL;
3189 } 3190 }
3190 runtime = substream->runtime; 3191 runtime = substream->runtime;
3191 snd_assert(runtime != NULL, return -EAGAIN);
3192 if (runtime->status->state == SNDRV_PCM_STATE_OPEN) 3192 if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
3193 return -EBADFD; 3193 return -EBADFD;
3194 if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) 3194 if (!(runtime->info & SNDRV_PCM_INFO_MMAP))
@@ -3220,7 +3220,8 @@ static int snd_pcm_mmap(struct file *file, struct vm_area_struct *area)
3220 3220
3221 pcm_file = file->private_data; 3221 pcm_file = file->private_data;
3222 substream = pcm_file->substream; 3222 substream = pcm_file->substream;
3223 snd_assert(substream != NULL, return -ENXIO); 3223 if (PCM_RUNTIME_CHECK(substream))
3224 return -ENXIO;
3224 3225
3225 offset = area->vm_pgoff << PAGE_SHIFT; 3226 offset = area->vm_pgoff << PAGE_SHIFT;
3226 switch (offset) { 3227 switch (offset) {
@@ -3248,9 +3249,9 @@ static int snd_pcm_fasync(int fd, struct file * file, int on)
3248 lock_kernel(); 3249 lock_kernel();
3249 pcm_file = file->private_data; 3250 pcm_file = file->private_data;
3250 substream = pcm_file->substream; 3251 substream = pcm_file->substream;
3251 snd_assert(substream != NULL, goto out); 3252 if (PCM_RUNTIME_CHECK(substream))
3253 goto out;
3252 runtime = substream->runtime; 3254 runtime = substream->runtime;
3253
3254 err = fasync_helper(fd, file, on, &runtime->fasync); 3255 err = fasync_helper(fd, file, on, &runtime->fasync);
3255out: 3256out:
3256 unlock_kernel(); 3257 unlock_kernel();