]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/drivers/vx/vx_pcm.c
ALSA: Kill snd_assert() in other places
[linux-2.6-omap-h63xx.git] / sound / drivers / vx / vx_pcm.c
index 464109e421d4cef5127c750cb5cdecc9cf83fc92..27de574c08f76c5ff5763e1051e6dba353402648 100644 (file)
@@ -45,7 +45,6 @@
  *  - scheduled action on the stream.
  */
 
-#include <sound/driver.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
@@ -98,10 +97,9 @@ static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t s
 static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs)
 {
        struct snd_pcm_runtime *runtime = subs->runtime;
-       if (runtime->dma_area) {
-               vfree(runtime->dma_area);
-               runtime->dma_area = NULL;
-       }
+
+       vfree(runtime->dma_area);
+       runtime->dma_area = NULL;
        return 0;
 }
 
@@ -589,7 +587,8 @@ static int vx_pcm_playback_open(struct snd_pcm_substream *subs)
                return -EBUSY;
 
        audio = subs->pcm->device * 2;
-       snd_assert(audio < chip->audio_outs, return -EINVAL);
+       if (snd_BUG_ON(audio >= chip->audio_outs))
+               return -EINVAL;
        
        /* playback pipe may have been already allocated for monitoring */
        pipe = chip->playback_pipes[audio];
@@ -998,7 +997,8 @@ static int vx_pcm_capture_open(struct snd_pcm_substream *subs)
                return -EBUSY;
 
        audio = subs->pcm->device * 2;
-       snd_assert(audio < chip->audio_ins, return -EINVAL);
+       if (snd_BUG_ON(audio >= chip->audio_ins))
+               return -EINVAL;
        err = vx_alloc_pipe(chip, 1, audio, 2, &pipe);
        if (err < 0)
                return err;
@@ -1216,7 +1216,8 @@ void vx_pcm_update_intr(struct vx_core *chip, unsigned int events)
                        }
                        if (capture)
                                continue;
-                       snd_assert(p >= 0 && (unsigned int)p < chip->audio_outs,);
+                       if (snd_BUG_ON(p < 0 || p >= chip->audio_outs))
+                               continue;
                        pipe = chip->playback_pipes[p];
                        if (pipe && pipe->substream) {
                                vx_pcm_playback_update(chip, pipe->substream, pipe);
@@ -1253,13 +1254,14 @@ static int vx_init_audio_io(struct vx_core *chip)
        chip->audio_info = rmh.Stat[1];
 
        /* allocate pipes */
-       chip->playback_pipes = kmalloc(sizeof(struct vx_pipe *) * chip->audio_outs, GFP_KERNEL);
-       chip->capture_pipes = kmalloc(sizeof(struct vx_pipe *) * chip->audio_ins, GFP_KERNEL);
-       if (! chip->playback_pipes || ! chip->capture_pipes)
+       chip->playback_pipes = kcalloc(chip->audio_outs, sizeof(struct vx_pipe *), GFP_KERNEL);
+       if (!chip->playback_pipes)
                return -ENOMEM;
-
-       memset(chip->playback_pipes, 0, sizeof(struct vx_pipe *) * chip->audio_outs);
-       memset(chip->capture_pipes, 0, sizeof(struct vx_pipe *) * chip->audio_ins);
+       chip->capture_pipes = kcalloc(chip->audio_ins, sizeof(struct vx_pipe *), GFP_KERNEL);
+       if (!chip->capture_pipes) {
+               kfree(chip->playback_pipes);
+               return -ENOMEM;
+       }
 
        preferred = chip->ibl.size;
        chip->ibl.size = 0;