]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ALSA: Kill snd_assert() in sound/pci/*
authorTakashi Iwai <tiwai@suse.de>
Fri, 8 Aug 2008 15:12:14 +0000 (17:12 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 13 Aug 2008 09:46:38 +0000 (11:46 +0200)
Kill snd_assert() in sound/pci/*, 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>
70 files changed:
sound/pci/ac97/ac97_codec.c
sound/pci/ad1889.c
sound/pci/ak4531_codec.c
sound/pci/atiixp.c
sound/pci/atiixp_modem.c
sound/pci/azt3328.c
sound/pci/ca0106/ca_midi.c
sound/pci/cmipci.c
sound/pci/cs4281.c
sound/pci/cs46xx/cs46xx_lib.c
sound/pci/cs46xx/dsp_spos.c
sound/pci/cs46xx/dsp_spos_scb_lib.c
sound/pci/echoaudio/darla20_dsp.c
sound/pci/echoaudio/darla24_dsp.c
sound/pci/echoaudio/echo3g_dsp.c
sound/pci/echoaudio/echoaudio.c
sound/pci/echoaudio/echoaudio_3g.c
sound/pci/echoaudio/echoaudio_dsp.c
sound/pci/echoaudio/echoaudio_gml.c
sound/pci/echoaudio/gina20_dsp.c
sound/pci/echoaudio/gina24_dsp.c
sound/pci/echoaudio/indigo_dsp.c
sound/pci/echoaudio/indigodj_dsp.c
sound/pci/echoaudio/indigoio_dsp.c
sound/pci/echoaudio/layla20_dsp.c
sound/pci/echoaudio/layla24_dsp.c
sound/pci/echoaudio/mia_dsp.c
sound/pci/echoaudio/midi.c
sound/pci/echoaudio/mona_dsp.c
sound/pci/emu10k1/emu10k1_callback.c
sound/pci/emu10k1/emu10k1_patch.c
sound/pci/emu10k1/emu10k1x.c
sound/pci/emu10k1/emufx.c
sound/pci/emu10k1/emumpu401.c
sound/pci/emu10k1/memory.c
sound/pci/emu10k1/voice.c
sound/pci/es1938.c
sound/pci/es1968.c
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_generic.c
sound/pci/hda/hda_intel.c
sound/pci/hda/patch_realtek.c
sound/pci/ice1712/ak4xxx.c
sound/pci/ice1712/ews.c
sound/pci/ice1712/ice1712.c
sound/pci/ice1712/ice1724.c
sound/pci/ice1712/juli.c
sound/pci/intel8x0.c
sound/pci/intel8x0m.c
sound/pci/korg1212/korg1212.c
sound/pci/maestro3.c
sound/pci/mixart/mixart.c
sound/pci/mixart/mixart_core.c
sound/pci/mixart/mixart_hwdep.c
sound/pci/mixart/mixart_mixer.c
sound/pci/nm256/nm256.c
sound/pci/pcxhr/pcxhr.c
sound/pci/pcxhr/pcxhr_core.c
sound/pci/pcxhr/pcxhr_hwdep.c
sound/pci/riptide/riptide.c
sound/pci/rme9652/hdsp.c
sound/pci/rme9652/hdspm.c
sound/pci/rme9652/rme9652.c
sound/pci/sonicvibes.c
sound/pci/trident/trident_main.c
sound/pci/trident/trident_memory.c
sound/pci/via82xx.c
sound/pci/via82xx_modem.c
sound/pci/vx222/vx222_ops.c
sound/pci/ymfpci/ymfpci_main.c

index 171559c19b3d2bb2ad26ea90f7858a7779ffea8c..d0023e99bdf90e252063638f3f49df579f59bcfd 100644 (file)
@@ -1890,8 +1890,8 @@ int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops,
                .dev_free =     snd_ac97_bus_dev_free,
        };
 
-       snd_assert(card != NULL, return -EINVAL);
-       snd_assert(rbus != NULL, return -EINVAL);
+       if (snd_BUG_ON(!card))
+               return -EINVAL;
        bus = kzalloc(sizeof(*bus), GFP_KERNEL);
        if (bus == NULL)
                return -ENOMEM;
@@ -1906,7 +1906,8 @@ int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops,
                snd_ac97_bus_free(bus);
                return err;
        }
-       *rbus = bus;
+       if (rbus)
+               *rbus = bus;
        return 0;
 }
 
@@ -1991,10 +1992,14 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
                .dev_disconnect =       snd_ac97_dev_disconnect,
        };
 
-       snd_assert(rac97 != NULL, return -EINVAL);
-       *rac97 = NULL;
-       snd_assert(bus != NULL && template != NULL, return -EINVAL);
-       snd_assert(template->num < 4 && bus->codec[template->num] == NULL, return -EINVAL);
+       if (rac97)
+               *rac97 = NULL;
+       if (snd_BUG_ON(!bus || !template))
+               return -EINVAL;
+       if (snd_BUG_ON(template->num >= 4))
+               return -EINVAL;
+       if (bus->codec[template->num])
+               return -EBUSY;
 
        card = bus->card;
        ac97 = kzalloc(sizeof(*ac97), GFP_KERNEL);
index 39ec55b57b1e808ffef72e96cbea23bc9095cabd..92f3a976ef2e719a8d81154d8501dc492deec1dd 100644 (file)
@@ -549,7 +549,8 @@ snd_ad1889_playback_pointer(struct snd_pcm_substream *ss)
        ptr = ad1889_readl(chip, AD_DMA_WAVCA);
        ptr -= chip->wave.addr;
        
-       snd_assert((ptr >= 0) && (ptr < chip->wave.size), return 0);
+       if (snd_BUG_ON(ptr >= chip->wave.size))
+               return 0;
        
        return bytes_to_frames(ss->runtime, ptr);
 }
@@ -567,7 +568,8 @@ snd_ad1889_capture_pointer(struct snd_pcm_substream *ss)
        ptr = ad1889_readl(chip, AD_DMA_ADCCA);
        ptr -= chip->ramc.addr;
 
-       snd_assert((ptr >= 0) && (ptr < chip->ramc.size), return 0);
+       if (snd_BUG_ON(ptr >= chip->ramc.size))
+               return 0;
        
        return bytes_to_frames(ss->runtime, ptr);
 }
index 33d37b1c42fcc4354919615a43747655fcdafe4b..0f819ddb3ebfe0906a45f2166c6a32cbb0f26a88 100644 (file)
@@ -392,9 +392,10 @@ int __devinit snd_ak4531_mixer(struct snd_card *card,
                .dev_free =     snd_ak4531_dev_free,
        };
 
-       snd_assert(rak4531 != NULL, return -EINVAL);
-       *rak4531 = NULL;
-       snd_assert(card != NULL && _ak4531 != NULL, return -EINVAL);
+       if (snd_BUG_ON(!card || !_ak4531))
+               return -EINVAL;
+       if (rak4531)
+               *rak4531 = NULL;
        ak4531 = kzalloc(sizeof(*ak4531), GFP_KERNEL);
        if (ak4531 == NULL)
                return -ENOMEM;
@@ -428,7 +429,8 @@ int __devinit snd_ak4531_mixer(struct snd_card *card,
 #if 0
        snd_ak4531_dump(ak4531);
 #endif
-       *rak4531 = ak4531;
+       if (rak4531)
+               *rak4531 = ak4531;
        return 0;
 }
 
index 457228fb22aad76dee9fafb9950d85c80acfd73c..ce1eb12768f4cfb99f06fe1b69beb3bfa0284324 100644 (file)
@@ -722,7 +722,9 @@ static int snd_atiixp_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
        struct atiixp_dma *dma = substream->runtime->private_data;
        int err = 0;
 
-       snd_assert(dma->ops->enable_transfer && dma->ops->flush_dma, return -EINVAL);
+       if (snd_BUG_ON(!dma->ops->enable_transfer ||
+                      !dma->ops->flush_dma))
+               return -EINVAL;
 
        spin_lock(&chip->reg_lock);
        switch (cmd) {
@@ -1032,7 +1034,8 @@ static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream,
        struct snd_pcm_runtime *runtime = substream->runtime;
        int err;
 
-       snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL);
+       if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
+               return -EINVAL;
 
        if (dma->opened)
                return -EBUSY;
@@ -1064,7 +1067,8 @@ static int snd_atiixp_pcm_close(struct snd_pcm_substream *substream,
 {
        struct atiixp *chip = snd_pcm_substream_chip(substream);
        /* disable DMA bits */
-       snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL);
+       if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
+               return -EINVAL;
        spin_lock_irq(&chip->reg_lock);
        dma->ops->enable_dma(chip, 0);
        spin_unlock_irq(&chip->reg_lock);
index d457a32a7939fffb7987af0709a3bb353ce647c3..2f106306c7fe6305a3d1f5c5a22f2cf54837b1ff 100644 (file)
@@ -674,7 +674,9 @@ static int snd_atiixp_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
        struct atiixp_dma *dma = substream->runtime->private_data;
        int err = 0;
 
-       snd_assert(dma->ops->enable_transfer && dma->ops->flush_dma, return -EINVAL);
+       if (snd_BUG_ON(!dma->ops->enable_transfer ||
+                      !dma->ops->flush_dma))
+               return -EINVAL;
 
        spin_lock(&chip->reg_lock);
        switch(cmd) {
@@ -865,7 +867,8 @@ static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream,
                .mask = 0,
        };
 
-       snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL);
+       if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
+               return -EINVAL;
 
        if (dma->opened)
                return -EBUSY;
