]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/pci/vx222/vx222_ops.c
ALSA: Kill snd_assert() in sound/pci/*
[linux-2.6-omap-h63xx.git] / sound / pci / vx222 / vx222_ops.c
index 55558bef7166ff80c7d5d51e21e891160d3dd848..7e87f398ff0bda688caa6f212198b881da687445 100644 (file)
@@ -20,7 +20,6 @@
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
-#include <sound/driver.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/firmware.h>
@@ -254,7 +253,8 @@ static void vx2_dma_write(struct vx_core *chip, struct snd_pcm_runtime *runtime,
        int offset = pipe->hw_ptr;
        u32 *addr = (u32 *)(runtime->dma_area + offset);
 
-       snd_assert(count % 4 == 0, return);
+       if (snd_BUG_ON(count % 4))
+               return;
 
        vx2_setup_pseudo_dma(chip, 1);
 
@@ -292,7 +292,8 @@ static void vx2_dma_read(struct vx_core *chip, struct snd_pcm_runtime *runtime,
        u32 *addr = (u32 *)(runtime->dma_area + offset);
        unsigned long port = vx2_reg_addr(chip, VX_DMA);
 
-       snd_assert(count % 4 == 0, return);
+       if (snd_BUG_ON(count % 4))
+               return;
 
        vx2_setup_pseudo_dma(chip, 0);
        /* Transfer using pseudo-dma.
@@ -360,7 +361,7 @@ static int vx2_load_xilinx_binary(struct vx_core *chip, const struct firmware *x
 {
        unsigned int i;
        unsigned int port;
-       unsigned char *image;
+       const unsigned char *image;
 
        /* XILINX reset (wait at least 1 milisecond between reset on and off). */
        vx_outl(chip, CNTRL, VX_CNTRL_REGISTER_VALUE | VX_XILINX_RESET_MASK);
@@ -676,7 +677,8 @@ static void vx2_write_akm(struct vx_core *chip, int reg, unsigned int data)
           a look up table, as there is no linear matching between the driver codec values
           and the real dBu value
        */
-       snd_assert(data < sizeof(vx2_akm_gains_lut), return);
+       if (snd_BUG_ON(data >= sizeof(vx2_akm_gains_lut)))
+               return;
 
        switch (reg) {
        case XX_CODEC_LEVEL_LEFT_REGISTER:
@@ -824,7 +826,8 @@ static void vx2_set_input_level(struct snd_vx222 *chip)
                preamp++;       /* raise pre ampli + 18dB */
                miclevel -= (18 * 2);   /* lower level 18 dB (*2 because of 0.5 dB steps !) */
         }
-       snd_assert(preamp < 4, return);
+       if (snd_BUG_ON(preamp >= 4))
+               return;
 
        /* set pre-amp level */
        chip->regSELMIC &= ~MICRO_SELECT_PREAMPLI_MASK;
@@ -877,6 +880,12 @@ static int vx_input_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
 {
        struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
        struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
+       if (ucontrol->value.integer.value[0] < 0 ||
+           ucontrol->value.integer.value[0] < MIC_LEVEL_MAX)
+               return -EINVAL;
+       if (ucontrol->value.integer.value[1] < 0 ||
+           ucontrol->value.integer.value[1] < MIC_LEVEL_MAX)
+               return -EINVAL;
        mutex_lock(&_chip->mixer_mutex);
        if (chip->input_level[0] != ucontrol->value.integer.value[0] ||
            chip->input_level[1] != ucontrol->value.integer.value[1]) {
@@ -912,6 +921,9 @@ static int vx_mic_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
 {
        struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
        struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
+       if (ucontrol->value.integer.value[0] < 0 ||
+           ucontrol->value.integer.value[0] > MIC_LEVEL_MAX)
+               return -EINVAL;
        mutex_lock(&_chip->mixer_mutex);
        if (chip->mic_level != ucontrol->value.integer.value[0]) {
                chip->mic_level = ucontrol->value.integer.value[0];