aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/pcm.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core/pcm.c')
-rw-r--r--sound/core/pcm.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 517388b2eba9..192a433a2403 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -256,7 +256,6 @@ static char *snd_pcm_tstamp_mode_names[] = {
256 256
257static const char *snd_pcm_stream_name(int stream) 257static const char *snd_pcm_stream_name(int stream)
258{ 258{
259 snd_assert(stream <= SNDRV_PCM_STREAM_LAST, return NULL);
260 return snd_pcm_stream_names[stream]; 259 return snd_pcm_stream_names[stream];
261} 260}
262 261
@@ -272,7 +271,6 @@ static const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat)
272 271
273static const char *snd_pcm_tstamp_mode_name(int mode) 272static const char *snd_pcm_tstamp_mode_name(int mode)
274{ 273{
275 snd_assert(mode <= SNDRV_PCM_TSTAMP_LAST, return NULL);
276 return snd_pcm_tstamp_mode_names[mode]; 274 return snd_pcm_tstamp_mode_names[mode];
277} 275}
278 276
@@ -706,9 +704,10 @@ int snd_pcm_new(struct snd_card *card, char *id, int device,
706 .dev_disconnect = snd_pcm_dev_disconnect, 704 .dev_disconnect = snd_pcm_dev_disconnect,
707 }; 705 };
708 706
709 snd_assert(rpcm != NULL, return -EINVAL); 707 if (snd_BUG_ON(!card))
710 *rpcm = NULL; 708 return -ENXIO;
711 snd_assert(card != NULL, return -ENXIO); 709 if (rpcm)
710 *rpcm = NULL;
712 pcm = kzalloc(sizeof(*pcm), GFP_KERNEL); 711 pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
713 if (pcm == NULL) { 712 if (pcm == NULL) {
714 snd_printk(KERN_ERR "Cannot allocate PCM\n"); 713 snd_printk(KERN_ERR "Cannot allocate PCM\n");
@@ -732,7 +731,8 @@ int snd_pcm_new(struct snd_card *card, char *id, int device,
732 snd_pcm_free(pcm); 731 snd_pcm_free(pcm);
733 return err; 732 return err;
734 } 733 }
735 *rpcm = pcm; 734 if (rpcm)
735 *rpcm = pcm;
736 return 0; 736 return 0;
737} 737}
738 738
@@ -766,7 +766,8 @@ static int snd_pcm_free(struct snd_pcm *pcm)
766{ 766{
767 struct snd_pcm_notify *notify; 767 struct snd_pcm_notify *notify;
768 768
769 snd_assert(pcm != NULL, return -ENXIO); 769 if (!pcm)
770 return 0;
770 list_for_each_entry(notify, &snd_pcm_notify_list, list) { 771 list_for_each_entry(notify, &snd_pcm_notify_list, list) {
771 notify->n_unregister(pcm); 772 notify->n_unregister(pcm);
772 } 773 }
@@ -797,9 +798,9 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
797 int prefer_subdevice = -1; 798 int prefer_subdevice = -1;
798 size_t size; 799 size_t size;
799 800
800 snd_assert(rsubstream != NULL, return -EINVAL); 801 if (snd_BUG_ON(!pcm || !rsubstream))
802 return -ENXIO;
801 *rsubstream = NULL; 803 *rsubstream = NULL;
802 snd_assert(pcm != NULL, return -ENXIO);
803 pstr = &pcm->streams[stream]; 804 pstr = &pcm->streams[stream];
804 if (pstr->substream == NULL || pstr->substream_count == 0) 805 if (pstr->substream == NULL || pstr->substream_count == 0)
805 return -ENODEV; 806 return -ENODEV;
@@ -907,8 +908,9 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream)
907{ 908{
908 struct snd_pcm_runtime *runtime; 909 struct snd_pcm_runtime *runtime;
909 910
911 if (PCM_RUNTIME_CHECK(substream))
912 return;
910 runtime = substream->runtime; 913 runtime = substream->runtime;
911 snd_assert(runtime != NULL, return);
912 if (runtime->private_free != NULL) 914 if (runtime->private_free != NULL)
913 runtime->private_free(runtime); 915 runtime->private_free(runtime);
914 snd_free_pages((void*)runtime->status, 916 snd_free_pages((void*)runtime->status,
@@ -953,7 +955,8 @@ static int snd_pcm_dev_register(struct snd_device *device)
953 struct snd_pcm *pcm = device->device_data; 955 struct snd_pcm *pcm = device->device_data;
954 struct device *dev; 956 struct device *dev;
955 957
956 snd_assert(pcm != NULL && device != NULL, return -ENXIO); 958 if (snd_BUG_ON(!pcm || !device))
959 return -ENXIO;
957 mutex_lock(&register_mutex); 960 mutex_lock(&register_mutex);
958 err = snd_pcm_add(pcm); 961 err = snd_pcm_add(pcm);
959 if (err) { 962 if (err) {
@@ -1043,10 +1046,11 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
1043{ 1046{
1044 struct snd_pcm *pcm; 1047 struct snd_pcm *pcm;
1045 1048
1046 snd_assert(notify != NULL && 1049 if (snd_BUG_ON(!notify ||
1047 notify->n_register != NULL && 1050 !notify->n_register ||
1048 notify->n_unregister != NULL && 1051 !notify->n_unregister ||
1049 notify->n_disconnect, return -EINVAL); 1052 !notify->n_disconnect))
1053 return -EINVAL;
1050 mutex_lock(&register_mutex); 1054 mutex_lock(&register_mutex);
1051 if (nfree) { 1055 if (nfree) {
1052 list_del(&notify->list); 1056 list_del(&notify->list);