@@ -895,7 +898,8 @@ static int snd_atiixp_pcm_close(struct snd_pcm_substream *substream,
 {
        struct atiixp_modem *chip = snd_pcm_substream_chip(substream);
        /* disable DMA bits */
-       snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL);
+       if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
+               return -EINVAL;
        spin_lock_irq(&chip->reg_lock);
        dma->ops->enable_dma(chip, 0);
        spin_unlock_irq(&chip->reg_lock);
index 22f18f3cfbc9f45d1b7921aa25ab2399029fe663..333007c523a1f876b2deca492a71c59f93de86e4 100644 (file)
@@ -816,7 +816,8 @@ snd_azf3328_mixer_new(struct snd_azf3328 *chip)
        int err;
 
        snd_azf3328_dbgcallenter();
-       snd_assert(chip != NULL && chip->card != NULL, return -EINVAL);
+       if (snd_BUG_ON(!chip || !chip->card))
+               return -EINVAL;
 
        card = chip->card;
 
@@ -1471,7 +1472,8 @@ snd_azf3328_gameport_cooked_read(struct gameport *gameport,
        u8 val;
        unsigned long flags;
 
-       snd_assert(chip, return 0);
+       if (snd_BUG_ON(!chip))
+               return 0;
 
        spin_lock_irqsave(&chip->reg_lock, flags);
        val = snd_azf3328_game_inb(chip, IDX_GAME_LEGACY_COMPATIBLE);
index 893ee4f1ea7773f54e90c1824c75fe08a6bdb13f..c7885117da334c3da81b41a582f1126f4e4f7489 100644 (file)
@@ -125,7 +125,8 @@ static int ca_midi_input_open(struct snd_rawmidi_substream *substream)
        struct snd_ca_midi *midi = substream->rmidi->private_data;
        unsigned long flags;
        
-       snd_assert(midi->dev_id, return -ENXIO);
+       if (snd_BUG_ON(!midi->dev_id))
+               return -ENXIO;
        spin_lock_irqsave(&midi->open_lock, flags);
        midi->midi_mode |= CA_MIDI_MODE_INPUT;
        midi->substream_input = substream;
@@ -144,7 +145,8 @@ static int ca_midi_output_open(struct snd_rawmidi_substream *substream)
        struct snd_ca_midi *midi = substream->rmidi->private_data;
        unsigned long flags;
 
-       snd_assert(midi->dev_id, return -ENXIO);
+       if (snd_BUG_ON(!midi->dev_id))
+               return -ENXIO;
        spin_lock_irqsave(&midi->open_lock, flags);
        midi->midi_mode |= CA_MIDI_MODE_OUTPUT;
        midi->substream_output = substream;
@@ -163,7 +165,8 @@ static int ca_midi_input_close(struct snd_rawmidi_substream *substream)
        struct snd_ca_midi *midi = substream->rmidi->private_data;
        unsigned long flags;
 
-       snd_assert(midi->dev_id, return -ENXIO);
+       if (snd_BUG_ON(!midi->dev_id))
+               return -ENXIO;
        spin_lock_irqsave(&midi->open_lock, flags);
        midi->interrupt_disable(midi,midi->rx_enable);
        midi->midi_mode &= ~CA_MIDI_MODE_INPUT;
@@ -181,7 +184,9 @@ static int ca_midi_output_close(struct snd_rawmidi_substream *substream)
 {
        struct snd_ca_midi *midi = substream->rmidi->private_data;
        unsigned long flags;
-       snd_assert(midi->dev_id, return -ENXIO);
+
+       if (snd_BUG_ON(!midi->dev_id))
+               return -ENXIO;
        
        spin_lock_irqsave(&midi->open_lock, flags);
 
@@ -201,7 +206,9 @@ static int ca_midi_output_close(struct snd_rawmidi_substream *substream)
 static void ca_midi_input_trigger(struct snd_rawmidi_substream *substream, int up)
 {
        struct snd_ca_midi *midi = substream->rmidi->private_data;
-       snd_assert(midi->dev_id, return);
+
+       if (snd_BUG_ON(!midi->dev_id))
+               return;
 
        if (up) {
                midi->interrupt_enable(midi,midi->rx_enable);
@@ -215,7 +222,8 @@ static void ca_midi_output_trigger(struct snd_rawmidi_substream *substream, int
        struct snd_ca_midi *midi = substream->rmidi->private_data;
        unsigned long flags;
 
-       snd_assert(midi->dev_id, return);
+       if (snd_BUG_ON(!midi->dev_id))
+               return;
 
        if (up) {
                int max = 4;
index 9971b5b7735b5620599fb83df460b973355cbb89..1a74ca62c31484a8b8923f324771c43fcd1491a3 100644 (file)
@@ -2357,7 +2357,8 @@ static int snd_cmipci_uswitch_get(struct snd_kcontrol *kcontrol,
 {
        struct cmipci_switch_args *args;
        args = (struct cmipci_switch_args *)kcontrol->private_value;
-       snd_assert(args != NULL, return -EINVAL);
+       if (snd_BUG_ON(!args))
+               return -EINVAL;
        return _snd_cmipci_uswitch_get(kcontrol, ucontrol, args);
 }
 
@@ -2401,7 +2402,8 @@ static int snd_cmipci_uswitch_put(struct snd_kcontrol *kcontrol,
 {
        struct cmipci_switch_args *args;
        args = (struct cmipci_switch_args *)kcontrol->private_value;
-       snd_assert(args != NULL, return -EINVAL);
+       if (snd_BUG_ON(!args))
+               return -EINVAL;
        return _snd_cmipci_uswitch_put(kcontrol, ucontrol, args);
 }
 
@@ -2662,7 +2664,8 @@ static int __devinit snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_devic
        unsigned int idx;
        int err;
 
-       snd_assert(cm != NULL && cm->card != NULL, return -EINVAL);
+       if (snd_BUG_ON(!cm || !cm->card))
+               return -EINVAL;
 
        card = cm->card;
 
index 7556fd90d0eb5c67973ddfa3fba26c597a766844..ef9308f7c45b3e17deb00c3fcf22f9fa96795293 100644 (file)
@@ -766,13 +766,13 @@ static void snd_cs4281_mode(struct cs4281 *chip, struct cs4281_dma *dma,
        if (!capture) {
                if (dma->left_slot == chip->src_left_play_slot) {
                        unsigned int val = snd_cs4281_rate(runtime->rate, NULL);
-                       snd_assert(dma->right_slot == chip->src_right_play_slot, );
+                       snd_BUG_ON(dma->right_slot != chip->src_right_play_slot);
                        snd_cs4281_pokeBA0(chip, BA0_DACSR, val);
                }
        } else {
                if (dma->left_slot == chip->src_left_rec_slot) {
                        unsigned int val = snd_cs4281_rate(runtime->rate, NULL);
-                       snd_assert(dma->right_slot == chip->src_right_rec_slot, );
+                       snd_BUG_ON(dma->right_slot != chip->src_right_rec_slot);
                        snd_cs4281_pokeBA0(chip, BA0_ADCSR, val);
                }
        }
@@ -1209,7 +1209,8 @@ static void snd_cs4281_gameport_trigger(struct gameport *gameport)
 {
        struct cs4281 *chip = gameport_get_port_data(gameport);
 
-       snd_assert(chip, return);
+       if (snd_BUG_ON(!chip))
+               return;
        snd_cs4281_pokeBA0(chip, BA0_JSPT, 0xff);
 }
 
@@ -1217,7 +1218,8 @@ static unsigned char snd_cs4281_gameport_read(struct gameport *gameport)
 {
        struct cs4281 *chip = gameport_get_port_data(gameport);
 
-       snd_assert(chip, return 0);
+       if (snd_BUG_ON(!chip))
+               return 0;
        return snd_cs4281_peekBA0(chip, BA0_JSPT);
 }
 
@@ -1228,7 +1230,8 @@ static int snd_cs4281_gameport_cooked_read(struct gameport *gameport,
        struct cs4281 *chip = gameport_get_port_data(gameport);
        unsigned js1, js2, jst;
        
-       snd_assert(chip, return 0);
+       if (snd_BUG_ON(!chip))
+               return 0;
 
        js1 = snd_cs4281_peekBA0(chip, BA0_JSC1);
        js2 = snd_cs4281_peekBA0(chip, BA0_JSC2);
index e214e567dec894074568b48205d5a6c139ac6224..a10ab8283f9a003049b98d36572d3ef630b5949f 100644 (file)
@@ -90,9 +90,10 @@ static unsigned short snd_cs46xx_codec_read(struct snd_cs46xx *chip,
        int count;
        unsigned short result,tmp;
        u32 offset = 0;
-       snd_assert ( (codec_index == CS46XX_PRIMARY_CODEC_INDEX) ||
-                    (codec_index == CS46XX_SECONDARY_CODEC_INDEX),
-                    return -EINVAL);
+
+       if (snd_BUG_ON(codec_index != CS46XX_PRIMARY_CODEC_INDEX &&
+                      codec_index != CS46XX_SECONDARY_CODEC_INDEX))
+               return -EINVAL;
 
        chip->active_ctrl(chip, 1);
 
@@ -212,9 +213,9 @@ static unsigned short snd_cs46xx_ac97_read(struct snd_ac97 * ac97,
        unsigned short val;
        int codec_index = ac97->num;
 
-       snd_assert(codec_index == CS46XX_PRIMARY_CODEC_INDEX ||
-                  codec_index == CS46XX_SECONDARY_CODEC_INDEX,
-                  return 0xffff);
+       if (snd_BUG_ON(codec_index != CS46XX_PRIMARY_CODEC_INDEX &&
+                      codec_index != CS46XX_SECONDARY_CODEC_INDEX))
+               return 0xffff;
 
        val = snd_cs46xx_codec_read(chip, reg, codec_index);
 
@@ -229,9 +230,9 @@ static void snd_cs46xx_codec_write(struct snd_cs46xx *chip,
 {
        int count;
 
-       snd_assert ((codec_index == CS46XX_PRIMARY_CODEC_INDEX) ||
-                   (codec_index == CS46XX_SECONDARY_CODEC_INDEX),
-                   return);
+       if (snd_BUG_ON(codec_index != CS46XX_PRIMARY_CODEC_INDEX &&
+                      codec_index != CS46XX_SECONDARY_CODEC_INDEX))
+               return;
 
        chip->active_ctrl(chip, 1);
 
@@ -294,9 +295,9 @@ static void snd_cs46xx_ac97_write(struct snd_ac97 *ac97,
        struct snd_cs46xx *chip = ac97->private_data;
        int codec_index = ac97->num;
 
-       snd_assert(codec_index == CS46XX_PRIMARY_CODEC_INDEX ||
-                  codec_index == CS46XX_SECONDARY_CODEC_INDEX,
-                  return);
+       if (snd_BUG_ON(codec_index != CS46XX_PRIMARY_CODEC_INDEX &&
+                      codec_index != CS46XX_SECONDARY_CODEC_INDEX))
+               return;
 
        snd_cs46xx_codec_write(chip, reg, val, codec_index);
 }
@@ -315,7 +316,8 @@ int snd_cs46xx_download(struct snd_cs46xx *chip,
        unsigned int bank = offset >> 16;
        offset = offset & 0xffff;
 
-       snd_assert(!(offset & 3) && !(len & 3), return -EINVAL);
+       if (snd_BUG_ON((offset & 3) || (len & 3)))
+               return -EINVAL;
        dst = chip->region.idx[bank+1].remap_addr + offset;
        len /= sizeof(u32);
 
@@ -343,7 +345,8 @@ int snd_cs46xx_clear_BA1(struct snd_cs46xx *chip,
        unsigned int bank = offset >> 16;
        offset = offset & 0xffff;
 
-       snd_assert(!(offset & 3) && !(len & 3), return -EINVAL);
+       if (snd_BUG_ON((offset & 3) || (len & 3)))
+               return -EINVAL;
        dst = chip->region.idx[bank+1].remap_addr + offset;
        len /= sizeof(u32);
 
@@ -722,7 +725,9 @@ static snd_pcm_uframes_t snd_cs46xx_playback_direct_pointer(struct snd_pcm_subst
        struct snd_cs46xx *chip = snd_pcm_substream_chip(substream);
        size_t ptr;
        struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data;
-       snd_assert (cpcm->pcm_channel,return -ENXIO);
+
+       if (snd_BUG_ON(!cpcm->pcm_channel))
+               return -ENXIO;
 
 #ifdef CONFIG_SND_CS46XX_NEW_DSP
        ptr = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 2) << 2);
@@ -740,7 +745,8 @@ static snd_pcm_uframes_t snd_cs46xx_playback_indirect_pointer(struct snd_pcm_sub
        struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data;
 
 #ifdef CONFIG_SND_CS46XX_NEW_DSP
-       snd_assert (cpcm->pcm_channel,return -ENXIO);
+       if (snd_BUG_ON(!cpcm->pcm_channel))
+               return -ENXIO;
        ptr = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 2) << 2);
 #else
        ptr = snd_cs46xx_peek(chip, BA1_PBA);
@@ -908,7 +914,8 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream,
        cpcm = runtime->private_data;
 
 #ifdef CONFIG_SND_CS46XX_NEW_DSP
-       snd_assert (sample_rate != 0, return -ENXIO);
+       if (snd_BUG_ON(!sample_rate))
+               return -ENXIO;
 
        mutex_lock(&chip->spos_mutex);
 
@@ -917,7 +924,7 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream,
                return -ENXIO;
        }
 
-       snd_assert (cpcm->pcm_channel != NULL);
+       snd_BUG_ON(!cpcm->pcm_channel);
        if (!cpcm->pcm_channel) {
                mutex_unlock(&chip->spos_mutex);
                return -ENXIO;
@@ -952,7 +959,7 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream,
                } else if (cpcm->pcm_channel_id == DSP_IEC958_CHANNEL) {
                        substream->ops = &snd_cs46xx_playback_iec958_ops;
                } else {
-                       snd_assert(0);
+                       snd_BUG();
                }
 #else
                substream->ops = &snd_cs46xx_playback_ops;
@@ -981,7 +988,7 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream,
                } else if (cpcm->pcm_channel_id == DSP_IEC958_CHANNEL) {
                        substream->ops = &snd_cs46xx_playback_indirect_iec958_ops;
                } else {
-                       snd_assert(0);
+                       snd_BUG();
                }
 #else
                substream->ops = &snd_cs46xx_playback_indirect_ops;
@@ -1029,7 +1036,8 @@ static int snd_cs46xx_playback_prepare(struct snd_pcm_substream *substream)
        cpcm = runtime->private_data;
 
 #ifdef CONFIG_SND_CS46XX_NEW_DSP
-    snd_assert (cpcm->pcm_channel != NULL, return -ENXIO);
+       if (snd_BUG_ON(!cpcm->pcm_channel))
+               return -ENXIO;
 
        pfie = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 1) << 2 );
        pfie &= ~0x0000f03f;
@@ -1714,9 +1722,9 @@ static void snd_cs46xx_mixer_free_ac97(struct snd_ac97 *ac97)
 {
        struct snd_cs46xx *chip = ac97->private_data;
 
-       snd_assert ((ac97 == chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]) ||
-                   (ac97 == chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]),
-                   return);
+       if (snd_BUG_ON(ac97 != chip->ac97[CS46XX_PRIMARY_CODEC_INDEX] &&
+                      ac97 != chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]))
+               return;
 
        if (ac97 == chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]) {
                chip->ac97[CS46XX_PRIMARY_CODEC_INDEX] = NULL;
@@ -1864,7 +1872,7 @@ static int snd_cs46xx_iec958_put(struct snd_kcontrol *kcontrol,
                break;
        default:
                res = -EINVAL;
-               snd_assert(0, (void)0);
+               snd_BUG(); /* should never happen ... */
        }
 
        return res;
@@ -2236,7 +2244,7 @@ static void snd_cs46xx_codec_reset (struct snd_ac97 * ac97)
                snd_printdd("cs46xx: CODOEC2 mode %04x\n",0x3);
                snd_cs46xx_ac97_write(ac97,AC97_CSR_ACMODE,0x3);
        } else {
-               snd_assert(0); /* should never happen ... */
+               snd_BUG(); /* should never happen ... */
        }
 
        udelay(50);
@@ -2553,7 +2561,8 @@ static void snd_cs46xx_gameport_trigger(struct gameport *gameport)
 {
        struct snd_cs46xx *chip = gameport_get_port_data(gameport);
 
-       snd_assert(chip, return);
+       if (snd_BUG_ON(!chip))
+               return;
        snd_cs46xx_pokeBA0(chip, BA0_JSPT, 0xFF);  //outb(gameport->io, 0xFF);
 }
 
@@ -2561,7 +2570,8 @@ static unsigned char snd_cs46xx_gameport_read(struct gameport *gameport)
 {
        struct snd_cs46xx *chip = gameport_get_port_data(gameport);
 
-       snd_assert(chip, return 0);
+       if (snd_BUG_ON(!chip))
+               return 0;
        return snd_cs46xx_peekBA0(chip, BA0_JSPT); //inb(gameport->io);
 }
 
@@ -2570,7 +2580,8 @@ static int snd_cs46xx_gameport_cooked_read(struct gameport *gameport, int *axes,
        struct snd_cs46xx *chip = gameport_get_port_data(gameport);
        unsigned js1, js2, jst;
 
-       snd_assert(chip, return 0);
+       if (snd_BUG_ON(!chip))
+               return 0;
 
        js1 = snd_cs46xx_peekBA0(chip, BA0_JSC1);
        js2 = snd_cs46xx_peekBA0(chip, BA0_JSC2);
@@ -2754,7 +2765,8 @@ static int snd_cs46xx_free(struct snd_cs46xx *chip)
 {
        int idx;
 
-       snd_assert(chip != NULL, return -EINVAL);
+       if (snd_BUG_ON(!chip))
+               return -EINVAL;
 
        if (chip->active_ctrl)
                chip->active_ctrl(chip, 1);
index ccc8bedb5b1a3e6136c913806cf347d60f7f8053..f4f0c8f5dad76ab71cf57eaf835bfda69922c972 100644 (file)
@@ -63,7 +63,8 @@ static int shadow_and_reallocate_code (struct snd_cs46xx * chip, u32 * data, u32
        u32 mop_operands,mop_type,wide_op;
        struct dsp_spos_instance * ins = chip->dsp_spos_instance;
 
-       snd_assert( ((size % 2) == 0), return -EINVAL);
+       if (snd_BUG_ON(size %2))
+               return -EINVAL;
   
        while (i < size) {
                loval = data[i++];
@@ -289,7 +290,8 @@ void  cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip)
        int i;
        struct dsp_spos_instance * ins = chip->dsp_spos_instance;
 
-       snd_assert(ins != NULL, return);
+       if (snd_BUG_ON(!ins))
+               return;
 
        mutex_lock(&chip->spos_mutex);
        for (i = 0; i < ins->nscb; ++i) {
@@ -404,7 +406,8 @@ int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * m
 
                /* if module has a code segment it must have
                   symbol table */
-               snd_assert(module->symbol_table.symbols != NULL ,return -ENOMEM);
+               if (snd_BUG_ON(!module->symbol_table.symbols))
+                       return -ENOMEM;
                if (add_symbols(chip,module)) {
                        snd_printk(KERN_ERR "dsp_spos: failed to load symbol table\n");
                        return -ENOMEM;
@@ -1369,7 +1372,8 @@ int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip)
 
        valid_slots = snd_cs46xx_peekBA0(chip, BA0_ACOSV);
 
-       snd_assert (chip->nr_ac97_codecs == 1 || chip->nr_ac97_codecs == 2);
+       if (snd_BUG_ON(chip->nr_ac97_codecs != 1 && chip->nr_ac97_codecs != 2))
+               goto _fail_end;
 
        if (chip->nr_ac97_codecs == 1) {
                /* output on slot 5 and 11 
@@ -1609,11 +1613,14 @@ static int cs46xx_dsp_async_init (struct snd_cs46xx *chip,
 
                spdifo_scb_desc = cs46xx_dsp_create_scb(chip,"SPDIFOSCB",(u32 *)&spdifo_scb,SPDIFO_SCB_INST);
 
-               snd_assert(spdifo_scb_desc, return -EIO);
+               if (snd_BUG_ON(!spdifo_scb_desc))
+                       return -EIO;
                spdifi_scb_desc = cs46xx_dsp_create_scb(chip,"SPDIFISCB",(u32 *)&spdifi_scb,SPDIFI_SCB_INST);
-               snd_assert(spdifi_scb_desc, return -EIO);
+               if (snd_BUG_ON(!spdifi_scb_desc))
+                       return -EIO;
                async_codec_scb_desc = cs46xx_dsp_create_scb(chip,"AsynCodecInputSCB",(u32 *)&async_codec_input_scb, HFG_TREE_SCB);
-               snd_assert(async_codec_scb_desc, return -EIO);
+               if (snd_BUG_ON(!async_codec_scb_desc))
+                       return -EIO;
 
                async_codec_scb_desc->parent_scb_ptr = NULL;
                async_codec_scb_desc->next_scb_ptr = spdifi_scb_desc;
@@ -1698,8 +1705,10 @@ int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip)
        chip->active_ctrl(chip, 1);
        chip->amplifier_ctrl(chip, 1);
 
-       snd_assert (ins->asynch_rx_scb == NULL,return -EINVAL);
-       snd_assert (ins->spdif_in_src != NULL,return -EINVAL);
+       if (snd_BUG_ON(ins->asynch_rx_scb))
+               return -EINVAL;
+       if (snd_BUG_ON(!ins->spdif_in_src))
+               return -EINVAL;
 
        mutex_lock(&chip->spos_mutex);
 
@@ -1754,8 +1763,10 @@ int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip)
 {
        struct dsp_spos_instance * ins = chip->dsp_spos_instance;
 
-       snd_assert (ins->asynch_rx_scb != NULL, return -EINVAL);
-       snd_assert (ins->spdif_in_src != NULL,return -EINVAL);  
+       if (snd_BUG_ON(!ins->asynch_rx_scb))
+               return -EINVAL;
+       if (snd_BUG_ON(!ins->spdif_in_src))
+               return -EINVAL;
 
        mutex_lock(&chip->spos_mutex);
 
@@ -1780,8 +1791,10 @@ int cs46xx_dsp_enable_pcm_capture (struct snd_cs46xx *chip)
 {
        struct dsp_spos_instance * ins = chip->dsp_spos_instance;
 
-       snd_assert (ins->pcm_input == NULL,return -EINVAL);
-       snd_assert (ins->ref_snoop_scb != NULL,return -EINVAL);
+       if (snd_BUG_ON(ins->pcm_input))
+               return -EINVAL;
+       if (snd_BUG_ON(!ins->ref_snoop_scb))
+               return -EINVAL;
 
        mutex_lock(&chip->spos_mutex);
        ins->pcm_input = cs46xx_add_record_source(chip,ins->ref_snoop_scb,PCMSERIALIN_PCM_SCB_ADDR,
@@ -1795,7 +1808,8 @@ int cs46xx_dsp_disable_pcm_capture (struct snd_cs46xx *chip)
 {
        struct dsp_spos_instance * ins = chip->dsp_spos_instance;
 
-       snd_assert (ins->pcm_input != NULL,return -EINVAL);
+       if (snd_BUG_ON(!ins->pcm_input))
+               return -EINVAL;
 
        mutex_lock(&chip->spos_mutex);
        cs46xx_dsp_remove_scb (chip,ins->pcm_input);
@@ -1809,8 +1823,10 @@ int cs46xx_dsp_enable_adc_capture (struct snd_cs46xx *chip)
 {
        struct dsp_spos_instance * ins = chip->dsp_spos_instance;
 
-       snd_assert (ins->adc_input == NULL,return -EINVAL);
-       snd_assert (ins->codec_in_scb != NULL,return -EINVAL);
+       if (snd_BUG_ON(ins->adc_input))
+               return -EINVAL;
+       if (snd_BUG_ON(!ins->codec_in_scb))
+               return -EINVAL;
 
        mutex_lock(&chip->spos_mutex);
        ins->adc_input = cs46xx_add_record_source(chip,ins->codec_in_scb,PCMSERIALIN_SCB_ADDR,
@@ -1824,7 +1840,8 @@ int cs46xx_dsp_disable_adc_capture (struct snd_cs46xx *chip)
 {
        struct dsp_spos_instance * ins = chip->dsp_spos_instance;
 
-       snd_assert (ins->adc_input != NULL,return -EINVAL);
+       if (snd_BUG_ON(!ins->adc_input))
+               return -EINVAL;
 
        mutex_lock(&chip->spos_mutex);
        cs46xx_dsp_remove_scb (chip,ins->adc_input);
index 2873cfe48c331605f50d23f84350ba4865ce9750..dd7c41b037b45e0700c55db9e32851a04e34ef55 100644 (file)
@@ -46,8 +46,11 @@ static void remove_symbol (struct snd_cs46xx * chip, struct dsp_symbol_entry * s
        struct dsp_spos_instance * ins = chip->dsp_spos_instance;
        int symbol_index = (int)(symbol - ins->symbol_table.symbols);
 
-       snd_assert(ins->symbol_table.nsymbols > 0,return);
-       snd_assert(symbol_index >= 0 && symbol_index < ins->symbol_table.nsymbols, return);
+       if (snd_BUG_ON(ins->symbol_table.nsymbols <= 0))
+               return;
+       if (snd_BUG_ON(symbol_index < 0 ||
+                      symbol_index >= ins->symbol_table.nsymbols))
+               return;
 
        ins->symbol_table.symbols[symbol_index].deleted = 1;
 
@@ -116,8 +119,9 @@ static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor
 
        if ( scb->parent_scb_ptr ) {
                /* unlink parent SCB */
-               snd_assert ((scb->parent_scb_ptr->sub_list_ptr == scb ||
-                            scb->parent_scb_ptr->next_scb_ptr == scb),return);
+               if (snd_BUG_ON(scb->parent_scb_ptr->sub_list_ptr != scb &&
+                              scb->parent_scb_ptr->next_scb_ptr != scb))
+                       return;
   
                if (scb->parent_scb_ptr->sub_list_ptr == scb) {
 
@@ -140,7 +144,6 @@ static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor
                                scb->next_scb_ptr = ins->the_null_scb;
                        }
                } else {
-                       /* snd_assert ( (scb->sub_list_ptr == ins->the_null_scb), return); */
                        scb->parent_scb_ptr->next_scb_ptr = scb->next_scb_ptr;
 
                        if (scb->next_scb_ptr != ins->the_null_scb) {
@@ -181,16 +184,17 @@ void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor *
        unsigned long flags;
 
        /* check integrety */
-       snd_assert ( (scb->index >= 0 && 
-                     scb->index < ins->nscb && 
-                     (ins->scbs + scb->index) == scb), return );
+       if (snd_BUG_ON(scb->index < 0 ||
+                      scb->index >= ins->nscb ||
+                      (ins->scbs + scb->index) != scb))
+               return;
 
 #if 0
        /* can't remove a SCB with childs before 
           removing childs first  */
-       snd_assert ( (scb->sub_list_ptr == ins->the_null_scb &&
-                     scb->next_scb_ptr == ins->the_null_scb),
-                    goto _end);
+       if (snd_BUG_ON(scb->sub_list_ptr != ins->the_null_scb ||
+                      scb->next_scb_ptr != ins->the_null_scb))
+               goto _end;
 #endif
 
        spin_lock_irqsave(&scb->lock, flags);
@@ -198,7 +202,8 @@ void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor *
        spin_unlock_irqrestore(&scb->lock, flags);
 
        cs46xx_dsp_proc_free_scb_desc(scb);
-       snd_assert (scb->scb_symbol != NULL, return );
+       if (snd_BUG_ON(!scb->scb_symbol))
+               return;
        remove_symbol (chip,scb->scb_symbol);
 
        ins->scbs[scb->index].deleted = 1;
@@ -234,7 +239,6 @@ void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb)
                snd_info_free_entry(scb->proc_info);
                scb->proc_info = NULL;
 
-               snd_assert (scb_info != NULL, return);
                kfree (scb_info);
        }
 }
@@ -291,7 +295,8 @@ _dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u
   
        unsigned long flags;
 
-       snd_assert (ins->the_null_scb != NULL,return NULL);
+       if (snd_BUG_ON(!ins->the_null_scb))
+               return NULL;
 
        /* fill the data that will be wroten to DSP */
        scb_data[SCBsubListPtr] = 
@@ -321,18 +326,20 @@ _dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u
 #endif
                /* link to  parent SCB */
                if (scb_child_type == SCB_ON_PARENT_NEXT_SCB) {
-                       snd_assert ( (scb->parent_scb_ptr->next_scb_ptr == ins->the_null_scb),
-                                    return NULL);
+                       if (snd_BUG_ON(scb->parent_scb_ptr->next_scb_ptr !=
+                                      ins->the_null_scb))
+                               return NULL;
 
                        scb->parent_scb_ptr->next_scb_ptr = scb;
 
                } else if (scb_child_type == SCB_ON_PARENT_SUBLIST_SCB) {
-                       snd_assert ( (scb->parent_scb_ptr->sub_list_ptr == ins->the_null_scb),
-                                    return NULL);
+                       if (snd_BUG_ON(scb->parent_scb_ptr->sub_list_ptr !=
+                                      ins->the_null_scb))
+                               return NULL;
 
                        scb->parent_scb_ptr->sub_list_ptr = scb;
                } else {
-                       snd_assert (0,return NULL);
+                       snd_BUG();
                }
 
                spin_lock_irqsave(&chip->reg_lock, flags);
@@ -675,7 +682,7 @@ cs46xx_dsp_create_src_task_scb(struct snd_cs46xx * chip, char * scb_name,
                if (pass_through) {
                        /* wont work with any other rate than
                           the native DSP rate */
-                       snd_assert (rate == 48000);
+                       snd_BUG_ON(rate != 48000);
 
                        scb = cs46xx_dsp_create_generic_scb(chip,scb_name,(u32 *)&src_task_scb,
                                                            dest,"DMAREADER",parent_scb,
@@ -1142,7 +1149,8 @@ find_next_free_scb (struct snd_cs46xx * chip, struct dsp_scb_descriptor * from)
        struct dsp_scb_descriptor * scb = from;
 
        while (scb->next_scb_ptr != ins->the_null_scb) {
-               snd_assert (scb->next_scb_ptr != NULL, return NULL);
+               if (snd_BUG_ON(!scb->next_scb_ptr))
+                       return NULL;
 
                scb = scb->next_scb_ptr;
        }
@@ -1246,10 +1254,11 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
                break;
        case DSP_PCM_S71_CHANNEL:
                /* TODO */
-               snd_assert(0);
+               snd_BUG();
                break;
        case DSP_IEC958_CHANNEL:
-               snd_assert (ins->asynch_tx_scb != NULL, return NULL);
+               if (snd_BUG_ON(!ins->asynch_tx_scb))
+                       return NULL;
                mixer_scb = ins->asynch_tx_scb;
 
                /* if sample rate is set to 48khz we pass
@@ -1262,7 +1271,7 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
                }
                break;
        default:
-               snd_assert (0);
+               snd_BUG();
                return NULL;
        }
        /* default sample rate is 44100 */
@@ -1308,7 +1317,8 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
                                break;
                        }
                }
-               snd_assert (src_index != -1,return NULL);
+               if (snd_BUG_ON(src_index == -1))
+                       return NULL;
 
                /* we need to create a new SRC SCB */
                if (mixer_scb->sub_list_ptr == ins->the_null_scb) {
@@ -1462,9 +1472,10 @@ void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip,
        struct dsp_spos_instance * ins = chip->dsp_spos_instance;
        unsigned long flags;
 
-       snd_assert(pcm_channel->active, return );
-       snd_assert(ins->npcm_channels > 0, return );
-       snd_assert(pcm_channel->src_scb->ref_count > 0, return );
+       if (snd_BUG_ON(!pcm_channel->active ||
+                      ins->npcm_channels <= 0 ||
+                      pcm_channel->src_scb->ref_count <= 0))
+               return;
 
        spin_lock_irqsave(&chip->reg_lock, flags);
        pcm_channel->unlinked = 1;
@@ -1479,8 +1490,9 @@ void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip,
        if (!pcm_channel->src_scb->ref_count) {
                cs46xx_dsp_remove_scb(chip,pcm_channel->src_scb);
 
-               snd_assert (pcm_channel->src_slot >= 0 && pcm_channel->src_slot < DSP_MAX_SRC_NR,
-                           return );
+               if (snd_BUG_ON(pcm_channel->src_slot < 0 ||
+                              pcm_channel->src_slot >= DSP_MAX_SRC_NR))
+                       return;
 
                ins->src_scb_slots[pcm_channel->src_slot] = 0;
                ins->nsrc_scb --;
@@ -1490,11 +1502,11 @@ void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip,
 int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip,
                           struct dsp_pcm_channel_descriptor * pcm_channel)
 {
-       struct dsp_spos_instance * ins = chip->dsp_spos_instance;
        unsigned long flags;
 
-       snd_assert(pcm_channel->active,return -EIO);
-       snd_assert(ins->npcm_channels > 0,return -EIO);
+       if (snd_BUG_ON(!pcm_channel->active ||
+                      chip->dsp_spos_instance->npcm_channels <= 0))
+               return -EIO;
 
        spin_lock(&pcm_channel->src_scb->lock);
 
@@ -1537,7 +1549,7 @@ int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip,
 
        src_scb->sub_list_ptr = pcm_channel->pcm_reader_scb;
 
-       snd_assert (pcm_channel->pcm_reader_scb->parent_scb_ptr == NULL, ; );
+       snd_BUG_ON(pcm_channel->pcm_reader_scb->parent_scb_ptr);
        pcm_channel->pcm_reader_scb->parent_scb_ptr = parent_scb;
 
        spin_lock_irqsave(&chip->reg_lock, flags);
@@ -1564,7 +1576,8 @@ cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * s
        struct dsp_scb_descriptor * pcm_input;
        int insert_point;
 
-       snd_assert (ins->record_mixer_scb != NULL,return NULL);
+       if (snd_BUG_ON(!ins->record_mixer_scb))
+               return NULL;
 
        if (ins->record_mixer_scb->sub_list_ptr != ins->the_null_scb) {
                parent = find_next_free_scb (chip,ins->record_mixer_scb->sub_list_ptr);
@@ -1583,7 +1596,8 @@ cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * s
 
 int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src)
 {
-       snd_assert (src->parent_scb_ptr != NULL,  return -EINVAL );
+       if (snd_BUG_ON(!src->parent_scb_ptr))
+               return -EINVAL;
 
        /* mute SCB */
        cs46xx_dsp_scb_set_volume (chip,src,0,0);
@@ -1598,8 +1612,10 @@ int cs46xx_src_link(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src)
        struct dsp_spos_instance * ins = chip->dsp_spos_instance;
        struct dsp_scb_descriptor * parent_scb;
 
-       snd_assert (src->parent_scb_ptr == NULL,   return -EINVAL );
-       snd_assert(ins->master_mix_scb !=NULL,   return -EINVAL );
+       if (snd_BUG_ON(src->parent_scb_ptr))
+               return -EINVAL;
+       if (snd_BUG_ON(!ins->master_mix_scb))
+               return -EINVAL;
 
        if (ins->master_mix_scb->sub_list_ptr != ins->the_null_scb) {
                parent_scb = find_next_free_scb (chip,ins->master_mix_scb->sub_list_ptr);
@@ -1635,8 +1651,11 @@ int cs46xx_dsp_enable_spdif_out (struct snd_cs46xx *chip)
                return -EBUSY;
        }
 
-       snd_assert (ins->asynch_tx_scb == NULL, return -EINVAL);
-       snd_assert (ins->master_mix_scb->next_scb_ptr == ins->the_null_scb, return -EINVAL);
+       if (snd_BUG_ON(ins->asynch_tx_scb))
+               return -EINVAL;
+       if (snd_BUG_ON(ins->master_mix_scb->next_scb_ptr !=
+                      ins->the_null_scb))
+               return -EINVAL;
 
        /* reset output snooper sample buffer pointer */
        snd_cs46xx_poke (chip, (ins->ref_snoop_scb->address + 2) << 2,
@@ -1676,10 +1695,15 @@ int  cs46xx_dsp_disable_spdif_out (struct snd_cs46xx *chip)
        }
 
        /* check integrety */
-       snd_assert (ins->asynch_tx_scb != NULL, return -EINVAL);
-       snd_assert (ins->spdif_pcm_input_scb != NULL,return -EINVAL);
-       snd_assert (ins->master_mix_scb->next_scb_ptr == ins->asynch_tx_scb, return -EINVAL);
-       snd_assert (ins->asynch_tx_scb->parent_scb_ptr == ins->master_mix_scb, return -EINVAL);
+       if (snd_BUG_ON(!ins->asynch_tx_scb))
+               return -EINVAL;
+       if (snd_BUG_ON(!ins->spdif_pcm_input_scb))
+               return -EINVAL;
+       if (snd_BUG_ON(ins->master_mix_scb->next_scb_ptr != ins->asynch_tx_scb))
+               return -EINVAL;
+       if (snd_BUG_ON(ins->asynch_tx_scb->parent_scb_ptr !=
+                      ins->master_mix_scb))
+               return -EINVAL;
 
        cs46xx_dsp_remove_scb (chip,ins->spdif_pcm_input_scb);
        cs46xx_dsp_remove_scb (chip,ins->asynch_tx_scb);
@@ -1734,7 +1758,8 @@ int cs46xx_iec958_post_close (struct snd_cs46xx *chip)
 {
        struct dsp_spos_instance * ins = chip->dsp_spos_instance;
 
-       snd_assert (ins->asynch_tx_scb != NULL, return -EINVAL);
+       if (snd_BUG_ON(!ins->asynch_tx_scb))
+               return -EINVAL;
 
        ins->spdif_status_out  &= ~DSP_SPDIF_STATUS_PLAYBACK_OPEN;
 
index 4159e3bc186f359ab3076dff75ce14c9f02b870b..29043301ebb867aaaf32f0b6221905407e0f5a0f 100644 (file)
@@ -34,7 +34,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
        int err;
 
        DE_INIT(("init_hw() - Darla20\n"));
-       snd_assert((subdevice_id & 0xfff0) == DARLA20, return -ENODEV);
+       if (snd_BUG_ON((subdevice_id & 0xfff0) != DARLA20))
+               return -ENODEV;
 
        if ((err = init_dsp_comm_page(chip))) {
                DE_INIT(("init_hw - could not initialize DSP comm page\n"));
index 79938eed7e9c20cbdaa106123877cb63526a5562..60228731841f84fc2b1bc814242f9e9d06839451 100644 (file)
@@ -34,7 +34,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
        int err;
 
        DE_INIT(("init_hw() - Darla24\n"));
-       snd_assert((subdevice_id & 0xfff0) == DARLA24, return -ENODEV);
+       if (snd_BUG_ON((subdevice_id & 0xfff0) != DARLA24))
+               return -ENODEV;
 
        if ((err = init_dsp_comm_page(chip))) {
                DE_INIT(("init_hw - could not initialize DSP comm page\n"));
@@ -148,8 +149,9 @@ static int set_sample_rate(struct echoaudio *chip, u32 rate)
 
 static int set_input_clock(struct echoaudio *chip, u16 clock)
 {
-       snd_assert(clock == ECHO_CLOCK_INTERNAL ||
-                  clock == ECHO_CLOCK_ESYNC, return -EINVAL);
+       if (snd_BUG_ON(clock != ECHO_CLOCK_INTERNAL &&
+                      clock != ECHO_CLOCK_ESYNC))
+               return -EINVAL;
        chip->input_clock = clock;
        return set_sample_rate(chip, chip->sample_rate);
 }
index 48eb7c599111b62e5a2af76b3962c1831db14808..417e25add82bccdb120724b837b5d32f52b2f62c 100644 (file)
@@ -47,7 +47,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
 
        local_irq_enable();
        DE_INIT(("init_hw() - Echo3G\n"));
-       snd_assert((subdevice_id & 0xfff0) == ECHO3G, return -ENODEV);
+       if (snd_BUG_ON((subdevice_id & 0xfff0) != ECHO3G))
+               return -ENODEV;
 
        if ((err = init_dsp_comm_page(chip))) {
                DE_INIT(("init_hw - could not initialize DSP comm page\n"));
@@ -104,9 +105,11 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
        if ((err = init_line_levels(chip)) < 0)
                return err;
        err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA);
-       snd_assert(err >= 0, return err);
+       if (err < 0)
+               return err;
        err = set_phantom_power(chip, 0);
-       snd_assert(err >= 0, return err);
+       if (err < 0)
+               return err;
        err = set_professional_spdif(chip, TRUE);
 
        DE_INIT(("init_hw done\n"));
index e16dc92e82fb4359e5ae92b11300fce4dd9e9c9c..160d470549227cbba9ac91e7ef2b2dc5b4b149dc 100644 (file)
@@ -503,7 +503,7 @@ static int init_engine(struct snd_pcm_substream *substream,
        if (pipe->index >= 0) {
                DE_HWP(("hwp_ie free(%d)\n", pipe->index));
                err = free_pipes(chip, pipe);
-               snd_assert(!err);
+               snd_BUG_ON(err);
                chip->substream[pipe->index] = NULL;
        }
 
@@ -690,8 +690,10 @@ static int pcm_prepare(struct snd_pcm_substream *substream)
                return -EINVAL;
        }
 
-       snd_assert(pipe_index < px_num(chip), return -EINVAL);
-       snd_assert(is_pipe_allocated(chip, pipe_index), return -EINVAL);
+       if (snd_BUG_ON(pipe_index >= px_num(chip)))
+               return -EINVAL;
+       if (snd_BUG_ON(!is_pipe_allocated(chip, pipe_index)))
+               return -EINVAL;
        set_audio_format(chip, pipe_index, &format);
        return 0;
 }
index 52a933189576ad5a2f1060347af38dc5d88786d7..c3736bbd819e31da81312ccf942ff687bfa787d7 100644 (file)
@@ -103,9 +103,11 @@ static int set_digital_mode(struct echoaudio *chip, u8 mode)
        int err, i, o;
 
        /* All audio channels must be closed before changing the digital mode */
-       snd_assert(!chip->pipe_alloc_mask, return -EAGAIN);
+       if (snd_BUG_ON(chip->pipe_alloc_mask))
+               return -EAGAIN;
 
-       snd_assert(chip->digital_modes & (1 << mode), return -EINVAL);
+       if (snd_BUG_ON(!(chip->digital_modes & (1 << mode))))
+               return -EINVAL;
 
        previous_mode = chip->digital_mode;
        err = dsp_set_digital_mode(chip, mode);
@@ -267,8 +269,9 @@ static int set_sample_rate(struct echoaudio *chip, u32 rate)
                return 0;
        }
 
-       snd_assert(rate < 50000 || chip->digital_mode != DIGITAL_MODE_ADAT,
-                  return -EINVAL);
+       if (snd_BUG_ON(rate >= 50000 &&
+                      chip->digital_mode == DIGITAL_MODE_ADAT))
+               return -EINVAL;
 
        clock = 0;
        control_reg = le32_to_cpu(chip->comm_page->control_register);
index e6c100770392ef20b146903bc142305323a301f8..be0e18192de3ffca06502cbbc23e872df3d0cecb 100644 (file)
@@ -474,7 +474,8 @@ static int load_firmware(struct echoaudio *chip)
        const struct firmware *fw;
        int box_type, err;
 
-       snd_assert(chip->dsp_code_to_load && chip->comm_page, return -EPERM);
+       if (snd_BUG_ON(!chip->dsp_code_to_load || !chip->comm_page))
+               return -EPERM;
 
        /* See if the ASIC is present and working - only if the DSP is already loaded */
        if (chip->dsp_code) {
@@ -512,8 +513,8 @@ static int load_firmware(struct echoaudio *chip)
 /* Set the nominal level for an input or output bus (true = -10dBV, false = +4dBu) */
 static int set_nominal_level(struct echoaudio *chip, u16 index, char consumer)
 {
-       snd_assert(index < num_busses_out(chip) + num_busses_in(chip),
-                  return -EINVAL);
+       if (snd_BUG_ON(index >= num_busses_out(chip) + num_busses_in(chip)))
+               return -EINVAL;
 
        /* Wait for the handshake (OK even if ASIC is not loaded) */
        if (wait_handshake(chip))
@@ -536,7 +537,8 @@ static int set_nominal_level(struct echoaudio *chip, u16 index, char consumer)
 /* Set the gain for a single physical output channel (dB). */
 static int set_output_gain(struct echoaudio *chip, u16 channel, s8 gain)
 {
-       snd_assert(channel < num_busses_out(chip), return -EINVAL);
+       if (snd_BUG_ON(channel >= num_busses_out(chip)))
+               return -EINVAL;
 
        if (wait_handshake(chip))
                return -EIO;
@@ -554,8 +556,9 @@ static int set_output_gain(struct echoaudio *chip, u16 channel, s8 gain)
 static int set_monitor_gain(struct echoaudio *chip, u16 output, u16 input,
                            s8 gain)
 {
-       snd_assert(output < num_busses_out(chip) &&
-                  input < num_busses_in(chip), return -EINVAL);
+       if (snd_BUG_ON(output >= num_busses_out(chip) ||
+                   input >= num_busses_in(chip)))
+               return -EINVAL;
 
        if (wait_handshake(chip))
                return -EIO;
@@ -1065,8 +1068,10 @@ static int free_pipes(struct echoaudio *chip, struct audiopipe *pipe)
        int i;
 
        DE_ACT(("free_pipes: Pipe %d\n", pipe->index));
-       snd_assert(is_pipe_allocated(chip, pipe->index), return -EINVAL);
-       snd_assert(pipe->state == PIPE_STATE_STOPPED, return -EINVAL);
+       if (snd_BUG_ON(!is_pipe_allocated(chip, pipe->index)))
+               return -EINVAL;
+       if (snd_BUG_ON(pipe->state != PIPE_STATE_STOPPED))
+               return -EINVAL;
 
        for (channel_mask = i = 0; i < pipe->interleave; i++)
                channel_mask |= 1 << (pipe->index + i);
index 3aa37e76ebab12f3f895d75f128d9eeada3fe209..afa273330e8a744b37327f679b55bda61f1924e4 100644 (file)
@@ -112,9 +112,11 @@ static int set_digital_mode(struct echoaudio *chip, u8 mode)
                return -EIO;
 
        /* All audio channels must be closed before changing the digital mode */
-       snd_assert(!chip->pipe_alloc_mask, return -EAGAIN);
+       if (snd_BUG_ON(chip->pipe_alloc_mask))
+               return -EAGAIN;
 
-       snd_assert(chip->digital_modes & (1 << mode), return -EINVAL);
+       if (snd_BUG_ON(!(chip->digital_modes & (1 << mode))))
+               return -EINVAL;
 
        previous_mode = chip->digital_mode;
        err = dsp_set_digital_mode(chip, mode);
index 2757c89608434f4a3c48f59d8520c0be39d800fe..db6c952e9d7f12e77a799d0e8edaabd12c8af5a8 100644 (file)
@@ -38,7 +38,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
        int err;
 
        DE_INIT(("init_hw() - Gina20\n"));
-       snd_assert((subdevice_id & 0xfff0) == GINA20, return -ENODEV);
+       if (snd_BUG_ON((subdevice_id & 0xfff0) != GINA20))
+               return -ENODEV;
 
        if ((err = init_dsp_comm_page(chip))) {
                DE_INIT(("init_hw - could not initialize DSP comm page\n"));
@@ -177,7 +178,8 @@ static int set_input_clock(struct echoaudio *chip, u16 clock)
 /* Set input bus gain (one unit is 0.5dB !) */
 static int set_input_gain(struct echoaudio *chip, u16 input, int gain)
 {
-       snd_assert(input < num_busses_in(chip), return -EINVAL);
+       if (snd_BUG_ON(input >= num_busses_in(chip)))
+               return -EINVAL;
 
        if (wait_handshake(chip))
                return -EIO;
index 144fc567becf1ff179ea6fac383c2162b350e19c..2fef37a2a5b96693abc5988fc420a7827d36b8ae 100644 (file)
@@ -43,7 +43,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
        int err;
 
        DE_INIT(("init_hw() - Gina24\n"));
-       snd_assert((subdevice_id & 0xfff0) == GINA24, return -ENODEV);
+       if (snd_BUG_ON((subdevice_id & 0xfff0) != GINA24))
+               return -ENODEV;
 
        if ((err = init_dsp_comm_page(chip))) {
                DE_INIT(("init_hw - could not initialize DSP comm page\n"));
@@ -84,7 +85,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
        if ((err = init_line_levels(chip)) < 0)
                return err;
        err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA);
-       snd_assert(err >= 0, return err);
+       if (err < 0)
+               return err;
        err = set_professional_spdif(chip, TRUE);
 
        DE_INIT(("init_hw done\n"));
@@ -163,8 +165,9 @@ static int set_sample_rate(struct echoaudio *chip, u32 rate)
 {
        u32 control_reg, clock;
 
-       snd_assert(rate < 50000 || chip->digital_mode != DIGITAL_MODE_ADAT,
-                  return -EINVAL);
+       if (snd_BUG_ON(rate >= 50000 &&
+                      chip->digital_mode == DIGITAL_MODE_ADAT))
+               return -EINVAL;
 
        /* Only set the clock for internal mode. */
        if (chip->input_clock != ECHO_CLOCK_INTERNAL) {
index d6ac7734609e7fcd151856cd22dc05a88d619889..f05e39f7aad943c2e5591cda8aac4b4336d524de 100644 (file)
@@ -39,7 +39,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
        int err;
 
        DE_INIT(("init_hw() - Indigo\n"));
-       snd_assert((subdevice_id & 0xfff0) == INDIGO, return -ENODEV);
+       if (snd_BUG_ON((subdevice_id & 0xfff0) != INDIGO))
+               return -ENODEV;
 
        if ((err = init_dsp_comm_page(chip))) {
                DE_INIT(("init_hw - could not initialize DSP comm page\n"));
@@ -143,8 +144,9 @@ static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
 {
        int index;
 
-       snd_assert(pipe < num_pipes_out(chip) &&
-                  output < num_busses_out(chip), return -EINVAL);
+       if (snd_BUG_ON(pipe >= num_pipes_out(chip) ||
+                      output >= num_busses_out(chip)))
+               return -EINVAL;
 
        if (wait_handshake(chip))
                return -EIO;
index 500e150b49fcaa340f6028300d1de19d62d57798..90730a5ecb422b880c8e36aff0d21adf2d8198aa 100644 (file)
@@ -39,7 +39,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
        int err;
 
        DE_INIT(("init_hw() - Indigo DJ\n"));
-       snd_assert((subdevice_id & 0xfff0) == INDIGO_DJ, return -ENODEV);
+       if (snd_BUG_ON((subdevice_id & 0xfff0) != INDIGO_DJ))
+               return -ENODEV;
 
        if ((err = init_dsp_comm_page(chip))) {
                DE_INIT(("init_hw - could not initialize DSP comm page\n"));
@@ -143,8 +144,9 @@ static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
 {
        int index;
 
-       snd_assert(pipe < num_pipes_out(chip) &&
-                  output < num_busses_out(chip), return -EINVAL);
+       if (snd_BUG_ON(pipe >= num_pipes_out(chip) ||
+                      output >= num_busses_out(chip)))
+               return -EINVAL;
 
        if (wait_handshake(chip))
                return -EIO;
index f3ad13d06be0237f42a4fd511943c50fb3aa1ee1..a7e09ec2107908f395319ca8b9cb0ab491b646f9 100644 (file)
@@ -39,7 +39,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
        int err;
 
        DE_INIT(("init_hw() - Indigo IO\n"));
-       snd_assert((subdevice_id & 0xfff0) == INDIGO_IO, return -ENODEV);
+       if (snd_BUG_ON((subdevice_id & 0xfff0) != INDIGO_IO))
+               return -ENODEV;
 
        if ((err = init_dsp_comm_page(chip))) {
                DE_INIT(("init_hw - could not initialize DSP comm page\n"));
@@ -114,8 +115,9 @@ static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
 {
        int index;
 
-       snd_assert(pipe < num_pipes_out(chip) &&
-                  output < num_busses_out(chip), return -EINVAL);
+       if (snd_BUG_ON(pipe >= num_pipes_out(chip) ||
+                      output >= num_busses_out(chip)))
+               return -EINVAL;
 
        if (wait_handshake(chip))
                return -EIO;
index 990c9a60a0a89a81f8acf6c280faa50395d17012..ede75c6ca0fb7520fb8ec8b93049da396618f946 100644 (file)
@@ -42,7 +42,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
        int err;
 
        DE_INIT(("init_hw() - Layla20\n"));
-       snd_assert((subdevice_id & 0xfff0) == LAYLA20, return -ENODEV);
+       if (snd_BUG_ON((subdevice_id & 0xfff0) != LAYLA20))
+               return -ENODEV;
 
        if ((err = init_dsp_comm_page(chip))) {
                DE_INIT(("init_hw - could not initialize DSP comm page\n"));
@@ -155,7 +156,8 @@ static int load_asic(struct echoaudio *chip)
 
 static int set_sample_rate(struct echoaudio *chip, u32 rate)
 {
-       snd_assert(rate >= 8000 && rate <= 50000, return -EINVAL);
+       if (snd_BUG_ON(rate < 8000 || rate > 50000))
+               return -EINVAL;
 
        /* Only set the clock for internal mode. Do not return failure,
           simply treat it as a non-event. */
@@ -252,7 +254,8 @@ static int set_output_clock(struct echoaudio *chip, u16 clock)
 /* Set input bus gain (one unit is 0.5dB !) */
 static int set_input_gain(struct echoaudio *chip, u16 input, int gain)
 {
-       snd_assert(input < num_busses_in(chip), return -EINVAL);
+       if (snd_BUG_ON(input >= num_busses_in(chip)))
+               return -EINVAL;
 
        if (wait_handshake(chip))
                return -EIO;
index 97e42e1151476cdafbb40ac83a6d09b2798bd704..d61b5cbcccad4235314d6d0bd05ee93e82ed282f 100644 (file)
@@ -42,7 +42,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
        int err;
 
        DE_INIT(("init_hw() - Layla24\n"));
-       snd_assert((subdevice_id & 0xfff0) == LAYLA24, return -ENODEV);
+       if (snd_BUG_ON((subdevice_id & 0xfff0) != LAYLA24))
+               return -ENODEV;
 
        if ((err = init_dsp_comm_page(chip))) {
                DE_INIT(("init_hw - could not initialize DSP comm page\n"));
@@ -73,7 +74,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
                return err;
 
        err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA);
-       snd_assert(err >= 0, return err);
+       if (err < 0)
+               return err;
        err = set_professional_spdif(chip, TRUE);
 
        DE_INIT(("init_hw done\n"));
@@ -158,8 +160,9 @@ static int set_sample_rate(struct echoaudio *chip, u32 rate)
 {
        u32 control_reg, clock, base_rate;
 
-       snd_assert(rate < 50000 || chip->digital_mode != DIGITAL_MODE_ADAT,
-                  return -EINVAL);
+       if (snd_BUG_ON(rate >= 50000 &&
+                      chip->digital_mode == DIGITAL_MODE_ADAT))
+               return -EINVAL;
 
        /* Only set the clock for internal mode. */
        if (chip->input_clock != ECHO_CLOCK_INTERNAL) {
index 891c7051909648948566eb0e8c0887ce25d1c899..227386602f9b6a86064f8c92c94acbb980a953f3 100644 (file)
@@ -42,7 +42,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
        int err;
 
        DE_INIT(("init_hw() - Mia\n"));
-       snd_assert((subdevice_id & 0xfff0) == MIA, return -ENODEV);
+       if (snd_BUG_ON((subdevice_id & 0xfff0) != MIA))
+               return -ENODEV;
 
        if ((err = init_dsp_comm_page(chip))) {
                DE_INIT(("init_hw - could not initialize DSP comm page\n"));
@@ -161,8 +162,9 @@ static int set_sample_rate(struct echoaudio *chip, u32 rate)
 static int set_input_clock(struct echoaudio *chip, u16 clock)
 {
        DE_ACT(("set_input_clock(%d)\n", clock));
-       snd_assert(clock == ECHO_CLOCK_INTERNAL || clock == ECHO_CLOCK_SPDIF,
-                  return -EINVAL);
+       if (snd_BUG_ON(clock != ECHO_CLOCK_INTERNAL &&
+                      clock != ECHO_CLOCK_SPDIF))
+               return -EINVAL;
 
        chip->input_clock = clock;
        return set_sample_rate(chip, chip->sample_rate);
@@ -176,8 +178,9 @@ static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
 {
        int index;
 
-       snd_assert(pipe < num_pipes_out(chip) &&
-                  output < num_busses_out(chip), return -EINVAL);
+       if (snd_BUG_ON(pipe >= num_pipes_out(chip) ||
+                      output >= num_busses_out(chip)))
+               return -EINVAL;
 
        if (wait_handshake(chip))
                return -EIO;
index 91f5bff66d3f923fa870184bfc3705be62b1f7a9..77bf2a83d9970751c3e26a449c7dfa1d882f89d8 100644 (file)
@@ -59,7 +59,8 @@ static int enable_midi_input(struct echoaudio *chip, char enable)
 Returns how many actually written or < 0 on error */
 static int write_midi(struct echoaudio *chip, u8 *data, int bytes)
 {
-       snd_assert(bytes > 0 && bytes < MIDI_OUT_BUFFER_SIZE, return -EINVAL);
+       if (snd_BUG_ON(bytes <= 0 || bytes >= MIDI_OUT_BUFFER_SIZE))
+               return -EINVAL;
 
        if (wait_handshake(chip))
                return -EIO;
@@ -119,7 +120,8 @@ static int midi_service_irq(struct echoaudio *chip)
        /* The count is at index 0, followed by actual data */
        count = le16_to_cpu(chip->comm_page->midi_input[0]);
 
-       snd_assert(count < MIDI_IN_BUFFER_SIZE, return 0);
+       if (snd_BUG_ON(count >= MIDI_IN_BUFFER_SIZE))
+               return 0;
 
        /* Get the MIDI data from the comm page */
        i = 1;
index c0b4bf0be7d1af6273ef8c8cab9c46e38e0b0c12..eaa619bd2a0343f2d9a5e7a7c7c8b54585a9413c 100644 (file)
@@ -43,7 +43,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
        int err;
 
        DE_INIT(("init_hw() - Mona\n"));
-       snd_assert((subdevice_id & 0xfff0) == MONA, return -ENODEV);
+       if (snd_BUG_ON((subdevice_id & 0xfff0) != MONA))
+               return -ENODEV;
 
        if ((err = init_dsp_comm_page(chip))) {
                DE_INIT(("init_hw - could not initialize DSP comm page\n"));
@@ -79,7 +80,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
                return err;
 
        err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA);
-       snd_assert(err >= 0, return err);
+       if (err < 0)
+               return err;
        err = set_professional_spdif(chip, TRUE);
 
        DE_INIT(("init_hw done\n"));
index 45088ebcce5041a9b25e147d41be6add78351f05..0e649dcdbf64bef54d800e8ad7b3384124ca0efe 100644 (file)
@@ -145,7 +145,8 @@ terminate_voice(struct snd_emux_voice *vp)
 {
        struct snd_emu10k1 *hw;
        
-       snd_assert(vp, return);
+       if (snd_BUG_ON(!vp))
+               return;
        hw = vp->hw;
        snd_emu10k1_ptr_write(hw, DCYSUSV, vp->ch, 0x807f | DCYSUSV_CHANNELENABLE_MASK);
        if (vp->block) {
@@ -325,7 +326,8 @@ start_voice(struct snd_emux_voice *vp)
        
        hw = vp->hw;
        ch = vp->ch;
-       snd_assert(ch >= 0, return -EINVAL);
+       if (snd_BUG_ON(ch < 0))
+               return -EINVAL;
        chan = vp->chan;
 
        emem = (struct snd_emu10k1_memblk *)vp->block;
index 42bae6f7e9a4c61458c96dab0cc89d5c2fa0252c..e10f027bde03a660899e1a440538c2a661d150e9 100644 (file)
@@ -46,8 +46,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
        struct snd_emu10k1 *emu;
 
        emu = rec->hw;
-       snd_assert(sp != NULL, return -EINVAL);
-       snd_assert(hdr != NULL, return -EINVAL);
+       if (snd_BUG_ON(!sp || !hdr))
+               return -EINVAL;
 
        if (sp->v.size == 0) {
                snd_printd("emu: rom font for sample %d\n", sp->v.sample);
@@ -104,7 +104,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
        size = BLANK_HEAD_SIZE;
        if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS))
                size *= 2;
-       snd_assert(offset + size <= blocksize, return -EINVAL);
+       if (offset + size > blocksize)
+               return -EINVAL;
        snd_emu10k1_synth_bzero(emu, sp->block, offset, size);
        offset += size;
 
@@ -112,7 +113,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
        size = loopend;
        if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS))
                size *= 2;
-       snd_assert(offset + size <= blocksize, return -EINVAL);
+       if (offset + size > blocksize)
+               return -EINVAL;
        if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size)) {
                snd_emu10k1_synth_free(emu, sp->block);
                sp->block = NULL;
@@ -129,12 +131,14 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
                        int woffset;
                        unsigned short *wblock = (unsigned short*)block;
                        woffset = offset / 2;
-                       snd_assert(offset + loopsize*2 <= blocksize, return -EINVAL);
+                       if (offset + loopsize * 2 > blocksize)
+                               return -EINVAL;
                        for (i = 0; i < loopsize; i++)
                                wblock[woffset + i] = wblock[woffset - i -1];
                        offset += loopsize * 2;
                } else {
-                       snd_assert(offset + loopsize <= blocksize, return -EINVAL);
+                       if (offset + loopsize > blocksize)
+                               return -EINVAL;
                        for (i = 0; i < loopsize; i++)
                                block[offset + i] = block[offset - i -1];
                        offset += loopsize;
@@ -154,7 +158,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
 
        /* loopend -> sample end */
        size = sp->v.size - loopend;
-       snd_assert(size >= 0, return -EINVAL);
+       if (size < 0)
+               return -EINVAL;
        if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS))
                size *= 2;
        if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size)) {
@@ -212,8 +217,8 @@ snd_emu10k1_sample_free(struct snd_emux *rec, struct snd_sf_sample *sp,
        struct snd_emu10k1 *emu;
 
        emu = rec->hw;
-       snd_assert(sp != NULL, return -EINVAL);
-       snd_assert(hdr != NULL, return -EINVAL);
+       if (snd_BUG_ON(!sp || !hdr))
+               return -EINVAL;
 
        if (sp->block) {
                snd_emu10k1_synth_free(emu, sp->block);
index 491a4a50f869c3dca9887bb9347ca6af64eb5d9b..5ff4dbb62dad1412e3f7ca987052427086912944 100644 (file)
@@ -1319,7 +1319,8 @@ static int snd_emu10k1x_midi_input_open(struct snd_rawmidi_substream *substream)
        unsigned long flags;
        
        emu = midi->emu;
-       snd_assert(emu, return -ENXIO);
+       if (snd_BUG_ON(!emu))
+               return -ENXIO;
        spin_lock_irqsave(&midi->open_lock, flags);
        midi->midi_mode |= EMU10K1X_MIDI_MODE_INPUT;
        midi->substream_input = substream;
@@ -1345,7 +1346,8 @@ static int snd_emu10k1x_midi_output_open(struct snd_rawmidi_substream *substream
        unsigned long flags;
 
        emu = midi->emu;
-       snd_assert(emu, return -ENXIO);
+       if (snd_BUG_ON(!emu))
+               return -ENXIO;
        spin_lock_irqsave(&midi->open_lock, flags);
        midi->midi_mode |= EMU10K1X_MIDI_MODE_OUTPUT;
        midi->substream_output = substream;
@@ -1372,7 +1374,8 @@ static int snd_emu10k1x_midi_input_close(struct snd_rawmidi_substream *substream
        int err = 0;
 
        emu = midi->emu;
-       snd_assert(emu, return -ENXIO);
+       if (snd_BUG_ON(!emu))
+               return -ENXIO;
        spin_lock_irqsave(&midi->open_lock, flags);
        snd_emu10k1x_intr_disable(emu, midi->rx_enable);
        midi->midi_mode &= ~EMU10K1X_MIDI_MODE_INPUT;
@@ -1394,7 +1397,8 @@ static int snd_emu10k1x_midi_output_close(struct snd_rawmidi_substream *substrea
        int err = 0;
 
        emu = midi->emu;
-       snd_assert(emu, return -ENXIO);
+       if (snd_BUG_ON(!emu))
+               return -ENXIO;
        spin_lock_irqsave(&midi->open_lock, flags);
        snd_emu10k1x_intr_disable(emu, midi->tx_enable);
        midi->midi_mode &= ~EMU10K1X_MIDI_MODE_OUTPUT;
@@ -1413,7 +1417,8 @@ static void snd_emu10k1x_midi_input_trigger(struct snd_rawmidi_substream *substr
        struct emu10k1x *emu;
        struct emu10k1x_midi *midi = substream->rmidi->private_data;
        emu = midi->emu;
-       snd_assert(emu, return);
+       if (snd_BUG_ON(!emu))
+               return;
 
        if (up)
                snd_emu10k1x_intr_enable(emu, midi->rx_enable);
@@ -1428,7 +1433,8 @@ static void snd_emu10k1x_midi_output_trigger(struct snd_rawmidi_substream *subst
        unsigned long flags;
 
        emu = midi->emu;
-       snd_assert(emu, return);
+       if (snd_BUG_ON(!emu))
+               return;
 
        if (up) {
                int max = 4;
index 71dc4c8865b88323edbe13a811c5171061d26e51..7dba08f0ab8e2c9d9e166fd12f3ed9934ed3cd34 100644 (file)
@@ -487,7 +487,8 @@ static void snd_emu10k1_write_op(struct snd_emu10k1_fx8010_code *icode,
                                 u32 op, u32 r, u32 a, u32 x, u32 y)
 {
        u_int32_t *code;
-       snd_assert(*ptr < 512, return);
+       if (snd_BUG_ON(*ptr >= 512))
+               return;
        code = (u_int32_t __force *)icode->code + (*ptr) * 2;
        set_bit(*ptr, icode->code_valid);
        code[0] = ((x & 0x3ff) << 10) | (y & 0x3ff);
@@ -503,7 +504,8 @@ static void snd_emu10k1_audigy_write_op(struct snd_emu10k1_fx8010_code *icode,
                                        u32 op, u32 r, u32 a, u32 x, u32 y)
 {
        u_int32_t *code;
-       snd_assert(*ptr < 1024, return);
+       if (snd_BUG_ON(*ptr >= 1024))
+               return;
        code = (u_int32_t __force *)icode->code + (*ptr) * 2;
        set_bit(*ptr, icode->code_valid);
        code[0] = ((x & 0x7ff) << 12) | (y & 0x7ff);
index c4d76d16661eed2d5af5a49ec51e81cb22cef45c..8578c70c61f2b4ee15a7583c47641bd2405d4e78 100644 (file)
@@ -157,7 +157,8 @@ static int snd_emu10k1_midi_input_open(struct snd_rawmidi_substream *substream)
        unsigned long flags;
 
        emu = midi->emu;
-       snd_assert(emu, return -ENXIO);
+       if (snd_BUG_ON(!emu))
+               return -ENXIO;
        spin_lock_irqsave(&midi->open_lock, flags);
        midi->midi_mode |= EMU10K1_MIDI_MODE_INPUT;
        midi->substream_input = substream;
@@ -183,7 +184,8 @@ static int snd_emu10k1_midi_output_open(struct snd_rawmidi_substream *substream)
        unsigned long flags;
 
        emu = midi->emu;
-       snd_assert(emu, return -ENXIO);
+       if (snd_BUG_ON(!emu))
+               return -ENXIO;
        spin_lock_irqsave(&midi->open_lock, flags);
        midi->midi_mode |= EMU10K1_MIDI_MODE_OUTPUT;
        midi->substream_output = substream;
@@ -210,7 +212,8 @@ static int snd_emu10k1_midi_input_close(struct snd_rawmidi_substream *substream)
        int err = 0;
 
        emu = midi->emu;
-       snd_assert(emu, return -ENXIO);
+       if (snd_BUG_ON(!emu))
+               return -ENXIO;
        spin_lock_irqsave(&midi->open_lock, flags);
        snd_emu10k1_intr_disable(emu, midi->rx_enable);
        midi->midi_mode &= ~EMU10K1_MIDI_MODE_INPUT;
@@ -232,7 +235,8 @@ static int snd_emu10k1_midi_output_close(struct snd_rawmidi_substream *substream
        int err = 0;
 
        emu = midi->emu;
-       snd_assert(emu, return -ENXIO);
+       if (snd_BUG_ON(!emu))
+               return -ENXIO;
        spin_lock_irqsave(&midi->open_lock, flags);
        snd_emu10k1_intr_disable(emu, midi->tx_enable);
        midi->midi_mode &= ~EMU10K1_MIDI_MODE_OUTPUT;
@@ -251,7 +255,8 @@ static void snd_emu10k1_midi_input_trigger(struct snd_rawmidi_substream *substre
        struct snd_emu10k1 *emu;
        struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data;
        emu = midi->emu;
-       snd_assert(emu, return);
+       if (snd_BUG_ON(!emu))
+               return;
 
        if (up)
                snd_emu10k1_intr_enable(emu, midi->rx_enable);
@@ -266,7 +271,8 @@ static void snd_emu10k1_midi_output_trigger(struct snd_rawmidi_substream *substr
        unsigned long flags;
 
        emu = midi->emu;
-       snd_assert(emu, return);
+       if (snd_BUG_ON(!emu))
+               return;
 
        if (up) {
                int max = 4;
index 7d379f5131fbf61d4ab527a51bac881592c96fff..e8ad56ed34fa23b49c0f237a71c11161fe6c7d45 100644 (file)
@@ -107,7 +107,8 @@ static int search_empty_map_area(struct snd_emu10k1 *emu, int npages, struct lis
 
        list_for_each (pos, &emu->mapped_link_head) {
                struct snd_emu10k1_memblk *blk = get_emu10k1_memblk(pos, mapped_link);
-               snd_assert(blk->mapped_page >= 0, continue);
+               if (blk->mapped_page < 0)
+                       continue;
                size = blk->mapped_page - page;
                if (size == npages) {
                        *nextp = pos;
@@ -300,10 +301,14 @@ snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *subst
        struct snd_emu10k1_memblk *blk;
        int page, err, idx;
 
-       snd_assert(emu, return NULL);
-       snd_assert(runtime->dma_bytes > 0 && runtime->dma_bytes < MAXPAGES * EMUPAGESIZE, return NULL);
+       if (snd_BUG_ON(!emu))
+               return NULL;
+       if (snd_BUG_ON(runtime->dma_bytes <= 0 ||
+                      runtime->dma_bytes >= MAXPAGES * EMUPAGESIZE))
+               return NULL;
        hdr = emu->memhdr;
-       snd_assert(hdr, return NULL);
+       if (snd_BUG_ON(!hdr))
+               return NULL;
 
        mutex_lock(&hdr->block_mutex);
        blk = search_empty(emu, runtime->dma_bytes);
@@ -353,7 +358,8 @@ snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *subst
  */
 int snd_emu10k1_free_pages(struct snd_emu10k1 *emu, struct snd_util_memblk *blk)
 {
-       snd_assert(emu && blk, return -EINVAL);
+       if (snd_BUG_ON(!emu || !blk))
+               return -EINVAL;
        return snd_emu10k1_synth_free(emu, blk);
 }
 
@@ -498,7 +504,8 @@ static int synth_free_pages(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *
 static inline void *offset_ptr(struct snd_emu10k1 *emu, int page, int offset)
 {
        char *ptr;
-       snd_assert(page >= 0 && page < emu->max_cache_pages, return NULL);
+       if (snd_BUG_ON(page < 0 || page >= emu->max_cache_pages))
+               return NULL;
        ptr = emu->page_ptr_table[page];
        if (! ptr) {
                printk(KERN_ERR "emu10k1: access to NULL ptr: page = %d\n", page);
index 958cb2a65a4ec8f79680f1bd8ed2a3570bfd2273..d7300a1aa262b64cc54a9ca060242167b4b90ba5 100644 (file)
@@ -111,8 +111,10 @@ int snd_emu10k1_voice_alloc(struct snd_emu10k1 *emu, int type, int number,
        unsigned long flags;
        int result;
 
-       snd_assert(rvoice != NULL, return -EINVAL);
-       snd_assert(number, return -EINVAL);
+       if (snd_BUG_ON(!rvoice))
+               return -EINVAL;
+       if (snd_BUG_ON(!number))
+               return -EINVAL;
 
        spin_lock_irqsave(&emu->voice_lock, flags);
        for (;;) {
@@ -145,7 +147,8 @@ int snd_emu10k1_voice_free(struct snd_emu10k1 *emu,
 {
        unsigned long flags;
 
-       snd_assert(pvoice != NULL, return -EINVAL);
+       if (snd_BUG_ON(!pvoice))
+               return -EINVAL;
        spin_lock_irqsave(&emu->voice_lock, flags);
        pvoice->interrupt = NULL;
        pvoice->use = pvoice->pcm = pvoice->synth = pvoice->midi = pvoice->efx = 0;
index 84fac1fbf10399bf9a3c0008945e78e9ad8c1d0f..4cd9a1faaecc186732b1ad911ebfd74e3c59e77e 100644 (file)
@@ -860,7 +860,8 @@ static int snd_es1938_capture_copy(struct snd_pcm_substream *substream,
        struct es1938 *chip = snd_pcm_substream_chip(substream);
        pos <<= chip->dma1_shift;
        count <<= chip->dma1_shift;
-       snd_assert(pos + count <= chip->dma1_size, return -EINVAL);
+       if (snd_BUG_ON(pos + count > chip->dma1_size))
+               return -EINVAL;
        if (pos + count < chip->dma1_size) {
                if (copy_to_user(dst, runtime->dma_area + pos + 1, count))
                        return -EFAULT;
index 1bf298d214b90462cfe7b5253c7d4d0f6c097fd1..20ee7599600bee87340f264e99842a4efa195465 100644 (file)
@@ -692,7 +692,8 @@ static void apu_data_set(struct es1968 *chip, u16 data)
 /* no spinlock */
 static void __apu_set_register(struct es1968 *chip, u16 channel, u8 reg, u16 data)
 {
-       snd_assert(channel < NR_APUS, return);
+       if (snd_BUG_ON(channel >= NR_APUS))
+               return;
 #ifdef CONFIG_PM
        chip->apu_map[channel][reg] = data;
 #endif
@@ -711,7 +712,8 @@ static void apu_set_register(struct es1968 *chip, u16 channel, u8 reg, u16 data)
 
 static u16 __apu_get_register(struct es1968 *chip, u16 channel, u8 reg)
 {
-       snd_assert(channel < NR_APUS, return 0);
+       if (snd_BUG_ON(channel >= NR_APUS))
+               return 0;
        reg |= (channel << 4);
        apu_index_set(chip, reg);
        return __maestro_read(chip, IDR0_DATA_PORT);
index d2e1093f8e972306727255a46ffb7ce7d59ccf2e..77fbcd4a69b71f828df7d51b8a3ef8c31a4b6c15 100644 (file)
@@ -211,7 +211,8 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
        unsigned int shift, num_elems, mask;
        hda_nid_t prev_nid;
 
-       snd_assert(conn_list && max_conns > 0, return -EINVAL);
+       if (snd_BUG_ON(!conn_list || max_conns <= 0))
+               return -EINVAL;
 
        parm = snd_hda_param_read(codec, nid, AC_PAR_CONNLIST_LEN);
        if (parm & AC_CLIST_LONG) {
@@ -407,8 +408,10 @@ int __devinit snd_hda_bus_new(struct snd_card *card,
                .dev_free = snd_hda_bus_dev_free,
        };
 
-       snd_assert(temp, return -EINVAL);
-       snd_assert(temp->ops.command && temp->ops.get_response, return -EINVAL);
+       if (snd_BUG_ON(!temp))
+               return -EINVAL;
+       if (snd_BUG_ON(!temp->ops.command || !temp->ops.get_response))
+               return -EINVAL;
 
        if (busp)
                *busp = NULL;
@@ -588,8 +591,10 @@ int __devinit snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
        char component[13];
        int err;
 
-       snd_assert(bus, return -EINVAL);
-       snd_assert(codec_addr <= HDA_MAX_CODEC_ADDRESS, return -EINVAL);
+       if (snd_BUG_ON(!bus))
+               return -EINVAL;
+       if (snd_BUG_ON(codec_addr > HDA_MAX_CODEC_ADDRESS))
+               return -EINVAL;
 
        if (bus->caddr_tbl[codec_addr]) {
                snd_printk(KERN_ERR "hda_codec: "
@@ -2236,11 +2241,13 @@ static int __devinit set_pcm_default_values(struct hda_codec *codec,
        if (info->ops.close == NULL)
                info->ops.close = hda_pcm_default_open_close;
        if (info->ops.prepare == NULL) {
-               snd_assert(info->nid, return -EINVAL);
+               if (snd_BUG_ON(!info->nid))
+                       return -EINVAL;
                info->ops.prepare = hda_pcm_default_prepare;
        }
        if (info->ops.cleanup == NULL) {
-               snd_assert(info->nid, return -EINVAL);
+               if (snd_BUG_ON(!info->nid))
+                       return -EINVAL;
                info->ops.cleanup = hda_pcm_default_cleanup;
        }
        return 0;
index 59e4389c94a4bb87b1aa85075d2d127e5ae542da..0ca30894f7c6fcf750ea46b3f009325388f7ecbb 100644 (file)
@@ -174,7 +174,8 @@ static int build_afg_tree(struct hda_codec *codec)
        int i, nodes, err;
        hda_nid_t nid;
 
-       snd_assert(spec, return -EINVAL);
+       if (snd_BUG_ON(!spec))
+               return -EINVAL;
 
        spec->def_amp_out_caps = snd_hda_param_read(codec, codec->afg, AC_PAR_AMP_OUT_CAP);
        spec->def_amp_in_caps = snd_hda_param_read(codec, codec->afg, AC_PAR_AMP_IN_CAP);
index 1c53e337ecb2dce93b833dcce526f64288cc9136..b2bcd94cf7a2d8f31561e0e2196e5f444863cb07 100644 (file)
@@ -1646,7 +1646,8 @@ static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec,
        if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams)
                return 0;
 
-       snd_assert(cpcm->name, return -EINVAL);
+       if (snd_BUG_ON(!cpcm->name))
+               return -EINVAL;
 
        err = snd_pcm_new(chip->card, cpcm->name, cpcm->device,
                          cpcm->stream[0].substreams,
index 4bd26725355c35e14b58182f18abdc5f7adcbeff..7e5422f64caf9d834eef20161d200f44b49b6984 100644 (file)
@@ -2633,12 +2633,14 @@ static int alc_build_pcms(struct hda_codec *codec)
 
        info->name = spec->stream_name_analog;
        if (spec->stream_analog_playback) {
-               snd_assert(spec->multiout.dac_nids, return -EINVAL);
+               if (snd_BUG_ON(!spec->multiout.dac_nids))
+                       return -EINVAL;
                info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
                info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
        }
        if (spec->stream_analog_capture) {
-               snd_assert(spec->adc_nids, return -EINVAL);
+               if (snd_BUG_ON(!spec->adc_nids))
+                       return -EINVAL;
                info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
                info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
        }
index dab31b2756a608b2e52f60c31058e4e4f19cd306..03391da8c8c7741304fff11f4e8ccc044393e984 100644 (file)
@@ -59,7 +59,8 @@ static void snd_ice1712_akm4xxx_write(struct snd_akm4xxx *ak, int chip,
        struct snd_ak4xxx_private *priv = (void *)ak->private_value[0];
        struct snd_ice1712 *ice = ak->private_data[0];
 
-       snd_assert(chip >= 0 && chip < 4, return);
+       if (snd_BUG_ON(chip < 0 || chip >= 4))
+               return;
 
        tmp = snd_ice1712_gpio_read(ice);
        tmp |= priv->add_flags;
index 013fc4f0482282fce0fb25da5a0a63b2012c6956..6fe35b8120400ddb8c073f9166879b9821984a33 100644 (file)
@@ -149,7 +149,8 @@ static int snd_ice1712_ews88mt_chip_select(struct snd_ice1712 *ice, int chip_mas
        struct ews_spec *spec = ice->spec;
        unsigned char data, ndata;
 
-       snd_assert(chip_mask >= 0 && chip_mask <= 0x0f, return -EINVAL);
+       if (snd_BUG_ON(chip_mask < 0 || chip_mask > 0x0f))
+               return -EINVAL;
        snd_i2c_lock(ice->i2c);
        if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF2], &data, 1) != 1)
                goto __error;
@@ -685,7 +686,8 @@ static int snd_ice1712_ews88mt_input_sense_get(struct snd_kcontrol *kcontrol, st
        int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
        unsigned char data;
 
-       snd_assert(channel >= 0 && channel <= 7, return 0);
+       if (snd_BUG_ON(channel < 0 || channel > 7))
+               return 0;
        snd_i2c_lock(ice->i2c);
        if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
                snd_i2c_unlock(ice->i2c);
@@ -705,7 +707,8 @@ static int snd_ice1712_ews88mt_input_sense_put(struct snd_kcontrol *kcontrol, st
        int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
        unsigned char data, ndata;
 
-       snd_assert(channel >= 0 && channel <= 7, return 0);
+       if (snd_BUG_ON(channel < 0 || channel > 7))
+               return 0;
        snd_i2c_lock(ice->i2c);
        if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
                snd_i2c_unlock(ice->i2c);
index 29d449d73c9864132d15ea0e4cd3313634870231..05ffab65d167b2be6213fa613da7c2e74a2963b7 100644 (file)
@@ -2416,7 +2416,8 @@ int __devinit snd_ice1712_spdif_build_controls(struct snd_ice1712 *ice)
        int err;
        struct snd_kcontrol *kctl;
 
-       snd_assert(ice->pcm_pro != NULL, return -EIO);
+       if (snd_BUG_ON(!ice->pcm_pro))
+               return -EIO;
        err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_default, ice));
        if (err < 0)
                return err;
index e596d777d9dde630d12532c55a578937f8d5b2ee..60119d220a6618b8e6aa7a61fe7f82acf5869f06 100644 (file)
@@ -2250,7 +2250,8 @@ static int __devinit snd_vt1724_spdif_build_controls(struct snd_ice1712 *ice)
        int err;
        struct snd_kcontrol *kctl;
 
-       snd_assert(ice->pcm != NULL, return -EIO);
+       if (snd_BUG_ON(!ice->pcm))
+               return -EIO;
 
        err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_mixer_pro_spdif_route, ice));
        if (err < 0)
index b4e0c16852a6a07ab4b35fe28c14d92466160ba2..21ff4de890b4a20fea689b84c1aefa5a3efaf32c 100644 (file)
@@ -208,7 +208,8 @@ static void juli_akm_write(struct snd_akm4xxx *ak, int chip,
 {
        struct snd_ice1712 *ice = ak->private_data[0];
         
-       snd_assert(chip == 0, return);
+       if (snd_BUG_ON(chip))
+               return;
        snd_vt1724_write_i2c(ice, AK4358_ADDR, addr, data);
 }
 
index 048d99e25ab0f0010ea1f4c7a7a06b553e1449d6..78760996632d69104fd51306e34315a2a9482705 100644 (file)
@@ -2132,8 +2132,8 @@ static int __devinit snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock,
                                snd_intel8x0_codec_read_test(chip, codecs);
                                chip->ac97_sdin[codecs] =
                                        igetbyte(chip, ICHREG(SDM)) & ICH_LDI_MASK;
-                               snd_assert(chip->ac97_sdin[codecs] < 3,
-                                          chip->ac97_sdin[codecs] = 0);
+                               if (snd_BUG_ON(chip->ac97_sdin[codecs] >= 3))
+                                       chip->ac97_sdin[codecs] = 0;
                        } else
                                chip->ac97_sdin[codecs] = i;
                        codecs++;
index faf674e671aca3c1432cf4d04860bb69f210d5df..93449e464566c019a5a0a3c11677bd8b2654fc56 100644 (file)
@@ -306,7 +306,8 @@ static unsigned int get_ich_codec_bit(struct intel8x0m *chip, unsigned int codec
        static unsigned int codec_bit[3] = {
                ICH_PCR, ICH_SCR, ICH_TCR
        };
-       snd_assert(codec < 3, return ICH_PCR);
+       if (snd_BUG_ON(codec >= 3))
+               return ICH_PCR;
        return codec_bit[codec];
 }
 
index 4a44c0f20f7605ebb754089ed281da1e279e1a69..5f8006b4275019ddd475e55e0ea7c8238b514b47 100644 (file)
@@ -1281,7 +1281,8 @@ static int snd_korg1212_silence(struct snd_korg1212 *korg1212, int pos, int coun
 
        K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_silence pos=%d offset=%d size=%d count=%d\n",
                                   pos, offset, size, count);
-       snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL);
+       if (snd_BUG_ON(pos + count > K1212_MAX_SAMPLES))
+               return -EINVAL;
 
        for (i=0; i < count; i++) {
 #if K1212_DEBUG_LEVEL > 0
@@ -1306,7 +1307,8 @@ static int snd_korg1212_copy_to(struct snd_korg1212 *korg1212, void __user *dst,
 
        K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_to pos=%d offset=%d size=%d\n",
                                   pos, offset, size);
-       snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL);
+       if (snd_BUG_ON(pos + count > K1212_MAX_SAMPLES))
+               return -EINVAL;
 
        for (i=0; i < count; i++) {
 #if K1212_DEBUG_LEVEL > 0
@@ -1336,7 +1338,8 @@ static int snd_korg1212_copy_from(struct snd_korg1212 *korg1212, void __user *sr
        K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_from pos=%d offset=%d size=%d count=%d\n",
                                   pos, offset, size, count);
 
-       snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL);
+       if (snd_BUG_ON(pos + count > K1212_MAX_SAMPLES))
+               return -EINVAL;
 
        for (i=0; i < count; i++) {
 #if K1212_DEBUG_LEVEL > 0
index 0037be74fdea9d87aaa7c89bbadf11e45d4a899c..9ff3f9e34404c4fa4c9c0b9b46a3b503d3c2fb03 100644 (file)
@@ -1175,7 +1175,8 @@ snd_m3_pcm_trigger(struct snd_pcm_substream *subs, int cmd)
        struct m3_dma *s = subs->runtime->private_data;
        int err = -EINVAL;
 
-       snd_assert(s != NULL, return -ENXIO);
+       if (snd_BUG_ON(!s))
+               return -ENXIO;
 
        spin_lock(&chip->reg_lock);
        switch (cmd) {
@@ -1487,7 +1488,8 @@ snd_m3_pcm_prepare(struct snd_pcm_substream *subs)
        struct snd_pcm_runtime *runtime = subs->runtime;
        struct m3_dma *s = runtime->private_data;
 
-       snd_assert(s != NULL, return -ENXIO);
+       if (snd_BUG_ON(!s))
+               return -ENXIO;
 
        if (runtime->format != SNDRV_PCM_FORMAT_U8 &&
            runtime->format != SNDRV_PCM_FORMAT_S16_LE)
@@ -1546,7 +1548,9 @@ snd_m3_pcm_pointer(struct snd_pcm_substream *subs)
        struct snd_m3 *chip = snd_pcm_substream_chip(subs);
        unsigned int ptr;
        struct m3_dma *s = subs->runtime->private_data;
-       snd_assert(s != NULL, return 0);
+
+       if (snd_BUG_ON(!s))
+               return 0;
 
        spin_lock(&chip->reg_lock);
        ptr = snd_m3_get_pointer(chip, s, subs);
index 3dd0c7963273c0f7bea2fcab56df88355900a6e2..2d0dce649a644fe4a5adc479ae76e53a541b3025 100644 (file)
@@ -708,7 +708,7 @@ static int snd_mixart_playback_open(struct snd_pcm_substream *subs)
                pcm_number = MIXART_PCM_ANALOG;
                runtime->hw = snd_mixart_analog_caps;
        } else {
-               snd_assert ( pcm == chip->pcm_dig ); 
+               snd_BUG_ON(pcm != chip->pcm_dig);
                pcm_number = MIXART_PCM_DIGITAL;
                runtime->hw = snd_mixart_digital_caps;
        }
@@ -783,7 +783,7 @@ static int snd_mixart_capture_open(struct snd_pcm_substream *subs)
                pcm_number = MIXART_PCM_ANALOG;
                runtime->hw = snd_mixart_analog_caps;
        } else {
-               snd_assert ( pcm == chip->pcm_dig ); 
+               snd_BUG_ON(pcm != chip->pcm_dig);
                pcm_number = MIXART_PCM_DIGITAL;
                runtime->hw = snd_mixart_digital_caps;
        }
index 785085e48353c3111f4e29085be77ade17298750..b9a06c2793970d4d13a29e6c2ca3f9a4cae7faa4 100644 (file)
@@ -56,8 +56,10 @@ static int retrieve_msg_frame(struct mixart_mgr *mgr, u32 *msg_frame)
        if (tailptr == headptr)
                return 0; /* no message posted */
 
-       snd_assert( tailptr >= MSG_OUTBOUND_POST_STACK, return 0); /* error */
-       snd_assert( tailptr < (MSG_OUTBOUND_POST_STACK+MSG_BOUND_STACK_SIZE), return 0); /* error */
+       if (tailptr < MSG_OUTBOUND_POST_STACK)
+               return 0; /* error */
+       if (tailptr >= MSG_OUTBOUND_POST_STACK + MSG_BOUND_STACK_SIZE)
+               return 0; /* error */
 
        *msg_frame = readl_be(MIXART_MEM(mgr, tailptr));
 
@@ -149,7 +151,8 @@ static int send_msg( struct mixart_mgr *mgr,
        u32 msg_frame_address;
        int err, i;
 
-       snd_assert(msg->size % 4 == 0, return -EINVAL);
+       if (snd_BUG_ON(msg->size % 4))
+               return -EINVAL;
 
        err = 0;
 
@@ -289,9 +292,12 @@ int snd_mixart_send_msg_wait_notif(struct mixart_mgr *mgr,
        wait_queue_t wait;
        long timeout;
 
-       snd_assert(notif_event != 0, return -EINVAL);
-       snd_assert((notif_event & MSG_TYPE_MASK) == MSG_TYPE_NOTIFY, return -EINVAL);
-       snd_assert((notif_event & MSG_CANCEL_NOTIFY_MASK) == 0, return -EINVAL);
+       if (snd_BUG_ON(!notif_event))
+               return -EINVAL;
+       if (snd_BUG_ON((notif_event & MSG_TYPE_MASK) != MSG_TYPE_NOTIFY))
+               return -EINVAL;
+       if (snd_BUG_ON(notif_event & MSG_CANCEL_NOTIFY_MASK))
+               return -EINVAL;
 
        mutex_lock(&mgr->msg_mutex);
 
index f98603146132cd7b6aabfbb6862aa0c1f50e69ee..3782b52bc0e8cb714466f0466991050e52c29b15 100644 (file)
@@ -288,7 +288,9 @@ static int mixart_enum_physio(struct mixart_mgr *mgr)
                return -EINVAL;
        }
 
-       snd_assert(phys_io.nb_uid >= (MIXART_MAX_CARDS * 2),  return -EINVAL); /* min 2 phys io per card (analog in + analog out) */
+       /* min 2 phys io per card (analog in + analog out) */
+       if (phys_io.nb_uid < MIXART_MAX_CARDS * 2)
+               return -EINVAL;
 
        for(k=0; k<mgr->num_cards; k++) {
                mgr->chip[k]->uid_in_analog_physio = phys_io.uid[k];
@@ -363,8 +365,10 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
                }
 
                /* check xilinx validity */
-               snd_assert(((u32*)(dsp->data))[0]==0xFFFFFFFF, return -EINVAL);
-               snd_assert(dsp->size % 4 == 0, return -EINVAL);
+               if (((u32*)(dsp->data))[0] == 0xffffffff)
+                       return -EINVAL;
+               if (dsp->size % 4)
+                       return -EINVAL;
 
                /* set xilinx status to copying */
                writel_be( 1, MIXART_MEM( mgr, MIXART_PSEUDOREG_MXLX_STATUS_OFFSET ));
@@ -462,8 +466,10 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
                }
  
                /* check daughterboard xilinx validity */
-               snd_assert(((u32*)(dsp->data))[0]==0xFFFFFFFF, return -EINVAL);
-               snd_assert(dsp->size % 4 == 0, return -EINVAL);
+               if (((u32*)(dsp->data))[0] == 0xffffffff)
+                       return -EINVAL;
+               if (dsp->size % 4)
+                       return -EINVAL;
 
                /* inform mixart about the size of the file */
                writel_be( dsp->size, MIXART_MEM( mgr, MIXART_PSEUDOREG_DXLX_SIZE_OFFSET ));
@@ -480,7 +486,8 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
 
                /* get the address where to write the file */
                val = readl_be( MIXART_MEM( mgr, MIXART_PSEUDOREG_DXLX_BASE_ADDR_OFFSET ));
-               snd_assert(val != 0, return -EINVAL);
+               if (!val)
+                       return -EINVAL;
 
                /* copy daughterboard xilinx code */
                memcpy_toio(  MIXART_MEM( mgr, val),  dsp->data,  dsp->size);
index 6fdda1f70b25d45b718e82bb9a3afc050b15741b..3ba6174c3df1d80a6d714ddc836b751bbf917bc5 100644 (file)
@@ -837,7 +837,7 @@ static int mixart_pcm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
                if(is_aes)      stored_volume = chip->digital_capture_volume[1];        /* AES capture */
                else            stored_volume = chip->digital_capture_volume[0];        /* analog capture */
        } else {
-               snd_assert ( idx < MIXART_PLAYBACK_STREAMS ); 
+               snd_BUG_ON(idx >= MIXART_PLAYBACK_STREAMS);
                if(is_aes)      stored_volume = chip->digital_playback_volume[MIXART_PLAYBACK_STREAMS + idx]; /* AES playback */
                else            stored_volume = chip->digital_playback_volume[idx];     /* analog playback */
        }
@@ -863,7 +863,7 @@ static int mixart_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
                else            /* analog capture */
                        stored_volume = chip->digital_capture_volume[0];
        } else {
-               snd_assert ( idx < MIXART_PLAYBACK_STREAMS ); 
+               snd_BUG_ON(idx >= MIXART_PLAYBACK_STREAMS);
                if (is_aes)     /* AES playback */
                        stored_volume = chip->digital_playback_volume[MIXART_PLAYBACK_STREAMS + idx];
                else            /* analog playback */
@@ -909,7 +909,7 @@ static int mixart_pcm_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
 {
        struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
        int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
-       snd_assert ( idx < MIXART_PLAYBACK_STREAMS ); 
+       snd_BUG_ON(idx >= MIXART_PLAYBACK_STREAMS);
        mutex_lock(&chip->mgr->mixer_mutex);
        if(kcontrol->private_value & MIXART_VOL_AES_MASK)       /* AES playback */
                idx += MIXART_PLAYBACK_STREAMS;
@@ -926,7 +926,7 @@ static int mixart_pcm_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
        int is_aes = kcontrol->private_value & MIXART_VOL_AES_MASK;
        int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
        int i, j;
-       snd_assert ( idx < MIXART_PLAYBACK_STREAMS ); 
+       snd_BUG_ON(idx >= MIXART_PLAYBACK_STREAMS);
        mutex_lock(&chip->mgr->mixer_mutex);
        j = idx;
        if (is_aes)
index 06d13e7171148d261fdeeccd21563da3ef59d577..50c9f8a05082fa6c5aa67919203d80e030895b18 100644 (file)
@@ -562,7 +562,8 @@ snd_nm256_playback_trigger(struct snd_pcm_substream *substream, int cmd)
        struct nm256_stream *s = substream->runtime->private_data;
        int err = 0;
 
-       snd_assert(s != NULL, return -ENXIO);
+       if (snd_BUG_ON(!s))
+               return -ENXIO;
 
        spin_lock(&chip->reg_lock);
        switch (cmd) {
@@ -599,7 +600,8 @@ snd_nm256_capture_trigger(struct snd_pcm_substream *substream, int cmd)
        struct nm256_stream *s = substream->runtime->private_data;
        int err = 0;
 
-       snd_assert(s != NULL, return -ENXIO);
+       if (snd_BUG_ON(!s))
+               return -ENXIO;
 
        spin_lock(&chip->reg_lock);
        switch (cmd) {
@@ -635,7 +637,8 @@ static int snd_nm256_pcm_prepare(struct snd_pcm_substream *substream)
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct nm256_stream *s = runtime->private_data;
 
-       snd_assert(s, return -ENXIO);
+       if (snd_BUG_ON(!s))
+               return -ENXIO;
        s->dma_size = frames_to_bytes(runtime, substream->runtime->buffer_size);
        s->period_size = frames_to_bytes(runtime, substream->runtime->period_size);
        s->periods = substream->runtime->periods;
@@ -660,7 +663,8 @@ snd_nm256_playback_pointer(struct snd_pcm_substream *substream)
        struct nm256_stream *s = substream->runtime->private_data;
        unsigned long curp;
 
-       snd_assert(s, return 0);
+       if (snd_BUG_ON(!s))
+               return 0;
        curp = snd_nm256_readl(chip, NM_PBUFFER_CURRP) - (unsigned long)s->buf;
        curp %= s->dma_size;
        return bytes_to_frames(substream->runtime, curp);
@@ -673,7 +677,8 @@ snd_nm256_capture_pointer(struct snd_pcm_substream *substream)
        struct nm256_stream *s = substream->runtime->private_data;
        unsigned long curp;
 
-       snd_assert(s != NULL, return 0);
+       if (snd_BUG_ON(!s))
+               return 0;
        curp = snd_nm256_readl(chip, NM_RBUFFER_CURRP) - (unsigned long)s->buf;
        curp %= s->dma_size;    
        return bytes_to_frames(substream->runtime, curp);
index 2c7e25336795d6bfb6588019069ff77947163e61..0e06c6c9fcc01d1406e3ba61921aece7bef9196f 100644 (file)
@@ -464,7 +464,8 @@ static int pcxhr_update_r_buffer(struct pcxhr_stream *stream)
        pcxhr_init_rmh(&rmh, CMD_UPDATE_R_BUFFERS);
        pcxhr_set_pipe_cmd_params(&rmh, is_capture, stream->pipe->first_audio, stream_num, 0);
 
-       snd_assert(subs->runtime->dma_bytes < 0x200000);        /* max buffer size is 2 MByte */
+       /* max buffer size is 2 MByte */
+       snd_BUG_ON(subs->runtime->dma_bytes >= 0x200000);
        rmh.cmd[1] = subs->runtime->dma_bytes * 8;              /* size in bits */
        rmh.cmd[2] = subs->runtime->dma_addr >> 24;             /* most significant byte */
        rmh.cmd[2] |= 1<<19;                                    /* this is a circular buffer */
@@ -1228,7 +1229,8 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id
                return -ENOMEM;
        }
 
-       snd_assert(pci_id->driver_data < PCI_ID_LAST, return -ENODEV);
+       if (snd_BUG_ON(pci_id->driver_data >= PCI_ID_LAST))
+               return -ENODEV;
        card_name = pcxhr_board_params[pci_id->driver_data].board_name;
        mgr->playback_chips = pcxhr_board_params[pci_id->driver_data].playback_chips;
        mgr->capture_chips  = pcxhr_board_params[pci_id->driver_data].capture_chips;
index 000e6fed6e3985c1a8ff1ceb5caab0c2acc23e13..7143259cfe3432f339c363d47a0589956f41b8d9 100644 (file)
@@ -319,16 +319,20 @@ static int pcxhr_download_dsp(struct pcxhr_mgr *mgr, const struct firmware *dsp)
        const unsigned char *data;
        unsigned char dummy;
        /* check the length of boot image */
-       snd_assert(dsp->size > 0, return -EINVAL);
-       snd_assert(dsp->size % 3 == 0, return -EINVAL);
-       snd_assert(dsp->data, return -EINVAL);
+       if (dsp->size <= 0)
+               return -EINVAL;
+       if (dsp->size % 3)
+               return -EINVAL;
+       if (snd_BUG_ON(!dsp->data))
+               return -EINVAL;
        /* transfert data buffer from PC to DSP */
        for (i = 0; i < dsp->size; i += 3) {
                data = dsp->data + i;
                if (i == 0) {
                        /* test data header consistency */
                        len = (unsigned int)((data[0]<<16) + (data[1]<<8) + data[2]);
-                       snd_assert((len==0) || (dsp->size == (len+2)*3), return -EINVAL);
+                       if (len && dsp->size != (len + 2) * 3)
+                               return -EINVAL;
                }
                /* wait DSP ready for new transfer */
                err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_TRDY,
@@ -389,7 +393,8 @@ int pcxhr_load_boot_binary(struct pcxhr_mgr *mgr, const struct firmware *boot)
        unsigned char dummy;
 
        /* send the hostport address to the DSP (only the upper 24 bit !) */
-       snd_assert((physaddr & 0xff) == 0, return -EINVAL);
+       if (snd_BUG_ON(physaddr & 0xff))
+               return -EINVAL;
        PCXHR_OUTPL(mgr, PCXHR_PLX_MBOX1, (physaddr >> 8));
 
        err = pcxhr_send_it_dsp(mgr, PCXHR_IT_DOWNLOAD_BOOT, 0);
@@ -570,7 +575,8 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
        u32 data;
        unsigned char reg;
 
-       snd_assert(rmh->cmd_len<PCXHR_SIZE_MAX_CMD, return -EINVAL);
+       if (snd_BUG_ON(rmh->cmd_len >= PCXHR_SIZE_MAX_CMD))
+               return -EINVAL;
        err = pcxhr_send_it_dsp(mgr, PCXHR_IT_MESSAGE, 1);
        if (err) {
                snd_printk(KERN_ERR "pcxhr_send_message : ED_DSP_CRASHED\n");
@@ -677,7 +683,8 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
  */
 void pcxhr_init_rmh(struct pcxhr_rmh *rmh, int cmd)
 {
-       snd_assert(cmd < CMD_LAST_INDEX, return);
+       if (snd_BUG_ON(cmd >= CMD_LAST_INDEX))
+               return;
        rmh->cmd[0] = pcxhr_dsp_cmds[cmd].opcode;
        rmh->cmd_len = 1;
        rmh->stat_len = pcxhr_dsp_cmds[cmd].st_length;
@@ -690,17 +697,17 @@ void pcxhr_set_pipe_cmd_params(struct pcxhr_rmh *rmh, int capture,
                               unsigned int param1, unsigned int param2,
                               unsigned int param3)
 {
-       snd_assert(param1 <= MASK_FIRST_FIELD);
+       snd_BUG_ON(param1 > MASK_FIRST_FIELD);
        if (capture)
                rmh->cmd[0] |= 0x800;           /* COMMAND_RECORD_MASK */
        if (param1)
                rmh->cmd[0] |= (param1 << FIELD_SIZE);
        if (param2) {
-               snd_assert(param2 <= MASK_FIRST_FIELD);
+               snd_BUG_ON(param2 > MASK_FIRST_FIELD);
                rmh->cmd[0] |= param2;
        }
        if(param3) {
-               snd_assert(param3 <= MASK_DSP_WORD);
+               snd_BUG_ON(param3 > MASK_DSP_WORD);
                rmh->cmd[1] = param3;
                rmh->cmd_len = 2;
        }
index d2f043278cf4f8a329affc0116d6d122f1f586ee..96640d9c227d83628234c81033fd31b870b00b4e 100644 (file)
@@ -65,15 +65,18 @@ static int pcxhr_init_board(struct pcxhr_mgr *mgr)
        if (err)
                return err;
        /* test 8 or 12 phys out */
-       snd_assert((rmh.stat[0] & MASK_FIRST_FIELD) == mgr->playback_chips*2,
-                  return -EINVAL);
+       if ((rmh.stat[0] & MASK_FIRST_FIELD) != mgr->playback_chips * 2)
+               return -EINVAL;
        /* test 8 or 2 phys in */
-       snd_assert(((rmh.stat[0] >> (2*FIELD_SIZE)) & MASK_FIRST_FIELD) ==
-                  mgr->capture_chips * 2, return -EINVAL);
+       if (((rmh.stat[0] >> (2 * FIELD_SIZE)) & MASK_FIRST_FIELD) !=
+           mgr->capture_chips * 2)
+               return -EINVAL;
        /* test max nb substream per board */
-       snd_assert((rmh.stat[1] & 0x5F) >= card_streams, return -EINVAL);
+       if ((rmh.stat[1] & 0x5F) < card_streams)
+               return -EINVAL;
        /* test max nb substream per pipe */
-       snd_assert(((rmh.stat[1]>>7)&0x5F) >= PCXHR_PLAYBACK_STREAMS, return -EINVAL);
+       if (((rmh.stat[1] >> 7) & 0x5F) < PCXHR_PLAYBACK_STREAMS)
+               return -EINVAL;
 
        pcxhr_init_rmh(&rmh, CMD_VERSION);
        /* firmware num for DSP */
index 6a35962473482bf9c46ce32e0baed87ac56963ad..124f9a2f1535eaa286f20b8d2a946c63686843d8 100644 (file)
@@ -865,7 +865,8 @@ static int sendcmd(struct cmdif *cif, u32 flags, u32 cmd, u32 parm,
        struct riptideport *hwport;
        struct cmdport *cmdport = NULL;
 
-       snd_assert(cif, return -EINVAL);
+       if (snd_BUG_ON(!cif))
+               return -EINVAL;
 
        hwport = cif->hwport;
        if (cif->errcnt > MAX_ERROR_COUNT) {
@@ -1490,7 +1491,8 @@ static int snd_riptide_prepare(struct snd_pcm_substream *substream)
        int err = 0;
        snd_pcm_format_t format;
 
-       snd_assert(cif && data, return -EINVAL);
+       if (snd_BUG_ON(!cif || !data))
+               return -EINVAL;
 
        snd_printdd("prepare id %d ch: %d f:0x%x r:%d\n", data->id,
                    runtime->channels, runtime->format, runtime->rate);
@@ -1772,7 +1774,8 @@ snd_riptide_codec_write(struct snd_ac97 *ac97, unsigned short reg,
        union cmdret rptr = CMDRET_ZERO;
        int i = 0;
 
-       snd_assert(cif, return);
+       if (snd_BUG_ON(!cif))
+               return;
 
        snd_printdd("Write AC97 reg 0x%x 0x%x\n", reg, val);
        do {
@@ -1790,7 +1793,8 @@ static unsigned short snd_riptide_codec_read(struct snd_ac97 *ac97,
        struct cmdif *cif = chip->cif;
        union cmdret rptr = CMDRET_ZERO;
 
-       snd_assert(cif, return 0);
+       if (snd_BUG_ON(!cif))
+               return 0;
 
        if (SEND_RACR(cif, reg, &rptr) != 0)
                SEND_RACR(cif, reg, &rptr);
@@ -1804,7 +1808,8 @@ static int snd_riptide_initialize(struct snd_riptide *chip)
        unsigned int device_id;
        int err;
 
-       snd_assert(chip, return -EINVAL);
+       if (snd_BUG_ON(!chip))
+               return -EINVAL;
 
        cif = chip->cif;
        if (!cif) {
@@ -1836,7 +1841,8 @@ static int snd_riptide_free(struct snd_riptide *chip)
 {
        struct cmdif *cif;
 
-       snd_assert(chip, return 0);
+       if (!chip)
+               return 0;
 
        if ((cif = chip->cif)) {
                SET_GRESET(cif->hwport);
index 4d6fbb36ab8af1f2b7df881ff402402af28f8b53..d723543beadd68af5fb9f88540412210c7e819be 100644 (file)
@@ -1036,7 +1036,7 @@ static void hdsp_set_dds_value(struct hdsp *hdsp, int rate)
        n = DDS_NUMERATOR;
        div64_32(&n, rate, &r);
        /* n should be less than 2^32 for being written to FREQ register */
-       snd_assert((n >> 32) == 0);
+       snd_BUG_ON(n >> 32);
        /* HDSP_freqReg and HDSP_resetPointer are the same, so keep the DDS
           value to write it after a reset */
        hdsp->dds_value = n;
@@ -3043,7 +3043,7 @@ static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct sn
        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
 
        offset = ucontrol->id.index - 1;
-       snd_assert(offset >= 0);
+       snd_BUG_ON(offset < 0);
 
        switch (hdsp->io_type) {
        case Digiface:
@@ -3767,7 +3767,8 @@ static char *hdsp_channel_buffer_location(struct hdsp *hdsp,
 {
        int mapped_channel;
 
-        snd_assert(channel >= 0 && channel < hdsp->max_channels, return NULL);
+        if (snd_BUG_ON(channel < 0 || channel >= hdsp->max_channels))
+               return NULL;
         
        if ((mapped_channel = hdsp->channel_map[channel]) < 0)
                return NULL;
@@ -3784,10 +3785,12 @@ static int snd_hdsp_playback_copy(struct snd_pcm_substream *substream, int chann
        struct hdsp *hdsp = snd_pcm_substream_chip(substream);
        char *channel_buf;
 
-       snd_assert(pos + count <= HDSP_CHANNEL_BUFFER_BYTES / 4, return -EINVAL);
+       if (snd_BUG_ON(pos + count > HDSP_CHANNEL_BUFFER_BYTES / 4))
+               return -EINVAL;
 
        channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel);
-       snd_assert(channel_buf != NULL, return -EIO);
+       if (snd_BUG_ON(!channel_buf))
+               return -EIO;
        if (copy_from_user(channel_buf + pos * 4, src, count * 4))
                return -EFAULT;
        return count;
@@ -3799,10 +3802,12 @@ static int snd_hdsp_capture_copy(struct snd_pcm_substream *substream, int channe
        struct hdsp *hdsp = snd_pcm_substream_chip(substream);
        char *channel_buf;
 
-       snd_assert(pos + count <= HDSP_CHANNEL_BUFFER_BYTES / 4, return -EINVAL);
+       if (snd_BUG_ON(pos + count > HDSP_CHANNEL_BUFFER_BYTES / 4))
+               return -EINVAL;
 
        channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel);
-       snd_assert(channel_buf != NULL, return -EIO);
+       if (snd_BUG_ON(!channel_buf))
+               return -EIO;
        if (copy_to_user(dst, channel_buf + pos * 4, count * 4))
                return -EFAULT;
        return count;
@@ -3815,7 +3820,8 @@ static int snd_hdsp_hw_silence(struct snd_pcm_substream *substream, int channel,
        char *channel_buf;
 
        channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel);
-       snd_assert(channel_buf != NULL, return -EIO);
+       if (snd_BUG_ON(!channel_buf))
+               return -EIO;
        memset(channel_buf + pos * 4, 0, count * 4);
        return count;
 }
@@ -3927,7 +3933,8 @@ static int snd_hdsp_channel_info(struct snd_pcm_substream *substream,
        struct hdsp *hdsp = snd_pcm_substream_chip(substream);
        int mapped_channel;
 
-       snd_assert(info->channel < hdsp->max_channels, return -EINVAL);
+       if (snd_BUG_ON(info->channel >= hdsp->max_channels))
+               return -EINVAL;
 
        if ((mapped_channel = hdsp->channel_map[info->channel]) < 0)
                return -EINVAL;
index ab423bc823425834c108a3f84d060094324970ea..83c92e6082a2feb06f75bfece79c948d5de50331 100644 (file)
@@ -845,7 +845,7 @@ static void hdspm_set_dds_value(struct hdspm *hdspm, int rate)
        n = 110100480000000ULL;    /* Value checked for AES32 and MADI */
        div64_32(&n, rate, &r);
        /* n should be less than 2^32 for being written to FREQ register */
-       snd_assert((n >> 32) == 0);
+       snd_BUG_ON(n >> 32);
        hdspm_write(hdspm, HDSPM_freqReg, (u32)n);
 }
 
@@ -2617,8 +2617,8 @@ static int snd_hdspm_get_playback_mixer(struct snd_kcontrol *kcontrol,
 
        channel = ucontrol->id.index - 1;
 
-       snd_assert(channel >= 0
-                  || channel < HDSPM_MAX_CHANNELS, return -EINVAL);
+       if (snd_BUG_ON(channel < 0 || channel >= HDSPM_MAX_CHANNELS))
+               return -EINVAL;
 
        mapped_channel = hdspm->channel_map[channel];
        if (mapped_channel < 0)
@@ -2652,8 +2652,8 @@ static int snd_hdspm_put_playback_mixer(struct snd_kcontrol *kcontrol,
 
        channel = ucontrol->id.index - 1;
 
-       snd_assert(channel >= 0
-                  || channel < HDSPM_MAX_CHANNELS, return -EINVAL);
+       if (snd_BUG_ON(channel < 0 || channel >= HDSPM_MAX_CHANNELS))
+               return -EINVAL;
 
        mapped_channel = hdspm->channel_map[channel];
        if (mapped_channel < 0)
@@ -3496,8 +3496,8 @@ static char *hdspm_channel_buffer_location(struct hdspm * hdspm,
 {
        int mapped_channel;
 
-       snd_assert(channel >= 0
-                  || channel < HDSPM_MAX_CHANNELS, return NULL);
+       if (snd_BUG_ON(channel < 0 || channel >= HDSPM_MAX_CHANNELS))
+               return NULL;
 
        mapped_channel = hdspm->channel_map[channel];
        if (mapped_channel < 0)
@@ -3520,14 +3520,15 @@ static int snd_hdspm_playback_copy(struct snd_pcm_substream *substream,
        struct hdspm *hdspm = snd_pcm_substream_chip(substream);
        char *channel_buf;
 
-       snd_assert(pos + count <= HDSPM_CHANNEL_BUFFER_BYTES / 4,
-                  return -EINVAL);
+       if (snd_BUG_ON(pos + count > HDSPM_CHANNEL_BUFFER_BYTES / 4))
+               return -EINVAL;
 
        channel_buf =
                hdspm_channel_buffer_location(hdspm, substream->pstr->stream,
                                              channel);
 
-       snd_assert(channel_buf != NULL, return -EIO);
+       if (snd_BUG_ON(!channel_buf))
+               return -EIO;
 
        return copy_from_user(channel_buf + pos * 4, src, count * 4);
 }
@@ -3539,13 +3540,14 @@ static int snd_hdspm_capture_copy(struct snd_pcm_substream *substream,
        struct hdspm *hdspm = snd_pcm_substream_chip(substream);
        char *channel_buf;
 
-       snd_assert(pos + count <= HDSPM_CHANNEL_BUFFER_BYTES / 4,
-                  return -EINVAL);
+       if (snd_BUG_ON(pos + count > HDSPM_CHANNEL_BUFFER_BYTES / 4))
+               return -EINVAL;
 
        channel_buf =
                hdspm_channel_buffer_location(hdspm, substream->pstr->stream,
                                              channel);
-       snd_assert(channel_buf != NULL, return -EIO);
+       if (snd_BUG_ON(!channel_buf))
+               return -EIO;
        return copy_to_user(dst, channel_buf + pos * 4, count * 4);
 }
 
@@ -3559,7 +3561,8 @@ static int snd_hdspm_hw_silence(struct snd_pcm_substream *substream,
        channel_buf =
                hdspm_channel_buffer_location(hdspm, substream->pstr->stream,
                                              channel);
-       snd_assert(channel_buf != NULL, return -EIO);
+       if (snd_BUG_ON(!channel_buf))
+               return -EIO;
        memset(channel_buf + pos * 4, 0, count * 4);
        return 0;
 }
@@ -3744,7 +3747,8 @@ static int snd_hdspm_channel_info(struct snd_pcm_substream *substream,
        struct hdspm *hdspm = snd_pcm_substream_chip(substream);
        int mapped_channel;
 
-       snd_assert(info->channel < HDSPM_MAX_CHANNELS, return -EINVAL);
+       if (snd_BUG_ON(info->channel >= HDSPM_MAX_CHANNELS))
+               return -EINVAL;
 
        mapped_channel = hdspm->channel_map[info->channel];
        if (mapped_channel < 0)
index a123f0e6ba23386213738dfdb835c7fa5a55353b..2570907134d75cd89067b14865fbd90355749df9 100644 (file)
@@ -595,8 +595,6 @@ static void rme9652_set_thru(struct snd_rme9652 *rme9652, int channel, int enabl
        } else {
                int mapped_channel;
 
-               snd_assert(channel == RME9652_NCHANNELS, return);
-
                mapped_channel = rme9652->channel_map[channel];
 
                if (enable) {
@@ -1893,7 +1891,8 @@ static char *rme9652_channel_buffer_location(struct snd_rme9652 *rme9652,
 {
        int mapped_channel;
 
-        snd_assert(channel >= 0 || channel < RME9652_NCHANNELS, return NULL);
+       if (snd_BUG_ON(channel < 0 || channel >= RME9652_NCHANNELS))
+               return NULL;
         
        if ((mapped_channel = rme9652->channel_map[channel]) < 0) {
                return NULL;
@@ -1914,12 +1913,14 @@ static int snd_rme9652_playback_copy(struct snd_pcm_substream *substream, int ch
        struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
        char *channel_buf;
 
-       snd_assert(pos + count <= RME9652_CHANNEL_BUFFER_BYTES / 4, return -EINVAL);
+       if (snd_BUG_ON(pos + count > RME9652_CHANNEL_BUFFER_BYTES / 4))
+               return -EINVAL;
 
        channel_buf = rme9652_channel_buffer_location (rme9652,
                                                       substream->pstr->stream,
                                                       channel);
-       snd_assert(channel_buf != NULL, return -EIO);
+       if (snd_BUG_ON(!channel_buf))
+               return -EIO;
        if (copy_from_user(channel_buf + pos * 4, src, count * 4))
                return -EFAULT;
        return count;
@@ -1931,12 +1932,14 @@ static int snd_rme9652_capture_copy(struct snd_pcm_substream *substream, int cha
        struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
        char *channel_buf;
 
-       snd_assert(pos + count <= RME9652_CHANNEL_BUFFER_BYTES / 4, return -EINVAL);
+       if (snd_BUG_ON(pos + count > RME9652_CHANNEL_BUFFER_BYTES / 4))
+               return -EINVAL;
 
        channel_buf = rme9652_channel_buffer_location (rme9652,
                                                       substream->pstr->stream,
                                                       channel);
-       snd_assert(channel_buf != NULL, return -EIO);
+       if (snd_BUG_ON(!channel_buf))
+               return -EIO;
        if (copy_to_user(dst, channel_buf + pos * 4, count * 4))
                return -EFAULT;
        return count;
@@ -1951,7 +1954,8 @@ static int snd_rme9652_hw_silence(struct snd_pcm_substream *substream, int chann
        channel_buf = rme9652_channel_buffer_location (rme9652,
                                                       substream->pstr->stream,
                                                       channel);
-       snd_assert(channel_buf != NULL, return -EIO);
+       if (snd_BUG_ON(!channel_buf))
+               return -EIO;
        memset(channel_buf + pos * 4, 0, count * 4);
        return count;
 }
@@ -2053,7 +2057,8 @@ static int snd_rme9652_channel_info(struct snd_pcm_substream *substream,
        struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
        int chn;
 
-       snd_assert(info->channel < RME9652_NCHANNELS, return -EINVAL);
+       if (snd_BUG_ON(info->channel >= RME9652_NCHANNELS))
+               return -EINVAL;
 
        if ((chn = rme9652->channel_map[info->channel]) < 0) {
                return -EINVAL;
index 0d3d305b0a0b0c2805ebf26cc1a0cd004a89db4d..cd408b86c839b1833e6f6a743f3459cc780cf10a 100644 (file)
@@ -534,8 +534,8 @@ static int snd_sonicvibes_hw_constraint_dac_rate(struct snd_pcm_hw_params *param
                        params->rate_den = 1;
                } else {
                        snd_sonicvibes_pll(rate, &r, &m, &n);
-                       snd_assert((SV_REFFREQUENCY % 16) == 0, return -EINVAL);
-                       snd_assert((SV_ADCMULT % 512) == 0, return -EINVAL);
+                       snd_BUG_ON(SV_REFFREQUENCY % 16);
+                       snd_BUG_ON(SV_ADCMULT % 512);
                        params->rate_num = (SV_REFFREQUENCY/16) * (n+2) * r;
                        params->rate_den = (SV_ADCMULT/512) * (m+2);
                }
@@ -849,7 +849,8 @@ static int __devinit snd_sonicvibes_pcm(struct sonicvibes * sonic, int device, s
 
        if ((err = snd_pcm_new(sonic->card, "s3_86c617", device, 1, 1, &pcm)) < 0)
                return err;
-       snd_assert(pcm != NULL, return -EINVAL);
+       if (snd_BUG_ON(!pcm))
+               return -EINVAL;
 
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sonicvibes_playback_ops);
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sonicvibes_capture_ops);
@@ -1089,7 +1090,8 @@ static int __devinit snd_sonicvibes_mixer(struct sonicvibes * sonic)
        unsigned int idx;
        int err;
 
-       snd_assert(sonic != NULL && sonic->card != NULL, return -EINVAL);
+       if (snd_BUG_ON(!sonic || !sonic->card))
+               return -EINVAL;
        card = sonic->card;
        strcpy(card->mixername, "S3 SonicVibes");
 
index a69b4206c69e205f9a88726f63182f75b36491ee..c612b435ca2bc6cd43a7ba77ce8ceb4dd81c6a3a 100644 (file)
@@ -2931,7 +2931,8 @@ static int snd_trident_pcm_mixer_build(struct snd_trident *trident,
 {
        struct snd_trident_pcm_mixer *tmix;
 
-       snd_assert(trident != NULL && voice != NULL && substream != NULL, return -EINVAL);
+       if (snd_BUG_ON(!trident || !voice || !substream))
+               return -EINVAL;
        tmix = &trident->pcm_mixer[substream->number];
        tmix->voice = voice;
        tmix->vol = T4D_DEFAULT_PCM_VOL;
@@ -2946,7 +2947,8 @@ static int snd_trident_pcm_mixer_free(struct snd_trident *trident, struct snd_tr
 {
        struct snd_trident_pcm_mixer *tmix;
 
-       snd_assert(trident != NULL && substream != NULL, return -EINVAL);
+       if (snd_BUG_ON(!trident || !substream))
+               return -EINVAL;
        tmix = &trident->pcm_mixer[substream->number];
        tmix->voice = NULL;
        snd_trident_notify_pcm_change(trident, tmix, substream->number, 0);
@@ -3131,7 +3133,8 @@ static unsigned char snd_trident_gameport_read(struct gameport *gameport)
 {
        struct snd_trident *chip = gameport_get_port_data(gameport);
 
-       snd_assert(chip, return 0);
+       if (snd_BUG_ON(!chip))
+               return 0;
        return inb(TRID_REG(chip, GAMEPORT_LEGACY));
 }
 
@@ -3139,7 +3142,8 @@ static void snd_trident_gameport_trigger(struct gameport *gameport)
 {
        struct snd_trident *chip = gameport_get_port_data(gameport);
 
-       snd_assert(chip, return);
+       if (snd_BUG_ON(!chip))
+               return;
        outb(0xff, TRID_REG(chip, GAMEPORT_LEGACY));
 }
 
@@ -3148,7 +3152,8 @@ static int snd_trident_gameport_cooked_read(struct gameport *gameport, int *axes
        struct snd_trident *chip = gameport_get_port_data(gameport);
        int i;
 
-       snd_assert(chip, return 0);
+       if (snd_BUG_ON(!chip))
+               return 0;
 
        *buttons = (~inb(TRID_REG(chip, GAMEPORT_LEGACY)) >> 4) & 0xf;
 
@@ -3164,7 +3169,8 @@ static int snd_trident_gameport_open(struct gameport *gameport, int mode)
 {
        struct snd_trident *chip = gameport_get_port_data(gameport);
 
-       snd_assert(chip, return 0);
+       if (snd_BUG_ON(!chip))
+               return 0;
 
        switch (mode) {
                case GAMEPORT_MODE_COOKED:
@@ -3891,8 +3897,8 @@ static void snd_trident_clear_voices(struct snd_trident * trident, unsigned shor
 {
        unsigned int i, val, mask[2] = { 0, 0 };
 
-       snd_assert(v_min <= 63, return);
-       snd_assert(v_max <= 63, return);
+       if (snd_BUG_ON(v_min > 63 || v_max > 63))
+               return;
        for (i = v_min; i <= v_max; i++)
                mask[i >> 5] |= 1 << (i & 0x1f);
        if (mask[0]) {
index 3fd7f1b29b0f57840192aff0e4a97294134c0a5b..2fe3b1fab53abfb3c2628cd1915a4cc5b927f2c0 100644 (file)
@@ -196,9 +196,13 @@ snd_trident_alloc_sg_pages(struct snd_trident *trident,
        int idx, page;
        struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream);
 
-       snd_assert(runtime->dma_bytes > 0 && runtime->dma_bytes <= SNDRV_TRIDENT_MAX_PAGES * SNDRV_TRIDENT_PAGE_SIZE, return NULL);
+       if (snd_BUG_ON(runtime->dma_bytes <= 0 ||
+                      runtime->dma_bytes > SNDRV_TRIDENT_MAX_PAGES *
+                                       SNDRV_TRIDENT_PAGE_SIZE))
+               return NULL;
        hdr = trident->tlb.memhdr;
-       snd_assert(hdr != NULL, return NULL);
+       if (snd_BUG_ON(!hdr))
+               return NULL;
 
        
 
@@ -245,9 +249,13 @@ snd_trident_alloc_cont_pages(struct snd_trident *trident,
        dma_addr_t addr;
        unsigned long ptr;
 
-       snd_assert(runtime->dma_bytes> 0 && runtime->dma_bytes <= SNDRV_TRIDENT_MAX_PAGES * SNDRV_TRIDENT_PAGE_SIZE, return NULL);
+       if (snd_BUG_ON(runtime->dma_bytes <= 0 ||
+                      runtime->dma_bytes > SNDRV_TRIDENT_MAX_PAGES *
+                                       SNDRV_TRIDENT_PAGE_SIZE))
+               return NULL;
        hdr = trident->tlb.memhdr;
-       snd_assert(hdr != NULL, return NULL);
+       if (snd_BUG_ON(!hdr))
+               return NULL;
 
        mutex_lock(&hdr->block_mutex);
        blk = search_empty(hdr, runtime->dma_bytes);
@@ -279,8 +287,8 @@ struct snd_util_memblk *
 snd_trident_alloc_pages(struct snd_trident *trident,
                        struct snd_pcm_substream *substream)
 {
-       snd_assert(trident != NULL, return NULL);
-       snd_assert(substream != NULL, return NULL);
+       if (snd_BUG_ON(!trident || !substream))
+               return NULL;
        if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV_SG)
                return snd_trident_alloc_sg_pages(trident, substream);
        else
@@ -297,8 +305,8 @@ int snd_trident_free_pages(struct snd_trident *trident,
        struct snd_util_memhdr *hdr;
        int page;
 
-       snd_assert(trident != NULL, return -EINVAL);
-       snd_assert(blk != NULL, return -EINVAL);
+       if (snd_BUG_ON(!trident || !blk))
+               return -EINVAL;
 
        hdr = trident->tlb.memhdr;
        mutex_lock(&hdr->block_mutex);
index 6781be9e3078ac702364770f407fbc4458486882..84ea35d8b252f00a1cdbd3c00c6d10a0a922ef71 100644 (file)
@@ -824,7 +824,8 @@ static snd_pcm_uframes_t snd_via686_pcm_pointer(struct snd_pcm_substream *substr
        struct viadev *viadev = substream->runtime->private_data;
        unsigned int idx, ptr, count, res;
 
-       snd_assert(viadev->tbl_entries, return 0);
+       if (snd_BUG_ON(!viadev->tbl_entries))
+               return 0;
        if (!(inb(VIADEV_REG(viadev, OFFSET_STATUS)) & VIA_REG_STAT_ACTIVE))
                return 0;
 
@@ -855,7 +856,8 @@ static snd_pcm_uframes_t snd_via8233_pcm_pointer(struct snd_pcm_substream *subst
        unsigned int idx, count, res;
        int status;
        
-       snd_assert(viadev->tbl_entries, return 0);
+       if (snd_BUG_ON(!viadev->tbl_entries))
+               return 0;
 
        spin_lock(&chip->reg_lock);
        count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT));
@@ -1037,7 +1039,7 @@ static int snd_via8233_playback_prepare(struct snd_pcm_substream *substream)
        else
                rbits = (0x100000 / 48000) * runtime->rate +
                        ((0x100000 % 48000) * runtime->rate) / 48000;
-       snd_assert((rbits & ~0xfffff) == 0, return -EINVAL);
+       snd_BUG_ON(rbits & ~0xfffff);
        snd_via82xx_channel_reset(chip, viadev);
        snd_via82xx_set_table_ptr(chip, viadev);
        outb(chip->playback_volume[viadev->reg_offset / 0x10][0],
index 31f64ee398820c62ffb8c9b51318a2c4e122e9b0..640c338ce0ab11488e57d2e10cc01bfe43137e36 100644 (file)
@@ -612,7 +612,8 @@ static snd_pcm_uframes_t snd_via686_pcm_pointer(struct snd_pcm_substream *substr
        struct viadev *viadev = substream->runtime->private_data;
        unsigned int idx, ptr, count, res;
 
-       snd_assert(viadev->tbl_entries, return 0);
+       if (snd_BUG_ON(!viadev->tbl_entries))
+               return 0;
        if (!(inb(VIADEV_REG(viadev, OFFSET_STATUS)) & VIA_REG_STAT_ACTIVE))
                return 0;
 
index 631f3a63999329a8bef69ac0afbc825aac47ae1b..7e87f398ff0bda688caa6f212198b881da687445 100644 (file)
@@ -253,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);
 
@@ -291,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.
@@ -675,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:
@@ -823,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;
index 92d49aadf579666a0c837ab692678fc414fece28..90d0d62bd0b40648406bd1db328c280fc572dbfe 100644 (file)
@@ -259,8 +259,10 @@ static int snd_ymfpci_voice_alloc(struct snd_ymfpci *chip,
        unsigned long flags;
        int result;
        
-       snd_assert(rvoice != NULL, return -EINVAL);
-       snd_assert(!pair || type == YMFPCI_PCM, return -EINVAL);
+       if (snd_BUG_ON(!rvoice))
+               return -EINVAL;
+       if (snd_BUG_ON(pair && type != YMFPCI_PCM))
+               return -EINVAL;
        
        spin_lock_irqsave(&chip->voice_lock, flags);
        for (;;) {
@@ -278,7 +280,8 @@ static int snd_ymfpci_voice_free(struct snd_ymfpci *chip, struct snd_ymfpci_voic
 {
        unsigned long flags;
        
-       snd_assert(pvoice != NULL, return -EINVAL);
+       if (snd_BUG_ON(!pvoice))
+               return -EINVAL;
        snd_ymfpci_hw_stop(chip);
        spin_lock_irqsave(&chip->voice_lock, flags);
        if (pvoice->number == chip->src441_used) {
@@ -494,7 +497,8 @@ static void snd_ymfpci_pcm_init_voice(struct snd_ymfpci_pcm *ypcm, unsigned int
        u8 use_left, use_right;
        unsigned long flags;
 
-       snd_assert(voice != NULL, return);
+       if (snd_BUG_ON(!voice))
+               return;
        if (runtime->channels == 1) {
                use_left = 1;
                use_right = 1;
@@ -1813,7 +1817,8 @@ int __devinit snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch)
        }
 
        /* add S/PDIF control */
-       snd_assert(chip->pcm_spdif != NULL, return -EIO);
+       if (snd_BUG_ON(!chip->pcm_spdif))
+               return -ENXIO;
        if ((err = snd_ctl_add(chip->card, kctl = snd_ctl_new1(&snd_ymfpci_spdif_default, chip))) < 0)
                return err;
        kctl->id.device = chip->pcm_spdif->device;
@@ -2133,7 +2138,8 @@ static int __devinit snd_ymfpci_memalloc(struct snd_ymfpci *chip)
        chip->work_base = ptr;
        chip->work_base_addr = ptr_addr;
        
-       snd_assert(ptr + chip->work_size == chip->work_ptr.area + chip->work_ptr.bytes, );
+       snd_BUG_ON(ptr + chip->work_size !=
+                  chip->work_ptr.area + chip->work_ptr.bytes);
 
        snd_ymfpci_writel(chip, YDSXGR_PLAYCTRLBASE, chip->bank_base_playback_addr);
        snd_ymfpci_writel(chip, YDSXGR_RECCTRLBASE, chip->bank_base_capture_addr);
@@ -2168,7 +2174,8 @@ static int snd_ymfpci_free(struct snd_ymfpci *chip)
 {
        u16 ctrl;
 
-       snd_assert(chip != NULL, return -EINVAL);
+       if (snd_BUG_ON(!chip))
+               return -EINVAL;
 
        if (chip->res_reg_area) {       /* don't touch busy hardware */
                snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0);