aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/pci/ac97/ac97_codec.c19
-rw-r--r--sound/pci/ad1889.c6
-rw-r--r--sound/pci/ak4531_codec.c10
-rw-r--r--sound/pci/atiixp.c10
-rw-r--r--sound/pci/atiixp_modem.c10
-rw-r--r--sound/pci/azt3328.c6
-rw-r--r--sound/pci/ca0106/ca_midi.c20
-rw-r--r--sound/pci/cmipci.c9
-rw-r--r--sound/pci/cs4281.c13
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c72
-rw-r--r--sound/pci/cs46xx/dsp_spos.c51
-rw-r--r--sound/pci/cs46xx/dsp_spos_scb_lib.c115
-rw-r--r--sound/pci/echoaudio/darla20_dsp.c3
-rw-r--r--sound/pci/echoaudio/darla24_dsp.c8
-rw-r--r--sound/pci/echoaudio/echo3g_dsp.c9
-rw-r--r--sound/pci/echoaudio/echoaudio.c8
-rw-r--r--sound/pci/echoaudio/echoaudio_3g.c11
-rw-r--r--sound/pci/echoaudio/echoaudio_dsp.c21
-rw-r--r--sound/pci/echoaudio/echoaudio_gml.c6
-rw-r--r--sound/pci/echoaudio/gina20_dsp.c6
-rw-r--r--sound/pci/echoaudio/gina24_dsp.c11
-rw-r--r--sound/pci/echoaudio/indigo_dsp.c8
-rw-r--r--sound/pci/echoaudio/indigodj_dsp.c8
-rw-r--r--sound/pci/echoaudio/indigoio_dsp.c8
-rw-r--r--sound/pci/echoaudio/layla20_dsp.c9
-rw-r--r--sound/pci/echoaudio/layla24_dsp.c11
-rw-r--r--sound/pci/echoaudio/mia_dsp.c13
-rw-r--r--sound/pci/echoaudio/midi.c6
-rw-r--r--sound/pci/echoaudio/mona_dsp.c6
-rw-r--r--sound/pci/emu10k1/emu10k1_callback.c6
-rw-r--r--sound/pci/emu10k1/emu10k1_patch.c23
-rw-r--r--sound/pci/emu10k1/emu10k1x.c18
-rw-r--r--sound/pci/emu10k1/emufx.c6
-rw-r--r--sound/pci/emu10k1/emumpu401.c18
-rw-r--r--sound/pci/emu10k1/memory.c19
-rw-r--r--sound/pci/emu10k1/voice.c9
-rw-r--r--sound/pci/es1938.c3
-rw-r--r--sound/pci/es1968.c6
-rw-r--r--sound/pci/hda/hda_codec.c21
-rw-r--r--sound/pci/hda/hda_generic.c3
-rw-r--r--sound/pci/hda/hda_intel.c3
-rw-r--r--sound/pci/hda/patch_realtek.c6
-rw-r--r--sound/pci/ice1712/ak4xxx.c3
-rw-r--r--sound/pci/ice1712/ews.c9
-rw-r--r--sound/pci/ice1712/ice1712.c3
-rw-r--r--sound/pci/ice1712/ice1724.c3
-rw-r--r--sound/pci/ice1712/juli.c3
-rw-r--r--sound/pci/intel8x0.c4
-rw-r--r--sound/pci/intel8x0m.c3
-rw-r--r--sound/pci/korg1212/korg1212.c9
-rw-r--r--sound/pci/maestro3.c10
-rw-r--r--sound/pci/mixart/mixart.c4
-rw-r--r--sound/pci/mixart/mixart_core.c18
-rw-r--r--sound/pci/mixart/mixart_hwdep.c19
-rw-r--r--sound/pci/mixart/mixart_mixer.c8
-rw-r--r--sound/pci/nm256/nm256.c15
-rw-r--r--sound/pci/pcxhr/pcxhr.c6
-rw-r--r--sound/pci/pcxhr/pcxhr_core.c27
-rw-r--r--sound/pci/pcxhr/pcxhr_hwdep.c15
-rw-r--r--sound/pci/riptide/riptide.c18
-rw-r--r--sound/pci/rme9652/hdsp.c25
-rw-r--r--sound/pci/rme9652/hdspm.c34
-rw-r--r--sound/pci/rme9652/rme9652.c23
-rw-r--r--sound/pci/sonicvibes.c10
-rw-r--r--sound/pci/trident/trident_main.c22
-rw-r--r--sound/pci/trident/trident_memory.c24
-rw-r--r--sound/pci/via82xx.c8
-rw-r--r--sound/pci/via82xx_modem.c3
-rw-r--r--sound/pci/vx222/vx222_ops.c12
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c21
70 files changed, 632 insertions, 361 deletions
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index 171559c19b3d..d0023e99bdf9 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -1890,8 +1890,8 @@ int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops,
1890 .dev_free = snd_ac97_bus_dev_free, 1890 .dev_free = snd_ac97_bus_dev_free,
1891 }; 1891 };
1892 1892
1893 snd_assert(card != NULL, return -EINVAL); 1893 if (snd_BUG_ON(!card))
1894 snd_assert(rbus != NULL, return -EINVAL); 1894 return -EINVAL;
1895 bus = kzalloc(sizeof(*bus), GFP_KERNEL); 1895 bus = kzalloc(sizeof(*bus), GFP_KERNEL);
1896 if (bus == NULL) 1896 if (bus == NULL)
1897 return -ENOMEM; 1897 return -ENOMEM;
@@ -1906,7 +1906,8 @@ int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops,
1906 snd_ac97_bus_free(bus); 1906 snd_ac97_bus_free(bus);
1907 return err; 1907 return err;
1908 } 1908 }
1909 *rbus = bus; 1909 if (rbus)
1910 *rbus = bus;
1910 return 0; 1911 return 0;
1911} 1912}
1912 1913
@@ -1991,10 +1992,14 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
1991 .dev_disconnect = snd_ac97_dev_disconnect, 1992 .dev_disconnect = snd_ac97_dev_disconnect,
1992 }; 1993 };
1993 1994
1994 snd_assert(rac97 != NULL, return -EINVAL); 1995 if (rac97)
1995 *rac97 = NULL; 1996 *rac97 = NULL;
1996 snd_assert(bus != NULL && template != NULL, return -EINVAL); 1997 if (snd_BUG_ON(!bus || !template))
1997 snd_assert(template->num < 4 && bus->codec[template->num] == NULL, return -EINVAL); 1998 return -EINVAL;
1999 if (snd_BUG_ON(template->num >= 4))
2000 return -EINVAL;
2001 if (bus->codec[template->num])
2002 return -EBUSY;
1998 2003
1999 card = bus->card; 2004 card = bus->card;
2000 ac97 = kzalloc(sizeof(*ac97), GFP_KERNEL); 2005 ac97 = kzalloc(sizeof(*ac97), GFP_KERNEL);
diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c
index 39ec55b57b1e..92f3a976ef2e 100644
--- a/sound/pci/ad1889.c
+++ b/sound/pci/ad1889.c
@@ -549,7 +549,8 @@ snd_ad1889_playback_pointer(struct snd_pcm_substream *ss)
549 ptr = ad1889_readl(chip, AD_DMA_WAVCA); 549 ptr = ad1889_readl(chip, AD_DMA_WAVCA);
550 ptr -= chip->wave.addr; 550 ptr -= chip->wave.addr;
551 551
552 snd_assert((ptr >= 0) && (ptr < chip->wave.size), return 0); 552 if (snd_BUG_ON(ptr >= chip->wave.size))
553 return 0;
553 554
554 return bytes_to_frames(ss->runtime, ptr); 555 return bytes_to_frames(ss->runtime, ptr);
555} 556}
@@ -567,7 +568,8 @@ snd_ad1889_capture_pointer(struct snd_pcm_substream *ss)
567 ptr = ad1889_readl(chip, AD_DMA_ADCCA); 568 ptr = ad1889_readl(chip, AD_DMA_ADCCA);
568 ptr -= chip->ramc.addr; 569 ptr -= chip->ramc.addr;
569 570
570 snd_assert((ptr >= 0) && (ptr < chip->ramc.size), return 0); 571 if (snd_BUG_ON(ptr >= chip->ramc.size))
572 return 0;
571 573
572 return bytes_to_frames(ss->runtime, ptr); 574 return bytes_to_frames(ss->runtime, ptr);
573} 575}
diff --git a/sound/pci/ak4531_codec.c b/sound/pci/ak4531_codec.c
index 33d37b1c42fc..0f819ddb3ebf 100644
--- a/sound/pci/ak4531_codec.c
+++ b/sound/pci/ak4531_codec.c
@@ -392,9 +392,10 @@ int __devinit snd_ak4531_mixer(struct snd_card *card,
392 .dev_free = snd_ak4531_dev_free, 392 .dev_free = snd_ak4531_dev_free,
393 }; 393 };
394 394
395 snd_assert(rak4531 != NULL, return -EINVAL); 395 if (snd_BUG_ON(!card || !_ak4531))
396 *rak4531 = NULL; 396 return -EINVAL;
397 snd_assert(card != NULL && _ak4531 != NULL, return -EINVAL); 397 if (rak4531)
398 *rak4531 = NULL;
398 ak4531 = kzalloc(sizeof(*ak4531), GFP_KERNEL); 399 ak4531 = kzalloc(sizeof(*ak4531), GFP_KERNEL);
399 if (ak4531 == NULL) 400 if (ak4531 == NULL)
400 return -ENOMEM; 401 return -ENOMEM;
@@ -428,7 +429,8 @@ int __devinit snd_ak4531_mixer(struct snd_card *card,
428#if 0 429#if 0
429 snd_ak4531_dump(ak4531); 430 snd_ak4531_dump(ak4531);
430#endif 431#endif
431 *rak4531 = ak4531; 432 if (rak4531)
433 *rak4531 = ak4531;
432 return 0; 434 return 0;
433} 435}
434 436
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 457228fb22aa..ce1eb12768f4 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -722,7 +722,9 @@ static int snd_atiixp_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
722 struct atiixp_dma *dma = substream->runtime->private_data; 722 struct atiixp_dma *dma = substream->runtime->private_data;
723 int err = 0; 723 int err = 0;
724 724
725 snd_assert(dma->ops->enable_transfer && dma->ops->flush_dma, return -EINVAL); 725 if (snd_BUG_ON(!dma->ops->enable_transfer ||
726 !dma->ops->flush_dma))
727 return -EINVAL;
726 728
727 spin_lock(&chip->reg_lock); 729 spin_lock(&chip->reg_lock);
728 switch (cmd) { 730 switch (cmd) {
@@ -1032,7 +1034,8 @@ static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream,
1032 struct snd_pcm_runtime *runtime = substream->runtime; 1034 struct snd_pcm_runtime *runtime = substream->runtime;
1033 int err; 1035 int err;
1034 1036
1035 snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL); 1037 if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
1038 return -EINVAL;
1036 1039
1037 if (dma->opened) 1040 if (dma->opened)
1038 return -EBUSY; 1041 return -EBUSY;
@@ -1064,7 +1067,8 @@ static int snd_atiixp_pcm_close(struct snd_pcm_substream *substream,
1064{ 1067{
1065 struct atiixp *chip = snd_pcm_substream_chip(substream); 1068 struct atiixp *chip = snd_pcm_substream_chip(substream);
1066 /* disable DMA bits */ 1069 /* disable DMA bits */
1067 snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL); 1070 if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
1071 return -EINVAL;
1068 spin_lock_irq(&chip->reg_lock); 1072 spin_lock_irq(&chip->reg_lock);
1069 dma->ops->enable_dma(chip, 0); 1073 dma->ops->enable_dma(chip, 0);
1070 spin_unlock_irq(&chip->reg_lock); 1074 spin_unlock_irq(&chip->reg_lock);
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index d457a32a7939..2f106306c7fe 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -674,7 +674,9 @@ static int snd_atiixp_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
674 struct atiixp_dma *dma = substream->runtime->private_data; 674 struct atiixp_dma *dma = substream->runtime->private_data;
675 int err = 0; 675 int err = 0;
676 676
677 snd_assert(dma->ops->enable_transfer && dma->ops->flush_dma, return -EINVAL); 677 if (snd_BUG_ON(!dma->ops->enable_transfer ||
678 !dma->ops->flush_dma))
679 return -EINVAL;
678 680
679 spin_lock(&chip->reg_lock); 681 spin_lock(&chip->reg_lock);
680 switch(cmd) { 682 switch(cmd) {
@@ -865,7 +867,8 @@ static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream,
865 .mask = 0, 867 .mask = 0,
866 }; 868 };
867 869
868 snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL); 870 if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
871 return -EINVAL;
869 872
870 if (dma->opened) 873 if (dma->opened)
871 return -EBUSY; 874 return -EBUSY;
@@ -895,7 +898,8 @@ static int snd_atiixp_pcm_close(struct snd_pcm_substream *substream,
895{ 898{
896 struct atiixp_modem *chip = snd_pcm_substream_chip(substream); 899 struct atiixp_modem *chip = snd_pcm_substream_chip(substream);
897 /* disable DMA bits */ 900 /* disable DMA bits */
898 snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL); 901 if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
902 return -EINVAL;
899 spin_lock_irq(&chip->reg_lock); 903 spin_lock_irq(&chip->reg_lock);
900 dma->ops->enable_dma(chip, 0); 904 dma->ops->enable_dma(chip, 0);
901 spin_unlock_irq(&chip->reg_lock); 905 spin_unlock_irq(&chip->reg_lock);
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index 22f18f3cfbc9..333007c523a1 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -816,7 +816,8 @@ snd_azf3328_mixer_new(struct snd_azf3328 *chip)
816 int err; 816 int err;
817 817
818 snd_azf3328_dbgcallenter(); 818 snd_azf3328_dbgcallenter();
819 snd_assert(chip != NULL && chip->card != NULL, return -EINVAL); 819 if (snd_BUG_ON(!chip || !chip->card))
820 return -EINVAL;
820 821
821 card = chip->card; 822 card = chip->card;
822 823
@@ -1471,7 +1472,8 @@ snd_azf3328_gameport_cooked_read(struct gameport *gameport,
1471 u8 val; 1472 u8 val;
1472 unsigned long flags; 1473 unsigned long flags;
1473 1474
1474 snd_assert(chip, return 0); 1475 if (snd_BUG_ON(!chip))
1476 return 0;
1475 1477
1476 spin_lock_irqsave(&chip->reg_lock, flags); 1478 spin_lock_irqsave(&chip->reg_lock, flags);
1477 val = snd_azf3328_game_inb(chip, IDX_GAME_LEGACY_COMPATIBLE); 1479 val = snd_azf3328_game_inb(chip, IDX_GAME_LEGACY_COMPATIBLE);
diff --git a/sound/pci/ca0106/ca_midi.c b/sound/pci/ca0106/ca_midi.c
index 893ee4f1ea77..c7885117da33 100644
--- a/sound/pci/ca0106/ca_midi.c
+++ b/sound/pci/ca0106/ca_midi.c
@@ -125,7 +125,8 @@ static int ca_midi_input_open(struct snd_rawmidi_substream *substream)
125 struct snd_ca_midi *midi = substream->rmidi->private_data; 125 struct snd_ca_midi *midi = substream->rmidi->private_data;
126 unsigned long flags; 126 unsigned long flags;
127 127
128 snd_assert(midi->dev_id, return -ENXIO); 128 if (snd_BUG_ON(!midi->dev_id))
129 return -ENXIO;
129 spin_lock_irqsave(&midi->open_lock, flags); 130 spin_lock_irqsave(&midi->open_lock, flags);
130 midi->midi_mode |= CA_MIDI_MODE_INPUT; 131 midi->midi_mode |= CA_MIDI_MODE_INPUT;
131 midi->substream_input = substream; 132 midi->substream_input = substream;
@@ -144,7 +145,8 @@ static int ca_midi_output_open(struct snd_rawmidi_substream *substream)
144 struct snd_ca_midi *midi = substream->rmidi->private_data; 145 struct snd_ca_midi *midi = substream->rmidi->private_data;
145 unsigned long flags; 146 unsigned long flags;
146 147
147 snd_assert(midi->dev_id, return -ENXIO); 148 if (snd_BUG_ON(!midi->dev_id))
149 return -ENXIO;
148 spin_lock_irqsave(&midi->open_lock, flags); 150 spin_lock_irqsave(&midi->open_lock, flags);
149 midi->midi_mode |= CA_MIDI_MODE_OUTPUT; 151 midi->midi_mode |= CA_MIDI_MODE_OUTPUT;
150 midi->substream_output = substream; 152 midi->substream_output = substream;
@@ -163,7 +165,8 @@ static int ca_midi_input_close(struct snd_rawmidi_substream *substream)
163 struct snd_ca_midi *midi = substream->rmidi->private_data; 165 struct snd_ca_midi *midi = substream->rmidi->private_data;
164 unsigned long flags; 166 unsigned long flags;
165 167
166 snd_assert(midi->dev_id, return -ENXIO); 168 if (snd_BUG_ON(!midi->dev_id))
169 return -ENXIO;
167 spin_lock_irqsave(&midi->open_lock, flags); 170 spin_lock_irqsave(&midi->open_lock, flags);
168 midi->interrupt_disable(midi,midi->rx_enable); 171 midi->interrupt_disable(midi,midi->rx_enable);
169 midi->midi_mode &= ~CA_MIDI_MODE_INPUT; 172 midi->midi_mode &= ~CA_MIDI_MODE_INPUT;
@@ -181,7 +184,9 @@ static int ca_midi_output_close(struct snd_rawmidi_substream *substream)
181{ 184{
182 struct snd_ca_midi *midi = substream->rmidi->private_data; 185 struct snd_ca_midi *midi = substream->rmidi->private_data;
183 unsigned long flags; 186 unsigned long flags;
184 snd_assert(midi->dev_id, return -ENXIO); 187
188 if (snd_BUG_ON(!midi->dev_id))
189 return -ENXIO;
185 190
186 spin_lock_irqsave(&midi->open_lock, flags); 191 spin_lock_irqsave(&midi->open_lock, flags);
187 192
@@ -201,7 +206,9 @@ static int ca_midi_output_close(struct snd_rawmidi_substream *substream)
201static void ca_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) 206static void ca_midi_input_trigger(struct snd_rawmidi_substream *substream, int up)
202{ 207{
203 struct snd_ca_midi *midi = substream->rmidi->private_data; 208 struct snd_ca_midi *midi = substream->rmidi->private_data;
204 snd_assert(midi->dev_id, return); 209
210 if (snd_BUG_ON(!midi->dev_id))
211 return;
205 212
206 if (up) { 213 if (up) {
207 midi->interrupt_enable(midi,midi->rx_enable); 214 midi->interrupt_enable(midi,midi->rx_enable);
@@ -215,7 +222,8 @@ static void ca_midi_output_trigger(struct snd_rawmidi_substream *substream, int
215 struct snd_ca_midi *midi = substream->rmidi->private_data; 222 struct snd_ca_midi *midi = substream->rmidi->private_data;
216 unsigned long flags; 223 unsigned long flags;
217 224
218 snd_assert(midi->dev_id, return); 225 if (snd_BUG_ON(!midi->dev_id))
226 return;
219 227
220 if (up) { 228 if (up) {
221 int max = 4; 229 int max = 4;
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index 9971b5b7735b..1a74ca62c314 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -2357,7 +2357,8 @@ static int snd_cmipci_uswitch_get(struct snd_kcontrol *kcontrol,
2357{ 2357{
2358 struct cmipci_switch_args *args; 2358 struct cmipci_switch_args *args;
2359 args = (struct cmipci_switch_args *)kcontrol->private_value; 2359 args = (struct cmipci_switch_args *)kcontrol->private_value;
2360 snd_assert(args != NULL, return -EINVAL); 2360 if (snd_BUG_ON(!args))
2361 return -EINVAL;
2361 return _snd_cmipci_uswitch_get(kcontrol, ucontrol, args); 2362 return _snd_cmipci_uswitch_get(kcontrol, ucontrol, args);
2362} 2363}
2363 2364
@@ -2401,7 +2402,8 @@ static int snd_cmipci_uswitch_put(struct snd_kcontrol *kcontrol,
2401{ 2402{
2402 struct cmipci_switch_args *args; 2403 struct cmipci_switch_args *args;
2403 args = (struct cmipci_switch_args *)kcontrol->private_value; 2404 args = (struct cmipci_switch_args *)kcontrol->private_value;
2404 snd_assert(args != NULL, return -EINVAL); 2405 if (snd_BUG_ON(!args))
2406 return -EINVAL;
2405 return _snd_cmipci_uswitch_put(kcontrol, ucontrol, args); 2407 return _snd_cmipci_uswitch_put(kcontrol, ucontrol, args);
2406} 2408}
2407 2409
@@ -2662,7 +2664,8 @@ static int __devinit snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_devic
2662 unsigned int idx; 2664 unsigned int idx;
2663 int err; 2665 int err;
2664 2666
2665 snd_assert(cm != NULL && cm->card != NULL, return -EINVAL); 2667 if (snd_BUG_ON(!cm || !cm->card))
2668 return -EINVAL;
2666 2669
2667 card = cm->card; 2670 card = cm->card;
2668 2671
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index 7556fd90d0eb..ef9308f7c45b 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -766,13 +766,13 @@ static void snd_cs4281_mode(struct cs4281 *chip, struct cs4281_dma *dma,
766 if (!capture) { 766 if (!capture) {
767 if (dma->left_slot == chip->src_left_play_slot) { 767 if (dma->left_slot == chip->src_left_play_slot) {
768 unsigned int val = snd_cs4281_rate(runtime->rate, NULL); 768 unsigned int val = snd_cs4281_rate(runtime->rate, NULL);
769 snd_assert(dma->right_slot == chip->src_right_play_slot, ); 769 snd_BUG_ON(dma->right_slot != chip->src_right_play_slot);
770 snd_cs4281_pokeBA0(chip, BA0_DACSR, val); 770 snd_cs4281_pokeBA0(chip, BA0_DACSR, val);
771 } 771 }
772 } else { 772 } else {
773 if (dma->left_slot == chip->src_left_rec_slot) { 773 if (dma->left_slot == chip->src_left_rec_slot) {
774 unsigned int val = snd_cs4281_rate(runtime->rate, NULL); 774 unsigned int val = snd_cs4281_rate(runtime->rate, NULL);
775 snd_assert(dma->right_slot == chip->src_right_rec_slot, ); 775 snd_BUG_ON(dma->right_slot != chip->src_right_rec_slot);
776 snd_cs4281_pokeBA0(chip, BA0_ADCSR, val); 776 snd_cs4281_pokeBA0(chip, BA0_ADCSR, val);
777 } 777 }
778 } 778 }
@@ -1209,7 +1209,8 @@ static void snd_cs4281_gameport_trigger(struct gameport *gameport)
1209{ 1209{
1210 struct cs4281 *chip = gameport_get_port_data(gameport); 1210 struct cs4281 *chip = gameport_get_port_data(gameport);
1211 1211
1212 snd_assert(chip, return); 1212 if (snd_BUG_ON(!chip))
1213 return;
1213 snd_cs4281_pokeBA0(chip, BA0_JSPT, 0xff); 1214 snd_cs4281_pokeBA0(chip, BA0_JSPT, 0xff);
1214} 1215}
1215 1216
@@ -1217,7 +1218,8 @@ static unsigned char snd_cs4281_gameport_read(struct gameport *gameport)
1217{ 1218{
1218 struct cs4281 *chip = gameport_get_port_data(gameport); 1219 struct cs4281 *chip = gameport_get_port_data(gameport);
1219 1220
1220 snd_assert(chip, return 0); 1221 if (snd_BUG_ON(!chip))
1222 return 0;
1221 return snd_cs4281_peekBA0(chip, BA0_JSPT); 1223 return snd_cs4281_peekBA0(chip, BA0_JSPT);
1222} 1224}
1223 1225
@@ -1228,7 +1230,8 @@ static int snd_cs4281_gameport_cooked_read(struct gameport *gameport,
1228 struct cs4281 *chip = gameport_get_port_data(gameport); 1230 struct cs4281 *chip = gameport_get_port_data(gameport);
1229 unsigned js1, js2, jst; 1231 unsigned js1, js2, jst;
1230 1232
1231 snd_assert(chip, return 0); 1233 if (snd_BUG_ON(!chip))
1234 return 0;
1232 1235
1233 js1 = snd_cs4281_peekBA0(chip, BA0_JSC1); 1236 js1 = snd_cs4281_peekBA0(chip, BA0_JSC1);
1234 js2 = snd_cs4281_peekBA0(chip, BA0_JSC2); 1237 js2 = snd_cs4281_peekBA0(chip, BA0_JSC2);
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index e214e567dec8..a10ab8283f9a 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -90,9 +90,10 @@ static unsigned short snd_cs46xx_codec_read(struct snd_cs46xx *chip,
90 int count; 90 int count;
91 unsigned short result,tmp; 91 unsigned short result,tmp;
92 u32 offset = 0; 92 u32 offset = 0;
93 snd_assert ( (codec_index == CS46XX_PRIMARY_CODEC_INDEX) || 93
94 (codec_index == CS46XX_SECONDARY_CODEC_INDEX), 94 if (snd_BUG_ON(codec_index != CS46XX_PRIMARY_CODEC_INDEX &&
95 return -EINVAL); 95 codec_index != CS46XX_SECONDARY_CODEC_INDEX))
96 return -EINVAL;
96 97
97 chip->active_ctrl(chip, 1); 98 chip->active_ctrl(chip, 1);
98 99
@@ -212,9 +213,9 @@ static unsigned short snd_cs46xx_ac97_read(struct snd_ac97 * ac97,
212 unsigned short val; 213 unsigned short val;
213 int codec_index = ac97->num; 214 int codec_index = ac97->num;
214 215
215 snd_assert(codec_index == CS46XX_PRIMARY_CODEC_INDEX || 216 if (snd_BUG_ON(codec_index != CS46XX_PRIMARY_CODEC_INDEX &&
216 codec_index == CS46XX_SECONDARY_CODEC_INDEX, 217 codec_index != CS46XX_SECONDARY_CODEC_INDEX))
217 return 0xffff); 218 return 0xffff;
218 219
219 val = snd_cs46xx_codec_read(chip, reg, codec_index); 220 val = snd_cs46xx_codec_read(chip, reg, codec_index);
220 221
@@ -229,9 +230,9 @@ static void snd_cs46xx_codec_write(struct snd_cs46xx *chip,
229{ 230{
230 int count; 231 int count;
231 232
232 snd_assert ((codec_index == CS46XX_PRIMARY_CODEC_INDEX) || 233 if (snd_BUG_ON(codec_index != CS46XX_PRIMARY_CODEC_INDEX &&
233 (codec_index == CS46XX_SECONDARY_CODEC_INDEX), 234 codec_index != CS46XX_SECONDARY_CODEC_INDEX))
234 return); 235 return;
235 236
236 chip->active_ctrl(chip, 1); 237 chip->active_ctrl(chip, 1);
237 238
@@ -294,9 +295,9 @@ static void snd_cs46xx_ac97_write(struct snd_ac97 *ac97,
294 struct snd_cs46xx *chip = ac97->private_data; 295 struct snd_cs46xx *chip = ac97->private_data;
295 int codec_index = ac97->num; 296 int codec_index = ac97->num;
296 297
297 snd_assert(codec_index == CS46XX_PRIMARY_CODEC_INDEX || 298 if (snd_BUG_ON(codec_index != CS46XX_PRIMARY_CODEC_INDEX &&
298 codec_index == CS46XX_SECONDARY_CODEC_INDEX, 299 codec_index != CS46XX_SECONDARY_CODEC_INDEX))
299 return); 300 return;
300 301
301 snd_cs46xx_codec_write(chip, reg, val, codec_index); 302 snd_cs46xx_codec_write(chip, reg, val, codec_index);
302} 303}
@@ -315,7 +316,8 @@ int snd_cs46xx_download(struct snd_cs46xx *chip,
315 unsigned int bank = offset >> 16; 316 unsigned int bank = offset >> 16;
316 offset = offset & 0xffff; 317 offset = offset & 0xffff;
317 318
318 snd_assert(!(offset & 3) && !(len & 3), return -EINVAL); 319 if (snd_BUG_ON((offset & 3) || (len & 3)))
320 return -EINVAL;
319 dst = chip->region.idx[bank+1].remap_addr + offset; 321 dst = chip->region.idx[bank+1].remap_addr + offset;
320 len /= sizeof(u32); 322 len /= sizeof(u32);
321 323
@@ -343,7 +345,8 @@ int snd_cs46xx_clear_BA1(struct snd_cs46xx *chip,
343 unsigned int bank = offset >> 16; 345 unsigned int bank = offset >> 16;
344 offset = offset & 0xffff; 346 offset = offset & 0xffff;
345 347
346 snd_assert(!(offset & 3) && !(len & 3), return -EINVAL); 348 if (snd_BUG_ON((offset & 3) || (len & 3)))
349 return -EINVAL;
347 dst = chip->region.idx[bank+1].remap_addr + offset; 350 dst = chip->region.idx[bank+1].remap_addr + offset;
348 len /= sizeof(u32); 351 len /= sizeof(u32);
349 352
@@ -722,7 +725,9 @@ static snd_pcm_uframes_t snd_cs46xx_playback_direct_pointer(struct snd_pcm_subst
722 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); 725 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream);
723 size_t ptr; 726 size_t ptr;
724 struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data; 727 struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data;
725 snd_assert (cpcm->pcm_channel,return -ENXIO); 728
729 if (snd_BUG_ON(!cpcm->pcm_channel))
730 return -ENXIO;
726 731
727#ifdef CONFIG_SND_CS46XX_NEW_DSP 732#ifdef CONFIG_SND_CS46XX_NEW_DSP
728 ptr = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 2) << 2); 733 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
740 struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data; 745 struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data;
741 746
742#ifdef CONFIG_SND_CS46XX_NEW_DSP 747#ifdef CONFIG_SND_CS46XX_NEW_DSP
743 snd_assert (cpcm->pcm_channel,return -ENXIO); 748 if (snd_BUG_ON(!cpcm->pcm_channel))
749 return -ENXIO;
744 ptr = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 2) << 2); 750 ptr = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 2) << 2);
745#else 751#else
746 ptr = snd_cs46xx_peek(chip, BA1_PBA); 752 ptr = snd_cs46xx_peek(chip, BA1_PBA);
@@ -908,7 +914,8 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream,
908 cpcm = runtime->private_data; 914 cpcm = runtime->private_data;
909 915
910#ifdef CONFIG_SND_CS46XX_NEW_DSP 916#ifdef CONFIG_SND_CS46XX_NEW_DSP
911 snd_assert (sample_rate != 0, return -ENXIO); 917 if (snd_BUG_ON(!sample_rate))
918 return -ENXIO;
912 919
913 mutex_lock(&chip->spos_mutex); 920 mutex_lock(&chip->spos_mutex);
914 921
@@ -917,7 +924,7 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream,
917 return -ENXIO; 924 return -ENXIO;
918 } 925 }
919 926
920 snd_assert (cpcm->pcm_channel != NULL); 927 snd_BUG_ON(!cpcm->pcm_channel);
921 if (!cpcm->pcm_channel) { 928 if (!cpcm->pcm_channel) {
922 mutex_unlock(&chip->spos_mutex); 929 mutex_unlock(&chip->spos_mutex);
923 return -ENXIO; 930 return -ENXIO;
@@ -952,7 +959,7 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream,
952 } else if (cpcm->pcm_channel_id == DSP_IEC958_CHANNEL) { 959 } else if (cpcm->pcm_channel_id == DSP_IEC958_CHANNEL) {
953 substream->ops = &snd_cs46xx_playback_iec958_ops; 960 substream->ops = &snd_cs46xx_playback_iec958_ops;
954 } else { 961 } else {
955 snd_assert(0); 962 snd_BUG();
956 } 963 }
957#else 964#else
958 substream->ops = &snd_cs46xx_playback_ops; 965 substream->ops = &snd_cs46xx_playback_ops;
@@ -981,7 +988,7 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream,
981 } else if (cpcm->pcm_channel_id == DSP_IEC958_CHANNEL) { 988 } else if (cpcm->pcm_channel_id == DSP_IEC958_CHANNEL) {
982 substream->ops = &snd_cs46xx_playback_indirect_iec958_ops; 989 substream->ops = &snd_cs46xx_playback_indirect_iec958_ops;
983 } else { 990 } else {
984 snd_assert(0); 991 snd_BUG();
985 } 992 }
986#else 993#else
987 substream->ops = &snd_cs46xx_playback_indirect_ops; 994 substream->ops = &snd_cs46xx_playback_indirect_ops;
@@ -1029,7 +1036,8 @@ static int snd_cs46xx_playback_prepare(struct snd_pcm_substream *substream)
1029 cpcm = runtime->private_data; 1036 cpcm = runtime->private_data;
1030 1037
1031#ifdef CONFIG_SND_CS46XX_NEW_DSP 1038#ifdef CONFIG_SND_CS46XX_NEW_DSP
1032 snd_assert (cpcm->pcm_channel != NULL, return -ENXIO); 1039 if (snd_BUG_ON(!cpcm->pcm_channel))
1040 return -ENXIO;
1033 1041
1034 pfie = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 1) << 2 ); 1042 pfie = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 1) << 2 );
1035 pfie &= ~0x0000f03f; 1043 pfie &= ~0x0000f03f;
@@ -1714,9 +1722,9 @@ static void snd_cs46xx_mixer_free_ac97(struct snd_ac97 *ac97)
1714{ 1722{
1715 struct snd_cs46xx *chip = ac97->private_data; 1723 struct snd_cs46xx *chip = ac97->private_data;
1716 1724
1717 snd_assert ((ac97 == chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]) || 1725 if (snd_BUG_ON(ac97 != chip->ac97[CS46XX_PRIMARY_CODEC_INDEX] &&
1718 (ac97 == chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]), 1726 ac97 != chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]))
1719 return); 1727 return;
1720 1728
1721 if (ac97 == chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]) { 1729 if (ac97 == chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]) {
1722 chip->ac97[CS46XX_PRIMARY_CODEC_INDEX] = NULL; 1730 chip->ac97[CS46XX_PRIMARY_CODEC_INDEX] = NULL;
@@ -1864,7 +1872,7 @@ static int snd_cs46xx_iec958_put(struct snd_kcontrol *kcontrol,
1864 break; 1872 break;
1865 default: 1873 default:
1866 res = -EINVAL; 1874 res = -EINVAL;
1867 snd_assert(0, (void)0); 1875 snd_BUG(); /* should never happen ... */
1868 } 1876 }
1869 1877
1870 return res; 1878 return res;
@@ -2236,7 +2244,7 @@ static void snd_cs46xx_codec_reset (struct snd_ac97 * ac97)
2236 snd_printdd("cs46xx: CODOEC2 mode %04x\n",0x3); 2244 snd_printdd("cs46xx: CODOEC2 mode %04x\n",0x3);
2237 snd_cs46xx_ac97_write(ac97,AC97_CSR_ACMODE,0x3); 2245 snd_cs46xx_ac97_write(ac97,AC97_CSR_ACMODE,0x3);
2238 } else { 2246 } else {
2239 snd_assert(0); /* should never happen ... */ 2247 snd_BUG(); /* should never happen ... */
2240 } 2248 }
2241 2249
2242 udelay(50); 2250 udelay(50);
@@ -2553,7 +2561,8 @@ static void snd_cs46xx_gameport_trigger(struct gameport *gameport)
2553{ 2561{
2554 struct snd_cs46xx *chip = gameport_get_port_data(gameport); 2562 struct snd_cs46xx *chip = gameport_get_port_data(gameport);
2555 2563
2556 snd_assert(chip, return); 2564 if (snd_BUG_ON(!chip))
2565 return;
2557 snd_cs46xx_pokeBA0(chip, BA0_JSPT, 0xFF); //outb(gameport->io, 0xFF); 2566 snd_cs46xx_pokeBA0(chip, BA0_JSPT, 0xFF); //outb(gameport->io, 0xFF);
2558} 2567}
2559 2568
@@ -2561,7 +2570,8 @@ static unsigned char snd_cs46xx_gameport_read(struct gameport *gameport)
2561{ 2570{
2562 struct snd_cs46xx *chip = gameport_get_port_data(gameport); 2571 struct snd_cs46xx *chip = gameport_get_port_data(gameport);
2563 2572
2564 snd_assert(chip, return 0); 2573 if (snd_BUG_ON(!chip))
2574 return 0;
2565 return snd_cs46xx_peekBA0(chip, BA0_JSPT); //inb(gameport->io); 2575 return snd_cs46xx_peekBA0(chip, BA0_JSPT); //inb(gameport->io);
2566} 2576}
2567 2577
@@ -2570,7 +2580,8 @@ static int snd_cs46xx_gameport_cooked_read(struct gameport *gameport, int *axes,
2570 struct snd_cs46xx *chip = gameport_get_port_data(gameport); 2580 struct snd_cs46xx *chip = gameport_get_port_data(gameport);
2571 unsigned js1, js2, jst; 2581 unsigned js1, js2, jst;
2572 2582
2573 snd_assert(chip, return 0); 2583 if (snd_BUG_ON(!chip))
2584 return 0;
2574 2585
2575 js1 = snd_cs46xx_peekBA0(chip, BA0_JSC1); 2586 js1 = snd_cs46xx_peekBA0(chip, BA0_JSC1);
2576 js2 = snd_cs46xx_peekBA0(chip, BA0_JSC2); 2587 js2 = snd_cs46xx_peekBA0(chip, BA0_JSC2);
@@ -2754,7 +2765,8 @@ static int snd_cs46xx_free(struct snd_cs46xx *chip)
2754{ 2765{
2755 int idx; 2766 int idx;
2756 2767
2757 snd_assert(chip != NULL, return -EINVAL); 2768 if (snd_BUG_ON(!chip))
2769 return -EINVAL;
2758 2770
2759 if (chip->active_ctrl) 2771 if (chip->active_ctrl)
2760 chip->active_ctrl(chip, 1); 2772 chip->active_ctrl(chip, 1);
diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c
index ccc8bedb5b1a..f4f0c8f5dad7 100644
--- a/sound/pci/cs46xx/dsp_spos.c
+++ b/sound/pci/cs46xx/dsp_spos.c
@@ -63,7 +63,8 @@ static int shadow_and_reallocate_code (struct snd_cs46xx * chip, u32 * data, u32
63 u32 mop_operands,mop_type,wide_op; 63 u32 mop_operands,mop_type,wide_op;
64 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 64 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
65 65
66 snd_assert( ((size % 2) == 0), return -EINVAL); 66 if (snd_BUG_ON(size %2))
67 return -EINVAL;
67 68
68 while (i < size) { 69 while (i < size) {
69 loval = data[i++]; 70 loval = data[i++];
@@ -289,7 +290,8 @@ void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip)
289 int i; 290 int i;
290 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 291 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
291 292
292 snd_assert(ins != NULL, return); 293 if (snd_BUG_ON(!ins))
294 return;
293 295
294 mutex_lock(&chip->spos_mutex); 296 mutex_lock(&chip->spos_mutex);
295 for (i = 0; i < ins->nscb; ++i) { 297 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
404 406
405 /* if module has a code segment it must have 407 /* if module has a code segment it must have
406 symbol table */ 408 symbol table */
407 snd_assert(module->symbol_table.symbols != NULL ,return -ENOMEM); 409 if (snd_BUG_ON(!module->symbol_table.symbols))
410 return -ENOMEM;
408 if (add_symbols(chip,module)) { 411 if (add_symbols(chip,module)) {
409 snd_printk(KERN_ERR "dsp_spos: failed to load symbol table\n"); 412 snd_printk(KERN_ERR "dsp_spos: failed to load symbol table\n");
410 return -ENOMEM; 413 return -ENOMEM;
@@ -1369,7 +1372,8 @@ int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip)
1369 1372
1370 valid_slots = snd_cs46xx_peekBA0(chip, BA0_ACOSV); 1373 valid_slots = snd_cs46xx_peekBA0(chip, BA0_ACOSV);
1371 1374
1372 snd_assert (chip->nr_ac97_codecs == 1 || chip->nr_ac97_codecs == 2); 1375 if (snd_BUG_ON(chip->nr_ac97_codecs != 1 && chip->nr_ac97_codecs != 2))
1376 goto _fail_end;
1373 1377
1374 if (chip->nr_ac97_codecs == 1) { 1378 if (chip->nr_ac97_codecs == 1) {
1375 /* output on slot 5 and 11 1379 /* output on slot 5 and 11
@@ -1609,11 +1613,14 @@ static int cs46xx_dsp_async_init (struct snd_cs46xx *chip,
1609 1613
1610 spdifo_scb_desc = cs46xx_dsp_create_scb(chip,"SPDIFOSCB",(u32 *)&spdifo_scb,SPDIFO_SCB_INST); 1614 spdifo_scb_desc = cs46xx_dsp_create_scb(chip,"SPDIFOSCB",(u32 *)&spdifo_scb,SPDIFO_SCB_INST);
1611 1615
1612 snd_assert(spdifo_scb_desc, return -EIO); 1616 if (snd_BUG_ON(!spdifo_scb_desc))
1617 return -EIO;
1613 spdifi_scb_desc = cs46xx_dsp_create_scb(chip,"SPDIFISCB",(u32 *)&spdifi_scb,SPDIFI_SCB_INST); 1618 spdifi_scb_desc = cs46xx_dsp_create_scb(chip,"SPDIFISCB",(u32 *)&spdifi_scb,SPDIFI_SCB_INST);
1614 snd_assert(spdifi_scb_desc, return -EIO); 1619 if (snd_BUG_ON(!spdifi_scb_desc))
1620 return -EIO;
1615 async_codec_scb_desc = cs46xx_dsp_create_scb(chip,"AsynCodecInputSCB",(u32 *)&async_codec_input_scb, HFG_TREE_SCB); 1621 async_codec_scb_desc = cs46xx_dsp_create_scb(chip,"AsynCodecInputSCB",(u32 *)&async_codec_input_scb, HFG_TREE_SCB);
1616 snd_assert(async_codec_scb_desc, return -EIO); 1622 if (snd_BUG_ON(!async_codec_scb_desc))
1623 return -EIO;
1617 1624
1618 async_codec_scb_desc->parent_scb_ptr = NULL; 1625 async_codec_scb_desc->parent_scb_ptr = NULL;
1619 async_codec_scb_desc->next_scb_ptr = spdifi_scb_desc; 1626 async_codec_scb_desc->next_scb_ptr = spdifi_scb_desc;
@@ -1698,8 +1705,10 @@ int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip)
1698 chip->active_ctrl(chip, 1); 1705 chip->active_ctrl(chip, 1);
1699 chip->amplifier_ctrl(chip, 1); 1706 chip->amplifier_ctrl(chip, 1);
1700 1707
1701 snd_assert (ins->asynch_rx_scb == NULL,return -EINVAL); 1708 if (snd_BUG_ON(ins->asynch_rx_scb))
1702 snd_assert (ins->spdif_in_src != NULL,return -EINVAL); 1709 return -EINVAL;
1710 if (snd_BUG_ON(!ins->spdif_in_src))
1711 return -EINVAL;
1703 1712
1704 mutex_lock(&chip->spos_mutex); 1713 mutex_lock(&chip->spos_mutex);
1705 1714
@@ -1754,8 +1763,10 @@ int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip)
1754{ 1763{
1755 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1764 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1756 1765
1757 snd_assert (ins->asynch_rx_scb != NULL, return -EINVAL); 1766 if (snd_BUG_ON(!ins->asynch_rx_scb))
1758 snd_assert (ins->spdif_in_src != NULL,return -EINVAL); 1767 return -EINVAL;
1768 if (snd_BUG_ON(!ins->spdif_in_src))
1769 return -EINVAL;
1759 1770
1760 mutex_lock(&chip->spos_mutex); 1771 mutex_lock(&chip->spos_mutex);
1761 1772
@@ -1780,8 +1791,10 @@ int cs46xx_dsp_enable_pcm_capture (struct snd_cs46xx *chip)
1780{ 1791{
1781 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1792 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1782 1793
1783 snd_assert (ins->pcm_input == NULL,return -EINVAL); 1794 if (snd_BUG_ON(ins->pcm_input))
1784 snd_assert (ins->ref_snoop_scb != NULL,return -EINVAL); 1795 return -EINVAL;
1796 if (snd_BUG_ON(!ins->ref_snoop_scb))
1797 return -EINVAL;
1785 1798
1786 mutex_lock(&chip->spos_mutex); 1799 mutex_lock(&chip->spos_mutex);
1787 ins->pcm_input = cs46xx_add_record_source(chip,ins->ref_snoop_scb,PCMSERIALIN_PCM_SCB_ADDR, 1800 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)
1795{ 1808{
1796 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1809 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1797 1810
1798 snd_assert (ins->pcm_input != NULL,return -EINVAL); 1811 if (snd_BUG_ON(!ins->pcm_input))
1812 return -EINVAL;
1799 1813
1800 mutex_lock(&chip->spos_mutex); 1814 mutex_lock(&chip->spos_mutex);
1801 cs46xx_dsp_remove_scb (chip,ins->pcm_input); 1815 cs46xx_dsp_remove_scb (chip,ins->pcm_input);
@@ -1809,8 +1823,10 @@ int cs46xx_dsp_enable_adc_capture (struct snd_cs46xx *chip)
1809{ 1823{
1810 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1824 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1811 1825
1812 snd_assert (ins->adc_input == NULL,return -EINVAL); 1826 if (snd_BUG_ON(ins->adc_input))
1813 snd_assert (ins->codec_in_scb != NULL,return -EINVAL); 1827 return -EINVAL;
1828 if (snd_BUG_ON(!ins->codec_in_scb))
1829 return -EINVAL;
1814 1830
1815 mutex_lock(&chip->spos_mutex); 1831 mutex_lock(&chip->spos_mutex);
1816 ins->adc_input = cs46xx_add_record_source(chip,ins->codec_in_scb,PCMSERIALIN_SCB_ADDR, 1832 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)
1824{ 1840{
1825 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1841 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1826 1842
1827 snd_assert (ins->adc_input != NULL,return -EINVAL); 1843 if (snd_BUG_ON(!ins->adc_input))
1844 return -EINVAL;
1828 1845
1829 mutex_lock(&chip->spos_mutex); 1846 mutex_lock(&chip->spos_mutex);
1830 cs46xx_dsp_remove_scb (chip,ins->adc_input); 1847 cs46xx_dsp_remove_scb (chip,ins->adc_input);
diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c
index 2873cfe48c33..dd7c41b037b4 100644
--- a/sound/pci/cs46xx/dsp_spos_scb_lib.c
+++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c
@@ -46,8 +46,11 @@ static void remove_symbol (struct snd_cs46xx * chip, struct dsp_symbol_entry * s
46 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 46 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
47 int symbol_index = (int)(symbol - ins->symbol_table.symbols); 47 int symbol_index = (int)(symbol - ins->symbol_table.symbols);
48 48
49 snd_assert(ins->symbol_table.nsymbols > 0,return); 49 if (snd_BUG_ON(ins->symbol_table.nsymbols <= 0))
50 snd_assert(symbol_index >= 0 && symbol_index < ins->symbol_table.nsymbols, return); 50 return;
51 if (snd_BUG_ON(symbol_index < 0 ||
52 symbol_index >= ins->symbol_table.nsymbols))
53 return;
51 54
52 ins->symbol_table.symbols[symbol_index].deleted = 1; 55 ins->symbol_table.symbols[symbol_index].deleted = 1;
53 56
@@ -116,8 +119,9 @@ static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor
116 119
117 if ( scb->parent_scb_ptr ) { 120 if ( scb->parent_scb_ptr ) {
118 /* unlink parent SCB */ 121 /* unlink parent SCB */
119 snd_assert ((scb->parent_scb_ptr->sub_list_ptr == scb || 122 if (snd_BUG_ON(scb->parent_scb_ptr->sub_list_ptr != scb &&
120 scb->parent_scb_ptr->next_scb_ptr == scb),return); 123 scb->parent_scb_ptr->next_scb_ptr != scb))
124 return;
121 125
122 if (scb->parent_scb_ptr->sub_list_ptr == scb) { 126 if (scb->parent_scb_ptr->sub_list_ptr == scb) {
123 127
@@ -140,7 +144,6 @@ static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor
140 scb->next_scb_ptr = ins->the_null_scb; 144 scb->next_scb_ptr = ins->the_null_scb;
141 } 145 }
142 } else { 146 } else {
143 /* snd_assert ( (scb->sub_list_ptr == ins->the_null_scb), return); */
144 scb->parent_scb_ptr->next_scb_ptr = scb->next_scb_ptr; 147 scb->parent_scb_ptr->next_scb_ptr = scb->next_scb_ptr;
145 148
146 if (scb->next_scb_ptr != ins->the_null_scb) { 149 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 *
181 unsigned long flags; 184 unsigned long flags;
182 185
183 /* check integrety */ 186 /* check integrety */
184 snd_assert ( (scb->index >= 0 && 187 if (snd_BUG_ON(scb->index < 0 ||
185 scb->index < ins->nscb && 188 scb->index >= ins->nscb ||
186 (ins->scbs + scb->index) == scb), return ); 189 (ins->scbs + scb->index) != scb))
190 return;
187 191
188#if 0 192#if 0
189 /* can't remove a SCB with childs before 193 /* can't remove a SCB with childs before
190 removing childs first */ 194 removing childs first */
191 snd_assert ( (scb->sub_list_ptr == ins->the_null_scb && 195 if (snd_BUG_ON(scb->sub_list_ptr != ins->the_null_scb ||
192 scb->next_scb_ptr == ins->the_null_scb), 196 scb->next_scb_ptr != ins->the_null_scb))
193 goto _end); 197 goto _end;
194#endif 198#endif
195 199
196 spin_lock_irqsave(&scb->lock, flags); 200 spin_lock_irqsave(&scb->lock, flags);
@@ -198,7 +202,8 @@ void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor *
198 spin_unlock_irqrestore(&scb->lock, flags); 202 spin_unlock_irqrestore(&scb->lock, flags);
199 203
200 cs46xx_dsp_proc_free_scb_desc(scb); 204 cs46xx_dsp_proc_free_scb_desc(scb);
201 snd_assert (scb->scb_symbol != NULL, return ); 205 if (snd_BUG_ON(!scb->scb_symbol))
206 return;
202 remove_symbol (chip,scb->scb_symbol); 207 remove_symbol (chip,scb->scb_symbol);
203 208
204 ins->scbs[scb->index].deleted = 1; 209 ins->scbs[scb->index].deleted = 1;
@@ -234,7 +239,6 @@ void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb)
234 snd_info_free_entry(scb->proc_info); 239 snd_info_free_entry(scb->proc_info);
235 scb->proc_info = NULL; 240 scb->proc_info = NULL;
236 241
237 snd_assert (scb_info != NULL, return);
238 kfree (scb_info); 242 kfree (scb_info);
239 } 243 }
240} 244}
@@ -291,7 +295,8 @@ _dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u
291 295
292 unsigned long flags; 296 unsigned long flags;
293 297
294 snd_assert (ins->the_null_scb != NULL,return NULL); 298 if (snd_BUG_ON(!ins->the_null_scb))
299 return NULL;
295 300
296 /* fill the data that will be wroten to DSP */ 301 /* fill the data that will be wroten to DSP */
297 scb_data[SCBsubListPtr] = 302 scb_data[SCBsubListPtr] =
@@ -321,18 +326,20 @@ _dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u
321#endif 326#endif
322 /* link to parent SCB */ 327 /* link to parent SCB */
323 if (scb_child_type == SCB_ON_PARENT_NEXT_SCB) { 328 if (scb_child_type == SCB_ON_PARENT_NEXT_SCB) {
324 snd_assert ( (scb->parent_scb_ptr->next_scb_ptr == ins->the_null_scb), 329 if (snd_BUG_ON(scb->parent_scb_ptr->next_scb_ptr !=
325 return NULL); 330 ins->the_null_scb))
331 return NULL;
326 332
327 scb->parent_scb_ptr->next_scb_ptr = scb; 333 scb->parent_scb_ptr->next_scb_ptr = scb;
328 334
329 } else if (scb_child_type == SCB_ON_PARENT_SUBLIST_SCB) { 335 } else if (scb_child_type == SCB_ON_PARENT_SUBLIST_SCB) {
330 snd_assert ( (scb->parent_scb_ptr->sub_list_ptr == ins->the_null_scb), 336 if (snd_BUG_ON(scb->parent_scb_ptr->sub_list_ptr !=
331 return NULL); 337 ins->the_null_scb))
338 return NULL;
332 339
333 scb->parent_scb_ptr->sub_list_ptr = scb; 340 scb->parent_scb_ptr->sub_list_ptr = scb;
334 } else { 341 } else {
335 snd_assert (0,return NULL); 342 snd_BUG();
336 } 343 }
337 344
338 spin_lock_irqsave(&chip->reg_lock, flags); 345 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -675,7 +682,7 @@ cs46xx_dsp_create_src_task_scb(struct snd_cs46xx * chip, char * scb_name,
675 if (pass_through) { 682 if (pass_through) {
676 /* wont work with any other rate than 683 /* wont work with any other rate than
677 the native DSP rate */ 684 the native DSP rate */
678 snd_assert (rate == 48000); 685 snd_BUG_ON(rate != 48000);
679 686
680 scb = cs46xx_dsp_create_generic_scb(chip,scb_name,(u32 *)&src_task_scb, 687 scb = cs46xx_dsp_create_generic_scb(chip,scb_name,(u32 *)&src_task_scb,
681 dest,"DMAREADER",parent_scb, 688 dest,"DMAREADER",parent_scb,
@@ -1142,7 +1149,8 @@ find_next_free_scb (struct snd_cs46xx * chip, struct dsp_scb_descriptor * from)
1142 struct dsp_scb_descriptor * scb = from; 1149 struct dsp_scb_descriptor * scb = from;
1143 1150
1144 while (scb->next_scb_ptr != ins->the_null_scb) { 1151 while (scb->next_scb_ptr != ins->the_null_scb) {
1145 snd_assert (scb->next_scb_ptr != NULL, return NULL); 1152 if (snd_BUG_ON(!scb->next_scb_ptr))
1153 return NULL;
1146 1154
1147 scb = scb->next_scb_ptr; 1155 scb = scb->next_scb_ptr;
1148 } 1156 }
@@ -1246,10 +1254,11 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
1246 break; 1254 break;
1247 case DSP_PCM_S71_CHANNEL: 1255 case DSP_PCM_S71_CHANNEL:
1248 /* TODO */ 1256 /* TODO */
1249 snd_assert(0); 1257 snd_BUG();
1250 break; 1258 break;
1251 case DSP_IEC958_CHANNEL: 1259 case DSP_IEC958_CHANNEL:
1252 snd_assert (ins->asynch_tx_scb != NULL, return NULL); 1260 if (snd_BUG_ON(!ins->asynch_tx_scb))
1261 return NULL;
1253 mixer_scb = ins->asynch_tx_scb; 1262 mixer_scb = ins->asynch_tx_scb;
1254 1263
1255 /* if sample rate is set to 48khz we pass 1264 /* if sample rate is set to 48khz we pass
@@ -1262,7 +1271,7 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
1262 } 1271 }
1263 break; 1272 break;
1264 default: 1273 default:
1265 snd_assert (0); 1274 snd_BUG();
1266 return NULL; 1275 return NULL;
1267 } 1276 }
1268 /* default sample rate is 44100 */ 1277 /* default sample rate is 44100 */
@@ -1308,7 +1317,8 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
1308 break; 1317 break;
1309 } 1318 }
1310 } 1319 }
1311 snd_assert (src_index != -1,return NULL); 1320 if (snd_BUG_ON(src_index == -1))
1321 return NULL;
1312 1322
1313 /* we need to create a new SRC SCB */ 1323 /* we need to create a new SRC SCB */
1314 if (mixer_scb->sub_list_ptr == ins->the_null_scb) { 1324 if (mixer_scb->sub_list_ptr == ins->the_null_scb) {
@@ -1462,9 +1472,10 @@ void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip,
1462 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1472 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1463 unsigned long flags; 1473 unsigned long flags;
1464 1474
1465 snd_assert(pcm_channel->active, return ); 1475 if (snd_BUG_ON(!pcm_channel->active ||
1466 snd_assert(ins->npcm_channels > 0, return ); 1476 ins->npcm_channels <= 0 ||
1467 snd_assert(pcm_channel->src_scb->ref_count > 0, return ); 1477 pcm_channel->src_scb->ref_count <= 0))
1478 return;
1468 1479
1469 spin_lock_irqsave(&chip->reg_lock, flags); 1480 spin_lock_irqsave(&chip->reg_lock, flags);
1470 pcm_channel->unlinked = 1; 1481 pcm_channel->unlinked = 1;
@@ -1479,8 +1490,9 @@ void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip,
1479 if (!pcm_channel->src_scb->ref_count) { 1490 if (!pcm_channel->src_scb->ref_count) {
1480 cs46xx_dsp_remove_scb(chip,pcm_channel->src_scb); 1491 cs46xx_dsp_remove_scb(chip,pcm_channel->src_scb);
1481 1492
1482 snd_assert (pcm_channel->src_slot >= 0 && pcm_channel->src_slot < DSP_MAX_SRC_NR, 1493 if (snd_BUG_ON(pcm_channel->src_slot < 0 ||
1483 return ); 1494 pcm_channel->src_slot >= DSP_MAX_SRC_NR))
1495 return;
1484 1496
1485 ins->src_scb_slots[pcm_channel->src_slot] = 0; 1497 ins->src_scb_slots[pcm_channel->src_slot] = 0;
1486 ins->nsrc_scb --; 1498 ins->nsrc_scb --;
@@ -1490,11 +1502,11 @@ void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip,
1490int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip, 1502int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip,
1491 struct dsp_pcm_channel_descriptor * pcm_channel) 1503 struct dsp_pcm_channel_descriptor * pcm_channel)
1492{ 1504{
1493 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1494 unsigned long flags; 1505 unsigned long flags;
1495 1506
1496 snd_assert(pcm_channel->active,return -EIO); 1507 if (snd_BUG_ON(!pcm_channel->active ||
1497 snd_assert(ins->npcm_channels > 0,return -EIO); 1508 chip->dsp_spos_instance->npcm_channels <= 0))
1509 return -EIO;
1498 1510
1499 spin_lock(&pcm_channel->src_scb->lock); 1511 spin_lock(&pcm_channel->src_scb->lock);
1500 1512
@@ -1537,7 +1549,7 @@ int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip,
1537 1549
1538 src_scb->sub_list_ptr = pcm_channel->pcm_reader_scb; 1550 src_scb->sub_list_ptr = pcm_channel->pcm_reader_scb;
1539 1551
1540 snd_assert (pcm_channel->pcm_reader_scb->parent_scb_ptr == NULL, ; ); 1552 snd_BUG_ON(pcm_channel->pcm_reader_scb->parent_scb_ptr);
1541 pcm_channel->pcm_reader_scb->parent_scb_ptr = parent_scb; 1553 pcm_channel->pcm_reader_scb->parent_scb_ptr = parent_scb;
1542 1554
1543 spin_lock_irqsave(&chip->reg_lock, flags); 1555 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -1564,7 +1576,8 @@ cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * s
1564 struct dsp_scb_descriptor * pcm_input; 1576 struct dsp_scb_descriptor * pcm_input;
1565 int insert_point; 1577 int insert_point;
1566 1578
1567 snd_assert (ins->record_mixer_scb != NULL,return NULL); 1579 if (snd_BUG_ON(!ins->record_mixer_scb))
1580 return NULL;
1568 1581
1569 if (ins->record_mixer_scb->sub_list_ptr != ins->the_null_scb) { 1582 if (ins->record_mixer_scb->sub_list_ptr != ins->the_null_scb) {
1570 parent = find_next_free_scb (chip,ins->record_mixer_scb->sub_list_ptr); 1583 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
1583 1596
1584int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src) 1597int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src)
1585{ 1598{
1586 snd_assert (src->parent_scb_ptr != NULL, return -EINVAL ); 1599 if (snd_BUG_ON(!src->parent_scb_ptr))
1600 return -EINVAL;
1587 1601
1588 /* mute SCB */ 1602 /* mute SCB */
1589 cs46xx_dsp_scb_set_volume (chip,src,0,0); 1603 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)
1598 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1612 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1599 struct dsp_scb_descriptor * parent_scb; 1613 struct dsp_scb_descriptor * parent_scb;
1600 1614
1601 snd_assert (src->parent_scb_ptr == NULL, return -EINVAL ); 1615 if (snd_BUG_ON(src->parent_scb_ptr))
1602 snd_assert(ins->master_mix_scb !=NULL, return -EINVAL ); 1616 return -EINVAL;
1617 if (snd_BUG_ON(!ins->master_mix_scb))
1618 return -EINVAL;
1603 1619
1604 if (ins->master_mix_scb->sub_list_ptr != ins->the_null_scb) { 1620 if (ins->master_mix_scb->sub_list_ptr != ins->the_null_scb) {
1605 parent_scb = find_next_free_scb (chip,ins->master_mix_scb->sub_list_ptr); 1621 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)
1635 return -EBUSY; 1651 return -EBUSY;
1636 } 1652 }
1637 1653
1638 snd_assert (ins->asynch_tx_scb == NULL, return -EINVAL); 1654 if (snd_BUG_ON(ins->asynch_tx_scb))
1639 snd_assert (ins->master_mix_scb->next_scb_ptr == ins->the_null_scb, return -EINVAL); 1655 return -EINVAL;
1656 if (snd_BUG_ON(ins->master_mix_scb->next_scb_ptr !=
1657 ins->the_null_scb))
1658 return -EINVAL;
1640 1659
1641 /* reset output snooper sample buffer pointer */ 1660 /* reset output snooper sample buffer pointer */
1642 snd_cs46xx_poke (chip, (ins->ref_snoop_scb->address + 2) << 2, 1661 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)
1676 } 1695 }
1677 1696
1678 /* check integrety */ 1697 /* check integrety */
1679 snd_assert (ins->asynch_tx_scb != NULL, return -EINVAL); 1698 if (snd_BUG_ON(!ins->asynch_tx_scb))
1680 snd_assert (ins->spdif_pcm_input_scb != NULL,return -EINVAL); 1699 return -EINVAL;
1681 snd_assert (ins->master_mix_scb->next_scb_ptr == ins->asynch_tx_scb, return -EINVAL); 1700 if (snd_BUG_ON(!ins->spdif_pcm_input_scb))
1682 snd_assert (ins->asynch_tx_scb->parent_scb_ptr == ins->master_mix_scb, return -EINVAL); 1701 return -EINVAL;
1702 if (snd_BUG_ON(ins->master_mix_scb->next_scb_ptr != ins->asynch_tx_scb))
1703 return -EINVAL;
1704 if (snd_BUG_ON(ins->asynch_tx_scb->parent_scb_ptr !=
1705 ins->master_mix_scb))
1706 return -EINVAL;
1683 1707
1684 cs46xx_dsp_remove_scb (chip,ins->spdif_pcm_input_scb); 1708 cs46xx_dsp_remove_scb (chip,ins->spdif_pcm_input_scb);
1685 cs46xx_dsp_remove_scb (chip,ins->asynch_tx_scb); 1709 cs46xx_dsp_remove_scb (chip,ins->asynch_tx_scb);
@@ -1734,7 +1758,8 @@ int cs46xx_iec958_post_close (struct snd_cs46xx *chip)
1734{ 1758{
1735 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1759 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1736 1760
1737 snd_assert (ins->asynch_tx_scb != NULL, return -EINVAL); 1761 if (snd_BUG_ON(!ins->asynch_tx_scb))
1762 return -EINVAL;
1738 1763
1739 ins->spdif_status_out &= ~DSP_SPDIF_STATUS_PLAYBACK_OPEN; 1764 ins->spdif_status_out &= ~DSP_SPDIF_STATUS_PLAYBACK_OPEN;
1740 1765
diff --git a/sound/pci/echoaudio/darla20_dsp.c b/sound/pci/echoaudio/darla20_dsp.c
index 4159e3bc186f..29043301ebb8 100644
--- a/sound/pci/echoaudio/darla20_dsp.c
+++ b/sound/pci/echoaudio/darla20_dsp.c
@@ -34,7 +34,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
34 int err; 34 int err;
35 35
36 DE_INIT(("init_hw() - Darla20\n")); 36 DE_INIT(("init_hw() - Darla20\n"));
37 snd_assert((subdevice_id & 0xfff0) == DARLA20, return -ENODEV); 37 if (snd_BUG_ON((subdevice_id & 0xfff0) != DARLA20))
38 return -ENODEV;
38 39
39 if ((err = init_dsp_comm_page(chip))) { 40 if ((err = init_dsp_comm_page(chip))) {
40 DE_INIT(("init_hw - could not initialize DSP comm page\n")); 41 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
diff --git a/sound/pci/echoaudio/darla24_dsp.c b/sound/pci/echoaudio/darla24_dsp.c
index 79938eed7e9c..60228731841f 100644
--- a/sound/pci/echoaudio/darla24_dsp.c
+++ b/sound/pci/echoaudio/darla24_dsp.c
@@ -34,7 +34,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
34 int err; 34 int err;
35 35
36 DE_INIT(("init_hw() - Darla24\n")); 36 DE_INIT(("init_hw() - Darla24\n"));
37 snd_assert((subdevice_id & 0xfff0) == DARLA24, return -ENODEV); 37 if (snd_BUG_ON((subdevice_id & 0xfff0) != DARLA24))
38 return -ENODEV;
38 39
39 if ((err = init_dsp_comm_page(chip))) { 40 if ((err = init_dsp_comm_page(chip))) {
40 DE_INIT(("init_hw - could not initialize DSP comm page\n")); 41 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)
148 149
149static int set_input_clock(struct echoaudio *chip, u16 clock) 150static int set_input_clock(struct echoaudio *chip, u16 clock)
150{ 151{
151 snd_assert(clock == ECHO_CLOCK_INTERNAL || 152 if (snd_BUG_ON(clock != ECHO_CLOCK_INTERNAL &&
152 clock == ECHO_CLOCK_ESYNC, return -EINVAL); 153 clock != ECHO_CLOCK_ESYNC))
154 return -EINVAL;
153 chip->input_clock = clock; 155 chip->input_clock = clock;
154 return set_sample_rate(chip, chip->sample_rate); 156 return set_sample_rate(chip, chip->sample_rate);
155} 157}
diff --git a/sound/pci/echoaudio/echo3g_dsp.c b/sound/pci/echoaudio/echo3g_dsp.c
index 48eb7c599111..417e25add82b 100644
--- a/sound/pci/echoaudio/echo3g_dsp.c
+++ b/sound/pci/echoaudio/echo3g_dsp.c
@@ -47,7 +47,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
47 47
48 local_irq_enable(); 48 local_irq_enable();
49 DE_INIT(("init_hw() - Echo3G\n")); 49 DE_INIT(("init_hw() - Echo3G\n"));
50 snd_assert((subdevice_id & 0xfff0) == ECHO3G, return -ENODEV); 50 if (snd_BUG_ON((subdevice_id & 0xfff0) != ECHO3G))
51 return -ENODEV;
51 52
52 if ((err = init_dsp_comm_page(chip))) { 53 if ((err = init_dsp_comm_page(chip))) {
53 DE_INIT(("init_hw - could not initialize DSP comm page\n")); 54 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)
104 if ((err = init_line_levels(chip)) < 0) 105 if ((err = init_line_levels(chip)) < 0)
105 return err; 106 return err;
106 err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA); 107 err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA);
107 snd_assert(err >= 0, return err); 108 if (err < 0)
109 return err;
108 err = set_phantom_power(chip, 0); 110 err = set_phantom_power(chip, 0);
109 snd_assert(err >= 0, return err); 111 if (err < 0)
112 return err;
110 err = set_professional_spdif(chip, TRUE); 113 err = set_professional_spdif(chip, TRUE);
111 114
112 DE_INIT(("init_hw done\n")); 115 DE_INIT(("init_hw done\n"));
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index e16dc92e82fb..160d47054922 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -503,7 +503,7 @@ static int init_engine(struct snd_pcm_substream *substream,
503 if (pipe->index >= 0) { 503 if (pipe->index >= 0) {
504 DE_HWP(("hwp_ie free(%d)\n", pipe->index)); 504 DE_HWP(("hwp_ie free(%d)\n", pipe->index));
505 err = free_pipes(chip, pipe); 505 err = free_pipes(chip, pipe);
506 snd_assert(!err); 506 snd_BUG_ON(err);
507 chip->substream[pipe->index] = NULL; 507 chip->substream[pipe->index] = NULL;
508 } 508 }
509 509
@@ -690,8 +690,10 @@ static int pcm_prepare(struct snd_pcm_substream *substream)
690 return -EINVAL; 690 return -EINVAL;
691 } 691 }
692 692
693 snd_assert(pipe_index < px_num(chip), return -EINVAL); 693 if (snd_BUG_ON(pipe_index >= px_num(chip)))
694 snd_assert(is_pipe_allocated(chip, pipe_index), return -EINVAL); 694 return -EINVAL;
695 if (snd_BUG_ON(!is_pipe_allocated(chip, pipe_index)))
696 return -EINVAL;
695 set_audio_format(chip, pipe_index, &format); 697 set_audio_format(chip, pipe_index, &format);
696 return 0; 698 return 0;
697} 699}
diff --git a/sound/pci/echoaudio/echoaudio_3g.c b/sound/pci/echoaudio/echoaudio_3g.c
index 52a933189576..c3736bbd819e 100644
--- a/sound/pci/echoaudio/echoaudio_3g.c
+++ b/sound/pci/echoaudio/echoaudio_3g.c
@@ -103,9 +103,11 @@ static int set_digital_mode(struct echoaudio *chip, u8 mode)
103 int err, i, o; 103 int err, i, o;
104 104
105 /* All audio channels must be closed before changing the digital mode */ 105 /* All audio channels must be closed before changing the digital mode */
106 snd_assert(!chip->pipe_alloc_mask, return -EAGAIN); 106 if (snd_BUG_ON(chip->pipe_alloc_mask))
107 return -EAGAIN;
107 108
108 snd_assert(chip->digital_modes & (1 << mode), return -EINVAL); 109 if (snd_BUG_ON(!(chip->digital_modes & (1 << mode))))
110 return -EINVAL;
109 111
110 previous_mode = chip->digital_mode; 112 previous_mode = chip->digital_mode;
111 err = dsp_set_digital_mode(chip, mode); 113 err = dsp_set_digital_mode(chip, mode);
@@ -267,8 +269,9 @@ static int set_sample_rate(struct echoaudio *chip, u32 rate)
267 return 0; 269 return 0;
268 } 270 }
269 271
270 snd_assert(rate < 50000 || chip->digital_mode != DIGITAL_MODE_ADAT, 272 if (snd_BUG_ON(rate >= 50000 &&
271 return -EINVAL); 273 chip->digital_mode == DIGITAL_MODE_ADAT))
274 return -EINVAL;
272 275
273 clock = 0; 276 clock = 0;
274 control_reg = le32_to_cpu(chip->comm_page->control_register); 277 control_reg = le32_to_cpu(chip->comm_page->control_register);
diff --git a/sound/pci/echoaudio/echoaudio_dsp.c b/sound/pci/echoaudio/echoaudio_dsp.c
index e6c100770392..be0e18192de3 100644
--- a/sound/pci/echoaudio/echoaudio_dsp.c
+++ b/sound/pci/echoaudio/echoaudio_dsp.c
@@ -474,7 +474,8 @@ static int load_firmware(struct echoaudio *chip)
474 const struct firmware *fw; 474 const struct firmware *fw;
475 int box_type, err; 475 int box_type, err;
476 476
477 snd_assert(chip->dsp_code_to_load && chip->comm_page, return -EPERM); 477 if (snd_BUG_ON(!chip->dsp_code_to_load || !chip->comm_page))
478 return -EPERM;
478 479
479 /* See if the ASIC is present and working - only if the DSP is already loaded */ 480 /* See if the ASIC is present and working - only if the DSP is already loaded */
480 if (chip->dsp_code) { 481 if (chip->dsp_code) {
@@ -512,8 +513,8 @@ static int load_firmware(struct echoaudio *chip)
512/* Set the nominal level for an input or output bus (true = -10dBV, false = +4dBu) */ 513/* Set the nominal level for an input or output bus (true = -10dBV, false = +4dBu) */
513static int set_nominal_level(struct echoaudio *chip, u16 index, char consumer) 514static int set_nominal_level(struct echoaudio *chip, u16 index, char consumer)
514{ 515{
515 snd_assert(index < num_busses_out(chip) + num_busses_in(chip), 516 if (snd_BUG_ON(index >= num_busses_out(chip) + num_busses_in(chip)))
516 return -EINVAL); 517 return -EINVAL;
517 518
518 /* Wait for the handshake (OK even if ASIC is not loaded) */ 519 /* Wait for the handshake (OK even if ASIC is not loaded) */
519 if (wait_handshake(chip)) 520 if (wait_handshake(chip))
@@ -536,7 +537,8 @@ static int set_nominal_level(struct echoaudio *chip, u16 index, char consumer)
536/* Set the gain for a single physical output channel (dB). */ 537/* Set the gain for a single physical output channel (dB). */
537static int set_output_gain(struct echoaudio *chip, u16 channel, s8 gain) 538static int set_output_gain(struct echoaudio *chip, u16 channel, s8 gain)
538{ 539{
539 snd_assert(channel < num_busses_out(chip), return -EINVAL); 540 if (snd_BUG_ON(channel >= num_busses_out(chip)))
541 return -EINVAL;
540 542
541 if (wait_handshake(chip)) 543 if (wait_handshake(chip))
542 return -EIO; 544 return -EIO;
@@ -554,8 +556,9 @@ static int set_output_gain(struct echoaudio *chip, u16 channel, s8 gain)
554static int set_monitor_gain(struct echoaudio *chip, u16 output, u16 input, 556static int set_monitor_gain(struct echoaudio *chip, u16 output, u16 input,
555 s8 gain) 557 s8 gain)
556{ 558{
557 snd_assert(output < num_busses_out(chip) && 559 if (snd_BUG_ON(output >= num_busses_out(chip) ||
558 input < num_busses_in(chip), return -EINVAL); 560 input >= num_busses_in(chip)))
561 return -EINVAL;
559 562
560 if (wait_handshake(chip)) 563 if (wait_handshake(chip))
561 return -EIO; 564 return -EIO;
@@ -1065,8 +1068,10 @@ static int free_pipes(struct echoaudio *chip, struct audiopipe *pipe)
1065 int i; 1068 int i;
1066 1069
1067 DE_ACT(("free_pipes: Pipe %d\n", pipe->index)); 1070 DE_ACT(("free_pipes: Pipe %d\n", pipe->index));
1068 snd_assert(is_pipe_allocated(chip, pipe->index), return -EINVAL); 1071 if (snd_BUG_ON(!is_pipe_allocated(chip, pipe->index)))
1069 snd_assert(pipe->state == PIPE_STATE_STOPPED, return -EINVAL); 1072 return -EINVAL;
1073 if (snd_BUG_ON(pipe->state != PIPE_STATE_STOPPED))
1074 return -EINVAL;
1070 1075
1071 for (channel_mask = i = 0; i < pipe->interleave; i++) 1076 for (channel_mask = i = 0; i < pipe->interleave; i++)
1072 channel_mask |= 1 << (pipe->index + i); 1077 channel_mask |= 1 << (pipe->index + i);
diff --git a/sound/pci/echoaudio/echoaudio_gml.c b/sound/pci/echoaudio/echoaudio_gml.c
index 3aa37e76ebab..afa273330e8a 100644
--- a/sound/pci/echoaudio/echoaudio_gml.c
+++ b/sound/pci/echoaudio/echoaudio_gml.c
@@ -112,9 +112,11 @@ static int set_digital_mode(struct echoaudio *chip, u8 mode)
112 return -EIO; 112 return -EIO;
113 113
114 /* All audio channels must be closed before changing the digital mode */ 114 /* All audio channels must be closed before changing the digital mode */
115 snd_assert(!chip->pipe_alloc_mask, return -EAGAIN); 115 if (snd_BUG_ON(chip->pipe_alloc_mask))
116 return -EAGAIN;
116 117
117 snd_assert(chip->digital_modes & (1 << mode), return -EINVAL); 118 if (snd_BUG_ON(!(chip->digital_modes & (1 << mode))))
119 return -EINVAL;
118 120
119 previous_mode = chip->digital_mode; 121 previous_mode = chip->digital_mode;
120 err = dsp_set_digital_mode(chip, mode); 122 err = dsp_set_digital_mode(chip, mode);
diff --git a/sound/pci/echoaudio/gina20_dsp.c b/sound/pci/echoaudio/gina20_dsp.c
index 2757c8960843..db6c952e9d7f 100644
--- a/sound/pci/echoaudio/gina20_dsp.c
+++ b/sound/pci/echoaudio/gina20_dsp.c
@@ -38,7 +38,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
38 int err; 38 int err;
39 39
40 DE_INIT(("init_hw() - Gina20\n")); 40 DE_INIT(("init_hw() - Gina20\n"));
41 snd_assert((subdevice_id & 0xfff0) == GINA20, return -ENODEV); 41 if (snd_BUG_ON((subdevice_id & 0xfff0) != GINA20))
42 return -ENODEV;
42 43
43 if ((err = init_dsp_comm_page(chip))) { 44 if ((err = init_dsp_comm_page(chip))) {
44 DE_INIT(("init_hw - could not initialize DSP comm page\n")); 45 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)
177/* Set input bus gain (one unit is 0.5dB !) */ 178/* Set input bus gain (one unit is 0.5dB !) */
178static int set_input_gain(struct echoaudio *chip, u16 input, int gain) 179static int set_input_gain(struct echoaudio *chip, u16 input, int gain)
179{ 180{
180 snd_assert(input < num_busses_in(chip), return -EINVAL); 181 if (snd_BUG_ON(input >= num_busses_in(chip)))
182 return -EINVAL;
181 183
182 if (wait_handshake(chip)) 184 if (wait_handshake(chip))
183 return -EIO; 185 return -EIO;
diff --git a/sound/pci/echoaudio/gina24_dsp.c b/sound/pci/echoaudio/gina24_dsp.c
index 144fc567becf..2fef37a2a5b9 100644
--- a/sound/pci/echoaudio/gina24_dsp.c
+++ b/sound/pci/echoaudio/gina24_dsp.c
@@ -43,7 +43,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
43 int err; 43 int err;
44 44
45 DE_INIT(("init_hw() - Gina24\n")); 45 DE_INIT(("init_hw() - Gina24\n"));
46 snd_assert((subdevice_id & 0xfff0) == GINA24, return -ENODEV); 46 if (snd_BUG_ON((subdevice_id & 0xfff0) != GINA24))
47 return -ENODEV;
47 48
48 if ((err = init_dsp_comm_page(chip))) { 49 if ((err = init_dsp_comm_page(chip))) {
49 DE_INIT(("init_hw - could not initialize DSP comm page\n")); 50 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)
84 if ((err = init_line_levels(chip)) < 0) 85 if ((err = init_line_levels(chip)) < 0)
85 return err; 86 return err;
86 err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA); 87 err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA);
87 snd_assert(err >= 0, return err); 88 if (err < 0)
89 return err;
88 err = set_professional_spdif(chip, TRUE); 90 err = set_professional_spdif(chip, TRUE);
89 91
90 DE_INIT(("init_hw done\n")); 92 DE_INIT(("init_hw done\n"));
@@ -163,8 +165,9 @@ static int set_sample_rate(struct echoaudio *chip, u32 rate)
163{ 165{
164 u32 control_reg, clock; 166 u32 control_reg, clock;
165 167
166 snd_assert(rate < 50000 || chip->digital_mode != DIGITAL_MODE_ADAT, 168 if (snd_BUG_ON(rate >= 50000 &&
167 return -EINVAL); 169 chip->digital_mode == DIGITAL_MODE_ADAT))
170 return -EINVAL;
168 171
169 /* Only set the clock for internal mode. */ 172 /* Only set the clock for internal mode. */
170 if (chip->input_clock != ECHO_CLOCK_INTERNAL) { 173 if (chip->input_clock != ECHO_CLOCK_INTERNAL) {
diff --git a/sound/pci/echoaudio/indigo_dsp.c b/sound/pci/echoaudio/indigo_dsp.c
index d6ac7734609e..f05e39f7aad9 100644
--- a/sound/pci/echoaudio/indigo_dsp.c
+++ b/sound/pci/echoaudio/indigo_dsp.c
@@ -39,7 +39,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
39 int err; 39 int err;
40 40
41 DE_INIT(("init_hw() - Indigo\n")); 41 DE_INIT(("init_hw() - Indigo\n"));
42 snd_assert((subdevice_id & 0xfff0) == INDIGO, return -ENODEV); 42 if (snd_BUG_ON((subdevice_id & 0xfff0) != INDIGO))
43 return -ENODEV;
43 44
44 if ((err = init_dsp_comm_page(chip))) { 45 if ((err = init_dsp_comm_page(chip))) {
45 DE_INIT(("init_hw - could not initialize DSP comm page\n")); 46 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,
143{ 144{
144 int index; 145 int index;
145 146
146 snd_assert(pipe < num_pipes_out(chip) && 147 if (snd_BUG_ON(pipe >= num_pipes_out(chip) ||
147 output < num_busses_out(chip), return -EINVAL); 148 output >= num_busses_out(chip)))
149 return -EINVAL;
148 150
149 if (wait_handshake(chip)) 151 if (wait_handshake(chip))
150 return -EIO; 152 return -EIO;
diff --git a/sound/pci/echoaudio/indigodj_dsp.c b/sound/pci/echoaudio/indigodj_dsp.c
index 500e150b49fc..90730a5ecb42 100644
--- a/sound/pci/echoaudio/indigodj_dsp.c
+++ b/sound/pci/echoaudio/indigodj_dsp.c
@@ -39,7 +39,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
39 int err; 39 int err;
40 40
41 DE_INIT(("init_hw() - Indigo DJ\n")); 41 DE_INIT(("init_hw() - Indigo DJ\n"));
42 snd_assert((subdevice_id & 0xfff0) == INDIGO_DJ, return -ENODEV); 42 if (snd_BUG_ON((subdevice_id & 0xfff0) != INDIGO_DJ))
43 return -ENODEV;
43 44
44 if ((err = init_dsp_comm_page(chip))) { 45 if ((err = init_dsp_comm_page(chip))) {
45 DE_INIT(("init_hw - could not initialize DSP comm page\n")); 46 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,
143{ 144{
144 int index; 145 int index;
145 146
146 snd_assert(pipe < num_pipes_out(chip) && 147 if (snd_BUG_ON(pipe >= num_pipes_out(chip) ||
147 output < num_busses_out(chip), return -EINVAL); 148 output >= num_busses_out(chip)))
149 return -EINVAL;
148 150
149 if (wait_handshake(chip)) 151 if (wait_handshake(chip))
150 return -EIO; 152 return -EIO;
diff --git a/sound/pci/echoaudio/indigoio_dsp.c b/sound/pci/echoaudio/indigoio_dsp.c
index f3ad13d06be0..a7e09ec21079 100644
--- a/sound/pci/echoaudio/indigoio_dsp.c
+++ b/sound/pci/echoaudio/indigoio_dsp.c
@@ -39,7 +39,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
39 int err; 39 int err;
40 40
41 DE_INIT(("init_hw() - Indigo IO\n")); 41 DE_INIT(("init_hw() - Indigo IO\n"));
42 snd_assert((subdevice_id & 0xfff0) == INDIGO_IO, return -ENODEV); 42 if (snd_BUG_ON((subdevice_id & 0xfff0) != INDIGO_IO))
43 return -ENODEV;
43 44
44 if ((err = init_dsp_comm_page(chip))) { 45 if ((err = init_dsp_comm_page(chip))) {
45 DE_INIT(("init_hw - could not initialize DSP comm page\n")); 46 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,
114{ 115{
115 int index; 116 int index;
116 117
117 snd_assert(pipe < num_pipes_out(chip) && 118 if (snd_BUG_ON(pipe >= num_pipes_out(chip) ||
118 output < num_busses_out(chip), return -EINVAL); 119 output >= num_busses_out(chip)))
120 return -EINVAL;
119 121
120 if (wait_handshake(chip)) 122 if (wait_handshake(chip))
121 return -EIO; 123 return -EIO;
diff --git a/sound/pci/echoaudio/layla20_dsp.c b/sound/pci/echoaudio/layla20_dsp.c
index 990c9a60a0a8..ede75c6ca0fb 100644
--- a/sound/pci/echoaudio/layla20_dsp.c
+++ b/sound/pci/echoaudio/layla20_dsp.c
@@ -42,7 +42,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
42 int err; 42 int err;
43 43
44 DE_INIT(("init_hw() - Layla20\n")); 44 DE_INIT(("init_hw() - Layla20\n"));
45 snd_assert((subdevice_id & 0xfff0) == LAYLA20, return -ENODEV); 45 if (snd_BUG_ON((subdevice_id & 0xfff0) != LAYLA20))
46 return -ENODEV;
46 47
47 if ((err = init_dsp_comm_page(chip))) { 48 if ((err = init_dsp_comm_page(chip))) {
48 DE_INIT(("init_hw - could not initialize DSP comm page\n")); 49 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
@@ -155,7 +156,8 @@ static int load_asic(struct echoaudio *chip)
155 156
156static int set_sample_rate(struct echoaudio *chip, u32 rate) 157static int set_sample_rate(struct echoaudio *chip, u32 rate)
157{ 158{
158 snd_assert(rate >= 8000 && rate <= 50000, return -EINVAL); 159 if (snd_BUG_ON(rate < 8000 || rate > 50000))
160 return -EINVAL;
159 161
160 /* Only set the clock for internal mode. Do not return failure, 162 /* Only set the clock for internal mode. Do not return failure,
161 simply treat it as a non-event. */ 163 simply treat it as a non-event. */
@@ -252,7 +254,8 @@ static int set_output_clock(struct echoaudio *chip, u16 clock)
252/* Set input bus gain (one unit is 0.5dB !) */ 254/* Set input bus gain (one unit is 0.5dB !) */
253static int set_input_gain(struct echoaudio *chip, u16 input, int gain) 255static int set_input_gain(struct echoaudio *chip, u16 input, int gain)
254{ 256{
255 snd_assert(input < num_busses_in(chip), return -EINVAL); 257 if (snd_BUG_ON(input >= num_busses_in(chip)))
258 return -EINVAL;
256 259
257 if (wait_handshake(chip)) 260 if (wait_handshake(chip))
258 return -EIO; 261 return -EIO;
diff --git a/sound/pci/echoaudio/layla24_dsp.c b/sound/pci/echoaudio/layla24_dsp.c
index 97e42e115147..d61b5cbcccad 100644
--- a/sound/pci/echoaudio/layla24_dsp.c
+++ b/sound/pci/echoaudio/layla24_dsp.c
@@ -42,7 +42,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
42 int err; 42 int err;
43 43
44 DE_INIT(("init_hw() - Layla24\n")); 44 DE_INIT(("init_hw() - Layla24\n"));
45 snd_assert((subdevice_id & 0xfff0) == LAYLA24, return -ENODEV); 45 if (snd_BUG_ON((subdevice_id & 0xfff0) != LAYLA24))
46 return -ENODEV;
46 47
47 if ((err = init_dsp_comm_page(chip))) { 48 if ((err = init_dsp_comm_page(chip))) {
48 DE_INIT(("init_hw - could not initialize DSP comm page\n")); 49 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)
73 return err; 74 return err;
74 75
75 err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA); 76 err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA);
76 snd_assert(err >= 0, return err); 77 if (err < 0)
78 return err;
77 err = set_professional_spdif(chip, TRUE); 79 err = set_professional_spdif(chip, TRUE);
78 80
79 DE_INIT(("init_hw done\n")); 81 DE_INIT(("init_hw done\n"));
@@ -158,8 +160,9 @@ static int set_sample_rate(struct echoaudio *chip, u32 rate)
158{ 160{
159 u32 control_reg, clock, base_rate; 161 u32 control_reg, clock, base_rate;
160 162
161 snd_assert(rate < 50000 || chip->digital_mode != DIGITAL_MODE_ADAT, 163 if (snd_BUG_ON(rate >= 50000 &&
162 return -EINVAL); 164 chip->digital_mode == DIGITAL_MODE_ADAT))
165 return -EINVAL;
163 166
164 /* Only set the clock for internal mode. */ 167 /* Only set the clock for internal mode. */
165 if (chip->input_clock != ECHO_CLOCK_INTERNAL) { 168 if (chip->input_clock != ECHO_CLOCK_INTERNAL) {
diff --git a/sound/pci/echoaudio/mia_dsp.c b/sound/pci/echoaudio/mia_dsp.c
index 891c70519096..227386602f9b 100644
--- a/sound/pci/echoaudio/mia_dsp.c
+++ b/sound/pci/echoaudio/mia_dsp.c
@@ -42,7 +42,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
42 int err; 42 int err;
43 43
44 DE_INIT(("init_hw() - Mia\n")); 44 DE_INIT(("init_hw() - Mia\n"));
45 snd_assert((subdevice_id & 0xfff0) == MIA, return -ENODEV); 45 if (snd_BUG_ON((subdevice_id & 0xfff0) != MIA))
46 return -ENODEV;
46 47
47 if ((err = init_dsp_comm_page(chip))) { 48 if ((err = init_dsp_comm_page(chip))) {
48 DE_INIT(("init_hw - could not initialize DSP comm page\n")); 49 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)
161static int set_input_clock(struct echoaudio *chip, u16 clock) 162static int set_input_clock(struct echoaudio *chip, u16 clock)
162{ 163{
163 DE_ACT(("set_input_clock(%d)\n", clock)); 164 DE_ACT(("set_input_clock(%d)\n", clock));
164 snd_assert(clock == ECHO_CLOCK_INTERNAL || clock == ECHO_CLOCK_SPDIF, 165 if (snd_BUG_ON(clock != ECHO_CLOCK_INTERNAL &&
165 return -EINVAL); 166 clock != ECHO_CLOCK_SPDIF))
167 return -EINVAL;
166 168
167 chip->input_clock = clock; 169 chip->input_clock = clock;
168 return set_sample_rate(chip, chip->sample_rate); 170 return set_sample_rate(chip, chip->sample_rate);
@@ -176,8 +178,9 @@ static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
176{ 178{
177 int index; 179 int index;
178 180
179 snd_assert(pipe < num_pipes_out(chip) && 181 if (snd_BUG_ON(pipe >= num_pipes_out(chip) ||
180 output < num_busses_out(chip), return -EINVAL); 182 output >= num_busses_out(chip)))
183 return -EINVAL;
181 184
182 if (wait_handshake(chip)) 185 if (wait_handshake(chip))
183 return -EIO; 186 return -EIO;
diff --git a/sound/pci/echoaudio/midi.c b/sound/pci/echoaudio/midi.c
index 91f5bff66d3f..77bf2a83d997 100644
--- a/sound/pci/echoaudio/midi.c
+++ b/sound/pci/echoaudio/midi.c
@@ -59,7 +59,8 @@ static int enable_midi_input(struct echoaudio *chip, char enable)
59Returns how many actually written or < 0 on error */ 59Returns how many actually written or < 0 on error */
60static int write_midi(struct echoaudio *chip, u8 *data, int bytes) 60static int write_midi(struct echoaudio *chip, u8 *data, int bytes)
61{ 61{
62 snd_assert(bytes > 0 && bytes < MIDI_OUT_BUFFER_SIZE, return -EINVAL); 62 if (snd_BUG_ON(bytes <= 0 || bytes >= MIDI_OUT_BUFFER_SIZE))
63 return -EINVAL;
63 64
64 if (wait_handshake(chip)) 65 if (wait_handshake(chip))
65 return -EIO; 66 return -EIO;
@@ -119,7 +120,8 @@ static int midi_service_irq(struct echoaudio *chip)
119 /* The count is at index 0, followed by actual data */ 120 /* The count is at index 0, followed by actual data */
120 count = le16_to_cpu(chip->comm_page->midi_input[0]); 121 count = le16_to_cpu(chip->comm_page->midi_input[0]);
121 122
122 snd_assert(count < MIDI_IN_BUFFER_SIZE, return 0); 123 if (snd_BUG_ON(count >= MIDI_IN_BUFFER_SIZE))
124 return 0;
123 125
124 /* Get the MIDI data from the comm page */ 126 /* Get the MIDI data from the comm page */
125 i = 1; 127 i = 1;
diff --git a/sound/pci/echoaudio/mona_dsp.c b/sound/pci/echoaudio/mona_dsp.c
index c0b4bf0be7d1..eaa619bd2a03 100644
--- a/sound/pci/echoaudio/mona_dsp.c
+++ b/sound/pci/echoaudio/mona_dsp.c
@@ -43,7 +43,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
43 int err; 43 int err;
44 44
45 DE_INIT(("init_hw() - Mona\n")); 45 DE_INIT(("init_hw() - Mona\n"));
46 snd_assert((subdevice_id & 0xfff0) == MONA, return -ENODEV); 46 if (snd_BUG_ON((subdevice_id & 0xfff0) != MONA))
47 return -ENODEV;
47 48
48 if ((err = init_dsp_comm_page(chip))) { 49 if ((err = init_dsp_comm_page(chip))) {
49 DE_INIT(("init_hw - could not initialize DSP comm page\n")); 50 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)
79 return err; 80 return err;
80 81
81 err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA); 82 err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA);
82 snd_assert(err >= 0, return err); 83 if (err < 0)
84 return err;
83 err = set_professional_spdif(chip, TRUE); 85 err = set_professional_spdif(chip, TRUE);
84 86
85 DE_INIT(("init_hw done\n")); 87 DE_INIT(("init_hw done\n"));
diff --git a/sound/pci/emu10k1/emu10k1_callback.c b/sound/pci/emu10k1/emu10k1_callback.c
index 45088ebcce50..0e649dcdbf64 100644
--- a/sound/pci/emu10k1/emu10k1_callback.c
+++ b/sound/pci/emu10k1/emu10k1_callback.c
@@ -145,7 +145,8 @@ terminate_voice(struct snd_emux_voice *vp)
145{ 145{
146 struct snd_emu10k1 *hw; 146 struct snd_emu10k1 *hw;
147 147
148 snd_assert(vp, return); 148 if (snd_BUG_ON(!vp))
149 return;
149 hw = vp->hw; 150 hw = vp->hw;
150 snd_emu10k1_ptr_write(hw, DCYSUSV, vp->ch, 0x807f | DCYSUSV_CHANNELENABLE_MASK); 151 snd_emu10k1_ptr_write(hw, DCYSUSV, vp->ch, 0x807f | DCYSUSV_CHANNELENABLE_MASK);
151 if (vp->block) { 152 if (vp->block) {
@@ -325,7 +326,8 @@ start_voice(struct snd_emux_voice *vp)
325 326
326 hw = vp->hw; 327 hw = vp->hw;
327 ch = vp->ch; 328 ch = vp->ch;
328 snd_assert(ch >= 0, return -EINVAL); 329 if (snd_BUG_ON(ch < 0))
330 return -EINVAL;
329 chan = vp->chan; 331 chan = vp->chan;
330 332
331 emem = (struct snd_emu10k1_memblk *)vp->block; 333 emem = (struct snd_emu10k1_memblk *)vp->block;
diff --git a/sound/pci/emu10k1/emu10k1_patch.c b/sound/pci/emu10k1/emu10k1_patch.c
index 42bae6f7e9a4..e10f027bde03 100644
--- a/sound/pci/emu10k1/emu10k1_patch.c
+++ b/sound/pci/emu10k1/emu10k1_patch.c
@@ -46,8 +46,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
46 struct snd_emu10k1 *emu; 46 struct snd_emu10k1 *emu;
47 47
48 emu = rec->hw; 48 emu = rec->hw;
49 snd_assert(sp != NULL, return -EINVAL); 49 if (snd_BUG_ON(!sp || !hdr))
50 snd_assert(hdr != NULL, return -EINVAL); 50 return -EINVAL;
51 51
52 if (sp->v.size == 0) { 52 if (sp->v.size == 0) {
53 snd_printd("emu: rom font for sample %d\n", sp->v.sample); 53 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,
104 size = BLANK_HEAD_SIZE; 104 size = BLANK_HEAD_SIZE;
105 if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) 105 if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS))
106 size *= 2; 106 size *= 2;
107 snd_assert(offset + size <= blocksize, return -EINVAL); 107 if (offset + size > blocksize)
108 return -EINVAL;
108 snd_emu10k1_synth_bzero(emu, sp->block, offset, size); 109 snd_emu10k1_synth_bzero(emu, sp->block, offset, size);
109 offset += size; 110 offset += size;
110 111
@@ -112,7 +113,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
112 size = loopend; 113 size = loopend;
113 if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) 114 if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS))
114 size *= 2; 115 size *= 2;
115 snd_assert(offset + size <= blocksize, return -EINVAL); 116 if (offset + size > blocksize)
117 return -EINVAL;
116 if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size)) { 118 if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size)) {
117 snd_emu10k1_synth_free(emu, sp->block); 119 snd_emu10k1_synth_free(emu, sp->block);
118 sp->block = NULL; 120 sp->block = NULL;
@@ -129,12 +131,14 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
129 int woffset; 131 int woffset;
130 unsigned short *wblock = (unsigned short*)block; 132 unsigned short *wblock = (unsigned short*)block;
131 woffset = offset / 2; 133 woffset = offset / 2;
132 snd_assert(offset + loopsize*2 <= blocksize, return -EINVAL); 134 if (offset + loopsize * 2 > blocksize)
135 return -EINVAL;
133 for (i = 0; i < loopsize; i++) 136 for (i = 0; i < loopsize; i++)
134 wblock[woffset + i] = wblock[woffset - i -1]; 137 wblock[woffset + i] = wblock[woffset - i -1];
135 offset += loopsize * 2; 138 offset += loopsize * 2;
136 } else { 139 } else {
137 snd_assert(offset + loopsize <= blocksize, return -EINVAL); 140 if (offset + loopsize > blocksize)
141 return -EINVAL;
138 for (i = 0; i < loopsize; i++) 142 for (i = 0; i < loopsize; i++)
139 block[offset + i] = block[offset - i -1]; 143 block[offset + i] = block[offset - i -1];
140 offset += loopsize; 144 offset += loopsize;
@@ -154,7 +158,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
154 158
155 /* loopend -> sample end */ 159 /* loopend -> sample end */
156 size = sp->v.size - loopend; 160 size = sp->v.size - loopend;
157 snd_assert(size >= 0, return -EINVAL); 161 if (size < 0)
162 return -EINVAL;
158 if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) 163 if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS))
159 size *= 2; 164 size *= 2;
160 if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size)) { 165 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,
212 struct snd_emu10k1 *emu; 217 struct snd_emu10k1 *emu;
213 218
214 emu = rec->hw; 219 emu = rec->hw;
215 snd_assert(sp != NULL, return -EINVAL); 220 if (snd_BUG_ON(!sp || !hdr))
216 snd_assert(hdr != NULL, return -EINVAL); 221 return -EINVAL;
217 222
218 if (sp->block) { 223 if (sp->block) {
219 snd_emu10k1_synth_free(emu, sp->block); 224 snd_emu10k1_synth_free(emu, sp->block);
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index 491a4a50f869..5ff4dbb62dad 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -1319,7 +1319,8 @@ static int snd_emu10k1x_midi_input_open(struct snd_rawmidi_substream *substream)
1319 unsigned long flags; 1319 unsigned long flags;
1320 1320
1321 emu = midi->emu; 1321 emu = midi->emu;
1322 snd_assert(emu, return -ENXIO); 1322 if (snd_BUG_ON(!emu))
1323 return -ENXIO;
1323 spin_lock_irqsave(&midi->open_lock, flags); 1324 spin_lock_irqsave(&midi->open_lock, flags);
1324 midi->midi_mode |= EMU10K1X_MIDI_MODE_INPUT; 1325 midi->midi_mode |= EMU10K1X_MIDI_MODE_INPUT;
1325 midi->substream_input = substream; 1326 midi->substream_input = substream;
@@ -1345,7 +1346,8 @@ static int snd_emu10k1x_midi_output_open(struct snd_rawmidi_substream *substream
1345 unsigned long flags; 1346 unsigned long flags;
1346 1347
1347 emu = midi->emu; 1348 emu = midi->emu;
1348 snd_assert(emu, return -ENXIO); 1349 if (snd_BUG_ON(!emu))
1350 return -ENXIO;
1349 spin_lock_irqsave(&midi->open_lock, flags); 1351 spin_lock_irqsave(&midi->open_lock, flags);
1350 midi->midi_mode |= EMU10K1X_MIDI_MODE_OUTPUT; 1352 midi->midi_mode |= EMU10K1X_MIDI_MODE_OUTPUT;
1351 midi->substream_output = substream; 1353 midi->substream_output = substream;
@@ -1372,7 +1374,8 @@ static int snd_emu10k1x_midi_input_close(struct snd_rawmidi_substream *substream
1372 int err = 0; 1374 int err = 0;
1373 1375
1374 emu = midi->emu; 1376 emu = midi->emu;
1375 snd_assert(emu, return -ENXIO); 1377 if (snd_BUG_ON(!emu))
1378 return -ENXIO;
1376 spin_lock_irqsave(&midi->open_lock, flags); 1379 spin_lock_irqsave(&midi->open_lock, flags);
1377 snd_emu10k1x_intr_disable(emu, midi->rx_enable); 1380 snd_emu10k1x_intr_disable(emu, midi->rx_enable);
1378 midi->midi_mode &= ~EMU10K1X_MIDI_MODE_INPUT; 1381 midi->midi_mode &= ~EMU10K1X_MIDI_MODE_INPUT;
@@ -1394,7 +1397,8 @@ static int snd_emu10k1x_midi_output_close(struct snd_rawmidi_substream *substrea
1394 int err = 0; 1397 int err = 0;
1395 1398
1396 emu = midi->emu; 1399 emu = midi->emu;
1397 snd_assert(emu, return -ENXIO); 1400 if (snd_BUG_ON(!emu))
1401 return -ENXIO;
1398 spin_lock_irqsave(&midi->open_lock, flags); 1402 spin_lock_irqsave(&midi->open_lock, flags);
1399 snd_emu10k1x_intr_disable(emu, midi->tx_enable); 1403 snd_emu10k1x_intr_disable(emu, midi->tx_enable);
1400 midi->midi_mode &= ~EMU10K1X_MIDI_MODE_OUTPUT; 1404 midi->midi_mode &= ~EMU10K1X_MIDI_MODE_OUTPUT;
@@ -1413,7 +1417,8 @@ static void snd_emu10k1x_midi_input_trigger(struct snd_rawmidi_substream *substr
1413 struct emu10k1x *emu; 1417 struct emu10k1x *emu;
1414 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1418 struct emu10k1x_midi *midi = substream->rmidi->private_data;
1415 emu = midi->emu; 1419 emu = midi->emu;
1416 snd_assert(emu, return); 1420 if (snd_BUG_ON(!emu))
1421 return;
1417 1422
1418 if (up) 1423 if (up)
1419 snd_emu10k1x_intr_enable(emu, midi->rx_enable); 1424 snd_emu10k1x_intr_enable(emu, midi->rx_enable);
@@ -1428,7 +1433,8 @@ static void snd_emu10k1x_midi_output_trigger(struct snd_rawmidi_substream *subst
1428 unsigned long flags; 1433 unsigned long flags;
1429 1434
1430 emu = midi->emu; 1435 emu = midi->emu;
1431 snd_assert(emu, return); 1436 if (snd_BUG_ON(!emu))
1437 return;
1432 1438
1433 if (up) { 1439 if (up) {
1434 int max = 4; 1440 int max = 4;
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 71dc4c8865b8..7dba08f0ab8e 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -487,7 +487,8 @@ static void snd_emu10k1_write_op(struct snd_emu10k1_fx8010_code *icode,
487 u32 op, u32 r, u32 a, u32 x, u32 y) 487 u32 op, u32 r, u32 a, u32 x, u32 y)
488{ 488{
489 u_int32_t *code; 489 u_int32_t *code;
490 snd_assert(*ptr < 512, return); 490 if (snd_BUG_ON(*ptr >= 512))
491 return;
491 code = (u_int32_t __force *)icode->code + (*ptr) * 2; 492 code = (u_int32_t __force *)icode->code + (*ptr) * 2;
492 set_bit(*ptr, icode->code_valid); 493 set_bit(*ptr, icode->code_valid);
493 code[0] = ((x & 0x3ff) << 10) | (y & 0x3ff); 494 code[0] = ((x & 0x3ff) << 10) | (y & 0x3ff);
@@ -503,7 +504,8 @@ static void snd_emu10k1_audigy_write_op(struct snd_emu10k1_fx8010_code *icode,
503 u32 op, u32 r, u32 a, u32 x, u32 y) 504 u32 op, u32 r, u32 a, u32 x, u32 y)
504{ 505{
505 u_int32_t *code; 506 u_int32_t *code;
506 snd_assert(*ptr < 1024, return); 507 if (snd_BUG_ON(*ptr >= 1024))
508 return;
507 code = (u_int32_t __force *)icode->code + (*ptr) * 2; 509 code = (u_int32_t __force *)icode->code + (*ptr) * 2;
508 set_bit(*ptr, icode->code_valid); 510 set_bit(*ptr, icode->code_valid);
509 code[0] = ((x & 0x7ff) << 12) | (y & 0x7ff); 511 code[0] = ((x & 0x7ff) << 12) | (y & 0x7ff);
diff --git a/sound/pci/emu10k1/emumpu401.c b/sound/pci/emu10k1/emumpu401.c
index c4d76d16661e..8578c70c61f2 100644
--- a/sound/pci/emu10k1/emumpu401.c
+++ b/sound/pci/emu10k1/emumpu401.c
@@ -157,7 +157,8 @@ static int snd_emu10k1_midi_input_open(struct snd_rawmidi_substream *substream)
157 unsigned long flags; 157 unsigned long flags;
158 158
159 emu = midi->emu; 159 emu = midi->emu;
160 snd_assert(emu, return -ENXIO); 160 if (snd_BUG_ON(!emu))
161 return -ENXIO;
161 spin_lock_irqsave(&midi->open_lock, flags); 162 spin_lock_irqsave(&midi->open_lock, flags);
162 midi->midi_mode |= EMU10K1_MIDI_MODE_INPUT; 163 midi->midi_mode |= EMU10K1_MIDI_MODE_INPUT;
163 midi->substream_input = substream; 164 midi->substream_input = substream;
@@ -183,7 +184,8 @@ static int snd_emu10k1_midi_output_open(struct snd_rawmidi_substream *substream)
183 unsigned long flags; 184 unsigned long flags;
184 185
185 emu = midi->emu; 186 emu = midi->emu;
186 snd_assert(emu, return -ENXIO); 187 if (snd_BUG_ON(!emu))
188 return -ENXIO;
187 spin_lock_irqsave(&midi->open_lock, flags); 189 spin_lock_irqsave(&midi->open_lock, flags);
188 midi->midi_mode |= EMU10K1_MIDI_MODE_OUTPUT; 190 midi->midi_mode |= EMU10K1_MIDI_MODE_OUTPUT;
189 midi->substream_output = substream; 191 midi->substream_output = substream;
@@ -210,7 +212,8 @@ static int snd_emu10k1_midi_input_close(struct snd_rawmidi_substream *substream)
210 int err = 0; 212 int err = 0;
211 213
212 emu = midi->emu; 214 emu = midi->emu;
213 snd_assert(emu, return -ENXIO); 215 if (snd_BUG_ON(!emu))
216 return -ENXIO;
214 spin_lock_irqsave(&midi->open_lock, flags); 217 spin_lock_irqsave(&midi->open_lock, flags);
215 snd_emu10k1_intr_disable(emu, midi->rx_enable); 218 snd_emu10k1_intr_disable(emu, midi->rx_enable);
216 midi->midi_mode &= ~EMU10K1_MIDI_MODE_INPUT; 219 midi->midi_mode &= ~EMU10K1_MIDI_MODE_INPUT;
@@ -232,7 +235,8 @@ static int snd_emu10k1_midi_output_close(struct snd_rawmidi_substream *substream
232 int err = 0; 235 int err = 0;
233 236
234 emu = midi->emu; 237 emu = midi->emu;
235 snd_assert(emu, return -ENXIO); 238 if (snd_BUG_ON(!emu))
239 return -ENXIO;
236 spin_lock_irqsave(&midi->open_lock, flags); 240 spin_lock_irqsave(&midi->open_lock, flags);
237 snd_emu10k1_intr_disable(emu, midi->tx_enable); 241 snd_emu10k1_intr_disable(emu, midi->tx_enable);
238 midi->midi_mode &= ~EMU10K1_MIDI_MODE_OUTPUT; 242 midi->midi_mode &= ~EMU10K1_MIDI_MODE_OUTPUT;
@@ -251,7 +255,8 @@ static void snd_emu10k1_midi_input_trigger(struct snd_rawmidi_substream *substre
251 struct snd_emu10k1 *emu; 255 struct snd_emu10k1 *emu;
252 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 256 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data;
253 emu = midi->emu; 257 emu = midi->emu;
254 snd_assert(emu, return); 258 if (snd_BUG_ON(!emu))
259 return;
255 260
256 if (up) 261 if (up)
257 snd_emu10k1_intr_enable(emu, midi->rx_enable); 262 snd_emu10k1_intr_enable(emu, midi->rx_enable);
@@ -266,7 +271,8 @@ static void snd_emu10k1_midi_output_trigger(struct snd_rawmidi_substream *substr
266 unsigned long flags; 271 unsigned long flags;
267 272
268 emu = midi->emu; 273 emu = midi->emu;
269 snd_assert(emu, return); 274 if (snd_BUG_ON(!emu))
275 return;
270 276
271 if (up) { 277 if (up) {
272 int max = 4; 278 int max = 4;
diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c
index 7d379f5131fb..e8ad56ed34fa 100644
--- a/sound/pci/emu10k1/memory.c
+++ b/sound/pci/emu10k1/memory.c
@@ -107,7 +107,8 @@ static int search_empty_map_area(struct snd_emu10k1 *emu, int npages, struct lis
107 107
108 list_for_each (pos, &emu->mapped_link_head) { 108 list_for_each (pos, &emu->mapped_link_head) {
109 struct snd_emu10k1_memblk *blk = get_emu10k1_memblk(pos, mapped_link); 109 struct snd_emu10k1_memblk *blk = get_emu10k1_memblk(pos, mapped_link);
110 snd_assert(blk->mapped_page >= 0, continue); 110 if (blk->mapped_page < 0)
111 continue;
111 size = blk->mapped_page - page; 112 size = blk->mapped_page - page;
112 if (size == npages) { 113 if (size == npages) {
113 *nextp = pos; 114 *nextp = pos;
@@ -300,10 +301,14 @@ snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *subst
300 struct snd_emu10k1_memblk *blk; 301 struct snd_emu10k1_memblk *blk;
301 int page, err, idx; 302 int page, err, idx;
302 303
303 snd_assert(emu, return NULL); 304 if (snd_BUG_ON(!emu))
304 snd_assert(runtime->dma_bytes > 0 && runtime->dma_bytes < MAXPAGES * EMUPAGESIZE, return NULL); 305 return NULL;
306 if (snd_BUG_ON(runtime->dma_bytes <= 0 ||
307 runtime->dma_bytes >= MAXPAGES * EMUPAGESIZE))
308 return NULL;
305 hdr = emu->memhdr; 309 hdr = emu->memhdr;
306 snd_assert(hdr, return NULL); 310 if (snd_BUG_ON(!hdr))
311 return NULL;
307 312
308 mutex_lock(&hdr->block_mutex); 313 mutex_lock(&hdr->block_mutex);
309 blk = search_empty(emu, runtime->dma_bytes); 314 blk = search_empty(emu, runtime->dma_bytes);
@@ -353,7 +358,8 @@ snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *subst
353 */ 358 */
354int snd_emu10k1_free_pages(struct snd_emu10k1 *emu, struct snd_util_memblk *blk) 359int snd_emu10k1_free_pages(struct snd_emu10k1 *emu, struct snd_util_memblk *blk)
355{ 360{
356 snd_assert(emu && blk, return -EINVAL); 361 if (snd_BUG_ON(!emu || !blk))
362 return -EINVAL;
357 return snd_emu10k1_synth_free(emu, blk); 363 return snd_emu10k1_synth_free(emu, blk);
358} 364}
359 365
@@ -498,7 +504,8 @@ static int synth_free_pages(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *
498static inline void *offset_ptr(struct snd_emu10k1 *emu, int page, int offset) 504static inline void *offset_ptr(struct snd_emu10k1 *emu, int page, int offset)
499{ 505{
500 char *ptr; 506 char *ptr;
501 snd_assert(page >= 0 && page < emu->max_cache_pages, return NULL); 507 if (snd_BUG_ON(page < 0 || page >= emu->max_cache_pages))
508 return NULL;
502 ptr = emu->page_ptr_table[page]; 509 ptr = emu->page_ptr_table[page];
503 if (! ptr) { 510 if (! ptr) {
504 printk(KERN_ERR "emu10k1: access to NULL ptr: page = %d\n", page); 511 printk(KERN_ERR "emu10k1: access to NULL ptr: page = %d\n", page);
diff --git a/sound/pci/emu10k1/voice.c b/sound/pci/emu10k1/voice.c
index 958cb2a65a4e..d7300a1aa262 100644
--- a/sound/pci/emu10k1/voice.c
+++ b/sound/pci/emu10k1/voice.c
@@ -111,8 +111,10 @@ int snd_emu10k1_voice_alloc(struct snd_emu10k1 *emu, int type, int number,
111 unsigned long flags; 111 unsigned long flags;
112 int result; 112 int result;
113 113
114 snd_assert(rvoice != NULL, return -EINVAL); 114 if (snd_BUG_ON(!rvoice))
115 snd_assert(number, return -EINVAL); 115 return -EINVAL;
116 if (snd_BUG_ON(!number))
117 return -EINVAL;
116 118
117 spin_lock_irqsave(&emu->voice_lock, flags); 119 spin_lock_irqsave(&emu->voice_lock, flags);
118 for (;;) { 120 for (;;) {
@@ -145,7 +147,8 @@ int snd_emu10k1_voice_free(struct snd_emu10k1 *emu,
145{ 147{
146 unsigned long flags; 148 unsigned long flags;
147 149
148 snd_assert(pvoice != NULL, return -EINVAL); 150 if (snd_BUG_ON(!pvoice))
151 return -EINVAL;
149 spin_lock_irqsave(&emu->voice_lock, flags); 152 spin_lock_irqsave(&emu->voice_lock, flags);
150 pvoice->interrupt = NULL; 153 pvoice->interrupt = NULL;
151 pvoice->use = pvoice->pcm = pvoice->synth = pvoice->midi = pvoice->efx = 0; 154 pvoice->use = pvoice->pcm = pvoice->synth = pvoice->midi = pvoice->efx = 0;
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index 84fac1fbf103..4cd9a1faaecc 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -860,7 +860,8 @@ static int snd_es1938_capture_copy(struct snd_pcm_substream *substream,
860 struct es1938 *chip = snd_pcm_substream_chip(substream); 860 struct es1938 *chip = snd_pcm_substream_chip(substream);
861 pos <<= chip->dma1_shift; 861 pos <<= chip->dma1_shift;
862 count <<= chip->dma1_shift; 862 count <<= chip->dma1_shift;
863 snd_assert(pos + count <= chip->dma1_size, return -EINVAL); 863 if (snd_BUG_ON(pos + count > chip->dma1_size))
864 return -EINVAL;
864 if (pos + count < chip->dma1_size) { 865 if (pos + count < chip->dma1_size) {
865 if (copy_to_user(dst, runtime->dma_area + pos + 1, count)) 866 if (copy_to_user(dst, runtime->dma_area + pos + 1, count))
866 return -EFAULT; 867 return -EFAULT;
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 1bf298d214b9..20ee7599600b 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -692,7 +692,8 @@ static void apu_data_set(struct es1968 *chip, u16 data)
692/* no spinlock */ 692/* no spinlock */
693static void __apu_set_register(struct es1968 *chip, u16 channel, u8 reg, u16 data) 693static void __apu_set_register(struct es1968 *chip, u16 channel, u8 reg, u16 data)
694{ 694{
695 snd_assert(channel < NR_APUS, return); 695 if (snd_BUG_ON(channel >= NR_APUS))
696 return;
696#ifdef CONFIG_PM 697#ifdef CONFIG_PM
697 chip->apu_map[channel][reg] = data; 698 chip->apu_map[channel][reg] = data;
698#endif 699#endif
@@ -711,7 +712,8 @@ static void apu_set_register(struct es1968 *chip, u16 channel, u8 reg, u16 data)
711 712
712static u16 __apu_get_register(struct es1968 *chip, u16 channel, u8 reg) 713static u16 __apu_get_register(struct es1968 *chip, u16 channel, u8 reg)
713{ 714{
714 snd_assert(channel < NR_APUS, return 0); 715 if (snd_BUG_ON(channel >= NR_APUS))
716 return 0;
715 reg |= (channel << 4); 717 reg |= (channel << 4);
716 apu_index_set(chip, reg); 718 apu_index_set(chip, reg);
717 return __maestro_read(chip, IDR0_DATA_PORT); 719 return __maestro_read(chip, IDR0_DATA_PORT);
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index d2e1093f8e97..77fbcd4a69b7 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -211,7 +211,8 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
211 unsigned int shift, num_elems, mask; 211 unsigned int shift, num_elems, mask;
212 hda_nid_t prev_nid; 212 hda_nid_t prev_nid;
213 213
214 snd_assert(conn_list && max_conns > 0, return -EINVAL); 214 if (snd_BUG_ON(!conn_list || max_conns <= 0))
215 return -EINVAL;
215 216
216 parm = snd_hda_param_read(codec, nid, AC_PAR_CONNLIST_LEN); 217 parm = snd_hda_param_read(codec, nid, AC_PAR_CONNLIST_LEN);
217 if (parm & AC_CLIST_LONG) { 218 if (parm & AC_CLIST_LONG) {
@@ -407,8 +408,10 @@ int __devinit snd_hda_bus_new(struct snd_card *card,
407 .dev_free = snd_hda_bus_dev_free, 408 .dev_free = snd_hda_bus_dev_free,
408 }; 409 };
409 410
410 snd_assert(temp, return -EINVAL); 411 if (snd_BUG_ON(!temp))
411 snd_assert(temp->ops.command && temp->ops.get_response, return -EINVAL); 412 return -EINVAL;
413 if (snd_BUG_ON(!temp->ops.command || !temp->ops.get_response))
414 return -EINVAL;
412 415
413 if (busp) 416 if (busp)
414 *busp = NULL; 417 *busp = NULL;
@@ -588,8 +591,10 @@ int __devinit snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
588 char component[13]; 591 char component[13];
589 int err; 592 int err;
590 593
591 snd_assert(bus, return -EINVAL); 594 if (snd_BUG_ON(!bus))
592 snd_assert(codec_addr <= HDA_MAX_CODEC_ADDRESS, return -EINVAL); 595 return -EINVAL;
596 if (snd_BUG_ON(codec_addr > HDA_MAX_CODEC_ADDRESS))
597 return -EINVAL;
593 598
594 if (bus->caddr_tbl[codec_addr]) { 599 if (bus->caddr_tbl[codec_addr]) {
595 snd_printk(KERN_ERR "hda_codec: " 600 snd_printk(KERN_ERR "hda_codec: "
@@ -2236,11 +2241,13 @@ static int __devinit set_pcm_default_values(struct hda_codec *codec,
2236 if (info->ops.close == NULL) 2241 if (info->ops.close == NULL)
2237 info->ops.close = hda_pcm_default_open_close; 2242 info->ops.close = hda_pcm_default_open_close;
2238 if (info->ops.prepare == NULL) { 2243 if (info->ops.prepare == NULL) {
2239 snd_assert(info->nid, return -EINVAL); 2244 if (snd_BUG_ON(!info->nid))
2245 return -EINVAL;
2240 info->ops.prepare = hda_pcm_default_prepare; 2246 info->ops.prepare = hda_pcm_default_prepare;
2241 } 2247 }
2242 if (info->ops.cleanup == NULL) { 2248 if (info->ops.cleanup == NULL) {
2243 snd_assert(info->nid, return -EINVAL); 2249 if (snd_BUG_ON(!info->nid))
2250 return -EINVAL;
2244 info->ops.cleanup = hda_pcm_default_cleanup; 2251 info->ops.cleanup = hda_pcm_default_cleanup;
2245 } 2252 }
2246 return 0; 2253 return 0;
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 59e4389c94a4..0ca30894f7c6 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -174,7 +174,8 @@ static int build_afg_tree(struct hda_codec *codec)
174 int i, nodes, err; 174 int i, nodes, err;
175 hda_nid_t nid; 175 hda_nid_t nid;
176 176
177 snd_assert(spec, return -EINVAL); 177 if (snd_BUG_ON(!spec))
178 return -EINVAL;
178 179
179 spec->def_amp_out_caps = snd_hda_param_read(codec, codec->afg, AC_PAR_AMP_OUT_CAP); 180 spec->def_amp_out_caps = snd_hda_param_read(codec, codec->afg, AC_PAR_AMP_OUT_CAP);
180 spec->def_amp_in_caps = snd_hda_param_read(codec, codec->afg, AC_PAR_AMP_IN_CAP); 181 spec->def_amp_in_caps = snd_hda_param_read(codec, codec->afg, AC_PAR_AMP_IN_CAP);
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 1c53e337ecb2..b2bcd94cf7a2 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1646,7 +1646,8 @@ static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec,
1646 if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams) 1646 if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams)
1647 return 0; 1647 return 0;
1648 1648
1649 snd_assert(cpcm->name, return -EINVAL); 1649 if (snd_BUG_ON(!cpcm->name))
1650 return -EINVAL;
1650 1651
1651 err = snd_pcm_new(chip->card, cpcm->name, cpcm->device, 1652 err = snd_pcm_new(chip->card, cpcm->name, cpcm->device,
1652 cpcm->stream[0].substreams, 1653 cpcm->stream[0].substreams,
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 4bd26725355c..7e5422f64caf 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -2633,12 +2633,14 @@ static int alc_build_pcms(struct hda_codec *codec)
2633 2633
2634 info->name = spec->stream_name_analog; 2634 info->name = spec->stream_name_analog;
2635 if (spec->stream_analog_playback) { 2635 if (spec->stream_analog_playback) {
2636 snd_assert(spec->multiout.dac_nids, return -EINVAL); 2636 if (snd_BUG_ON(!spec->multiout.dac_nids))
2637 return -EINVAL;
2637 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); 2638 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2638 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; 2639 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2639 } 2640 }
2640 if (spec->stream_analog_capture) { 2641 if (spec->stream_analog_capture) {
2641 snd_assert(spec->adc_nids, return -EINVAL); 2642 if (snd_BUG_ON(!spec->adc_nids))
2643 return -EINVAL;
2642 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); 2644 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2643 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 2645 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2644 } 2646 }
diff --git a/sound/pci/ice1712/ak4xxx.c b/sound/pci/ice1712/ak4xxx.c
index dab31b2756a6..03391da8c8c7 100644
--- a/sound/pci/ice1712/ak4xxx.c
+++ b/sound/pci/ice1712/ak4xxx.c
@@ -59,7 +59,8 @@ static void snd_ice1712_akm4xxx_write(struct snd_akm4xxx *ak, int chip,
59 struct snd_ak4xxx_private *priv = (void *)ak->private_value[0]; 59 struct snd_ak4xxx_private *priv = (void *)ak->private_value[0];
60 struct snd_ice1712 *ice = ak->private_data[0]; 60 struct snd_ice1712 *ice = ak->private_data[0];
61 61
62 snd_assert(chip >= 0 && chip < 4, return); 62 if (snd_BUG_ON(chip < 0 || chip >= 4))
63 return;
63 64
64 tmp = snd_ice1712_gpio_read(ice); 65 tmp = snd_ice1712_gpio_read(ice);
65 tmp |= priv->add_flags; 66 tmp |= priv->add_flags;
diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c
index 013fc4f04822..6fe35b812040 100644
--- a/sound/pci/ice1712/ews.c
+++ b/sound/pci/ice1712/ews.c
@@ -149,7 +149,8 @@ static int snd_ice1712_ews88mt_chip_select(struct snd_ice1712 *ice, int chip_mas
149 struct ews_spec *spec = ice->spec; 149 struct ews_spec *spec = ice->spec;
150 unsigned char data, ndata; 150 unsigned char data, ndata;
151 151
152 snd_assert(chip_mask >= 0 && chip_mask <= 0x0f, return -EINVAL); 152 if (snd_BUG_ON(chip_mask < 0 || chip_mask > 0x0f))
153 return -EINVAL;
153 snd_i2c_lock(ice->i2c); 154 snd_i2c_lock(ice->i2c);
154 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF2], &data, 1) != 1) 155 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF2], &data, 1) != 1)
155 goto __error; 156 goto __error;
@@ -685,7 +686,8 @@ static int snd_ice1712_ews88mt_input_sense_get(struct snd_kcontrol *kcontrol, st
685 int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 686 int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
686 unsigned char data; 687 unsigned char data;
687 688
688 snd_assert(channel >= 0 && channel <= 7, return 0); 689 if (snd_BUG_ON(channel < 0 || channel > 7))
690 return 0;
689 snd_i2c_lock(ice->i2c); 691 snd_i2c_lock(ice->i2c);
690 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) { 692 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
691 snd_i2c_unlock(ice->i2c); 693 snd_i2c_unlock(ice->i2c);
@@ -705,7 +707,8 @@ static int snd_ice1712_ews88mt_input_sense_put(struct snd_kcontrol *kcontrol, st
705 int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 707 int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
706 unsigned char data, ndata; 708 unsigned char data, ndata;
707 709
708 snd_assert(channel >= 0 && channel <= 7, return 0); 710 if (snd_BUG_ON(channel < 0 || channel > 7))
711 return 0;
709 snd_i2c_lock(ice->i2c); 712 snd_i2c_lock(ice->i2c);
710 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) { 713 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
711 snd_i2c_unlock(ice->i2c); 714 snd_i2c_unlock(ice->i2c);
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 29d449d73c98..05ffab65d167 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -2416,7 +2416,8 @@ int __devinit snd_ice1712_spdif_build_controls(struct snd_ice1712 *ice)
2416 int err; 2416 int err;
2417 struct snd_kcontrol *kctl; 2417 struct snd_kcontrol *kctl;
2418 2418
2419 snd_assert(ice->pcm_pro != NULL, return -EIO); 2419 if (snd_BUG_ON(!ice->pcm_pro))
2420 return -EIO;
2420 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_default, ice)); 2421 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_default, ice));
2421 if (err < 0) 2422 if (err < 0)
2422 return err; 2423 return err;
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index e596d777d9dd..60119d220a66 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -2250,7 +2250,8 @@ static int __devinit snd_vt1724_spdif_build_controls(struct snd_ice1712 *ice)
2250 int err; 2250 int err;
2251 struct snd_kcontrol *kctl; 2251 struct snd_kcontrol *kctl;
2252 2252
2253 snd_assert(ice->pcm != NULL, return -EIO); 2253 if (snd_BUG_ON(!ice->pcm))
2254 return -EIO;
2254 2255
2255 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_mixer_pro_spdif_route, ice)); 2256 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_mixer_pro_spdif_route, ice));
2256 if (err < 0) 2257 if (err < 0)
diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c
index b4e0c16852a6..21ff4de890b4 100644
--- a/sound/pci/ice1712/juli.c
+++ b/sound/pci/ice1712/juli.c
@@ -208,7 +208,8 @@ static void juli_akm_write(struct snd_akm4xxx *ak, int chip,
208{ 208{
209 struct snd_ice1712 *ice = ak->private_data[0]; 209 struct snd_ice1712 *ice = ak->private_data[0];
210 210
211 snd_assert(chip == 0, return); 211 if (snd_BUG_ON(chip))
212 return;
212 snd_vt1724_write_i2c(ice, AK4358_ADDR, addr, data); 213 snd_vt1724_write_i2c(ice, AK4358_ADDR, addr, data);
213} 214}
214 215
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 048d99e25ab0..78760996632d 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -2132,8 +2132,8 @@ static int __devinit snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock,
2132 snd_intel8x0_codec_read_test(chip, codecs); 2132 snd_intel8x0_codec_read_test(chip, codecs);
2133 chip->ac97_sdin[codecs] = 2133 chip->ac97_sdin[codecs] =
2134 igetbyte(chip, ICHREG(SDM)) & ICH_LDI_MASK; 2134 igetbyte(chip, ICHREG(SDM)) & ICH_LDI_MASK;
2135 snd_assert(chip->ac97_sdin[codecs] < 3, 2135 if (snd_BUG_ON(chip->ac97_sdin[codecs] >= 3))
2136 chip->ac97_sdin[codecs] = 0); 2136 chip->ac97_sdin[codecs] = 0;
2137 } else 2137 } else
2138 chip->ac97_sdin[codecs] = i; 2138 chip->ac97_sdin[codecs] = i;
2139 codecs++; 2139 codecs++;
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index faf674e671ac..93449e464566 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -306,7 +306,8 @@ static unsigned int get_ich_codec_bit(struct intel8x0m *chip, unsigned int codec
306 static unsigned int codec_bit[3] = { 306 static unsigned int codec_bit[3] = {
307 ICH_PCR, ICH_SCR, ICH_TCR 307 ICH_PCR, ICH_SCR, ICH_TCR
308 }; 308 };
309 snd_assert(codec < 3, return ICH_PCR); 309 if (snd_BUG_ON(codec >= 3))
310 return ICH_PCR;
310 return codec_bit[codec]; 311 return codec_bit[codec];
311} 312}
312 313
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 4a44c0f20f76..5f8006b42750 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -1281,7 +1281,8 @@ static int snd_korg1212_silence(struct snd_korg1212 *korg1212, int pos, int coun
1281 1281
1282 K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_silence pos=%d offset=%d size=%d count=%d\n", 1282 K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_silence pos=%d offset=%d size=%d count=%d\n",
1283 pos, offset, size, count); 1283 pos, offset, size, count);
1284 snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL); 1284 if (snd_BUG_ON(pos + count > K1212_MAX_SAMPLES))
1285 return -EINVAL;
1285 1286
1286 for (i=0; i < count; i++) { 1287 for (i=0; i < count; i++) {
1287#if K1212_DEBUG_LEVEL > 0 1288#if K1212_DEBUG_LEVEL > 0
@@ -1306,7 +1307,8 @@ static int snd_korg1212_copy_to(struct snd_korg1212 *korg1212, void __user *dst,
1306 1307
1307 K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_to pos=%d offset=%d size=%d\n", 1308 K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_to pos=%d offset=%d size=%d\n",
1308 pos, offset, size); 1309 pos, offset, size);
1309 snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL); 1310 if (snd_BUG_ON(pos + count > K1212_MAX_SAMPLES))
1311 return -EINVAL;
1310 1312
1311 for (i=0; i < count; i++) { 1313 for (i=0; i < count; i++) {
1312#if K1212_DEBUG_LEVEL > 0 1314#if K1212_DEBUG_LEVEL > 0
@@ -1336,7 +1338,8 @@ static int snd_korg1212_copy_from(struct snd_korg1212 *korg1212, void __user *sr
1336 K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_from pos=%d offset=%d size=%d count=%d\n", 1338 K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_from pos=%d offset=%d size=%d count=%d\n",
1337 pos, offset, size, count); 1339 pos, offset, size, count);
1338 1340
1339 snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL); 1341 if (snd_BUG_ON(pos + count > K1212_MAX_SAMPLES))
1342 return -EINVAL;
1340 1343
1341 for (i=0; i < count; i++) { 1344 for (i=0; i < count; i++) {
1342#if K1212_DEBUG_LEVEL > 0 1345#if K1212_DEBUG_LEVEL > 0
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 0037be74fdea..9ff3f9e34404 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -1175,7 +1175,8 @@ snd_m3_pcm_trigger(struct snd_pcm_substream *subs, int cmd)
1175 struct m3_dma *s = subs->runtime->private_data; 1175 struct m3_dma *s = subs->runtime->private_data;
1176 int err = -EINVAL; 1176 int err = -EINVAL;
1177 1177
1178 snd_assert(s != NULL, return -ENXIO); 1178 if (snd_BUG_ON(!s))
1179 return -ENXIO;
1179 1180
1180 spin_lock(&chip->reg_lock); 1181 spin_lock(&chip->reg_lock);
1181 switch (cmd) { 1182 switch (cmd) {
@@ -1487,7 +1488,8 @@ snd_m3_pcm_prepare(struct snd_pcm_substream *subs)
1487 struct snd_pcm_runtime *runtime = subs->runtime; 1488 struct snd_pcm_runtime *runtime = subs->runtime;
1488 struct m3_dma *s = runtime->private_data; 1489 struct m3_dma *s = runtime->private_data;
1489 1490
1490 snd_assert(s != NULL, return -ENXIO); 1491 if (snd_BUG_ON(!s))
1492 return -ENXIO;
1491 1493
1492 if (runtime->format != SNDRV_PCM_FORMAT_U8 && 1494 if (runtime->format != SNDRV_PCM_FORMAT_U8 &&
1493 runtime->format != SNDRV_PCM_FORMAT_S16_LE) 1495 runtime->format != SNDRV_PCM_FORMAT_S16_LE)
@@ -1546,7 +1548,9 @@ snd_m3_pcm_pointer(struct snd_pcm_substream *subs)
1546 struct snd_m3 *chip = snd_pcm_substream_chip(subs); 1548 struct snd_m3 *chip = snd_pcm_substream_chip(subs);
1547 unsigned int ptr; 1549 unsigned int ptr;
1548 struct m3_dma *s = subs->runtime->private_data; 1550 struct m3_dma *s = subs->runtime->private_data;
1549 snd_assert(s != NULL, return 0); 1551
1552 if (snd_BUG_ON(!s))
1553 return 0;
1550 1554
1551 spin_lock(&chip->reg_lock); 1555 spin_lock(&chip->reg_lock);
1552 ptr = snd_m3_get_pointer(chip, s, subs); 1556 ptr = snd_m3_get_pointer(chip, s, subs);
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index 3dd0c7963273..2d0dce649a64 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -708,7 +708,7 @@ static int snd_mixart_playback_open(struct snd_pcm_substream *subs)
708 pcm_number = MIXART_PCM_ANALOG; 708 pcm_number = MIXART_PCM_ANALOG;
709 runtime->hw = snd_mixart_analog_caps; 709 runtime->hw = snd_mixart_analog_caps;
710 } else { 710 } else {
711 snd_assert ( pcm == chip->pcm_dig ); 711 snd_BUG_ON(pcm != chip->pcm_dig);
712 pcm_number = MIXART_PCM_DIGITAL; 712 pcm_number = MIXART_PCM_DIGITAL;
713 runtime->hw = snd_mixart_digital_caps; 713 runtime->hw = snd_mixart_digital_caps;
714 } 714 }
@@ -783,7 +783,7 @@ static int snd_mixart_capture_open(struct snd_pcm_substream *subs)
783 pcm_number = MIXART_PCM_ANALOG; 783 pcm_number = MIXART_PCM_ANALOG;
784 runtime->hw = snd_mixart_analog_caps; 784 runtime->hw = snd_mixart_analog_caps;
785 } else { 785 } else {
786 snd_assert ( pcm == chip->pcm_dig ); 786 snd_BUG_ON(pcm != chip->pcm_dig);
787 pcm_number = MIXART_PCM_DIGITAL; 787 pcm_number = MIXART_PCM_DIGITAL;
788 runtime->hw = snd_mixart_digital_caps; 788 runtime->hw = snd_mixart_digital_caps;
789 } 789 }
diff --git a/sound/pci/mixart/mixart_core.c b/sound/pci/mixart/mixart_core.c
index 785085e48353..b9a06c279397 100644
--- a/sound/pci/mixart/mixart_core.c
+++ b/sound/pci/mixart/mixart_core.c
@@ -56,8 +56,10 @@ static int retrieve_msg_frame(struct mixart_mgr *mgr, u32 *msg_frame)
56 if (tailptr == headptr) 56 if (tailptr == headptr)
57 return 0; /* no message posted */ 57 return 0; /* no message posted */
58 58
59 snd_assert( tailptr >= MSG_OUTBOUND_POST_STACK, return 0); /* error */ 59 if (tailptr < MSG_OUTBOUND_POST_STACK)
60 snd_assert( tailptr < (MSG_OUTBOUND_POST_STACK+MSG_BOUND_STACK_SIZE), return 0); /* error */ 60 return 0; /* error */
61 if (tailptr >= MSG_OUTBOUND_POST_STACK + MSG_BOUND_STACK_SIZE)
62 return 0; /* error */
61 63
62 *msg_frame = readl_be(MIXART_MEM(mgr, tailptr)); 64 *msg_frame = readl_be(MIXART_MEM(mgr, tailptr));
63 65
@@ -149,7 +151,8 @@ static int send_msg( struct mixart_mgr *mgr,
149 u32 msg_frame_address; 151 u32 msg_frame_address;
150 int err, i; 152 int err, i;
151 153
152 snd_assert(msg->size % 4 == 0, return -EINVAL); 154 if (snd_BUG_ON(msg->size % 4))
155 return -EINVAL;
153 156
154 err = 0; 157 err = 0;
155 158
@@ -289,9 +292,12 @@ int snd_mixart_send_msg_wait_notif(struct mixart_mgr *mgr,
289 wait_queue_t wait; 292 wait_queue_t wait;
290 long timeout; 293 long timeout;
291 294
292 snd_assert(notif_event != 0, return -EINVAL); 295 if (snd_BUG_ON(!notif_event))
293 snd_assert((notif_event & MSG_TYPE_MASK) == MSG_TYPE_NOTIFY, return -EINVAL); 296 return -EINVAL;
294 snd_assert((notif_event & MSG_CANCEL_NOTIFY_MASK) == 0, return -EINVAL); 297 if (snd_BUG_ON((notif_event & MSG_TYPE_MASK) != MSG_TYPE_NOTIFY))
298 return -EINVAL;
299 if (snd_BUG_ON(notif_event & MSG_CANCEL_NOTIFY_MASK))
300 return -EINVAL;
295 301
296 mutex_lock(&mgr->msg_mutex); 302 mutex_lock(&mgr->msg_mutex);
297 303
diff --git a/sound/pci/mixart/mixart_hwdep.c b/sound/pci/mixart/mixart_hwdep.c
index f98603146132..3782b52bc0e8 100644
--- a/sound/pci/mixart/mixart_hwdep.c
+++ b/sound/pci/mixart/mixart_hwdep.c
@@ -288,7 +288,9 @@ static int mixart_enum_physio(struct mixart_mgr *mgr)
288 return -EINVAL; 288 return -EINVAL;
289 } 289 }
290 290
291 snd_assert(phys_io.nb_uid >= (MIXART_MAX_CARDS * 2), return -EINVAL); /* min 2 phys io per card (analog in + analog out) */ 291 /* min 2 phys io per card (analog in + analog out) */
292 if (phys_io.nb_uid < MIXART_MAX_CARDS * 2)
293 return -EINVAL;
292 294
293 for(k=0; k<mgr->num_cards; k++) { 295 for(k=0; k<mgr->num_cards; k++) {
294 mgr->chip[k]->uid_in_analog_physio = phys_io.uid[k]; 296 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
363 } 365 }
364 366
365 /* check xilinx validity */ 367 /* check xilinx validity */
366 snd_assert(((u32*)(dsp->data))[0]==0xFFFFFFFF, return -EINVAL); 368 if (((u32*)(dsp->data))[0] == 0xffffffff)
367 snd_assert(dsp->size % 4 == 0, return -EINVAL); 369 return -EINVAL;
370 if (dsp->size % 4)
371 return -EINVAL;
368 372
369 /* set xilinx status to copying */ 373 /* set xilinx status to copying */
370 writel_be( 1, MIXART_MEM( mgr, MIXART_PSEUDOREG_MXLX_STATUS_OFFSET )); 374 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
462 } 466 }
463 467
464 /* check daughterboard xilinx validity */ 468 /* check daughterboard xilinx validity */
465 snd_assert(((u32*)(dsp->data))[0]==0xFFFFFFFF, return -EINVAL); 469 if (((u32*)(dsp->data))[0] == 0xffffffff)
466 snd_assert(dsp->size % 4 == 0, return -EINVAL); 470 return -EINVAL;
471 if (dsp->size % 4)
472 return -EINVAL;
467 473
468 /* inform mixart about the size of the file */ 474 /* inform mixart about the size of the file */
469 writel_be( dsp->size, MIXART_MEM( mgr, MIXART_PSEUDOREG_DXLX_SIZE_OFFSET )); 475 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
480 486
481 /* get the address where to write the file */ 487 /* get the address where to write the file */
482 val = readl_be( MIXART_MEM( mgr, MIXART_PSEUDOREG_DXLX_BASE_ADDR_OFFSET )); 488 val = readl_be( MIXART_MEM( mgr, MIXART_PSEUDOREG_DXLX_BASE_ADDR_OFFSET ));
483 snd_assert(val != 0, return -EINVAL); 489 if (!val)
490 return -EINVAL;
484 491
485 /* copy daughterboard xilinx code */ 492 /* copy daughterboard xilinx code */
486 memcpy_toio( MIXART_MEM( mgr, val), dsp->data, dsp->size); 493 memcpy_toio( MIXART_MEM( mgr, val), dsp->data, dsp->size);
diff --git a/sound/pci/mixart/mixart_mixer.c b/sound/pci/mixart/mixart_mixer.c
index 6fdda1f70b25..3ba6174c3df1 100644
--- a/sound/pci/mixart/mixart_mixer.c
+++ b/sound/pci/mixart/mixart_mixer.c
@@ -837,7 +837,7 @@ static int mixart_pcm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
837 if(is_aes) stored_volume = chip->digital_capture_volume[1]; /* AES capture */ 837 if(is_aes) stored_volume = chip->digital_capture_volume[1]; /* AES capture */
838 else stored_volume = chip->digital_capture_volume[0]; /* analog capture */ 838 else stored_volume = chip->digital_capture_volume[0]; /* analog capture */
839 } else { 839 } else {
840 snd_assert ( idx < MIXART_PLAYBACK_STREAMS ); 840 snd_BUG_ON(idx >= MIXART_PLAYBACK_STREAMS);
841 if(is_aes) stored_volume = chip->digital_playback_volume[MIXART_PLAYBACK_STREAMS + idx]; /* AES playback */ 841 if(is_aes) stored_volume = chip->digital_playback_volume[MIXART_PLAYBACK_STREAMS + idx]; /* AES playback */
842 else stored_volume = chip->digital_playback_volume[idx]; /* analog playback */ 842 else stored_volume = chip->digital_playback_volume[idx]; /* analog playback */
843 } 843 }
@@ -863,7 +863,7 @@ static int mixart_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
863 else /* analog capture */ 863 else /* analog capture */
864 stored_volume = chip->digital_capture_volume[0]; 864 stored_volume = chip->digital_capture_volume[0];
865 } else { 865 } else {
866 snd_assert ( idx < MIXART_PLAYBACK_STREAMS ); 866 snd_BUG_ON(idx >= MIXART_PLAYBACK_STREAMS);
867 if (is_aes) /* AES playback */ 867 if (is_aes) /* AES playback */
868 stored_volume = chip->digital_playback_volume[MIXART_PLAYBACK_STREAMS + idx]; 868 stored_volume = chip->digital_playback_volume[MIXART_PLAYBACK_STREAMS + idx];
869 else /* analog playback */ 869 else /* analog playback */
@@ -909,7 +909,7 @@ static int mixart_pcm_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
909{ 909{
910 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); 910 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
911 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ 911 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
912 snd_assert ( idx < MIXART_PLAYBACK_STREAMS ); 912 snd_BUG_ON(idx >= MIXART_PLAYBACK_STREAMS);
913 mutex_lock(&chip->mgr->mixer_mutex); 913 mutex_lock(&chip->mgr->mixer_mutex);
914 if(kcontrol->private_value & MIXART_VOL_AES_MASK) /* AES playback */ 914 if(kcontrol->private_value & MIXART_VOL_AES_MASK) /* AES playback */
915 idx += MIXART_PLAYBACK_STREAMS; 915 idx += MIXART_PLAYBACK_STREAMS;
@@ -926,7 +926,7 @@ static int mixart_pcm_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
926 int is_aes = kcontrol->private_value & MIXART_VOL_AES_MASK; 926 int is_aes = kcontrol->private_value & MIXART_VOL_AES_MASK;
927 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ 927 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
928 int i, j; 928 int i, j;
929 snd_assert ( idx < MIXART_PLAYBACK_STREAMS ); 929 snd_BUG_ON(idx >= MIXART_PLAYBACK_STREAMS);
930 mutex_lock(&chip->mgr->mixer_mutex); 930 mutex_lock(&chip->mgr->mixer_mutex);
931 j = idx; 931 j = idx;
932 if (is_aes) 932 if (is_aes)
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index 06d13e717114..50c9f8a05082 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -562,7 +562,8 @@ snd_nm256_playback_trigger(struct snd_pcm_substream *substream, int cmd)
562 struct nm256_stream *s = substream->runtime->private_data; 562 struct nm256_stream *s = substream->runtime->private_data;
563 int err = 0; 563 int err = 0;
564 564
565 snd_assert(s != NULL, return -ENXIO); 565 if (snd_BUG_ON(!s))
566 return -ENXIO;
566 567
567 spin_lock(&chip->reg_lock); 568 spin_lock(&chip->reg_lock);
568 switch (cmd) { 569 switch (cmd) {
@@ -599,7 +600,8 @@ snd_nm256_capture_trigger(struct snd_pcm_substream *substream, int cmd)
599 struct nm256_stream *s = substream->runtime->private_data; 600 struct nm256_stream *s = substream->runtime->private_data;
600 int err = 0; 601 int err = 0;
601 602
602 snd_assert(s != NULL, return -ENXIO); 603 if (snd_BUG_ON(!s))
604 return -ENXIO;
603 605
604 spin_lock(&chip->reg_lock); 606 spin_lock(&chip->reg_lock);
605 switch (cmd) { 607 switch (cmd) {
@@ -635,7 +637,8 @@ static int snd_nm256_pcm_prepare(struct snd_pcm_substream *substream)
635 struct snd_pcm_runtime *runtime = substream->runtime; 637 struct snd_pcm_runtime *runtime = substream->runtime;
636 struct nm256_stream *s = runtime->private_data; 638 struct nm256_stream *s = runtime->private_data;
637 639
638 snd_assert(s, return -ENXIO); 640 if (snd_BUG_ON(!s))
641 return -ENXIO;
639 s->dma_size = frames_to_bytes(runtime, substream->runtime->buffer_size); 642 s->dma_size = frames_to_bytes(runtime, substream->runtime->buffer_size);
640 s->period_size = frames_to_bytes(runtime, substream->runtime->period_size); 643 s->period_size = frames_to_bytes(runtime, substream->runtime->period_size);
641 s->periods = substream->runtime->periods; 644 s->periods = substream->runtime->periods;
@@ -660,7 +663,8 @@ snd_nm256_playback_pointer(struct snd_pcm_substream *substream)
660 struct nm256_stream *s = substream->runtime->private_data; 663 struct nm256_stream *s = substream->runtime->private_data;
661 unsigned long curp; 664 unsigned long curp;
662 665
663 snd_assert(s, return 0); 666 if (snd_BUG_ON(!s))
667 return 0;
664 curp = snd_nm256_readl(chip, NM_PBUFFER_CURRP) - (unsigned long)s->buf; 668 curp = snd_nm256_readl(chip, NM_PBUFFER_CURRP) - (unsigned long)s->buf;
665 curp %= s->dma_size; 669 curp %= s->dma_size;
666 return bytes_to_frames(substream->runtime, curp); 670 return bytes_to_frames(substream->runtime, curp);
@@ -673,7 +677,8 @@ snd_nm256_capture_pointer(struct snd_pcm_substream *substream)
673 struct nm256_stream *s = substream->runtime->private_data; 677 struct nm256_stream *s = substream->runtime->private_data;
674 unsigned long curp; 678 unsigned long curp;
675 679
676 snd_assert(s != NULL, return 0); 680 if (snd_BUG_ON(!s))
681 return 0;
677 curp = snd_nm256_readl(chip, NM_RBUFFER_CURRP) - (unsigned long)s->buf; 682 curp = snd_nm256_readl(chip, NM_RBUFFER_CURRP) - (unsigned long)s->buf;
678 curp %= s->dma_size; 683 curp %= s->dma_size;
679 return bytes_to_frames(substream->runtime, curp); 684 return bytes_to_frames(substream->runtime, curp);
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index 2c7e25336795..0e06c6c9fcc0 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -464,7 +464,8 @@ static int pcxhr_update_r_buffer(struct pcxhr_stream *stream)
464 pcxhr_init_rmh(&rmh, CMD_UPDATE_R_BUFFERS); 464 pcxhr_init_rmh(&rmh, CMD_UPDATE_R_BUFFERS);
465 pcxhr_set_pipe_cmd_params(&rmh, is_capture, stream->pipe->first_audio, stream_num, 0); 465 pcxhr_set_pipe_cmd_params(&rmh, is_capture, stream->pipe->first_audio, stream_num, 0);
466 466
467 snd_assert(subs->runtime->dma_bytes < 0x200000); /* max buffer size is 2 MByte */ 467 /* max buffer size is 2 MByte */
468 snd_BUG_ON(subs->runtime->dma_bytes >= 0x200000);
468 rmh.cmd[1] = subs->runtime->dma_bytes * 8; /* size in bits */ 469 rmh.cmd[1] = subs->runtime->dma_bytes * 8; /* size in bits */
469 rmh.cmd[2] = subs->runtime->dma_addr >> 24; /* most significant byte */ 470 rmh.cmd[2] = subs->runtime->dma_addr >> 24; /* most significant byte */
470 rmh.cmd[2] |= 1<<19; /* this is a circular buffer */ 471 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
1228 return -ENOMEM; 1229 return -ENOMEM;
1229 } 1230 }
1230 1231
1231 snd_assert(pci_id->driver_data < PCI_ID_LAST, return -ENODEV); 1232 if (snd_BUG_ON(pci_id->driver_data >= PCI_ID_LAST))
1233 return -ENODEV;
1232 card_name = pcxhr_board_params[pci_id->driver_data].board_name; 1234 card_name = pcxhr_board_params[pci_id->driver_data].board_name;
1233 mgr->playback_chips = pcxhr_board_params[pci_id->driver_data].playback_chips; 1235 mgr->playback_chips = pcxhr_board_params[pci_id->driver_data].playback_chips;
1234 mgr->capture_chips = pcxhr_board_params[pci_id->driver_data].capture_chips; 1236 mgr->capture_chips = pcxhr_board_params[pci_id->driver_data].capture_chips;
diff --git a/sound/pci/pcxhr/pcxhr_core.c b/sound/pci/pcxhr/pcxhr_core.c
index 000e6fed6e39..7143259cfe34 100644
--- a/sound/pci/pcxhr/pcxhr_core.c
+++ b/sound/pci/pcxhr/pcxhr_core.c
@@ -319,16 +319,20 @@ static int pcxhr_download_dsp(struct pcxhr_mgr *mgr, const struct firmware *dsp)
319 const unsigned char *data; 319 const unsigned char *data;
320 unsigned char dummy; 320 unsigned char dummy;
321 /* check the length of boot image */ 321 /* check the length of boot image */
322 snd_assert(dsp->size > 0, return -EINVAL); 322 if (dsp->size <= 0)
323 snd_assert(dsp->size % 3 == 0, return -EINVAL); 323 return -EINVAL;
324 snd_assert(dsp->data, return -EINVAL); 324 if (dsp->size % 3)
325 return -EINVAL;
326 if (snd_BUG_ON(!dsp->data))
327 return -EINVAL;
325 /* transfert data buffer from PC to DSP */ 328 /* transfert data buffer from PC to DSP */
326 for (i = 0; i < dsp->size; i += 3) { 329 for (i = 0; i < dsp->size; i += 3) {
327 data = dsp->data + i; 330 data = dsp->data + i;
328 if (i == 0) { 331 if (i == 0) {
329 /* test data header consistency */ 332 /* test data header consistency */
330 len = (unsigned int)((data[0]<<16) + (data[1]<<8) + data[2]); 333 len = (unsigned int)((data[0]<<16) + (data[1]<<8) + data[2]);
331 snd_assert((len==0) || (dsp->size == (len+2)*3), return -EINVAL); 334 if (len && dsp->size != (len + 2) * 3)
335 return -EINVAL;
332 } 336 }
333 /* wait DSP ready for new transfer */ 337 /* wait DSP ready for new transfer */
334 err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_TRDY, 338 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)
389 unsigned char dummy; 393 unsigned char dummy;
390 394
391 /* send the hostport address to the DSP (only the upper 24 bit !) */ 395 /* send the hostport address to the DSP (only the upper 24 bit !) */
392 snd_assert((physaddr & 0xff) == 0, return -EINVAL); 396 if (snd_BUG_ON(physaddr & 0xff))
397 return -EINVAL;
393 PCXHR_OUTPL(mgr, PCXHR_PLX_MBOX1, (physaddr >> 8)); 398 PCXHR_OUTPL(mgr, PCXHR_PLX_MBOX1, (physaddr >> 8));
394 399
395 err = pcxhr_send_it_dsp(mgr, PCXHR_IT_DOWNLOAD_BOOT, 0); 400 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)
570 u32 data; 575 u32 data;
571 unsigned char reg; 576 unsigned char reg;
572 577
573 snd_assert(rmh->cmd_len<PCXHR_SIZE_MAX_CMD, return -EINVAL); 578 if (snd_BUG_ON(rmh->cmd_len >= PCXHR_SIZE_MAX_CMD))
579 return -EINVAL;
574 err = pcxhr_send_it_dsp(mgr, PCXHR_IT_MESSAGE, 1); 580 err = pcxhr_send_it_dsp(mgr, PCXHR_IT_MESSAGE, 1);
575 if (err) { 581 if (err) {
576 snd_printk(KERN_ERR "pcxhr_send_message : ED_DSP_CRASHED\n"); 582 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)
677 */ 683 */
678void pcxhr_init_rmh(struct pcxhr_rmh *rmh, int cmd) 684void pcxhr_init_rmh(struct pcxhr_rmh *rmh, int cmd)
679{ 685{
680 snd_assert(cmd < CMD_LAST_INDEX, return); 686 if (snd_BUG_ON(cmd >= CMD_LAST_INDEX))
687 return;
681 rmh->cmd[0] = pcxhr_dsp_cmds[cmd].opcode; 688 rmh->cmd[0] = pcxhr_dsp_cmds[cmd].opcode;
682 rmh->cmd_len = 1; 689 rmh->cmd_len = 1;
683 rmh->stat_len = pcxhr_dsp_cmds[cmd].st_length; 690 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,
690 unsigned int param1, unsigned int param2, 697 unsigned int param1, unsigned int param2,
691 unsigned int param3) 698 unsigned int param3)
692{ 699{
693 snd_assert(param1 <= MASK_FIRST_FIELD); 700 snd_BUG_ON(param1 > MASK_FIRST_FIELD);
694 if (capture) 701 if (capture)
695 rmh->cmd[0] |= 0x800; /* COMMAND_RECORD_MASK */ 702 rmh->cmd[0] |= 0x800; /* COMMAND_RECORD_MASK */
696 if (param1) 703 if (param1)
697 rmh->cmd[0] |= (param1 << FIELD_SIZE); 704 rmh->cmd[0] |= (param1 << FIELD_SIZE);
698 if (param2) { 705 if (param2) {
699 snd_assert(param2 <= MASK_FIRST_FIELD); 706 snd_BUG_ON(param2 > MASK_FIRST_FIELD);
700 rmh->cmd[0] |= param2; 707 rmh->cmd[0] |= param2;
701 } 708 }
702 if(param3) { 709 if(param3) {
703 snd_assert(param3 <= MASK_DSP_WORD); 710 snd_BUG_ON(param3 > MASK_DSP_WORD);
704 rmh->cmd[1] = param3; 711 rmh->cmd[1] = param3;
705 rmh->cmd_len = 2; 712 rmh->cmd_len = 2;
706 } 713 }
diff --git a/sound/pci/pcxhr/pcxhr_hwdep.c b/sound/pci/pcxhr/pcxhr_hwdep.c
index d2f043278cf4..96640d9c227d 100644
--- a/sound/pci/pcxhr/pcxhr_hwdep.c
+++ b/sound/pci/pcxhr/pcxhr_hwdep.c
@@ -65,15 +65,18 @@ static int pcxhr_init_board(struct pcxhr_mgr *mgr)
65 if (err) 65 if (err)
66 return err; 66 return err;
67 /* test 8 or 12 phys out */ 67 /* test 8 or 12 phys out */
68 snd_assert((rmh.stat[0] & MASK_FIRST_FIELD) == mgr->playback_chips*2, 68 if ((rmh.stat[0] & MASK_FIRST_FIELD) != mgr->playback_chips * 2)
69 return -EINVAL); 69 return -EINVAL;
70 /* test 8 or 2 phys in */ 70 /* test 8 or 2 phys in */
71 snd_assert(((rmh.stat[0] >> (2*FIELD_SIZE)) & MASK_FIRST_FIELD) == 71 if (((rmh.stat[0] >> (2 * FIELD_SIZE)) & MASK_FIRST_FIELD) !=
72 mgr->capture_chips * 2, return -EINVAL); 72 mgr->capture_chips * 2)
73 return -EINVAL;
73 /* test max nb substream per board */ 74 /* test max nb substream per board */
74 snd_assert((rmh.stat[1] & 0x5F) >= card_streams, return -EINVAL); 75 if ((rmh.stat[1] & 0x5F) < card_streams)
76 return -EINVAL;
75 /* test max nb substream per pipe */ 77 /* test max nb substream per pipe */
76 snd_assert(((rmh.stat[1]>>7)&0x5F) >= PCXHR_PLAYBACK_STREAMS, return -EINVAL); 78 if (((rmh.stat[1] >> 7) & 0x5F) < PCXHR_PLAYBACK_STREAMS)
79 return -EINVAL;
77 80
78 pcxhr_init_rmh(&rmh, CMD_VERSION); 81 pcxhr_init_rmh(&rmh, CMD_VERSION);
79 /* firmware num for DSP */ 82 /* firmware num for DSP */
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index 6a3596247348..124f9a2f1535 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -865,7 +865,8 @@ static int sendcmd(struct cmdif *cif, u32 flags, u32 cmd, u32 parm,
865 struct riptideport *hwport; 865 struct riptideport *hwport;
866 struct cmdport *cmdport = NULL; 866 struct cmdport *cmdport = NULL;
867 867
868 snd_assert(cif, return -EINVAL); 868 if (snd_BUG_ON(!cif))
869 return -EINVAL;
869 870
870 hwport = cif->hwport; 871 hwport = cif->hwport;
871 if (cif->errcnt > MAX_ERROR_COUNT) { 872 if (cif->errcnt > MAX_ERROR_COUNT) {
@@ -1490,7 +1491,8 @@ static int snd_riptide_prepare(struct snd_pcm_substream *substream)
1490 int err = 0; 1491 int err = 0;
1491 snd_pcm_format_t format; 1492 snd_pcm_format_t format;
1492 1493
1493 snd_assert(cif && data, return -EINVAL); 1494 if (snd_BUG_ON(!cif || !data))
1495 return -EINVAL;
1494 1496
1495 snd_printdd("prepare id %d ch: %d f:0x%x r:%d\n", data->id, 1497 snd_printdd("prepare id %d ch: %d f:0x%x r:%d\n", data->id,
1496 runtime->channels, runtime->format, runtime->rate); 1498 runtime->channels, runtime->format, runtime->rate);
@@ -1772,7 +1774,8 @@ snd_riptide_codec_write(struct snd_ac97 *ac97, unsigned short reg,
1772 union cmdret rptr = CMDRET_ZERO; 1774 union cmdret rptr = CMDRET_ZERO;
1773 int i = 0; 1775 int i = 0;
1774 1776
1775 snd_assert(cif, return); 1777 if (snd_BUG_ON(!cif))
1778 return;
1776 1779
1777 snd_printdd("Write AC97 reg 0x%x 0x%x\n", reg, val); 1780 snd_printdd("Write AC97 reg 0x%x 0x%x\n", reg, val);
1778 do { 1781 do {
@@ -1790,7 +1793,8 @@ static unsigned short snd_riptide_codec_read(struct snd_ac97 *ac97,
1790 struct cmdif *cif = chip->cif; 1793 struct cmdif *cif = chip->cif;
1791 union cmdret rptr = CMDRET_ZERO; 1794 union cmdret rptr = CMDRET_ZERO;
1792 1795
1793 snd_assert(cif, return 0); 1796 if (snd_BUG_ON(!cif))
1797 return 0;
1794 1798
1795 if (SEND_RACR(cif, reg, &rptr) != 0) 1799 if (SEND_RACR(cif, reg, &rptr) != 0)
1796 SEND_RACR(cif, reg, &rptr); 1800 SEND_RACR(cif, reg, &rptr);
@@ -1804,7 +1808,8 @@ static int snd_riptide_initialize(struct snd_riptide *chip)
1804 unsigned int device_id; 1808 unsigned int device_id;
1805 int err; 1809 int err;
1806 1810
1807 snd_assert(chip, return -EINVAL); 1811 if (snd_BUG_ON(!chip))
1812 return -EINVAL;
1808 1813
1809 cif = chip->cif; 1814 cif = chip->cif;
1810 if (!cif) { 1815 if (!cif) {
@@ -1836,7 +1841,8 @@ static int snd_riptide_free(struct snd_riptide *chip)
1836{ 1841{
1837 struct cmdif *cif; 1842 struct cmdif *cif;
1838 1843
1839 snd_assert(chip, return 0); 1844 if (!chip)
1845 return 0;
1840 1846
1841 if ((cif = chip->cif)) { 1847 if ((cif = chip->cif)) {
1842 SET_GRESET(cif->hwport); 1848 SET_GRESET(cif->hwport);
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 4d6fbb36ab8a..d723543beadd 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -1036,7 +1036,7 @@ static void hdsp_set_dds_value(struct hdsp *hdsp, int rate)
1036 n = DDS_NUMERATOR; 1036 n = DDS_NUMERATOR;
1037 div64_32(&n, rate, &r); 1037 div64_32(&n, rate, &r);
1038 /* n should be less than 2^32 for being written to FREQ register */ 1038 /* n should be less than 2^32 for being written to FREQ register */
1039 snd_assert((n >> 32) == 0); 1039 snd_BUG_ON(n >> 32);
1040 /* HDSP_freqReg and HDSP_resetPointer are the same, so keep the DDS 1040 /* HDSP_freqReg and HDSP_resetPointer are the same, so keep the DDS
1041 value to write it after a reset */ 1041 value to write it after a reset */
1042 hdsp->dds_value = n; 1042 hdsp->dds_value = n;
@@ -3043,7 +3043,7 @@ static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct sn
3043 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 3043 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
3044 3044
3045 offset = ucontrol->id.index - 1; 3045 offset = ucontrol->id.index - 1;
3046 snd_assert(offset >= 0); 3046 snd_BUG_ON(offset < 0);
3047 3047
3048 switch (hdsp->io_type) { 3048 switch (hdsp->io_type) {
3049 case Digiface: 3049 case Digiface:
@@ -3767,7 +3767,8 @@ static char *hdsp_channel_buffer_location(struct hdsp *hdsp,
3767{ 3767{
3768 int mapped_channel; 3768 int mapped_channel;
3769 3769
3770 snd_assert(channel >= 0 && channel < hdsp->max_channels, return NULL); 3770 if (snd_BUG_ON(channel < 0 || channel >= hdsp->max_channels))
3771 return NULL;
3771 3772
3772 if ((mapped_channel = hdsp->channel_map[channel]) < 0) 3773 if ((mapped_channel = hdsp->channel_map[channel]) < 0)
3773 return NULL; 3774 return NULL;
@@ -3784,10 +3785,12 @@ static int snd_hdsp_playback_copy(struct snd_pcm_substream *substream, int chann
3784 struct hdsp *hdsp = snd_pcm_substream_chip(substream); 3785 struct hdsp *hdsp = snd_pcm_substream_chip(substream);
3785 char *channel_buf; 3786 char *channel_buf;
3786 3787
3787 snd_assert(pos + count <= HDSP_CHANNEL_BUFFER_BYTES / 4, return -EINVAL); 3788 if (snd_BUG_ON(pos + count > HDSP_CHANNEL_BUFFER_BYTES / 4))
3789 return -EINVAL;
3788 3790
3789 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); 3791 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel);
3790 snd_assert(channel_buf != NULL, return -EIO); 3792 if (snd_BUG_ON(!channel_buf))
3793 return -EIO;
3791 if (copy_from_user(channel_buf + pos * 4, src, count * 4)) 3794 if (copy_from_user(channel_buf + pos * 4, src, count * 4))
3792 return -EFAULT; 3795 return -EFAULT;
3793 return count; 3796 return count;
@@ -3799,10 +3802,12 @@ static int snd_hdsp_capture_copy(struct snd_pcm_substream *substream, int channe
3799 struct hdsp *hdsp = snd_pcm_substream_chip(substream); 3802 struct hdsp *hdsp = snd_pcm_substream_chip(substream);
3800 char *channel_buf; 3803 char *channel_buf;
3801 3804
3802 snd_assert(pos + count <= HDSP_CHANNEL_BUFFER_BYTES / 4, return -EINVAL); 3805 if (snd_BUG_ON(pos + count > HDSP_CHANNEL_BUFFER_BYTES / 4))
3806 return -EINVAL;
3803 3807
3804 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); 3808 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel);
3805 snd_assert(channel_buf != NULL, return -EIO); 3809 if (snd_BUG_ON(!channel_buf))
3810 return -EIO;
3806 if (copy_to_user(dst, channel_buf + pos * 4, count * 4)) 3811 if (copy_to_user(dst, channel_buf + pos * 4, count * 4))
3807 return -EFAULT; 3812 return -EFAULT;
3808 return count; 3813 return count;
@@ -3815,7 +3820,8 @@ static int snd_hdsp_hw_silence(struct snd_pcm_substream *substream, int channel,
3815 char *channel_buf; 3820 char *channel_buf;
3816 3821
3817 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); 3822 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel);
3818 snd_assert(channel_buf != NULL, return -EIO); 3823 if (snd_BUG_ON(!channel_buf))
3824 return -EIO;
3819 memset(channel_buf + pos * 4, 0, count * 4); 3825 memset(channel_buf + pos * 4, 0, count * 4);
3820 return count; 3826 return count;
3821} 3827}
@@ -3927,7 +3933,8 @@ static int snd_hdsp_channel_info(struct snd_pcm_substream *substream,
3927 struct hdsp *hdsp = snd_pcm_substream_chip(substream); 3933 struct hdsp *hdsp = snd_pcm_substream_chip(substream);
3928 int mapped_channel; 3934 int mapped_channel;
3929 3935
3930 snd_assert(info->channel < hdsp->max_channels, return -EINVAL); 3936 if (snd_BUG_ON(info->channel >= hdsp->max_channels))
3937 return -EINVAL;
3931 3938
3932 if ((mapped_channel = hdsp->channel_map[info->channel]) < 0) 3939 if ((mapped_channel = hdsp->channel_map[info->channel]) < 0)
3933 return -EINVAL; 3940 return -EINVAL;
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index ab423bc82342..83c92e6082a2 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -845,7 +845,7 @@ static void hdspm_set_dds_value(struct hdspm *hdspm, int rate)
845 n = 110100480000000ULL; /* Value checked for AES32 and MADI */ 845 n = 110100480000000ULL; /* Value checked for AES32 and MADI */
846 div64_32(&n, rate, &r); 846 div64_32(&n, rate, &r);
847 /* n should be less than 2^32 for being written to FREQ register */ 847 /* n should be less than 2^32 for being written to FREQ register */
848 snd_assert((n >> 32) == 0); 848 snd_BUG_ON(n >> 32);
849 hdspm_write(hdspm, HDSPM_freqReg, (u32)n); 849 hdspm_write(hdspm, HDSPM_freqReg, (u32)n);
850} 850}
851 851
@@ -2617,8 +2617,8 @@ static int snd_hdspm_get_playback_mixer(struct snd_kcontrol *kcontrol,
2617 2617
2618 channel = ucontrol->id.index - 1; 2618 channel = ucontrol->id.index - 1;
2619 2619
2620 snd_assert(channel >= 0 2620 if (snd_BUG_ON(channel < 0 || channel >= HDSPM_MAX_CHANNELS))
2621 || channel < HDSPM_MAX_CHANNELS, return -EINVAL); 2621 return -EINVAL;
2622 2622
2623 mapped_channel = hdspm->channel_map[channel]; 2623 mapped_channel = hdspm->channel_map[channel];
2624 if (mapped_channel < 0) 2624 if (mapped_channel < 0)
@@ -2652,8 +2652,8 @@ static int snd_hdspm_put_playback_mixer(struct snd_kcontrol *kcontrol,
2652 2652
2653 channel = ucontrol->id.index - 1; 2653 channel = ucontrol->id.index - 1;
2654 2654
2655 snd_assert(channel >= 0 2655 if (snd_BUG_ON(channel < 0 || channel >= HDSPM_MAX_CHANNELS))
2656 || channel < HDSPM_MAX_CHANNELS, return -EINVAL); 2656 return -EINVAL;
2657 2657
2658 mapped_channel = hdspm->channel_map[channel]; 2658 mapped_channel = hdspm->channel_map[channel];
2659 if (mapped_channel < 0) 2659 if (mapped_channel < 0)
@@ -3496,8 +3496,8 @@ static char *hdspm_channel_buffer_location(struct hdspm * hdspm,
3496{ 3496{
3497 int mapped_channel; 3497 int mapped_channel;
3498 3498
3499 snd_assert(channel >= 0 3499 if (snd_BUG_ON(channel < 0 || channel >= HDSPM_MAX_CHANNELS))
3500 || channel < HDSPM_MAX_CHANNELS, return NULL); 3500 return NULL;
3501 3501
3502 mapped_channel = hdspm->channel_map[channel]; 3502 mapped_channel = hdspm->channel_map[channel];
3503 if (mapped_channel < 0) 3503 if (mapped_channel < 0)
@@ -3520,14 +3520,15 @@ static int snd_hdspm_playback_copy(struct snd_pcm_substream *substream,
3520 struct hdspm *hdspm = snd_pcm_substream_chip(substream); 3520 struct hdspm *hdspm = snd_pcm_substream_chip(substream);
3521 char *channel_buf; 3521 char *channel_buf;
3522 3522
3523 snd_assert(pos + count <= HDSPM_CHANNEL_BUFFER_BYTES / 4, 3523 if (snd_BUG_ON(pos + count > HDSPM_CHANNEL_BUFFER_BYTES / 4))
3524 return -EINVAL); 3524 return -EINVAL;
3525 3525
3526 channel_buf = 3526 channel_buf =
3527 hdspm_channel_buffer_location(hdspm, substream->pstr->stream, 3527 hdspm_channel_buffer_location(hdspm, substream->pstr->stream,
3528 channel); 3528 channel);
3529 3529
3530 snd_assert(channel_buf != NULL, return -EIO); 3530 if (snd_BUG_ON(!channel_buf))
3531 return -EIO;
3531 3532
3532 return copy_from_user(channel_buf + pos * 4, src, count * 4); 3533 return copy_from_user(channel_buf + pos * 4, src, count * 4);
3533} 3534}
@@ -3539,13 +3540,14 @@ static int snd_hdspm_capture_copy(struct snd_pcm_substream *substream,
3539 struct hdspm *hdspm = snd_pcm_substream_chip(substream); 3540 struct hdspm *hdspm = snd_pcm_substream_chip(substream);
3540 char *channel_buf; 3541 char *channel_buf;
3541 3542
3542 snd_assert(pos + count <= HDSPM_CHANNEL_BUFFER_BYTES / 4, 3543 if (snd_BUG_ON(pos + count > HDSPM_CHANNEL_BUFFER_BYTES / 4))
3543 return -EINVAL); 3544 return -EINVAL;
3544 3545
3545 channel_buf = 3546 channel_buf =
3546 hdspm_channel_buffer_location(hdspm, substream->pstr->stream, 3547 hdspm_channel_buffer_location(hdspm, substream->pstr->stream,
3547 channel); 3548 channel);
3548 snd_assert(channel_buf != NULL, return -EIO); 3549 if (snd_BUG_ON(!channel_buf))
3550 return -EIO;
3549 return copy_to_user(dst, channel_buf + pos * 4, count * 4); 3551 return copy_to_user(dst, channel_buf + pos * 4, count * 4);
3550} 3552}
3551 3553
@@ -3559,7 +3561,8 @@ static int snd_hdspm_hw_silence(struct snd_pcm_substream *substream,
3559 channel_buf = 3561 channel_buf =
3560 hdspm_channel_buffer_location(hdspm, substream->pstr->stream, 3562 hdspm_channel_buffer_location(hdspm, substream->pstr->stream,
3561 channel); 3563 channel);
3562 snd_assert(channel_buf != NULL, return -EIO); 3564 if (snd_BUG_ON(!channel_buf))
3565 return -EIO;
3563 memset(channel_buf + pos * 4, 0, count * 4); 3566 memset(channel_buf + pos * 4, 0, count * 4);
3564 return 0; 3567 return 0;
3565} 3568}
@@ -3744,7 +3747,8 @@ static int snd_hdspm_channel_info(struct snd_pcm_substream *substream,
3744 struct hdspm *hdspm = snd_pcm_substream_chip(substream); 3747 struct hdspm *hdspm = snd_pcm_substream_chip(substream);
3745 int mapped_channel; 3748 int mapped_channel;
3746 3749
3747 snd_assert(info->channel < HDSPM_MAX_CHANNELS, return -EINVAL); 3750 if (snd_BUG_ON(info->channel >= HDSPM_MAX_CHANNELS))
3751 return -EINVAL;
3748 3752
3749 mapped_channel = hdspm->channel_map[info->channel]; 3753 mapped_channel = hdspm->channel_map[info->channel];
3750 if (mapped_channel < 0) 3754 if (mapped_channel < 0)
diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
index a123f0e6ba23..2570907134d7 100644
--- a/sound/pci/rme9652/rme9652.c
+++ b/sound/pci/rme9652/rme9652.c
@@ -595,8 +595,6 @@ static void rme9652_set_thru(struct snd_rme9652 *rme9652, int channel, int enabl
595 } else { 595 } else {
596 int mapped_channel; 596 int mapped_channel;
597 597
598 snd_assert(channel == RME9652_NCHANNELS, return);
599
600 mapped_channel = rme9652->channel_map[channel]; 598 mapped_channel = rme9652->channel_map[channel];
601 599
602 if (enable) { 600 if (enable) {
@@ -1893,7 +1891,8 @@ static char *rme9652_channel_buffer_location(struct snd_rme9652 *rme9652,
1893{ 1891{
1894 int mapped_channel; 1892 int mapped_channel;
1895 1893
1896 snd_assert(channel >= 0 || channel < RME9652_NCHANNELS, return NULL); 1894 if (snd_BUG_ON(channel < 0 || channel >= RME9652_NCHANNELS))
1895 return NULL;
1897 1896
1898 if ((mapped_channel = rme9652->channel_map[channel]) < 0) { 1897 if ((mapped_channel = rme9652->channel_map[channel]) < 0) {
1899 return NULL; 1898 return NULL;
@@ -1914,12 +1913,14 @@ static int snd_rme9652_playback_copy(struct snd_pcm_substream *substream, int ch
1914 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); 1913 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
1915 char *channel_buf; 1914 char *channel_buf;
1916 1915
1917 snd_assert(pos + count <= RME9652_CHANNEL_BUFFER_BYTES / 4, return -EINVAL); 1916 if (snd_BUG_ON(pos + count > RME9652_CHANNEL_BUFFER_BYTES / 4))
1917 return -EINVAL;
1918 1918
1919 channel_buf = rme9652_channel_buffer_location (rme9652, 1919 channel_buf = rme9652_channel_buffer_location (rme9652,
1920 substream->pstr->stream, 1920 substream->pstr->stream,
1921 channel); 1921 channel);
1922 snd_assert(channel_buf != NULL, return -EIO); 1922 if (snd_BUG_ON(!channel_buf))
1923 return -EIO;
1923 if (copy_from_user(channel_buf + pos * 4, src, count * 4)) 1924 if (copy_from_user(channel_buf + pos * 4, src, count * 4))
1924 return -EFAULT; 1925 return -EFAULT;
1925 return count; 1926 return count;
@@ -1931,12 +1932,14 @@ static int snd_rme9652_capture_copy(struct snd_pcm_substream *substream, int cha
1931 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); 1932 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
1932 char *channel_buf; 1933 char *channel_buf;
1933 1934
1934 snd_assert(pos + count <= RME9652_CHANNEL_BUFFER_BYTES / 4, return -EINVAL); 1935 if (snd_BUG_ON(pos + count > RME9652_CHANNEL_BUFFER_BYTES / 4))
1936 return -EINVAL;
1935 1937
1936 channel_buf = rme9652_channel_buffer_location (rme9652, 1938 channel_buf = rme9652_channel_buffer_location (rme9652,
1937 substream->pstr->stream, 1939 substream->pstr->stream,
1938 channel); 1940 channel);
1939 snd_assert(channel_buf != NULL, return -EIO); 1941 if (snd_BUG_ON(!channel_buf))
1942 return -EIO;
1940 if (copy_to_user(dst, channel_buf + pos * 4, count * 4)) 1943 if (copy_to_user(dst, channel_buf + pos * 4, count * 4))
1941 return -EFAULT; 1944 return -EFAULT;
1942 return count; 1945 return count;
@@ -1951,7 +1954,8 @@ static int snd_rme9652_hw_silence(struct snd_pcm_substream *substream, int chann
1951 channel_buf = rme9652_channel_buffer_location (rme9652, 1954 channel_buf = rme9652_channel_buffer_location (rme9652,
1952 substream->pstr->stream, 1955 substream->pstr->stream,
1953 channel); 1956 channel);
1954 snd_assert(channel_buf != NULL, return -EIO); 1957 if (snd_BUG_ON(!channel_buf))
1958 return -EIO;
1955 memset(channel_buf + pos * 4, 0, count * 4); 1959 memset(channel_buf + pos * 4, 0, count * 4);
1956 return count; 1960 return count;
1957} 1961}
@@ -2053,7 +2057,8 @@ static int snd_rme9652_channel_info(struct snd_pcm_substream *substream,
2053 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); 2057 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
2054 int chn; 2058 int chn;
2055 2059
2056 snd_assert(info->channel < RME9652_NCHANNELS, return -EINVAL); 2060 if (snd_BUG_ON(info->channel >= RME9652_NCHANNELS))
2061 return -EINVAL;
2057 2062
2058 if ((chn = rme9652->channel_map[info->channel]) < 0) { 2063 if ((chn = rme9652->channel_map[info->channel]) < 0) {
2059 return -EINVAL; 2064 return -EINVAL;
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
index 0d3d305b0a0b..cd408b86c839 100644
--- a/sound/pci/sonicvibes.c
+++ b/sound/pci/sonicvibes.c
@@ -534,8 +534,8 @@ static int snd_sonicvibes_hw_constraint_dac_rate(struct snd_pcm_hw_params *param
534 params->rate_den = 1; 534 params->rate_den = 1;
535 } else { 535 } else {
536 snd_sonicvibes_pll(rate, &r, &m, &n); 536 snd_sonicvibes_pll(rate, &r, &m, &n);
537 snd_assert((SV_REFFREQUENCY % 16) == 0, return -EINVAL); 537 snd_BUG_ON(SV_REFFREQUENCY % 16);
538 snd_assert((SV_ADCMULT % 512) == 0, return -EINVAL); 538 snd_BUG_ON(SV_ADCMULT % 512);
539 params->rate_num = (SV_REFFREQUENCY/16) * (n+2) * r; 539 params->rate_num = (SV_REFFREQUENCY/16) * (n+2) * r;
540 params->rate_den = (SV_ADCMULT/512) * (m+2); 540 params->rate_den = (SV_ADCMULT/512) * (m+2);
541 } 541 }
@@ -849,7 +849,8 @@ static int __devinit snd_sonicvibes_pcm(struct sonicvibes * sonic, int device, s
849 849
850 if ((err = snd_pcm_new(sonic->card, "s3_86c617", device, 1, 1, &pcm)) < 0) 850 if ((err = snd_pcm_new(sonic->card, "s3_86c617", device, 1, 1, &pcm)) < 0)
851 return err; 851 return err;
852 snd_assert(pcm != NULL, return -EINVAL); 852 if (snd_BUG_ON(!pcm))
853 return -EINVAL;
853 854
854 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sonicvibes_playback_ops); 855 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sonicvibes_playback_ops);
855 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sonicvibes_capture_ops); 856 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)
1089 unsigned int idx; 1090 unsigned int idx;
1090 int err; 1091 int err;
1091 1092
1092 snd_assert(sonic != NULL && sonic->card != NULL, return -EINVAL); 1093 if (snd_BUG_ON(!sonic || !sonic->card))
1094 return -EINVAL;
1093 card = sonic->card; 1095 card = sonic->card;
1094 strcpy(card->mixername, "S3 SonicVibes"); 1096 strcpy(card->mixername, "S3 SonicVibes");
1095 1097
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index a69b4206c69e..c612b435ca2b 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -2931,7 +2931,8 @@ static int snd_trident_pcm_mixer_build(struct snd_trident *trident,
2931{ 2931{
2932 struct snd_trident_pcm_mixer *tmix; 2932 struct snd_trident_pcm_mixer *tmix;
2933 2933
2934 snd_assert(trident != NULL && voice != NULL && substream != NULL, return -EINVAL); 2934 if (snd_BUG_ON(!trident || !voice || !substream))
2935 return -EINVAL;
2935 tmix = &trident->pcm_mixer[substream->number]; 2936 tmix = &trident->pcm_mixer[substream->number];
2936 tmix->voice = voice; 2937 tmix->voice = voice;
2937 tmix->vol = T4D_DEFAULT_PCM_VOL; 2938 tmix->vol = T4D_DEFAULT_PCM_VOL;
@@ -2946,7 +2947,8 @@ static int snd_trident_pcm_mixer_free(struct snd_trident *trident, struct snd_tr
2946{ 2947{
2947 struct snd_trident_pcm_mixer *tmix; 2948 struct snd_trident_pcm_mixer *tmix;
2948 2949
2949 snd_assert(trident != NULL && substream != NULL, return -EINVAL); 2950 if (snd_BUG_ON(!trident || !substream))
2951 return -EINVAL;
2950 tmix = &trident->pcm_mixer[substream->number]; 2952 tmix = &trident->pcm_mixer[substream->number];
2951 tmix->voice = NULL; 2953 tmix->voice = NULL;
2952 snd_trident_notify_pcm_change(trident, tmix, substream->number, 0); 2954 snd_trident_notify_pcm_change(trident, tmix, substream->number, 0);
@@ -3131,7 +3133,8 @@ static unsigned char snd_trident_gameport_read(struct gameport *gameport)
3131{ 3133{
3132 struct snd_trident *chip = gameport_get_port_data(gameport); 3134 struct snd_trident *chip = gameport_get_port_data(gameport);
3133 3135
3134 snd_assert(chip, return 0); 3136 if (snd_BUG_ON(!chip))
3137 return 0;
3135 return inb(TRID_REG(chip, GAMEPORT_LEGACY)); 3138 return inb(TRID_REG(chip, GAMEPORT_LEGACY));
3136} 3139}
3137 3140
@@ -3139,7 +3142,8 @@ static void snd_trident_gameport_trigger(struct gameport *gameport)
3139{ 3142{
3140 struct snd_trident *chip = gameport_get_port_data(gameport); 3143 struct snd_trident *chip = gameport_get_port_data(gameport);
3141 3144
3142 snd_assert(chip, return); 3145 if (snd_BUG_ON(!chip))
3146 return;
3143 outb(0xff, TRID_REG(chip, GAMEPORT_LEGACY)); 3147 outb(0xff, TRID_REG(chip, GAMEPORT_LEGACY));
3144} 3148}
3145 3149
@@ -3148,7 +3152,8 @@ static int snd_trident_gameport_cooked_read(struct gameport *gameport, int *axes
3148 struct snd_trident *chip = gameport_get_port_data(gameport); 3152 struct snd_trident *chip = gameport_get_port_data(gameport);
3149 int i; 3153 int i;
3150 3154
3151 snd_assert(chip, return 0); 3155 if (snd_BUG_ON(!chip))
3156 return 0;
3152 3157
3153 *buttons = (~inb(TRID_REG(chip, GAMEPORT_LEGACY)) >> 4) & 0xf; 3158 *buttons = (~inb(TRID_REG(chip, GAMEPORT_LEGACY)) >> 4) & 0xf;
3154 3159
@@ -3164,7 +3169,8 @@ static int snd_trident_gameport_open(struct gameport *gameport, int mode)
3164{ 3169{
3165 struct snd_trident *chip = gameport_get_port_data(gameport); 3170 struct snd_trident *chip = gameport_get_port_data(gameport);
3166 3171
3167 snd_assert(chip, return 0); 3172 if (snd_BUG_ON(!chip))
3173 return 0;
3168 3174
3169 switch (mode) { 3175 switch (mode) {
3170 case GAMEPORT_MODE_COOKED: 3176 case GAMEPORT_MODE_COOKED:
@@ -3891,8 +3897,8 @@ static void snd_trident_clear_voices(struct snd_trident * trident, unsigned shor
3891{ 3897{
3892 unsigned int i, val, mask[2] = { 0, 0 }; 3898 unsigned int i, val, mask[2] = { 0, 0 };
3893 3899
3894 snd_assert(v_min <= 63, return); 3900 if (snd_BUG_ON(v_min > 63 || v_max > 63))
3895 snd_assert(v_max <= 63, return); 3901 return;
3896 for (i = v_min; i <= v_max; i++) 3902 for (i = v_min; i <= v_max; i++)
3897 mask[i >> 5] |= 1 << (i & 0x1f); 3903 mask[i >> 5] |= 1 << (i & 0x1f);
3898 if (mask[0]) { 3904 if (mask[0]) {
diff --git a/sound/pci/trident/trident_memory.c b/sound/pci/trident/trident_memory.c
index 3fd7f1b29b0f..2fe3b1fab53a 100644
--- a/sound/pci/trident/trident_memory.c
+++ b/sound/pci/trident/trident_memory.c
@@ -196,9 +196,13 @@ snd_trident_alloc_sg_pages(struct snd_trident *trident,
196 int idx, page; 196 int idx, page;
197 struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream); 197 struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream);
198 198
199 snd_assert(runtime->dma_bytes > 0 && runtime->dma_bytes <= SNDRV_TRIDENT_MAX_PAGES * SNDRV_TRIDENT_PAGE_SIZE, return NULL); 199 if (snd_BUG_ON(runtime->dma_bytes <= 0 ||
200 runtime->dma_bytes > SNDRV_TRIDENT_MAX_PAGES *
201 SNDRV_TRIDENT_PAGE_SIZE))
202 return NULL;
200 hdr = trident->tlb.memhdr; 203 hdr = trident->tlb.memhdr;
201 snd_assert(hdr != NULL, return NULL); 204 if (snd_BUG_ON(!hdr))
205 return NULL;
202 206
203 207
204 208
@@ -245,9 +249,13 @@ snd_trident_alloc_cont_pages(struct snd_trident *trident,
245 dma_addr_t addr; 249 dma_addr_t addr;
246 unsigned long ptr; 250 unsigned long ptr;
247 251
248 snd_assert(runtime->dma_bytes> 0 && runtime->dma_bytes <= SNDRV_TRIDENT_MAX_PAGES * SNDRV_TRIDENT_PAGE_SIZE, return NULL); 252 if (snd_BUG_ON(runtime->dma_bytes <= 0 ||
253 runtime->dma_bytes > SNDRV_TRIDENT_MAX_PAGES *
254 SNDRV_TRIDENT_PAGE_SIZE))
255 return NULL;
249 hdr = trident->tlb.memhdr; 256 hdr = trident->tlb.memhdr;
250 snd_assert(hdr != NULL, return NULL); 257 if (snd_BUG_ON(!hdr))
258 return NULL;
251 259
252 mutex_lock(&hdr->block_mutex); 260 mutex_lock(&hdr->block_mutex);
253 blk = search_empty(hdr, runtime->dma_bytes); 261 blk = search_empty(hdr, runtime->dma_bytes);
@@ -279,8 +287,8 @@ struct snd_util_memblk *
279snd_trident_alloc_pages(struct snd_trident *trident, 287snd_trident_alloc_pages(struct snd_trident *trident,
280 struct snd_pcm_substream *substream) 288 struct snd_pcm_substream *substream)
281{ 289{
282 snd_assert(trident != NULL, return NULL); 290 if (snd_BUG_ON(!trident || !substream))
283 snd_assert(substream != NULL, return NULL); 291 return NULL;
284 if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV_SG) 292 if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV_SG)
285 return snd_trident_alloc_sg_pages(trident, substream); 293 return snd_trident_alloc_sg_pages(trident, substream);
286 else 294 else
@@ -297,8 +305,8 @@ int snd_trident_free_pages(struct snd_trident *trident,
297 struct snd_util_memhdr *hdr; 305 struct snd_util_memhdr *hdr;
298 int page; 306 int page;
299 307
300 snd_assert(trident != NULL, return -EINVAL); 308 if (snd_BUG_ON(!trident || !blk))
301 snd_assert(blk != NULL, return -EINVAL); 309 return -EINVAL;
302 310
303 hdr = trident->tlb.memhdr; 311 hdr = trident->tlb.memhdr;
304 mutex_lock(&hdr->block_mutex); 312 mutex_lock(&hdr->block_mutex);
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index 6781be9e3078..84ea35d8b252 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -824,7 +824,8 @@ static snd_pcm_uframes_t snd_via686_pcm_pointer(struct snd_pcm_substream *substr
824 struct viadev *viadev = substream->runtime->private_data; 824 struct viadev *viadev = substream->runtime->private_data;
825 unsigned int idx, ptr, count, res; 825 unsigned int idx, ptr, count, res;
826 826
827 snd_assert(viadev->tbl_entries, return 0); 827 if (snd_BUG_ON(!viadev->tbl_entries))
828 return 0;
828 if (!(inb(VIADEV_REG(viadev, OFFSET_STATUS)) & VIA_REG_STAT_ACTIVE)) 829 if (!(inb(VIADEV_REG(viadev, OFFSET_STATUS)) & VIA_REG_STAT_ACTIVE))
829 return 0; 830 return 0;
830 831
@@ -855,7 +856,8 @@ static snd_pcm_uframes_t snd_via8233_pcm_pointer(struct snd_pcm_substream *subst
855 unsigned int idx, count, res; 856 unsigned int idx, count, res;
856 int status; 857 int status;
857 858
858 snd_assert(viadev->tbl_entries, return 0); 859 if (snd_BUG_ON(!viadev->tbl_entries))
860 return 0;
859 861
860 spin_lock(&chip->reg_lock); 862 spin_lock(&chip->reg_lock);
861 count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT)); 863 count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT));
@@ -1037,7 +1039,7 @@ static int snd_via8233_playback_prepare(struct snd_pcm_substream *substream)
1037 else 1039 else
1038 rbits = (0x100000 / 48000) * runtime->rate + 1040 rbits = (0x100000 / 48000) * runtime->rate +
1039 ((0x100000 % 48000) * runtime->rate) / 48000; 1041 ((0x100000 % 48000) * runtime->rate) / 48000;
1040 snd_assert((rbits & ~0xfffff) == 0, return -EINVAL); 1042 snd_BUG_ON(rbits & ~0xfffff);
1041 snd_via82xx_channel_reset(chip, viadev); 1043 snd_via82xx_channel_reset(chip, viadev);
1042 snd_via82xx_set_table_ptr(chip, viadev); 1044 snd_via82xx_set_table_ptr(chip, viadev);
1043 outb(chip->playback_volume[viadev->reg_offset / 0x10][0], 1045 outb(chip->playback_volume[viadev->reg_offset / 0x10][0],
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index 31f64ee39882..640c338ce0ab 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -612,7 +612,8 @@ static snd_pcm_uframes_t snd_via686_pcm_pointer(struct snd_pcm_substream *substr
612 struct viadev *viadev = substream->runtime->private_data; 612 struct viadev *viadev = substream->runtime->private_data;
613 unsigned int idx, ptr, count, res; 613 unsigned int idx, ptr, count, res;
614 614
615 snd_assert(viadev->tbl_entries, return 0); 615 if (snd_BUG_ON(!viadev->tbl_entries))
616 return 0;
616 if (!(inb(VIADEV_REG(viadev, OFFSET_STATUS)) & VIA_REG_STAT_ACTIVE)) 617 if (!(inb(VIADEV_REG(viadev, OFFSET_STATUS)) & VIA_REG_STAT_ACTIVE))
617 return 0; 618 return 0;
618 619
diff --git a/sound/pci/vx222/vx222_ops.c b/sound/pci/vx222/vx222_ops.c
index 631f3a639993..7e87f398ff0b 100644
--- a/sound/pci/vx222/vx222_ops.c
+++ b/sound/pci/vx222/vx222_ops.c
@@ -253,7 +253,8 @@ static void vx2_dma_write(struct vx_core *chip, struct snd_pcm_runtime *runtime,
253 int offset = pipe->hw_ptr; 253 int offset = pipe->hw_ptr;
254 u32 *addr = (u32 *)(runtime->dma_area + offset); 254 u32 *addr = (u32 *)(runtime->dma_area + offset);
255 255
256 snd_assert(count % 4 == 0, return); 256 if (snd_BUG_ON(count % 4))
257 return;
257 258
258 vx2_setup_pseudo_dma(chip, 1); 259 vx2_setup_pseudo_dma(chip, 1);
259 260
@@ -291,7 +292,8 @@ static void vx2_dma_read(struct vx_core *chip, struct snd_pcm_runtime *runtime,
291 u32 *addr = (u32 *)(runtime->dma_area + offset); 292 u32 *addr = (u32 *)(runtime->dma_area + offset);
292 unsigned long port = vx2_reg_addr(chip, VX_DMA); 293 unsigned long port = vx2_reg_addr(chip, VX_DMA);
293 294
294 snd_assert(count % 4 == 0, return); 295 if (snd_BUG_ON(count % 4))
296 return;
295 297
296 vx2_setup_pseudo_dma(chip, 0); 298 vx2_setup_pseudo_dma(chip, 0);
297 /* Transfer using pseudo-dma. 299 /* Transfer using pseudo-dma.
@@ -675,7 +677,8 @@ static void vx2_write_akm(struct vx_core *chip, int reg, unsigned int data)
675 a look up table, as there is no linear matching between the driver codec values 677 a look up table, as there is no linear matching between the driver codec values
676 and the real dBu value 678 and the real dBu value
677 */ 679 */
678 snd_assert(data < sizeof(vx2_akm_gains_lut), return); 680 if (snd_BUG_ON(data >= sizeof(vx2_akm_gains_lut)))
681 return;
679 682
680 switch (reg) { 683 switch (reg) {
681 case XX_CODEC_LEVEL_LEFT_REGISTER: 684 case XX_CODEC_LEVEL_LEFT_REGISTER:
@@ -823,7 +826,8 @@ static void vx2_set_input_level(struct snd_vx222 *chip)
823 preamp++; /* raise pre ampli + 18dB */ 826 preamp++; /* raise pre ampli + 18dB */
824 miclevel -= (18 * 2); /* lower level 18 dB (*2 because of 0.5 dB steps !) */ 827 miclevel -= (18 * 2); /* lower level 18 dB (*2 because of 0.5 dB steps !) */
825 } 828 }
826 snd_assert(preamp < 4, return); 829 if (snd_BUG_ON(preamp >= 4))
830 return;
827 831
828 /* set pre-amp level */ 832 /* set pre-amp level */
829 chip->regSELMIC &= ~MICRO_SELECT_PREAMPLI_MASK; 833 chip->regSELMIC &= ~MICRO_SELECT_PREAMPLI_MASK;
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index 92d49aadf579..90d0d62bd0b4 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -259,8 +259,10 @@ static int snd_ymfpci_voice_alloc(struct snd_ymfpci *chip,
259 unsigned long flags; 259 unsigned long flags;
260 int result; 260 int result;
261 261
262 snd_assert(rvoice != NULL, return -EINVAL); 262 if (snd_BUG_ON(!rvoice))
263 snd_assert(!pair || type == YMFPCI_PCM, return -EINVAL); 263 return -EINVAL;
264 if (snd_BUG_ON(pair && type != YMFPCI_PCM))
265 return -EINVAL;
264 266
265 spin_lock_irqsave(&chip->voice_lock, flags); 267 spin_lock_irqsave(&chip->voice_lock, flags);
266 for (;;) { 268 for (;;) {
@@ -278,7 +280,8 @@ static int snd_ymfpci_voice_free(struct snd_ymfpci *chip, struct snd_ymfpci_voic
278{ 280{
279 unsigned long flags; 281 unsigned long flags;
280 282
281 snd_assert(pvoice != NULL, return -EINVAL); 283 if (snd_BUG_ON(!pvoice))
284 return -EINVAL;
282 snd_ymfpci_hw_stop(chip); 285 snd_ymfpci_hw_stop(chip);
283 spin_lock_irqsave(&chip->voice_lock, flags); 286 spin_lock_irqsave(&chip->voice_lock, flags);
284 if (pvoice->number == chip->src441_used) { 287 if (pvoice->number == chip->src441_used) {
@@ -494,7 +497,8 @@ static void snd_ymfpci_pcm_init_voice(struct snd_ymfpci_pcm *ypcm, unsigned int
494 u8 use_left, use_right; 497 u8 use_left, use_right;
495 unsigned long flags; 498 unsigned long flags;
496 499
497 snd_assert(voice != NULL, return); 500 if (snd_BUG_ON(!voice))
501 return;
498 if (runtime->channels == 1) { 502 if (runtime->channels == 1) {
499 use_left = 1; 503 use_left = 1;
500 use_right = 1; 504 use_right = 1;
@@ -1813,7 +1817,8 @@ int __devinit snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch)
1813 } 1817 }
1814 1818
1815 /* add S/PDIF control */ 1819 /* add S/PDIF control */
1816 snd_assert(chip->pcm_spdif != NULL, return -EIO); 1820 if (snd_BUG_ON(!chip->pcm_spdif))
1821 return -ENXIO;
1817 if ((err = snd_ctl_add(chip->card, kctl = snd_ctl_new1(&snd_ymfpci_spdif_default, chip))) < 0) 1822 if ((err = snd_ctl_add(chip->card, kctl = snd_ctl_new1(&snd_ymfpci_spdif_default, chip))) < 0)
1818 return err; 1823 return err;
1819 kctl->id.device = chip->pcm_spdif->device; 1824 kctl->id.device = chip->pcm_spdif->device;
@@ -2133,7 +2138,8 @@ static int __devinit snd_ymfpci_memalloc(struct snd_ymfpci *chip)
2133 chip->work_base = ptr; 2138 chip->work_base = ptr;
2134 chip->work_base_addr = ptr_addr; 2139 chip->work_base_addr = ptr_addr;
2135 2140
2136 snd_assert(ptr + chip->work_size == chip->work_ptr.area + chip->work_ptr.bytes, ); 2141 snd_BUG_ON(ptr + chip->work_size !=
2142 chip->work_ptr.area + chip->work_ptr.bytes);
2137 2143
2138 snd_ymfpci_writel(chip, YDSXGR_PLAYCTRLBASE, chip->bank_base_playback_addr); 2144 snd_ymfpci_writel(chip, YDSXGR_PLAYCTRLBASE, chip->bank_base_playback_addr);
2139 snd_ymfpci_writel(chip, YDSXGR_RECCTRLBASE, chip->bank_base_capture_addr); 2145 snd_ymfpci_writel(chip, YDSXGR_RECCTRLBASE, chip->bank_base_capture_addr);
@@ -2168,7 +2174,8 @@ static int snd_ymfpci_free(struct snd_ymfpci *chip)
2168{ 2174{
2169 u16 ctrl; 2175 u16 ctrl;
2170 2176
2171 snd_assert(chip != NULL, return -EINVAL); 2177 if (snd_BUG_ON(!chip))
2178 return -EINVAL;
2172 2179
2173 if (chip->res_reg_area) { /* don't touch busy hardware */ 2180 if (chip->res_reg_area) { /* don't touch busy hardware */
2174 snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0); 2181 snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0);