aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-08-08 11:12:47 -0400
committerJaroslav Kysela <perex@perex.cz>2008-08-13 05:46:40 -0400
commit5e246b850df563224be26f1d409cf66fd6c968df (patch)
tree970e7faf60b86cb2c489a08ca506075c398165e5
parentda3cec35dd3c31d8706db4bf379372ce70d92118 (diff)
ALSA: Kill snd_assert() in other places
Kill snd_assert() in other places, either removed or replaced with if () with snd_BUG_ON(). Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r--drivers/media/video/saa7134/saa7134-alsa.c13
-rw-r--r--include/sound/vx_core.h9
-rw-r--r--sound/arm/sa11xx-uda1341.c5
-rw-r--r--sound/drivers/dummy.c3
-rw-r--r--sound/drivers/opl3/opl3_lib.c6
-rw-r--r--sound/drivers/opl3/opl3_midi.c6
-rw-r--r--sound/drivers/opl3/opl3_oss.c15
-rw-r--r--sound/drivers/opl3/opl3_synth.c3
-rw-r--r--sound/drivers/opl4/opl4_synth.c2
-rw-r--r--sound/drivers/vx/vx_cmd.c3
-rw-r--r--sound/drivers/vx/vx_core.c21
-rw-r--r--sound/drivers/vx/vx_hwdep.c6
-rw-r--r--sound/drivers/vx/vx_mixer.c3
-rw-r--r--sound/drivers/vx/vx_pcm.c9
-rw-r--r--sound/drivers/vx/vx_uer.c6
-rw-r--r--sound/i2c/cs8427.c15
-rw-r--r--sound/i2c/i2c.c6
-rw-r--r--sound/i2c/l3/uda1341.c3
-rw-r--r--sound/i2c/other/ak4114.c3
-rw-r--r--sound/i2c/other/ak4117.c3
-rw-r--r--sound/mips/au1x00.c6
-rw-r--r--sound/parisc/harmony.c3
-rw-r--r--sound/pcmcia/vx/vxp_ops.c3
-rw-r--r--sound/ppc/awacs.c23
-rw-r--r--sound/ppc/beep.c6
-rw-r--r--sound/ppc/tumbler.c17
-rw-r--r--sound/sh/aica.c3
-rw-r--r--sound/sparc/amd7930.c19
-rw-r--r--sound/sparc/cs4231.c3
-rw-r--r--sound/sparc/dbri.c17
-rw-r--r--sound/synth/emux/emux.c8
-rw-r--r--sound/synth/emux/emux_nrpn.c8
-rw-r--r--sound/synth/emux/emux_oss.c42
-rw-r--r--sound/synth/emux/emux_seq.c15
-rw-r--r--sound/synth/emux/emux_synth.c47
-rw-r--r--sound/synth/util_mem.c10
-rw-r--r--sound/usb/usbaudio.c12
-rw-r--r--sound/usb/usbmixer.c3
38 files changed, 217 insertions, 168 deletions
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c
index 9929d20320b4..26194a0ce927 100644
--- a/drivers/media/video/saa7134/saa7134-alsa.c
+++ b/drivers/media/video/saa7134/saa7134-alsa.c
@@ -488,10 +488,12 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream,
488 period_size = params_period_bytes(hw_params); 488 period_size = params_period_bytes(hw_params);
489 periods = params_periods(hw_params); 489 periods = params_periods(hw_params);
490 490
491 snd_assert(period_size >= 0x100 && period_size <= 0x10000, 491 if (period_size < 0x100 || period_size > 0x10000)
492 return -EINVAL); 492 return -EINVAL;
493 snd_assert(periods >= 4, return -EINVAL); 493 if (periods < 4)
494 snd_assert(period_size * periods <= 1024 * 1024, return -EINVAL); 494 return -EINVAL;
495 if (period_size * periods > 1024 * 1024)
496 return -EINVAL;
495 497
496 dev = saa7134->dev; 498 dev = saa7134->dev;
497 499
@@ -942,7 +944,8 @@ static int snd_card_saa7134_new_mixer(snd_card_saa7134_t * chip)
942 unsigned int idx; 944 unsigned int idx;
943 int err; 945 int err;
944 946
945 snd_assert(chip != NULL, return -EINVAL); 947 if (snd_BUG_ON(!chip))
948 return -EINVAL;
946 strcpy(card->mixername, "SAA7134 Mixer"); 949 strcpy(card->mixername, "SAA7134 Mixer");
947 950
948 for (idx = 0; idx < ARRAY_SIZE(snd_saa7134_controls); idx++) { 951 for (idx = 0; idx < ARRAY_SIZE(snd_saa7134_controls); idx++) {
diff --git a/include/sound/vx_core.h b/include/sound/vx_core.h
index 4830651cc4cf..5456343ebe4c 100644
--- a/include/sound/vx_core.h
+++ b/include/sound/vx_core.h
@@ -235,37 +235,31 @@ irqreturn_t snd_vx_irq_handler(int irq, void *dev);
235 */ 235 */
236static inline int vx_test_and_ack(struct vx_core *chip) 236static inline int vx_test_and_ack(struct vx_core *chip)
237{ 237{
238 snd_assert(chip->ops->test_and_ack, return -ENXIO);
239 return chip->ops->test_and_ack(chip); 238 return chip->ops->test_and_ack(chip);
240} 239}
241 240
242static inline void vx_validate_irq(struct vx_core *chip, int enable) 241static inline void vx_validate_irq(struct vx_core *chip, int enable)
243{ 242{
244 snd_assert(chip->ops->validate_irq, return);
245 chip->ops->validate_irq(chip, enable); 243 chip->ops->validate_irq(chip, enable);
246} 244}
247 245
248static inline unsigned char snd_vx_inb(struct vx_core *chip, int reg) 246static inline unsigned char snd_vx_inb(struct vx_core *chip, int reg)
249{ 247{
250 snd_assert(chip->ops->in8, return 0);
251 return chip->ops->in8(chip, reg); 248 return chip->ops->in8(chip, reg);
252} 249}
253 250
254static inline unsigned int snd_vx_inl(struct vx_core *chip, int reg) 251static inline unsigned int snd_vx_inl(struct vx_core *chip, int reg)
255{ 252{
256 snd_assert(chip->ops->in32, return 0);
257 return chip->ops->in32(chip, reg); 253 return chip->ops->in32(chip, reg);
258} 254}
259 255
260static inline void snd_vx_outb(struct vx_core *chip, int reg, unsigned char val) 256static inline void snd_vx_outb(struct vx_core *chip, int reg, unsigned char val)
261{ 257{
262 snd_assert(chip->ops->out8, return);
263 chip->ops->out8(chip, reg, val); 258 chip->ops->out8(chip, reg, val);
264} 259}
265 260
266static inline void snd_vx_outl(struct vx_core *chip, int reg, unsigned int val) 261static inline void snd_vx_outl(struct vx_core *chip, int reg, unsigned int val)
267{ 262{
268 snd_assert(chip->ops->out32, return);
269 chip->ops->out32(chip, reg, val); 263 chip->ops->out32(chip, reg, val);
270} 264}
271 265
@@ -276,7 +270,6 @@ static inline void snd_vx_outl(struct vx_core *chip, int reg, unsigned int val)
276 270
277static inline void vx_reset_dsp(struct vx_core *chip) 271static inline void vx_reset_dsp(struct vx_core *chip)
278{ 272{
279 snd_assert(chip->ops->reset_dsp, return);
280 chip->ops->reset_dsp(chip); 273 chip->ops->reset_dsp(chip);
281} 274}
282 275
@@ -304,14 +297,12 @@ int snd_vx_check_reg_bit(struct vx_core *chip, int reg, int mask, int bit, int t
304static inline void vx_pseudo_dma_write(struct vx_core *chip, struct snd_pcm_runtime *runtime, 297static inline void vx_pseudo_dma_write(struct vx_core *chip, struct snd_pcm_runtime *runtime,
305 struct vx_pipe *pipe, int count) 298 struct vx_pipe *pipe, int count)
306{ 299{
307 snd_assert(chip->ops->dma_write, return);
308 chip->ops->dma_write(chip, runtime, pipe, count); 300 chip->ops->dma_write(chip, runtime, pipe, count);
309} 301}
310 302
311static inline void vx_pseudo_dma_read(struct vx_core *chip, struct snd_pcm_runtime *runtime, 303static inline void vx_pseudo_dma_read(struct vx_core *chip, struct snd_pcm_runtime *runtime,
312 struct vx_pipe *pipe, int count) 304 struct vx_pipe *pipe, int count)
313{ 305{
314 snd_assert(chip->ops->dma_read, return);
315 chip->ops->dma_read(chip, runtime, pipe, count); 306 chip->ops->dma_read(chip, runtime, pipe, count);
316} 307}
317 308
diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c
index b9c51bf8cd71..8addb9d914c1 100644
--- a/sound/arm/sa11xx-uda1341.c
+++ b/sound/arm/sa11xx-uda1341.c
@@ -442,7 +442,8 @@ static void audio_process_dma(struct audio_stream *s)
442 442
443 /* we are requested to process synchronization DMA transfer */ 443 /* we are requested to process synchronization DMA transfer */
444 if (s->tx_spin) { 444 if (s->tx_spin) {
445 snd_assert(s->stream_id == SNDRV_PCM_STREAM_PLAYBACK, return); 445 if (snd_BUG_ON(s->stream_id != SNDRV_PCM_STREAM_PLAYBACK))
446 return;
446 /* fill the xmit dma buffers and return */ 447 /* fill the xmit dma buffers and return */
447#ifdef HH_VERSION 448#ifdef HH_VERSION
448 sa1100_dma_set_spin(s->dmach, FORCE_CLOCK_ADDR, FORCE_CLOCK_SIZE); 449 sa1100_dma_set_spin(s->dmach, FORCE_CLOCK_ADDR, FORCE_CLOCK_SIZE);
@@ -472,7 +473,7 @@ static void audio_process_dma(struct audio_stream *s)
472 continue; /* special case */ 473 continue; /* special case */
473 } else { 474 } else {
474 offset = dma_size * s->period; 475 offset = dma_size * s->period;
475 snd_assert(dma_size <= DMA_BUF_SIZE, ); 476 snd_BUG_ON(dma_size > DMA_BUF_SIZE);
476 } 477 }
477#ifdef HH_VERSION 478#ifdef HH_VERSION
478 ret = sa1100_dma_queue_buffer(s->dmach, s, runtime->dma_addr + offset, dma_size); 479 ret = sa1100_dma_queue_buffer(s->dmach, s, runtime->dma_addr + offset, dma_size);
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
index 4e4c69e6cb4c..c873243e6713 100644
--- a/sound/drivers/dummy.c
+++ b/sound/drivers/dummy.c
@@ -565,7 +565,8 @@ static int __devinit snd_card_dummy_new_mixer(struct snd_dummy *dummy)
565 unsigned int idx; 565 unsigned int idx;
566 int err; 566 int err;
567 567
568 snd_assert(dummy != NULL, return -EINVAL); 568 if (snd_BUG_ON(!dummy))
569 return -EINVAL;
569 spin_lock_init(&dummy->mixer_lock); 570 spin_lock_init(&dummy->mixer_lock);
570 strcpy(card->mixername, "Dummy Mixer"); 571 strcpy(card->mixername, "Dummy Mixer");
571 572
diff --git a/sound/drivers/opl3/opl3_lib.c b/sound/drivers/opl3/opl3_lib.c
index ebe4359047cb..780582340fef 100644
--- a/sound/drivers/opl3/opl3_lib.c
+++ b/sound/drivers/opl3/opl3_lib.c
@@ -139,7 +139,8 @@ static int snd_opl3_detect(struct snd_opl3 * opl3)
139 * If we had an OPL4 chip, opl3->hardware would have been set 139 * If we had an OPL4 chip, opl3->hardware would have been set
140 * by the OPL4 driver; so we can assume OPL3 here. 140 * by the OPL4 driver; so we can assume OPL3 here.
141 */ 141 */
142 snd_assert(opl3->r_port != 0, return -ENODEV); 142 if (snd_BUG_ON(!opl3->r_port))
143 return -ENODEV;
143 opl3->hardware = OPL3_HW_OPL3; 144 opl3->hardware = OPL3_HW_OPL3;
144 } 145 }
145 return 0; 146 return 0;
@@ -324,7 +325,8 @@ EXPORT_SYMBOL(snd_opl3_interrupt);
324 325
325static int snd_opl3_free(struct snd_opl3 *opl3) 326static int snd_opl3_free(struct snd_opl3 *opl3)
326{ 327{
327 snd_assert(opl3 != NULL, return -ENXIO); 328 if (snd_BUG_ON(!opl3))
329 return -ENXIO;
328 if (opl3->private_free) 330 if (opl3->private_free)
329 opl3->private_free(opl3); 331 opl3->private_free(opl3);
330 snd_opl3_clear_patches(opl3); 332 snd_opl3_clear_patches(opl3);
diff --git a/sound/drivers/opl3/opl3_midi.c b/sound/drivers/opl3/opl3_midi.c
index cebcb8b78acb..16feafa2c51e 100644
--- a/sound/drivers/opl3/opl3_midi.c
+++ b/sound/drivers/opl3/opl3_midi.c
@@ -617,7 +617,8 @@ static void snd_opl3_kill_voice(struct snd_opl3 *opl3, int voice)
617 617
618 struct snd_opl3_voice *vp, *vp2; 618 struct snd_opl3_voice *vp, *vp2;
619 619
620 snd_assert(voice < MAX_OPL3_VOICES, return); 620 if (snd_BUG_ON(voice >= MAX_OPL3_VOICES))
621 return;
621 622
622 vp = &opl3->voices[voice]; 623 vp = &opl3->voices[voice];
623 if (voice < MAX_OPL2_VOICES) { 624 if (voice < MAX_OPL2_VOICES) {
@@ -737,7 +738,8 @@ static void snd_opl3_update_pitch(struct snd_opl3 *opl3, int voice)
737 738
738 struct snd_opl3_voice *vp; 739 struct snd_opl3_voice *vp;
739 740
740 snd_assert(voice < MAX_OPL3_VOICES, return); 741 if (snd_BUG_ON(voice >= MAX_OPL3_VOICES))
742 return;
741 743
742 vp = &opl3->voices[voice]; 744 vp = &opl3->voices[voice];
743 if (vp->chan == NULL) 745 if (vp->chan == NULL)
diff --git a/sound/drivers/opl3/opl3_oss.c b/sound/drivers/opl3/opl3_oss.c
index 239347f26154..9a2271dc046a 100644
--- a/sound/drivers/opl3/opl3_oss.c
+++ b/sound/drivers/opl3/opl3_oss.c
@@ -162,7 +162,8 @@ static int snd_opl3_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure)
162 struct snd_opl3 *opl3 = closure; 162 struct snd_opl3 *opl3 = closure;
163 int err; 163 int err;
164 164
165 snd_assert(arg != NULL, return -ENXIO); 165 if (snd_BUG_ON(!arg))
166 return -ENXIO;
166 167
167 if ((err = snd_opl3_synth_setup(opl3)) < 0) 168 if ((err = snd_opl3_synth_setup(opl3)) < 0)
168 return err; 169 return err;
@@ -184,7 +185,8 @@ static int snd_opl3_close_seq_oss(struct snd_seq_oss_arg *arg)
184{ 185{
185 struct snd_opl3 *opl3; 186 struct snd_opl3 *opl3;
186 187
187 snd_assert(arg != NULL, return -ENXIO); 188 if (snd_BUG_ON(!arg))
189 return -ENXIO;
188 opl3 = arg->private_data; 190 opl3 = arg->private_data;
189 191
190 snd_opl3_synth_cleanup(opl3); 192 snd_opl3_synth_cleanup(opl3);
@@ -206,7 +208,8 @@ static int snd_opl3_load_patch_seq_oss(struct snd_seq_oss_arg *arg, int format,
206 char name[32]; 208 char name[32];
207 int err, type; 209 int err, type;
208 210
209 snd_assert(arg != NULL, return -ENXIO); 211 if (snd_BUG_ON(!arg))
212 return -ENXIO;
210 opl3 = arg->private_data; 213 opl3 = arg->private_data;
211 214
212 if (format == FM_PATCH) 215 if (format == FM_PATCH)
@@ -246,7 +249,8 @@ static int snd_opl3_ioctl_seq_oss(struct snd_seq_oss_arg *arg, unsigned int cmd,
246{ 249{
247 struct snd_opl3 *opl3; 250 struct snd_opl3 *opl3;
248 251
249 snd_assert(arg != NULL, return -ENXIO); 252 if (snd_BUG_ON(!arg))
253 return -ENXIO;
250 opl3 = arg->private_data; 254 opl3 = arg->private_data;
251 switch (cmd) { 255 switch (cmd) {
252 case SNDCTL_FM_LOAD_INSTR: 256 case SNDCTL_FM_LOAD_INSTR:
@@ -271,7 +275,8 @@ static int snd_opl3_reset_seq_oss(struct snd_seq_oss_arg *arg)
271{ 275{
272 struct snd_opl3 *opl3; 276 struct snd_opl3 *opl3;
273 277
274 snd_assert(arg != NULL, return -ENXIO); 278 if (snd_BUG_ON(!arg))
279 return -ENXIO;
275 opl3 = arg->private_data; 280 opl3 = arg->private_data;
276 281
277 return 0; 282 return 0;
diff --git a/sound/drivers/opl3/opl3_synth.c b/sound/drivers/opl3/opl3_synth.c
index fb64c890109b..962bb9c8b9c8 100644
--- a/sound/drivers/opl3/opl3_synth.c
+++ b/sound/drivers/opl3/opl3_synth.c
@@ -92,7 +92,8 @@ int snd_opl3_ioctl(struct snd_hwdep * hw, struct file *file,
92 struct snd_opl3 *opl3 = hw->private_data; 92 struct snd_opl3 *opl3 = hw->private_data;
93 void __user *argp = (void __user *)arg; 93 void __user *argp = (void __user *)arg;
94 94
95 snd_assert(opl3 != NULL, return -EINVAL); 95 if (snd_BUG_ON(!opl3))
96 return -EINVAL;
96 97
97 switch (cmd) { 98 switch (cmd) {
98 /* get information */ 99 /* get information */
diff --git a/sound/drivers/opl4/opl4_synth.c b/sound/drivers/opl4/opl4_synth.c
index 74f6e53eae0d..49b9e240915c 100644
--- a/sound/drivers/opl4/opl4_synth.c
+++ b/sound/drivers/opl4/opl4_synth.c
@@ -467,7 +467,7 @@ static struct opl4_voice *snd_opl4_get_voice(struct snd_opl4 *opl4)
467 if (!list_empty(&opl4->off_voices)) 467 if (!list_empty(&opl4->off_voices))
468 return list_entry(opl4->off_voices.next, struct opl4_voice, list); 468 return list_entry(opl4->off_voices.next, struct opl4_voice, list);
469 /* then get the oldest key-on voice */ 469 /* then get the oldest key-on voice */
470 snd_assert(!list_empty(&opl4->on_voices), ); 470 snd_BUG_ON(list_empty(&opl4->on_voices));
471 return list_entry(opl4->on_voices.next, struct opl4_voice, list); 471 return list_entry(opl4->on_voices.next, struct opl4_voice, list);
472} 472}
473 473
diff --git a/sound/drivers/vx/vx_cmd.c b/sound/drivers/vx/vx_cmd.c
index 9529e3bf2866..23f4857f02c8 100644
--- a/sound/drivers/vx/vx_cmd.c
+++ b/sound/drivers/vx/vx_cmd.c
@@ -99,7 +99,8 @@ static struct vx_cmd_info vx_dsp_cmds[] = {
99 */ 99 */
100void vx_init_rmh(struct vx_rmh *rmh, unsigned int cmd) 100void vx_init_rmh(struct vx_rmh *rmh, unsigned int cmd)
101{ 101{
102 snd_assert(cmd < CMD_LAST_INDEX, return); 102 if (snd_BUG_ON(cmd >= CMD_LAST_INDEX))
103 return;
103 rmh->LgCmd = vx_dsp_cmds[cmd].length; 104 rmh->LgCmd = vx_dsp_cmds[cmd].length;
104 rmh->LgStat = vx_dsp_cmds[cmd].st_length; 105 rmh->LgStat = vx_dsp_cmds[cmd].st_length;
105 rmh->DspStat = vx_dsp_cmds[cmd].st_type; 106 rmh->DspStat = vx_dsp_cmds[cmd].st_type;
diff --git a/sound/drivers/vx/vx_core.c b/sound/drivers/vx/vx_core.c
index 585af2eb1438..473b07f6ae85 100644
--- a/sound/drivers/vx/vx_core.c
+++ b/sound/drivers/vx/vx_core.c
@@ -205,7 +205,8 @@ static int vx_read_status(struct vx_core *chip, struct vx_rmh *rmh)
205 205
206 if (size < 1) 206 if (size < 1)
207 return 0; 207 return 0;
208 snd_assert(size <= SIZE_MAX_STATUS, return -EINVAL); 208 if (snd_BUG_ON(size > SIZE_MAX_STATUS))
209 return -EINVAL;
209 210
210 for (i = 1; i <= size; i++) { 211 for (i = 1; i <= size; i++) {
211 /* trigger an irq MESS_WRITE_NEXT */ 212 /* trigger an irq MESS_WRITE_NEXT */
@@ -425,13 +426,16 @@ int snd_vx_load_boot_image(struct vx_core *chip, const struct firmware *boot)
425 int no_fillup = vx_has_new_dsp(chip); 426 int no_fillup = vx_has_new_dsp(chip);
426 427
427 /* check the length of boot image */ 428 /* check the length of boot image */
428 snd_assert(boot->size > 0, return -EINVAL); 429 if (boot->size <= 0)
429 snd_assert(boot->size % 3 == 0, return -EINVAL); 430 return -EINVAL;
431 if (boot->size % 3)
432 return -EINVAL;
430#if 0 433#if 0
431 { 434 {
432 /* more strict check */ 435 /* more strict check */
433 unsigned int c = ((u32)boot->data[0] << 16) | ((u32)boot->data[1] << 8) | boot->data[2]; 436 unsigned int c = ((u32)boot->data[0] << 16) | ((u32)boot->data[1] << 8) | boot->data[2];
434 snd_assert(boot->size == (c + 2) * 3, return -EINVAL); 437 if (boot->size != (c + 2) * 3)
438 return -EINVAL;
435 } 439 }
436#endif 440#endif
437 441
@@ -554,7 +558,8 @@ EXPORT_SYMBOL(snd_vx_irq_handler);
554 */ 558 */
555static void vx_reset_board(struct vx_core *chip, int cold_reset) 559static void vx_reset_board(struct vx_core *chip, int cold_reset)
556{ 560{
557 snd_assert(chip->ops->reset_board, return); 561 if (snd_BUG_ON(!chip->ops->reset_board))
562 return;
558 563
559 /* current source, later sync'ed with target */ 564 /* current source, later sync'ed with target */
560 chip->audio_source = VX_AUDIO_SRC_LINE; 565 chip->audio_source = VX_AUDIO_SRC_LINE;
@@ -673,7 +678,8 @@ int snd_vx_dsp_load(struct vx_core *chip, const struct firmware *dsp)
673 unsigned int csum = 0; 678 unsigned int csum = 0;
674 const unsigned char *image, *cptr; 679 const unsigned char *image, *cptr;
675 680
676 snd_assert(dsp->size % 3 == 0, return -EINVAL); 681 if (dsp->size % 3)
682 return -EINVAL;
677 683
678 vx_toggle_dac_mute(chip, 1); 684 vx_toggle_dac_mute(chip, 1);
679 685
@@ -775,7 +781,8 @@ struct vx_core *snd_vx_create(struct snd_card *card, struct snd_vx_hardware *hw,
775{ 781{
776 struct vx_core *chip; 782 struct vx_core *chip;
777 783
778 snd_assert(card && hw && ops, return NULL); 784 if (snd_BUG_ON(!card || !hw || !ops))
785 return NULL;
779 786
780 chip = kzalloc(sizeof(*chip) + extra_size, GFP_KERNEL); 787 chip = kzalloc(sizeof(*chip) + extra_size, GFP_KERNEL);
781 if (! chip) { 788 if (! chip) {
diff --git a/sound/drivers/vx/vx_hwdep.c b/sound/drivers/vx/vx_hwdep.c
index efd22e92bced..8d6362e2d4c9 100644
--- a/sound/drivers/vx/vx_hwdep.c
+++ b/sound/drivers/vx/vx_hwdep.c
@@ -141,7 +141,8 @@ static int vx_hwdep_dsp_status(struct snd_hwdep *hw,
141 }; 141 };
142 struct vx_core *vx = hw->private_data; 142 struct vx_core *vx = hw->private_data;
143 143
144 snd_assert(type_ids[vx->type], return -EINVAL); 144 if (snd_BUG_ON(!type_ids[vx->type]))
145 return -EINVAL;
145 strcpy(info->id, type_ids[vx->type]); 146 strcpy(info->id, type_ids[vx->type]);
146 if (vx_is_pcmcia(vx)) 147 if (vx_is_pcmcia(vx))
147 info->num_dsps = 4; 148 info->num_dsps = 4;
@@ -168,7 +169,8 @@ static int vx_hwdep_dsp_load(struct snd_hwdep *hw,
168 int index, err; 169 int index, err;
169 struct firmware *fw; 170 struct firmware *fw;
170 171
171 snd_assert(vx->ops->load_dsp, return -ENXIO); 172 if (snd_BUG_ON(!vx->ops->load_dsp))
173 return -ENXIO;
172 174
173 fw = kmalloc(sizeof(*fw), GFP_KERNEL); 175 fw = kmalloc(sizeof(*fw), GFP_KERNEL);
174 if (! fw) { 176 if (! fw) {
diff --git a/sound/drivers/vx/vx_mixer.c b/sound/drivers/vx/vx_mixer.c
index 5a347321f8c0..c71b8d148d7f 100644
--- a/sound/drivers/vx/vx_mixer.c
+++ b/sound/drivers/vx/vx_mixer.c
@@ -34,7 +34,8 @@ static void vx_write_codec_reg(struct vx_core *chip, int codec, unsigned int dat
34{ 34{
35 unsigned long flags; 35 unsigned long flags;
36 36
37 snd_assert(chip->ops->write_codec, return); 37 if (snd_BUG_ON(!chip->ops->write_codec))
38 return;
38 39
39 if (chip->chip_status & VX_STAT_IS_STALE) 40 if (chip->chip_status & VX_STAT_IS_STALE)
40 return; 41 return;
diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c
index fdbf86571b1f..27de574c08f7 100644
--- a/sound/drivers/vx/vx_pcm.c
+++ b/sound/drivers/vx/vx_pcm.c
@@ -587,7 +587,8 @@ static int vx_pcm_playback_open(struct snd_pcm_substream *subs)
587 return -EBUSY; 587 return -EBUSY;
588 588
589 audio = subs->pcm->device * 2; 589 audio = subs->pcm->device * 2;
590 snd_assert(audio < chip->audio_outs, return -EINVAL); 590 if (snd_BUG_ON(audio >= chip->audio_outs))
591 return -EINVAL;
591 592
592 /* playback pipe may have been already allocated for monitoring */ 593 /* playback pipe may have been already allocated for monitoring */
593 pipe = chip->playback_pipes[audio]; 594 pipe = chip->playback_pipes[audio];
@@ -996,7 +997,8 @@ static int vx_pcm_capture_open(struct snd_pcm_substream *subs)
996 return -EBUSY; 997 return -EBUSY;
997 998
998 audio = subs->pcm->device * 2; 999 audio = subs->pcm->device * 2;
999 snd_assert(audio < chip->audio_ins, return -EINVAL); 1000 if (snd_BUG_ON(audio >= chip->audio_ins))
1001 return -EINVAL;
1000 err = vx_alloc_pipe(chip, 1, audio, 2, &pipe); 1002 err = vx_alloc_pipe(chip, 1, audio, 2, &pipe);
1001 if (err < 0) 1003 if (err < 0)
1002 return err; 1004 return err;
@@ -1214,7 +1216,8 @@ void vx_pcm_update_intr(struct vx_core *chip, unsigned int events)
1214 } 1216 }
1215 if (capture) 1217 if (capture)
1216 continue; 1218 continue;
1217 snd_assert(p >= 0 && (unsigned int)p < chip->audio_outs,); 1219 if (snd_BUG_ON(p < 0 || p >= chip->audio_outs))
1220 continue;
1218 pipe = chip->playback_pipes[p]; 1221 pipe = chip->playback_pipes[p];
1219 if (pipe && pipe->substream) { 1222 if (pipe && pipe->substream) {
1220 vx_pcm_playback_update(chip, pipe->substream, pipe); 1223 vx_pcm_playback_update(chip, pipe->substream, pipe);
diff --git a/sound/drivers/vx/vx_uer.c b/sound/drivers/vx/vx_uer.c
index fb8932af888d..0e1ba9b47904 100644
--- a/sound/drivers/vx/vx_uer.c
+++ b/sound/drivers/vx/vx_uer.c
@@ -163,13 +163,15 @@ static int vx_calc_clock_from_freq(struct vx_core *chip, int freq)
163{ 163{
164 int hexfreq; 164 int hexfreq;
165 165
166 snd_assert(freq > 0, return 0); 166 if (snd_BUG_ON(freq <= 0))
167 return 0;
167 168
168 hexfreq = (28224000 * 10) / freq; 169 hexfreq = (28224000 * 10) / freq;
169 hexfreq = (hexfreq + 5) / 10; 170 hexfreq = (hexfreq + 5) / 10;
170 171
171 /* max freq = 55125 Hz */ 172 /* max freq = 55125 Hz */
172 snd_assert(hexfreq > 0x00000200, return 0); 173 if (snd_BUG_ON(hexfreq <= 0x00000200))
174 return 0;
173 175
174 if (hexfreq <= 0x03ff) 176 if (hexfreq <= 0x03ff)
175 return hexfreq - 0x00000201; 177 return hexfreq - 0x00000201;
diff --git a/sound/i2c/cs8427.c b/sound/i2c/cs8427.c
index 9c3d361accfb..020a5d512472 100644
--- a/sound/i2c/cs8427.c
+++ b/sound/i2c/cs8427.c
@@ -314,7 +314,8 @@ static void snd_cs8427_reset(struct snd_i2c_device *cs8427)
314 unsigned long end_time; 314 unsigned long end_time;
315 int data, aes3input = 0; 315 int data, aes3input = 0;
316 316
317 snd_assert(cs8427, return); 317 if (snd_BUG_ON(!cs8427))
318 return;
318 chip = cs8427->private_data; 319 chip = cs8427->private_data;
319 snd_i2c_lock(cs8427->bus); 320 snd_i2c_lock(cs8427->bus);
320 if ((chip->regmap[CS8427_REG_CLOCKSOURCE] & CS8427_RXDAES3INPUT) == 321 if ((chip->regmap[CS8427_REG_CLOCKSOURCE] & CS8427_RXDAES3INPUT) ==
@@ -526,7 +527,8 @@ int snd_cs8427_iec958_build(struct snd_i2c_device *cs8427,
526 unsigned int idx; 527 unsigned int idx;
527 int err; 528 int err;
528 529
529 snd_assert(play_substream && cap_substream, return -EINVAL); 530 if (snd_BUG_ON(!play_substream || !cap_substream))
531 return -EINVAL;
530 for (idx = 0; idx < ARRAY_SIZE(snd_cs8427_iec958_controls); idx++) { 532 for (idx = 0; idx < ARRAY_SIZE(snd_cs8427_iec958_controls); idx++) {
531 kctl = snd_ctl_new1(&snd_cs8427_iec958_controls[idx], cs8427); 533 kctl = snd_ctl_new1(&snd_cs8427_iec958_controls[idx], cs8427);
532 if (kctl == NULL) 534 if (kctl == NULL)
@@ -543,7 +545,8 @@ int snd_cs8427_iec958_build(struct snd_i2c_device *cs8427,
543 545
544 chip->playback.substream = play_substream; 546 chip->playback.substream = play_substream;
545 chip->capture.substream = cap_substream; 547 chip->capture.substream = cap_substream;
546 snd_assert(chip->playback.pcm_ctl, return -EIO); 548 if (snd_BUG_ON(!chip->playback.pcm_ctl))
549 return -EIO;
547 return 0; 550 return 0;
548} 551}
549 552
@@ -553,7 +556,8 @@ int snd_cs8427_iec958_active(struct snd_i2c_device *cs8427, int active)
553{ 556{
554 struct cs8427 *chip; 557 struct cs8427 *chip;
555 558
556 snd_assert(cs8427, return -ENXIO); 559 if (snd_BUG_ON(!cs8427))
560 return -ENXIO;
557 chip = cs8427->private_data; 561 chip = cs8427->private_data;
558 if (active) 562 if (active)
559 memcpy(chip->playback.pcm_status, 563 memcpy(chip->playback.pcm_status,
@@ -573,7 +577,8 @@ int snd_cs8427_iec958_pcm(struct snd_i2c_device *cs8427, unsigned int rate)
573 char *status; 577 char *status;
574 int err, reset; 578 int err, reset;
575 579
576 snd_assert(cs8427, return -ENXIO); 580 if (snd_BUG_ON(!cs8427))
581 return -ENXIO;
577 chip = cs8427->private_data; 582 chip = cs8427->private_data;
578 status = chip->playback.pcm_status; 583 status = chip->playback.pcm_status;
579 snd_i2c_lock(cs8427->bus); 584 snd_i2c_lock(cs8427->bus);
diff --git a/sound/i2c/i2c.c b/sound/i2c/i2c.c
index b1e74e40cba0..5c0c77dd01c3 100644
--- a/sound/i2c/i2c.c
+++ b/sound/i2c/i2c.c
@@ -49,7 +49,8 @@ static int snd_i2c_bus_free(struct snd_i2c_bus *bus)
49 struct snd_i2c_bus *slave; 49 struct snd_i2c_bus *slave;
50 struct snd_i2c_device *device; 50 struct snd_i2c_device *device;
51 51
52 snd_assert(bus != NULL, return -EINVAL); 52 if (snd_BUG_ON(!bus))
53 return -EINVAL;
53 while (!list_empty(&bus->devices)) { 54 while (!list_empty(&bus->devices)) {
54 device = snd_i2c_device(bus->devices.next); 55 device = snd_i2c_device(bus->devices.next);
55 snd_i2c_device_free(device); 56 snd_i2c_device_free(device);
@@ -113,7 +114,8 @@ int snd_i2c_device_create(struct snd_i2c_bus *bus, const char *name,
113 struct snd_i2c_device *device; 114 struct snd_i2c_device *device;
114 115
115 *rdevice = NULL; 116 *rdevice = NULL;
116 snd_assert(bus != NULL, return -EINVAL); 117 if (snd_BUG_ON(!bus))
118 return -EINVAL;
117 device = kzalloc(sizeof(*device), GFP_KERNEL); 119 device = kzalloc(sizeof(*device), GFP_KERNEL);
118 if (device == NULL) 120 if (device == NULL)
119 return -ENOMEM; 121 return -ENOMEM;
diff --git a/sound/i2c/l3/uda1341.c b/sound/i2c/l3/uda1341.c
index 1f4942ea1414..9840eb43648d 100644
--- a/sound/i2c/l3/uda1341.c
+++ b/sound/i2c/l3/uda1341.c
@@ -771,7 +771,8 @@ int __init snd_chip_uda1341_mixer_new(struct snd_card *card, struct l3_client **
771 struct l3_client *clnt; 771 struct l3_client *clnt;
772 int idx, err; 772 int idx, err;
773 773
774 snd_assert(card != NULL, return -EINVAL); 774 if (snd_BUG_ON(!card))
775 return -EINVAL;
775 776
776 clnt = kzalloc(sizeof(*clnt), GFP_KERNEL); 777 clnt = kzalloc(sizeof(*clnt), GFP_KERNEL);
777 if (clnt == NULL) 778 if (clnt == NULL)
diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c
index d20d893b3b60..0341451f814c 100644
--- a/sound/i2c/other/ak4114.c
+++ b/sound/i2c/other/ak4114.c
@@ -475,7 +475,8 @@ int snd_ak4114_build(struct ak4114 *ak4114,
475 unsigned int idx; 475 unsigned int idx;
476 int err; 476 int err;
477 477
478 snd_assert(cap_substream, return -EINVAL); 478 if (snd_BUG_ON(!cap_substream))
479 return -EINVAL;
479 ak4114->playback_substream = ply_substream; 480 ak4114->playback_substream = ply_substream;
480 ak4114->capture_substream = cap_substream; 481 ak4114->capture_substream = cap_substream;
481 for (idx = 0; idx < AK4114_CONTROLS; idx++) { 482 for (idx = 0; idx < AK4114_CONTROLS; idx++) {
diff --git a/sound/i2c/other/ak4117.c b/sound/i2c/other/ak4117.c
index f350835ade96..2cad2d612518 100644
--- a/sound/i2c/other/ak4117.c
+++ b/sound/i2c/other/ak4117.c
@@ -431,7 +431,8 @@ int snd_ak4117_build(struct ak4117 *ak4117, struct snd_pcm_substream *cap_substr
431 unsigned int idx; 431 unsigned int idx;
432 int err; 432 int err;
433 433
434 snd_assert(cap_substream, return -EINVAL); 434 if (snd_BUG_ON(!cap_substream))
435 return -EINVAL;
435 ak4117->substream = cap_substream; 436 ak4117->substream = cap_substream;
436 for (idx = 0; idx < AK4117_CONTROLS; idx++) { 437 for (idx = 0; idx < AK4117_CONTROLS; idx++) {
437 kctl = snd_ctl_new1(&snd_ak4117_iec958_controls[idx], ak4117); 438 kctl = snd_ctl_new1(&snd_ak4117_iec958_controls[idx], ak4117);
diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c
index fbef38a9604a..1881cec11e78 100644
--- a/sound/mips/au1x00.c
+++ b/sound/mips/au1x00.c
@@ -190,14 +190,16 @@ au1000_setup_dma_link(struct audio_stream *stream, unsigned int period_bytes,
190static void 190static void
191au1000_dma_stop(struct audio_stream *stream) 191au1000_dma_stop(struct audio_stream *stream)
192{ 192{
193 snd_assert(stream->buffer, return); 193 if (snd_BUG_ON(!stream->buffer))
194 return;
194 disable_dma(stream->dma); 195 disable_dma(stream->dma);
195} 196}
196 197
197static void 198static void
198au1000_dma_start(struct audio_stream *stream) 199au1000_dma_start(struct audio_stream *stream)
199{ 200{
200 snd_assert(stream->buffer, return); 201 if (snd_BUG_ON(!stream->buffer))
202 return;
201 203
202 init_dma(stream->dma); 204 init_dma(stream->dma);
203 if (get_dma_active_buffer(stream->dma) == 0) { 205 if (get_dma_active_buffer(stream->dma) == 0) {
diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c
index 99f5483abf2e..774372fe34ad 100644
--- a/sound/parisc/harmony.c
+++ b/sound/parisc/harmony.c
@@ -868,7 +868,8 @@ snd_harmony_mixer_init(struct snd_harmony *h)
868 struct snd_card *card = h->card; 868 struct snd_card *card = h->card;
869 int idx, err; 869 int idx, err;
870 870
871 snd_assert(h != NULL, return -EINVAL); 871 if (snd_BUG_ON(!h))
872 reutrn -EINVAL;
872 strcpy(card->mixername, "Harmony Gain control interface"); 873 strcpy(card->mixername, "Harmony Gain control interface");
873 874
874 for (idx = 0; idx < HARMONY_CONTROLS; idx++) { 875 for (idx = 0; idx < HARMONY_CONTROLS; idx++) {
diff --git a/sound/pcmcia/vx/vxp_ops.c b/sound/pcmcia/vx/vxp_ops.c
index 99bf2a65a6f5..989e04abb520 100644
--- a/sound/pcmcia/vx/vxp_ops.c
+++ b/sound/pcmcia/vx/vxp_ops.c
@@ -408,7 +408,8 @@ static void vxp_dma_read(struct vx_core *chip, struct snd_pcm_runtime *runtime,
408 int offset = pipe->hw_ptr; 408 int offset = pipe->hw_ptr;
409 unsigned short *addr = (unsigned short *)(runtime->dma_area + offset); 409 unsigned short *addr = (unsigned short *)(runtime->dma_area + offset);
410 410
411 snd_assert(count % 2 == 0, return); 411 if (snd_BUG_ON(count % 2))
412 return;
412 vx_setup_pseudo_dma(chip, 0); 413 vx_setup_pseudo_dma(chip, 0);
413 if (offset + count > pipe->buffer_bytes) { 414 if (offset + count > pipe->buffer_bytes) {
414 int length = pipe->buffer_bytes - offset; 415 int length = pipe->buffer_bytes - offset;
diff --git a/sound/ppc/awacs.c b/sound/ppc/awacs.c
index 106c48225bba..7bd33e6552ab 100644
--- a/sound/ppc/awacs.c
+++ b/sound/ppc/awacs.c
@@ -319,7 +319,8 @@ static void awacs_amp_set_master(struct awacs_amp *amp, int vol)
319static void awacs_amp_free(struct snd_pmac *chip) 319static void awacs_amp_free(struct snd_pmac *chip)
320{ 320{
321 struct awacs_amp *amp = chip->mixer_data; 321 struct awacs_amp *amp = chip->mixer_data;
322 snd_assert(amp, return); 322 if (!amp)
323 return;
323 kfree(amp); 324 kfree(amp);
324 chip->mixer_data = NULL; 325 chip->mixer_data = NULL;
325 chip->mixer_free = NULL; 326 chip->mixer_free = NULL;
@@ -345,8 +346,7 @@ static int snd_pmac_awacs_get_volume_amp(struct snd_kcontrol *kcontrol,
345 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 346 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
346 int index = kcontrol->private_value; 347 int index = kcontrol->private_value;
347 struct awacs_amp *amp = chip->mixer_data; 348 struct awacs_amp *amp = chip->mixer_data;
348 snd_assert(amp, return -EINVAL); 349
349 snd_assert(index >= 0 && index <= 1, return -EINVAL);
350 ucontrol->value.integer.value[0] = 31 - (amp->amp_vol[index][0] & 31); 350 ucontrol->value.integer.value[0] = 31 - (amp->amp_vol[index][0] & 31);
351 ucontrol->value.integer.value[1] = 31 - (amp->amp_vol[index][1] & 31); 351 ucontrol->value.integer.value[1] = 31 - (amp->amp_vol[index][1] & 31);
352 return 0; 352 return 0;
@@ -359,8 +359,6 @@ static int snd_pmac_awacs_put_volume_amp(struct snd_kcontrol *kcontrol,
359 int index = kcontrol->private_value; 359 int index = kcontrol->private_value;
360 int vol[2]; 360 int vol[2];
361 struct awacs_amp *amp = chip->mixer_data; 361 struct awacs_amp *amp = chip->mixer_data;
362 snd_assert(amp, return -EINVAL);
363 snd_assert(index >= 0 && index <= 1, return -EINVAL);
364 362
365 vol[0] = (31 - (ucontrol->value.integer.value[0] & 31)) 363 vol[0] = (31 - (ucontrol->value.integer.value[0] & 31))
366 | (amp->amp_vol[index][0] & 32); 364 | (amp->amp_vol[index][0] & 32);
@@ -375,8 +373,7 @@ static int snd_pmac_awacs_get_switch_amp(struct snd_kcontrol *kcontrol,
375 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 373 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
376 int index = kcontrol->private_value; 374 int index = kcontrol->private_value;
377 struct awacs_amp *amp = chip->mixer_data; 375 struct awacs_amp *amp = chip->mixer_data;
378 snd_assert(amp, return -EINVAL); 376
379 snd_assert(index >= 0 && index <= 1, return -EINVAL);
380 ucontrol->value.integer.value[0] = (amp->amp_vol[index][0] & 32) 377 ucontrol->value.integer.value[0] = (amp->amp_vol[index][0] & 32)
381 ? 0 : 1; 378 ? 0 : 1;
382 ucontrol->value.integer.value[1] = (amp->amp_vol[index][1] & 32) 379 ucontrol->value.integer.value[1] = (amp->amp_vol[index][1] & 32)
@@ -391,8 +388,6 @@ static int snd_pmac_awacs_put_switch_amp(struct snd_kcontrol *kcontrol,
391 int index = kcontrol->private_value; 388 int index = kcontrol->private_value;
392 int vol[2]; 389 int vol[2];
393 struct awacs_amp *amp = chip->mixer_data; 390 struct awacs_amp *amp = chip->mixer_data;
394 snd_assert(amp, return -EINVAL);
395 snd_assert(index >= 0 && index <= 1, return -EINVAL);
396 391
397 vol[0] = (ucontrol->value.integer.value[0] ? 0 : 32) 392 vol[0] = (ucontrol->value.integer.value[0] ? 0 : 32)
398 | (amp->amp_vol[index][0] & 31); 393 | (amp->amp_vol[index][0] & 31);
@@ -417,8 +412,7 @@ static int snd_pmac_awacs_get_tone_amp(struct snd_kcontrol *kcontrol,
417 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 412 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
418 int index = kcontrol->private_value; 413 int index = kcontrol->private_value;
419 struct awacs_amp *amp = chip->mixer_data; 414 struct awacs_amp *amp = chip->mixer_data;
420 snd_assert(amp, return -EINVAL); 415
421 snd_assert(index >= 0 && index <= 1, return -EINVAL);
422 ucontrol->value.integer.value[0] = amp->amp_tone[index]; 416 ucontrol->value.integer.value[0] = amp->amp_tone[index];
423 return 0; 417 return 0;
424} 418}
@@ -430,8 +424,7 @@ static int snd_pmac_awacs_put_tone_amp(struct snd_kcontrol *kcontrol,
430 int index = kcontrol->private_value; 424 int index = kcontrol->private_value;
431 struct awacs_amp *amp = chip->mixer_data; 425 struct awacs_amp *amp = chip->mixer_data;
432 unsigned int val; 426 unsigned int val;
433 snd_assert(amp, return -EINVAL); 427
434 snd_assert(index >= 0 && index <= 1, return -EINVAL);
435 val = ucontrol->value.integer.value[0]; 428 val = ucontrol->value.integer.value[0];
436 if (val > 14) 429 if (val > 14)
437 return -EINVAL; 430 return -EINVAL;
@@ -458,7 +451,7 @@ static int snd_pmac_awacs_get_master_amp(struct snd_kcontrol *kcontrol,
458{ 451{
459 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 452 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
460 struct awacs_amp *amp = chip->mixer_data; 453 struct awacs_amp *amp = chip->mixer_data;
461 snd_assert(amp, return -EINVAL); 454
462 ucontrol->value.integer.value[0] = amp->amp_master; 455 ucontrol->value.integer.value[0] = amp->amp_master;
463 return 0; 456 return 0;
464} 457}
@@ -469,7 +462,7 @@ static int snd_pmac_awacs_put_master_amp(struct snd_kcontrol *kcontrol,
469 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 462 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
470 struct awacs_amp *amp = chip->mixer_data; 463 struct awacs_amp *amp = chip->mixer_data;
471 unsigned int val; 464 unsigned int val;
472 snd_assert(amp, return -EINVAL); 465
473 val = ucontrol->value.integer.value[0]; 466 val = ucontrol->value.integer.value[0];
474 if (val > 99) 467 if (val > 99)
475 return -EINVAL; 468 return -EINVAL;
diff --git a/sound/ppc/beep.c b/sound/ppc/beep.c
index baa2a7237370..89f5c328acfe 100644
--- a/sound/ppc/beep.c
+++ b/sound/ppc/beep.c
@@ -185,7 +185,8 @@ static int snd_pmac_get_beep(struct snd_kcontrol *kcontrol,
185 struct snd_ctl_elem_value *ucontrol) 185 struct snd_ctl_elem_value *ucontrol)
186{ 186{
187 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 187 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
188 snd_assert(chip->beep, return -ENXIO); 188 if (snd_BUG_ON(!chip->beep))
189 return -ENXIO;
189 ucontrol->value.integer.value[0] = chip->beep->volume; 190 ucontrol->value.integer.value[0] = chip->beep->volume;
190 return 0; 191 return 0;
191} 192}
@@ -195,7 +196,8 @@ static int snd_pmac_put_beep(struct snd_kcontrol *kcontrol,
195{ 196{
196 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 197 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
197 unsigned int oval, nval; 198 unsigned int oval, nval;
198 snd_assert(chip->beep, return -ENXIO); 199 if (snd_BUG_ON(!chip->beep))
200 return -ENXIO;
199 oval = chip->beep->volume; 201 oval = chip->beep->volume;
200 nval = ucontrol->value.integer.value[0]; 202 nval = ucontrol->value.integer.value[0];
201 if (nval > 100) 203 if (nval > 100)
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c
index 009df8dd37a8..f746e15b8481 100644
--- a/sound/ppc/tumbler.c
+++ b/sound/ppc/tumbler.c
@@ -263,7 +263,7 @@ static int tumbler_get_master_volume(struct snd_kcontrol *kcontrol,
263{ 263{
264 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 264 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
265 struct pmac_tumbler *mix = chip->mixer_data; 265 struct pmac_tumbler *mix = chip->mixer_data;
266 snd_assert(mix, return -ENODEV); 266
267 ucontrol->value.integer.value[0] = mix->master_vol[0]; 267 ucontrol->value.integer.value[0] = mix->master_vol[0];
268 ucontrol->value.integer.value[1] = mix->master_vol[1]; 268 ucontrol->value.integer.value[1] = mix->master_vol[1];
269 return 0; 269 return 0;
@@ -277,7 +277,6 @@ static int tumbler_put_master_volume(struct snd_kcontrol *kcontrol,
277 unsigned int vol[2]; 277 unsigned int vol[2];
278 int change; 278 int change;
279 279
280 snd_assert(mix, return -ENODEV);
281 vol[0] = ucontrol->value.integer.value[0]; 280 vol[0] = ucontrol->value.integer.value[0];
282 vol[1] = ucontrol->value.integer.value[1]; 281 vol[1] = ucontrol->value.integer.value[1];
283 if (vol[0] >= ARRAY_SIZE(master_volume_table) || 282 if (vol[0] >= ARRAY_SIZE(master_volume_table) ||
@@ -299,7 +298,7 @@ static int tumbler_get_master_switch(struct snd_kcontrol *kcontrol,
299{ 298{
300 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 299 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
301 struct pmac_tumbler *mix = chip->mixer_data; 300 struct pmac_tumbler *mix = chip->mixer_data;
302 snd_assert(mix, return -ENODEV); 301
303 ucontrol->value.integer.value[0] = mix->master_switch[0]; 302 ucontrol->value.integer.value[0] = mix->master_switch[0];
304 ucontrol->value.integer.value[1] = mix->master_switch[1]; 303 ucontrol->value.integer.value[1] = mix->master_switch[1];
305 return 0; 304 return 0;
@@ -312,7 +311,6 @@ static int tumbler_put_master_switch(struct snd_kcontrol *kcontrol,
312 struct pmac_tumbler *mix = chip->mixer_data; 311 struct pmac_tumbler *mix = chip->mixer_data;
313 int change; 312 int change;
314 313
315 snd_assert(mix, return -ENODEV);
316 change = mix->master_switch[0] != ucontrol->value.integer.value[0] || 314 change = mix->master_switch[0] != ucontrol->value.integer.value[0] ||
317 mix->master_switch[1] != ucontrol->value.integer.value[1]; 315 mix->master_switch[1] != ucontrol->value.integer.value[1];
318 if (change) { 316 if (change) {
@@ -807,7 +805,6 @@ static int snapper_get_capture_source(struct snd_kcontrol *kcontrol,
807 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 805 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
808 struct pmac_tumbler *mix = chip->mixer_data; 806 struct pmac_tumbler *mix = chip->mixer_data;
809 807
810 snd_assert(mix, return -ENODEV);
811 ucontrol->value.enumerated.item[0] = mix->capture_source; 808 ucontrol->value.enumerated.item[0] = mix->capture_source;
812 return 0; 809 return 0;
813} 810}
@@ -819,7 +816,6 @@ static int snapper_put_capture_source(struct snd_kcontrol *kcontrol,
819 struct pmac_tumbler *mix = chip->mixer_data; 816 struct pmac_tumbler *mix = chip->mixer_data;
820 int change; 817 int change;
821 818
822 snd_assert(mix, return -ENODEV);
823 change = ucontrol->value.enumerated.item[0] != mix->capture_source; 819 change = ucontrol->value.enumerated.item[0] != mix->capture_source;
824 if (change) { 820 if (change) {
825 mix->capture_source = !!ucontrol->value.enumerated.item[0]; 821 mix->capture_source = !!ucontrol->value.enumerated.item[0];
@@ -978,7 +974,8 @@ static void device_change_handler(struct work_struct *work)
978 return; 974 return;
979 975
980 mix = chip->mixer_data; 976 mix = chip->mixer_data;
981 snd_assert(mix, return); 977 if (snd_BUG_ON(!mix))
978 return;
982 979
983 headphone = tumbler_detect_headphone(chip); 980 headphone = tumbler_detect_headphone(chip);
984 lineout = tumbler_detect_lineout(chip); 981 lineout = tumbler_detect_lineout(chip);
@@ -1033,7 +1030,8 @@ static void tumbler_update_automute(struct snd_pmac *chip, int do_notify)
1033 if (chip->auto_mute) { 1030 if (chip->auto_mute) {
1034 struct pmac_tumbler *mix; 1031 struct pmac_tumbler *mix;
1035 mix = chip->mixer_data; 1032 mix = chip->mixer_data;
1036 snd_assert(mix, return); 1033 if (snd_BUG_ON(!mix))
1034 return;
1037 mix->auto_mute_notify = do_notify; 1035 mix->auto_mute_notify = do_notify;
1038 schedule_work(&device_change); 1036 schedule_work(&device_change);
1039 } 1037 }
@@ -1227,8 +1225,6 @@ static void tumbler_resume(struct snd_pmac *chip)
1227{ 1225{
1228 struct pmac_tumbler *mix = chip->mixer_data; 1226 struct pmac_tumbler *mix = chip->mixer_data;
1229 1227
1230 snd_assert(mix, return);
1231
1232 mix->acs &= ~1; 1228 mix->acs &= ~1;
1233 mix->master_switch[0] = mix->save_master_switch[0]; 1229 mix->master_switch[0] = mix->save_master_switch[0];
1234 mix->master_switch[1] = mix->save_master_switch[1]; 1230 mix->master_switch[1] = mix->save_master_switch[1];
@@ -1275,7 +1271,6 @@ static int __init tumbler_init(struct snd_pmac *chip)
1275{ 1271{
1276 int irq; 1272 int irq;
1277 struct pmac_tumbler *mix = chip->mixer_data; 1273 struct pmac_tumbler *mix = chip->mixer_data;
1278 snd_assert(mix, return -EINVAL);
1279 1274
1280 if (tumbler_find_device("audio-hw-reset", 1275 if (tumbler_find_device("audio-hw-reset",
1281 "platform-do-hw-reset", 1276 "platform-do-hw-reset",
diff --git a/sound/sh/aica.c b/sound/sh/aica.c
index 54df8baf916f..55031d0a6558 100644
--- a/sound/sh/aica.c
+++ b/sound/sh/aica.c
@@ -106,7 +106,8 @@ static void spu_memset(u32 toi, u32 what, int length)
106{ 106{
107 int i; 107 int i;
108 unsigned long flags; 108 unsigned long flags;
109 snd_assert(length % 4 == 0, return); 109 if (snd_BUG_ON(length % 4))
110 return;
110 for (i = 0; i < length; i++) { 111 for (i = 0; i < length; i++) {
111 if (!(i % 8)) 112 if (!(i % 8))
112 spu_write_wait(); 113 spu_write_wait();
diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c
index 0c63e0585b15..49acee0c4840 100644
--- a/sound/sparc/amd7930.c
+++ b/sound/sparc/amd7930.c
@@ -765,7 +765,6 @@ static int __devinit snd_amd7930_pcm(struct snd_amd7930 *amd)
765 /* playback count */ 1, 765 /* playback count */ 1,
766 /* capture count */ 1, &pcm)) < 0) 766 /* capture count */ 1, &pcm)) < 0)
767 return err; 767 return err;
768 snd_assert(pcm != NULL, return -EINVAL);
769 768
770 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_amd7930_playback_ops); 769 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_amd7930_playback_ops);
771 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_amd7930_capture_ops); 770 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_amd7930_capture_ops);
@@ -788,13 +787,6 @@ static int __devinit snd_amd7930_pcm(struct snd_amd7930 *amd)
788 787
789static int snd_amd7930_info_volume(struct snd_kcontrol *kctl, struct snd_ctl_elem_info *uinfo) 788static int snd_amd7930_info_volume(struct snd_kcontrol *kctl, struct snd_ctl_elem_info *uinfo)
790{ 789{
791 int type = kctl->private_value;
792
793 snd_assert(type == VOLUME_MONITOR ||
794 type == VOLUME_CAPTURE ||
795 type == VOLUME_PLAYBACK, return -EINVAL);
796 (void) type;
797
798 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 790 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
799 uinfo->count = 1; 791 uinfo->count = 1;
800 uinfo->value.integer.min = 0; 792 uinfo->value.integer.min = 0;
@@ -809,10 +801,6 @@ static int snd_amd7930_get_volume(struct snd_kcontrol *kctl, struct snd_ctl_elem
809 int type = kctl->private_value; 801 int type = kctl->private_value;
810 int *swval; 802 int *swval;
811 803
812 snd_assert(type == VOLUME_MONITOR ||
813 type == VOLUME_CAPTURE ||
814 type == VOLUME_PLAYBACK, return -EINVAL);
815
816 switch (type) { 804 switch (type) {
817 case VOLUME_MONITOR: 805 case VOLUME_MONITOR:
818 swval = &amd->mgain; 806 swval = &amd->mgain;
@@ -838,10 +826,6 @@ static int snd_amd7930_put_volume(struct snd_kcontrol *kctl, struct snd_ctl_elem
838 int type = kctl->private_value; 826 int type = kctl->private_value;
839 int *swval, change; 827 int *swval, change;
840 828
841 snd_assert(type == VOLUME_MONITOR ||
842 type == VOLUME_CAPTURE ||
843 type == VOLUME_PLAYBACK, return -EINVAL);
844
845 switch (type) { 829 switch (type) {
846 case VOLUME_MONITOR: 830 case VOLUME_MONITOR:
847 swval = &amd->mgain; 831 swval = &amd->mgain;
@@ -904,7 +888,8 @@ static int __devinit snd_amd7930_mixer(struct snd_amd7930 *amd)
904 struct snd_card *card; 888 struct snd_card *card;
905 int idx, err; 889 int idx, err;
906 890
907 snd_assert(amd != NULL && amd->card != NULL, return -EINVAL); 891 if (snd_BUG_ON(!amd || !amd->card))
892 return -EINVAL;
908 893
909 card = amd->card; 894 card = amd->card;
910 strcpy(card->mixername, card->shortname); 895 strcpy(card->mixername, card->shortname);
diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c
index 1c4797be72ee..791d2fb821d1 100644
--- a/sound/sparc/cs4231.c
+++ b/sound/sparc/cs4231.c
@@ -1560,7 +1560,8 @@ static int __init snd_cs4231_mixer(struct snd_card *card)
1560 struct snd_cs4231 *chip = card->private_data; 1560 struct snd_cs4231 *chip = card->private_data;
1561 int err, idx; 1561 int err, idx;
1562 1562
1563 snd_assert(chip != NULL && chip->pcm != NULL, return -EINVAL); 1563 if (snd_BUG_ON(!chip || !chip->pcm))
1564 return -EINVAL;
1564 1565
1565 strcpy(card->mixername, chip->pcm->name); 1566 strcpy(card->mixername, chip->pcm->name);
1566 1567
diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c
index ee2e1b4f3551..c534a2a849fa 100644
--- a/sound/sparc/dbri.c
+++ b/sound/sparc/dbri.c
@@ -2223,7 +2223,6 @@ static int __devinit snd_dbri_pcm(struct snd_card *card)
2223 /* playback count */ 1, 2223 /* playback count */ 1,
2224 /* capture count */ 1, &pcm)) < 0) 2224 /* capture count */ 1, &pcm)) < 0)
2225 return err; 2225 return err;
2226 snd_assert(pcm != NULL, return -EINVAL);
2227 2226
2228 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_dbri_ops); 2227 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_dbri_ops);
2229 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_dbri_ops); 2228 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_dbri_ops);
@@ -2263,9 +2262,10 @@ static int snd_cs4215_get_volume(struct snd_kcontrol *kcontrol,
2263{ 2262{
2264 struct snd_dbri *dbri = snd_kcontrol_chip(kcontrol); 2263 struct snd_dbri *dbri = snd_kcontrol_chip(kcontrol);
2265 struct dbri_streaminfo *info; 2264 struct dbri_streaminfo *info;
2266 snd_assert(dbri != NULL, return -EINVAL); 2265
2266 if (snd_BUG_ON(!dbri))
2267 return -EINVAL;
2267 info = &dbri->stream_info[kcontrol->private_value]; 2268 info = &dbri->stream_info[kcontrol->private_value];
2268 snd_assert(info != NULL, return -EINVAL);
2269 2269
2270 ucontrol->value.integer.value[0] = info->left_gain; 2270 ucontrol->value.integer.value[0] = info->left_gain;
2271 ucontrol->value.integer.value[1] = info->right_gain; 2271 ucontrol->value.integer.value[1] = info->right_gain;
@@ -2331,7 +2331,9 @@ static int snd_cs4215_get_single(struct snd_kcontrol *kcontrol,
2331 int shift = (kcontrol->private_value >> 8) & 0xff; 2331 int shift = (kcontrol->private_value >> 8) & 0xff;
2332 int mask = (kcontrol->private_value >> 16) & 0xff; 2332 int mask = (kcontrol->private_value >> 16) & 0xff;
2333 int invert = (kcontrol->private_value >> 24) & 1; 2333 int invert = (kcontrol->private_value >> 24) & 1;
2334 snd_assert(dbri != NULL, return -EINVAL); 2334
2335 if (snd_BUG_ON(!dbri))
2336 return -EINVAL;
2335 2337
2336 if (elem < 4) 2338 if (elem < 4)
2337 ucontrol->value.integer.value[0] = 2339 ucontrol->value.integer.value[0] =
@@ -2356,7 +2358,9 @@ static int snd_cs4215_put_single(struct snd_kcontrol *kcontrol,
2356 int invert = (kcontrol->private_value >> 24) & 1; 2358 int invert = (kcontrol->private_value >> 24) & 1;
2357 int changed = 0; 2359 int changed = 0;
2358 unsigned short val; 2360 unsigned short val;
2359 snd_assert(dbri != NULL, return -EINVAL); 2361
2362 if (snd_BUG_ON(!dbri))
2363 return -EINVAL;
2360 2364
2361 val = (ucontrol->value.integer.value[0] & mask); 2365 val = (ucontrol->value.integer.value[0] & mask);
2362 if (invert == 1) 2366 if (invert == 1)
@@ -2432,7 +2436,8 @@ static int __devinit snd_dbri_mixer(struct snd_card *card)
2432 int idx, err; 2436 int idx, err;
2433 struct snd_dbri *dbri; 2437 struct snd_dbri *dbri;
2434 2438
2435 snd_assert(card != NULL && card->private_data != NULL, return -EINVAL); 2439 if (snd_BUG_ON(!card || !card->private_data))
2440 return -EINVAL;
2436 dbri = card->private_data; 2441 dbri = card->private_data;
2437 2442
2438 strcpy(card->mixername, card->shortname); 2443 strcpy(card->mixername, card->shortname);
diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c
index c89d2ea594b9..f16a3fce4597 100644
--- a/sound/synth/emux/emux.c
+++ b/sound/synth/emux/emux.c
@@ -93,10 +93,10 @@ int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, ch
93 int err; 93 int err;
94 struct snd_sf_callback sf_cb; 94 struct snd_sf_callback sf_cb;
95 95
96 snd_assert(emu->hw != NULL, return -EINVAL); 96 if (snd_BUG_ON(!emu->hw || emu->max_voices <= 0))
97 snd_assert(emu->max_voices > 0, return -EINVAL); 97 return -EINVAL;
98 snd_assert(card != NULL, return -EINVAL); 98 if (snd_BUG_ON(!card || !name))
99 snd_assert(name != NULL, return -EINVAL); 99 return -EINVAL;
100 100
101 emu->card = card; 101 emu->card = card;
102 emu->name = kstrdup(name, GFP_KERNEL); 102 emu->name = kstrdup(name, GFP_KERNEL);
diff --git a/sound/synth/emux/emux_nrpn.c b/sound/synth/emux/emux_nrpn.c
index c6917ba2c934..00fc005ecf6e 100644
--- a/sound/synth/emux/emux_nrpn.c
+++ b/sound/synth/emux/emux_nrpn.c
@@ -289,8 +289,8 @@ snd_emux_nrpn(void *p, struct snd_midi_channel *chan,
289 struct snd_emux_port *port; 289 struct snd_emux_port *port;
290 290
291 port = p; 291 port = p;
292 snd_assert(port != NULL, return); 292 if (snd_BUG_ON(!port || !chan))
293 snd_assert(chan != NULL, return); 293 return;
294 294
295 if (chan->control[MIDI_CTL_NONREG_PARM_NUM_MSB] == 127 && 295 if (chan->control[MIDI_CTL_NONREG_PARM_NUM_MSB] == 127 &&
296 chan->control[MIDI_CTL_NONREG_PARM_NUM_LSB] <= 26) { 296 chan->control[MIDI_CTL_NONREG_PARM_NUM_LSB] <= 26) {
@@ -379,8 +379,8 @@ snd_emux_sysex(void *p, unsigned char *buf, int len, int parsed,
379 struct snd_emux *emu; 379 struct snd_emux *emu;
380 380
381 port = p; 381 port = p;
382 snd_assert(port != NULL, return); 382 if (snd_BUG_ON(!port || !chset))
383 snd_assert(chset != NULL, return); 383 return;
384 emu = port->emu; 384 emu = port->emu;
385 385
386 switch (parsed) { 386 switch (parsed) {
diff --git a/sound/synth/emux/emux_oss.c b/sound/synth/emux/emux_oss.c
index f60a98ef7dec..5c47b6c09264 100644
--- a/sound/synth/emux/emux_oss.c
+++ b/sound/synth/emux/emux_oss.c
@@ -114,7 +114,8 @@ snd_emux_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure)
114 char tmpname[64]; 114 char tmpname[64];
115 115
116 emu = closure; 116 emu = closure;
117 snd_assert(arg != NULL && emu != NULL, return -ENXIO); 117 if (snd_BUG_ON(!arg || !emu))
118 return -ENXIO;
118 119
119 mutex_lock(&emu->register_mutex); 120 mutex_lock(&emu->register_mutex);
120 121
@@ -183,12 +184,15 @@ snd_emux_close_seq_oss(struct snd_seq_oss_arg *arg)
183 struct snd_emux *emu; 184 struct snd_emux *emu;
184 struct snd_emux_port *p; 185 struct snd_emux_port *p;
185 186
186 snd_assert(arg != NULL, return -ENXIO); 187 if (snd_BUG_ON(!arg))
188 return -ENXIO;
187 p = arg->private_data; 189 p = arg->private_data;
188 snd_assert(p != NULL, return -ENXIO); 190 if (snd_BUG_ON(!p))
191 return -ENXIO;
189 192
190 emu = p->emu; 193 emu = p->emu;
191 snd_assert(emu != NULL, return -ENXIO); 194 if (snd_BUG_ON(!emu))
195 return -ENXIO;
192 196
193 mutex_lock(&emu->register_mutex); 197 mutex_lock(&emu->register_mutex);
194 snd_emux_sounds_off_all(p); 198 snd_emux_sounds_off_all(p);
@@ -212,12 +216,15 @@ snd_emux_load_patch_seq_oss(struct snd_seq_oss_arg *arg, int format,
212 struct snd_emux_port *p; 216 struct snd_emux_port *p;
213 int rc; 217 int rc;
214 218
215 snd_assert(arg != NULL, return -ENXIO); 219 if (snd_BUG_ON(!arg))
220 return -ENXIO;
216 p = arg->private_data; 221 p = arg->private_data;
217 snd_assert(p != NULL, return -ENXIO); 222 if (snd_BUG_ON(!p))
223 return -ENXIO;
218 224
219 emu = p->emu; 225 emu = p->emu;
220 snd_assert(emu != NULL, return -ENXIO); 226 if (snd_BUG_ON(!emu))
227 return -ENXIO;
221 228
222 if (format == GUS_PATCH) 229 if (format == GUS_PATCH)
223 rc = snd_soundfont_load_guspatch(emu->sflist, buf, count, 230 rc = snd_soundfont_load_guspatch(emu->sflist, buf, count,
@@ -252,12 +259,15 @@ snd_emux_ioctl_seq_oss(struct snd_seq_oss_arg *arg, unsigned int cmd, unsigned l
252 struct snd_emux_port *p; 259 struct snd_emux_port *p;
253 struct snd_emux *emu; 260 struct snd_emux *emu;
254 261
255 snd_assert(arg != NULL, return -ENXIO); 262 if (snd_BUG_ON(!arg))
263 return -ENXIO;
256 p = arg->private_data; 264 p = arg->private_data;
257 snd_assert(p != NULL, return -ENXIO); 265 if (snd_BUG_ON(!p))
266 return -ENXIO;
258 267
259 emu = p->emu; 268 emu = p->emu;
260 snd_assert(emu != NULL, return -ENXIO); 269 if (snd_BUG_ON(!emu))
270 return -ENXIO;
261 271
262 switch (cmd) { 272 switch (cmd) {
263 case SNDCTL_SEQ_RESETSAMPLES: 273 case SNDCTL_SEQ_RESETSAMPLES:
@@ -282,9 +292,11 @@ snd_emux_reset_seq_oss(struct snd_seq_oss_arg *arg)
282{ 292{
283 struct snd_emux_port *p; 293 struct snd_emux_port *p;
284 294
285 snd_assert(arg != NULL, return -ENXIO); 295 if (snd_BUG_ON(!arg))
296 return -ENXIO;
286 p = arg->private_data; 297 p = arg->private_data;
287 snd_assert(p != NULL, return -ENXIO); 298 if (snd_BUG_ON(!p))
299 return -ENXIO;
288 snd_emux_reset_port(p); 300 snd_emux_reset_port(p);
289 return 0; 301 return 0;
290} 302}
@@ -302,9 +314,11 @@ snd_emux_event_oss_input(struct snd_seq_event *ev, int direct, void *private_dat
302 unsigned char cmd, *data; 314 unsigned char cmd, *data;
303 315
304 p = private_data; 316 p = private_data;
305 snd_assert(p != NULL, return -EINVAL); 317 if (snd_BUG_ON(!p))
318 return -EINVAL;
306 emu = p->emu; 319 emu = p->emu;
307 snd_assert(emu != NULL, return -EINVAL); 320 if (snd_BUG_ON(!emu))
321 return -EINVAL;
308 if (ev->type != SNDRV_SEQ_EVENT_OSS) 322 if (ev->type != SNDRV_SEQ_EVENT_OSS)
309 return snd_emux_event_input(ev, direct, private_data, atomic, hop); 323 return snd_emux_event_input(ev, direct, private_data, atomic, hop);
310 324
diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c
index d176cc01742d..335aa2ce2574 100644
--- a/sound/synth/emux/emux_seq.c
+++ b/sound/synth/emux/emux_seq.c
@@ -257,7 +257,8 @@ snd_emux_event_input(struct snd_seq_event *ev, int direct, void *private_data,
257 struct snd_emux_port *port; 257 struct snd_emux_port *port;
258 258
259 port = private_data; 259 port = private_data;
260 snd_assert(port != NULL && ev != NULL, return -EINVAL); 260 if (snd_BUG_ON(!port || !ev))
261 return -EINVAL;
261 262
262 snd_midi_process_event(&emux_ops, ev, &port->chset); 263 snd_midi_process_event(&emux_ops, ev, &port->chset);
263 264
@@ -308,9 +309,11 @@ snd_emux_use(void *private_data, struct snd_seq_port_subscribe *info)
308 struct snd_emux *emu; 309 struct snd_emux *emu;
309 310
310 p = private_data; 311 p = private_data;
311 snd_assert(p != NULL, return -EINVAL); 312 if (snd_BUG_ON(!p))
313 return -EINVAL;
312 emu = p->emu; 314 emu = p->emu;
313 snd_assert(emu != NULL, return -EINVAL); 315 if (snd_BUG_ON(!emu))
316 return -EINVAL;
314 317
315 mutex_lock(&emu->register_mutex); 318 mutex_lock(&emu->register_mutex);
316 snd_emux_init_port(p); 319 snd_emux_init_port(p);
@@ -329,9 +332,11 @@ snd_emux_unuse(void *private_data, struct snd_seq_port_subscribe *info)
329 struct snd_emux *emu; 332 struct snd_emux *emu;
330 333
331 p = private_data; 334 p = private_data;
332 snd_assert(p != NULL, return -EINVAL); 335 if (snd_BUG_ON(!p))
336 return -EINVAL;
333 emu = p->emu; 337 emu = p->emu;
334 snd_assert(emu != NULL, return -EINVAL); 338 if (snd_BUG_ON(!emu))
339 return -EINVAL;
335 340
336 mutex_lock(&emu->register_mutex); 341 mutex_lock(&emu->register_mutex);
337 snd_emux_sounds_off_all(p); 342 snd_emux_sounds_off_all(p);
diff --git a/sound/synth/emux/emux_synth.c b/sound/synth/emux/emux_synth.c
index b343818dbb96..2cc6f6f79065 100644
--- a/sound/synth/emux/emux_synth.c
+++ b/sound/synth/emux/emux_synth.c
@@ -66,12 +66,12 @@ snd_emux_note_on(void *p, int note, int vel, struct snd_midi_channel *chan)
66 struct snd_emux_port *port; 66 struct snd_emux_port *port;
67 67
68 port = p; 68 port = p;
69 snd_assert(port != NULL && chan != NULL, return); 69 if (snd_BUG_ON(!port || !chan))
70 return;
70 71
71 emu = port->emu; 72 emu = port->emu;
72 snd_assert(emu != NULL, return); 73 if (snd_BUG_ON(!emu || !emu->ops.get_voice || !emu->ops.trigger))
73 snd_assert(emu->ops.get_voice != NULL, return); 74 return;
74 snd_assert(emu->ops.trigger != NULL, return);
75 75
76 key = note; /* remember the original note */ 76 key = note; /* remember the original note */
77 nvoices = get_zone(emu, port, &note, vel, chan, table); 77 nvoices = get_zone(emu, port, &note, vel, chan, table);
@@ -164,11 +164,12 @@ snd_emux_note_off(void *p, int note, int vel, struct snd_midi_channel *chan)
164 struct snd_emux_port *port; 164 struct snd_emux_port *port;
165 165
166 port = p; 166 port = p;
167 snd_assert(port != NULL && chan != NULL, return); 167 if (snd_BUG_ON(!port || !chan))
168 return;
168 169
169 emu = port->emu; 170 emu = port->emu;
170 snd_assert(emu != NULL, return); 171 if (snd_BUG_ON(!emu || !emu->ops.release))
171 snd_assert(emu->ops.release != NULL, return); 172 return;
172 173
173 spin_lock_irqsave(&emu->voice_lock, flags); 174 spin_lock_irqsave(&emu->voice_lock, flags);
174 for (ch = 0; ch < emu->max_voices; ch++) { 175 for (ch = 0; ch < emu->max_voices; ch++) {
@@ -242,11 +243,12 @@ snd_emux_key_press(void *p, int note, int vel, struct snd_midi_channel *chan)
242 struct snd_emux_port *port; 243 struct snd_emux_port *port;
243 244
244 port = p; 245 port = p;
245 snd_assert(port != NULL && chan != NULL, return); 246 if (snd_BUG_ON(!port || !chan))
247 return;
246 248
247 emu = port->emu; 249 emu = port->emu;
248 snd_assert(emu != NULL, return); 250 if (snd_BUG_ON(!emu || !emu->ops.update))
249 snd_assert(emu->ops.update != NULL, return); 251 return;
250 252
251 spin_lock_irqsave(&emu->voice_lock, flags); 253 spin_lock_irqsave(&emu->voice_lock, flags);
252 for (ch = 0; ch < emu->max_voices; ch++) { 254 for (ch = 0; ch < emu->max_voices; ch++) {
@@ -276,8 +278,8 @@ snd_emux_update_channel(struct snd_emux_port *port, struct snd_midi_channel *cha
276 return; 278 return;
277 279
278 emu = port->emu; 280 emu = port->emu;
279 snd_assert(emu != NULL, return); 281 if (snd_BUG_ON(!emu || !emu->ops.update))
280 snd_assert(emu->ops.update != NULL, return); 282 return;
281 283
282 spin_lock_irqsave(&emu->voice_lock, flags); 284 spin_lock_irqsave(&emu->voice_lock, flags);
283 for (i = 0; i < emu->max_voices; i++) { 285 for (i = 0; i < emu->max_voices; i++) {
@@ -303,8 +305,8 @@ snd_emux_update_port(struct snd_emux_port *port, int update)
303 return; 305 return;
304 306
305 emu = port->emu; 307 emu = port->emu;
306 snd_assert(emu != NULL, return); 308 if (snd_BUG_ON(!emu || !emu->ops.update))
307 snd_assert(emu->ops.update != NULL, return); 309 return;
308 310
309 spin_lock_irqsave(&emu->voice_lock, flags); 311 spin_lock_irqsave(&emu->voice_lock, flags);
310 for (i = 0; i < emu->max_voices; i++) { 312 for (i = 0; i < emu->max_voices; i++) {
@@ -326,7 +328,8 @@ snd_emux_control(void *p, int type, struct snd_midi_channel *chan)
326 struct snd_emux_port *port; 328 struct snd_emux_port *port;
327 329
328 port = p; 330 port = p;
329 snd_assert(port != NULL && chan != NULL, return); 331 if (snd_BUG_ON(!port || !chan))
332 return;
330 333
331 switch (type) { 334 switch (type) {
332 case MIDI_CTL_MSB_MAIN_VOLUME: 335 case MIDI_CTL_MSB_MAIN_VOLUME:
@@ -400,11 +403,12 @@ snd_emux_terminate_note(void *p, int note, struct snd_midi_channel *chan)
400 struct snd_emux_port *port; 403 struct snd_emux_port *port;
401 404
402 port = p; 405 port = p;
403 snd_assert(port != NULL && chan != NULL, return); 406 if (snd_BUG_ON(!port || !chan))
407 return;
404 408
405 emu = port->emu; 409 emu = port->emu;
406 snd_assert(emu != NULL, return); 410 if (snd_BUG_ON(!emu || !emu->ops.terminate))
407 snd_assert(emu->ops.terminate != NULL, return); 411 return;
408 412
409 terminate_note1(emu, note, chan, 1); 413 terminate_note1(emu, note, chan, 1);
410} 414}
@@ -451,10 +455,11 @@ snd_emux_sounds_off_all(struct snd_emux_port *port)
451 struct snd_emux_voice *vp; 455 struct snd_emux_voice *vp;
452 unsigned long flags; 456 unsigned long flags;
453 457
454 snd_assert(port != NULL, return); 458 if (snd_BUG_ON(!port))
459 return;
455 emu = port->emu; 460 emu = port->emu;
456 snd_assert(emu != NULL, return); 461 if (snd_BUG_ON(!emu || !emu->ops.terminate))
457 snd_assert(emu->ops.terminate != NULL, return); 462 return;
458 463
459 spin_lock_irqsave(&emu->voice_lock, flags); 464 spin_lock_irqsave(&emu->voice_lock, flags);
460 for (i = 0; i < emu->max_voices; i++) { 465 for (i = 0; i < emu->max_voices; i++) {
diff --git a/sound/synth/util_mem.c b/sound/synth/util_mem.c
index deabe5f899c4..c85522e3808d 100644
--- a/sound/synth/util_mem.c
+++ b/sound/synth/util_mem.c
@@ -55,7 +55,8 @@ void snd_util_memhdr_free(struct snd_util_memhdr *hdr)
55{ 55{
56 struct list_head *p; 56 struct list_head *p;
57 57
58 snd_assert(hdr != NULL, return); 58 if (!hdr)
59 return;
59 /* release all blocks */ 60 /* release all blocks */
60 while ((p = hdr->block.next) != &hdr->block) { 61 while ((p = hdr->block.next) != &hdr->block) {
61 list_del(p); 62 list_del(p);
@@ -74,8 +75,8 @@ __snd_util_mem_alloc(struct snd_util_memhdr *hdr, int size)
74 unsigned int units, prev_offset; 75 unsigned int units, prev_offset;
75 struct list_head *p; 76 struct list_head *p;
76 77
77 snd_assert(hdr != NULL, return NULL); 78 if (snd_BUG_ON(!hdr || size <= 0))
78 snd_assert(size > 0, return NULL); 79 return NULL;
79 80
80 /* word alignment */ 81 /* word alignment */
81 units = size; 82 units = size;
@@ -161,7 +162,8 @@ __snd_util_mem_free(struct snd_util_memhdr *hdr, struct snd_util_memblk *blk)
161 */ 162 */
162int snd_util_mem_free(struct snd_util_memhdr *hdr, struct snd_util_memblk *blk) 163int snd_util_mem_free(struct snd_util_memhdr *hdr, struct snd_util_memblk *blk)
163{ 164{
164 snd_assert(hdr && blk, return -EINVAL); 165 if (snd_BUG_ON(!hdr || !blk))
166 return -EINVAL;
165 167
166 mutex_lock(&hdr->block_mutex); 168 mutex_lock(&hdr->block_mutex);
167 __snd_util_mem_free(hdr, blk); 169 __snd_util_mem_free(hdr, blk);
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index b8cfb7c22768..c91f18cdc8b5 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -841,7 +841,8 @@ static int start_urbs(struct snd_usb_substream *subs, struct snd_pcm_runtime *ru
841 return -EBADFD; 841 return -EBADFD;
842 842
843 for (i = 0; i < subs->nurbs; i++) { 843 for (i = 0; i < subs->nurbs; i++) {
844 snd_assert(subs->dataurb[i].urb, return -EINVAL); 844 if (snd_BUG_ON(!subs->dataurb[i].urb))
845 return -EINVAL;
845 if (subs->ops.prepare(subs, runtime, subs->dataurb[i].urb) < 0) { 846 if (subs->ops.prepare(subs, runtime, subs->dataurb[i].urb) < 0) {
846 snd_printk(KERN_ERR "cannot prepare datapipe for urb %d\n", i); 847 snd_printk(KERN_ERR "cannot prepare datapipe for urb %d\n", i);
847 goto __error; 848 goto __error;
@@ -849,7 +850,8 @@ static int start_urbs(struct snd_usb_substream *subs, struct snd_pcm_runtime *ru
849 } 850 }
850 if (subs->syncpipe) { 851 if (subs->syncpipe) {
851 for (i = 0; i < SYNC_URBS; i++) { 852 for (i = 0; i < SYNC_URBS; i++) {
852 snd_assert(subs->syncurb[i].urb, return -EINVAL); 853 if (snd_BUG_ON(!subs->syncurb[i].urb))
854 return -EINVAL;
853 if (subs->ops.prepare_sync(subs, runtime, subs->syncurb[i].urb) < 0) { 855 if (subs->ops.prepare_sync(subs, runtime, subs->syncurb[i].urb) < 0) {
854 snd_printk(KERN_ERR "cannot prepare syncpipe for urb %d\n", i); 856 snd_printk(KERN_ERR "cannot prepare syncpipe for urb %d\n", i);
855 goto __error; 857 goto __error;
@@ -1321,10 +1323,12 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
1321 int err; 1323 int err;
1322 1324
1323 iface = usb_ifnum_to_if(dev, fmt->iface); 1325 iface = usb_ifnum_to_if(dev, fmt->iface);
1324 snd_assert(iface, return -EINVAL); 1326 if (WARN_ON(!iface))
1327 return -EINVAL;
1325 alts = &iface->altsetting[fmt->altset_idx]; 1328 alts = &iface->altsetting[fmt->altset_idx];
1326 altsd = get_iface_desc(alts); 1329 altsd = get_iface_desc(alts);
1327 snd_assert(altsd->bAlternateSetting == fmt->altsetting, return -EINVAL); 1330 if (WARN_ON(altsd->bAlternateSetting != fmt->altsetting))
1331 return -EINVAL;
1328 1332
1329 if (fmt == subs->cur_audiofmt) 1333 if (fmt == subs->cur_audiofmt)
1330 return 0; 1334 return 0;
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c
index 5f98bee06959..6621fad8c5f0 100644
--- a/sound/usb/usbmixer.c
+++ b/sound/usb/usbmixer.c
@@ -1389,7 +1389,8 @@ static int mixer_ctl_selector_info(struct snd_kcontrol *kcontrol, struct snd_ctl
1389 struct usb_mixer_elem_info *cval = kcontrol->private_data; 1389 struct usb_mixer_elem_info *cval = kcontrol->private_data;
1390 char **itemlist = (char **)kcontrol->private_value; 1390 char **itemlist = (char **)kcontrol->private_value;
1391 1391
1392 snd_assert(itemlist, return -EINVAL); 1392 if (snd_BUG_ON(!itemlist))
1393 return -EINVAL;
1393 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1394 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1394 uinfo->count = 1; 1395 uinfo->count = 1;
1395 uinfo->value.enumerated.items = cval->max; 1396 uinfo->value.enumerated.items = cval->max;