Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: Kill snd_assert() in sound/pci/*

Kill snd_assert() in sound/pci/*, either removed or replaced with
if () with snd_BUG_ON().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

authored by

Takashi Iwai and committed by
Jaroslav Kysela
da3cec35 622207dc

+632 -361
+12 -7
sound/pci/ac97/ac97_codec.c
··· 1890 1890 .dev_free = snd_ac97_bus_dev_free, 1891 1891 }; 1892 1892 1893 - snd_assert(card != NULL, return -EINVAL); 1894 - snd_assert(rbus != NULL, return -EINVAL); 1893 + if (snd_BUG_ON(!card)) 1894 + return -EINVAL; 1895 1895 bus = kzalloc(sizeof(*bus), GFP_KERNEL); 1896 1896 if (bus == NULL) 1897 1897 return -ENOMEM; ··· 1906 1906 snd_ac97_bus_free(bus); 1907 1907 return err; 1908 1908 } 1909 - *rbus = bus; 1909 + if (rbus) 1910 + *rbus = bus; 1910 1911 return 0; 1911 1912 } 1912 1913 ··· 1992 1991 .dev_disconnect = snd_ac97_dev_disconnect, 1993 1992 }; 1994 1993 1995 - snd_assert(rac97 != NULL, return -EINVAL); 1996 - *rac97 = NULL; 1997 - snd_assert(bus != NULL && template != NULL, return -EINVAL); 1998 - snd_assert(template->num < 4 && bus->codec[template->num] == NULL, return -EINVAL); 1994 + if (rac97) 1995 + *rac97 = NULL; 1996 + if (snd_BUG_ON(!bus || !template)) 1997 + return -EINVAL; 1998 + if (snd_BUG_ON(template->num >= 4)) 1999 + return -EINVAL; 2000 + if (bus->codec[template->num]) 2001 + return -EBUSY; 1999 2002 2000 2003 card = bus->card; 2001 2004 ac97 = kzalloc(sizeof(*ac97), GFP_KERNEL);
+4 -2
sound/pci/ad1889.c
··· 549 549 ptr = ad1889_readl(chip, AD_DMA_WAVCA); 550 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 555 return bytes_to_frames(ss->runtime, ptr); 555 556 } ··· 568 567 ptr = ad1889_readl(chip, AD_DMA_ADCCA); 569 568 ptr -= chip->ramc.addr; 570 569 571 - snd_assert((ptr >= 0) && (ptr < chip->ramc.size), return 0); 570 + if (snd_BUG_ON(ptr >= chip->ramc.size)) 571 + return 0; 572 572 573 573 return bytes_to_frames(ss->runtime, ptr); 574 574 }
+6 -4
sound/pci/ak4531_codec.c
··· 392 392 .dev_free = snd_ak4531_dev_free, 393 393 }; 394 394 395 - snd_assert(rak4531 != NULL, return -EINVAL); 396 - *rak4531 = NULL; 397 - snd_assert(card != NULL && _ak4531 != NULL, return -EINVAL); 395 + if (snd_BUG_ON(!card || !_ak4531)) 396 + return -EINVAL; 397 + if (rak4531) 398 + *rak4531 = NULL; 398 399 ak4531 = kzalloc(sizeof(*ak4531), GFP_KERNEL); 399 400 if (ak4531 == NULL) 400 401 return -ENOMEM; ··· 429 428 #if 0 430 429 snd_ak4531_dump(ak4531); 431 430 #endif 432 - *rak4531 = ak4531; 431 + if (rak4531) 432 + *rak4531 = ak4531; 433 433 return 0; 434 434 } 435 435
+7 -3
sound/pci/atiixp.c
··· 722 722 struct atiixp_dma *dma = substream->runtime->private_data; 723 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 729 spin_lock(&chip->reg_lock); 728 730 switch (cmd) { ··· 1034 1032 struct snd_pcm_runtime *runtime = substream->runtime; 1035 1033 int err; 1036 1034 1037 - snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL); 1035 + if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma)) 1036 + return -EINVAL; 1038 1037 1039 1038 if (dma->opened) 1040 1039 return -EBUSY; ··· 1067 1064 { 1068 1065 struct atiixp *chip = snd_pcm_substream_chip(substream); 1069 1066 /* disable DMA bits */ 1070 - snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL); 1067 + if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma)) 1068 + return -EINVAL; 1071 1069 spin_lock_irq(&chip->reg_lock); 1072 1070 dma->ops->enable_dma(chip, 0); 1073 1071 spin_unlock_irq(&chip->reg_lock);
+7 -3
sound/pci/atiixp_modem.c
··· 674 674 struct atiixp_dma *dma = substream->runtime->private_data; 675 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 681 spin_lock(&chip->reg_lock); 680 682 switch(cmd) { ··· 867 865 .mask = 0, 868 866 }; 869 867 870 - snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL); 868 + if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma)) 869 + return -EINVAL; 871 870 872 871 if (dma->opened) 873 872 return -EBUSY; ··· 898 895 { 899 896 struct atiixp_modem *chip = snd_pcm_substream_chip(substream); 900 897 /* disable DMA bits */ 901 - snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL); 898 + if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma)) 899 + return -EINVAL; 902 900 spin_lock_irq(&chip->reg_lock); 903 901 dma->ops->enable_dma(chip, 0); 904 902 spin_unlock_irq(&chip->reg_lock);
+4 -2
sound/pci/azt3328.c
··· 816 816 int err; 817 817 818 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 822 card = chip->card; 822 823 ··· 1472 1471 u8 val; 1473 1472 unsigned long flags; 1474 1473 1475 - snd_assert(chip, return 0); 1474 + if (snd_BUG_ON(!chip)) 1475 + return 0; 1476 1476 1477 1477 spin_lock_irqsave(&chip->reg_lock, flags); 1478 1478 val = snd_azf3328_game_inb(chip, IDX_GAME_LEGACY_COMPATIBLE);
+14 -6
sound/pci/ca0106/ca_midi.c
··· 125 125 struct snd_ca_midi *midi = substream->rmidi->private_data; 126 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 130 spin_lock_irqsave(&midi->open_lock, flags); 130 131 midi->midi_mode |= CA_MIDI_MODE_INPUT; 131 132 midi->substream_input = substream; ··· 145 144 struct snd_ca_midi *midi = substream->rmidi->private_data; 146 145 unsigned long flags; 147 146 148 - snd_assert(midi->dev_id, return -ENXIO); 147 + if (snd_BUG_ON(!midi->dev_id)) 148 + return -ENXIO; 149 149 spin_lock_irqsave(&midi->open_lock, flags); 150 150 midi->midi_mode |= CA_MIDI_MODE_OUTPUT; 151 151 midi->substream_output = substream; ··· 165 163 struct snd_ca_midi *midi = substream->rmidi->private_data; 166 164 unsigned long flags; 167 165 168 - snd_assert(midi->dev_id, return -ENXIO); 166 + if (snd_BUG_ON(!midi->dev_id)) 167 + return -ENXIO; 169 168 spin_lock_irqsave(&midi->open_lock, flags); 170 169 midi->interrupt_disable(midi,midi->rx_enable); 171 170 midi->midi_mode &= ~CA_MIDI_MODE_INPUT; ··· 184 181 { 185 182 struct snd_ca_midi *midi = substream->rmidi->private_data; 186 183 unsigned long flags; 187 - snd_assert(midi->dev_id, return -ENXIO); 184 + 185 + if (snd_BUG_ON(!midi->dev_id)) 186 + return -ENXIO; 188 187 189 188 spin_lock_irqsave(&midi->open_lock, flags); 190 189 ··· 206 201 static void ca_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) 207 202 { 208 203 struct snd_ca_midi *midi = substream->rmidi->private_data; 209 - snd_assert(midi->dev_id, return); 204 + 205 + if (snd_BUG_ON(!midi->dev_id)) 206 + return; 210 207 211 208 if (up) { 212 209 midi->interrupt_enable(midi,midi->rx_enable); ··· 222 215 struct snd_ca_midi *midi = substream->rmidi->private_data; 223 216 unsigned long flags; 224 217 225 - snd_assert(midi->dev_id, return); 218 + if (snd_BUG_ON(!midi->dev_id)) 219 + return; 226 220 227 221 if (up) { 228 222 int max = 4;
+6 -3
sound/pci/cmipci.c
··· 2357 2357 { 2358 2358 struct cmipci_switch_args *args; 2359 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 2362 return _snd_cmipci_uswitch_get(kcontrol, ucontrol, args); 2362 2363 } 2363 2364 ··· 2402 2401 { 2403 2402 struct cmipci_switch_args *args; 2404 2403 args = (struct cmipci_switch_args *)kcontrol->private_value; 2405 - snd_assert(args != NULL, return -EINVAL); 2404 + if (snd_BUG_ON(!args)) 2405 + return -EINVAL; 2406 2406 return _snd_cmipci_uswitch_put(kcontrol, ucontrol, args); 2407 2407 } 2408 2408 ··· 2664 2662 unsigned int idx; 2665 2663 int err; 2666 2664 2667 - snd_assert(cm != NULL && cm->card != NULL, return -EINVAL); 2665 + if (snd_BUG_ON(!cm || !cm->card)) 2666 + return -EINVAL; 2668 2667 2669 2668 card = cm->card; 2670 2669
+8 -5
sound/pci/cs4281.c
··· 766 766 if (!capture) { 767 767 if (dma->left_slot == chip->src_left_play_slot) { 768 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 770 snd_cs4281_pokeBA0(chip, BA0_DACSR, val); 771 771 } 772 772 } else { 773 773 if (dma->left_slot == chip->src_left_rec_slot) { 774 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 776 snd_cs4281_pokeBA0(chip, BA0_ADCSR, val); 777 777 } 778 778 } ··· 1209 1209 { 1210 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 1214 snd_cs4281_pokeBA0(chip, BA0_JSPT, 0xff); 1214 1215 } 1215 1216 ··· 1218 1217 { 1219 1218 struct cs4281 *chip = gameport_get_port_data(gameport); 1220 1219 1221 - snd_assert(chip, return 0); 1220 + if (snd_BUG_ON(!chip)) 1221 + return 0; 1222 1222 return snd_cs4281_peekBA0(chip, BA0_JSPT); 1223 1223 } 1224 1224 ··· 1230 1228 struct cs4281 *chip = gameport_get_port_data(gameport); 1231 1229 unsigned js1, js2, jst; 1232 1230 1233 - snd_assert(chip, return 0); 1231 + if (snd_BUG_ON(!chip)) 1232 + return 0; 1234 1233 1235 1234 js1 = snd_cs4281_peekBA0(chip, BA0_JSC1); 1236 1235 js2 = snd_cs4281_peekBA0(chip, BA0_JSC2);
+42 -30
sound/pci/cs46xx/cs46xx_lib.c
··· 90 90 int count; 91 91 unsigned short result,tmp; 92 92 u32 offset = 0; 93 - snd_assert ( (codec_index == CS46XX_PRIMARY_CODEC_INDEX) || 94 - (codec_index == CS46XX_SECONDARY_CODEC_INDEX), 95 - return -EINVAL); 93 + 94 + if (snd_BUG_ON(codec_index != CS46XX_PRIMARY_CODEC_INDEX && 95 + codec_index != CS46XX_SECONDARY_CODEC_INDEX)) 96 + return -EINVAL; 96 97 97 98 chip->active_ctrl(chip, 1); 98 99 ··· 213 212 unsigned short val; 214 213 int codec_index = ac97->num; 215 214 216 - snd_assert(codec_index == CS46XX_PRIMARY_CODEC_INDEX || 217 - codec_index == CS46XX_SECONDARY_CODEC_INDEX, 218 - return 0xffff); 215 + if (snd_BUG_ON(codec_index != CS46XX_PRIMARY_CODEC_INDEX && 216 + codec_index != CS46XX_SECONDARY_CODEC_INDEX)) 217 + return 0xffff; 219 218 220 219 val = snd_cs46xx_codec_read(chip, reg, codec_index); 221 220 ··· 230 229 { 231 230 int count; 232 231 233 - snd_assert ((codec_index == CS46XX_PRIMARY_CODEC_INDEX) || 234 - (codec_index == CS46XX_SECONDARY_CODEC_INDEX), 235 - return); 232 + if (snd_BUG_ON(codec_index != CS46XX_PRIMARY_CODEC_INDEX && 233 + codec_index != CS46XX_SECONDARY_CODEC_INDEX)) 234 + return; 236 235 237 236 chip->active_ctrl(chip, 1); 238 237 ··· 295 294 struct snd_cs46xx *chip = ac97->private_data; 296 295 int codec_index = ac97->num; 297 296 298 - snd_assert(codec_index == CS46XX_PRIMARY_CODEC_INDEX || 299 - codec_index == CS46XX_SECONDARY_CODEC_INDEX, 300 - return); 297 + if (snd_BUG_ON(codec_index != CS46XX_PRIMARY_CODEC_INDEX && 298 + codec_index != CS46XX_SECONDARY_CODEC_INDEX)) 299 + return; 301 300 302 301 snd_cs46xx_codec_write(chip, reg, val, codec_index); 303 302 } ··· 316 315 unsigned int bank = offset >> 16; 317 316 offset = offset & 0xffff; 318 317 319 - snd_assert(!(offset & 3) && !(len & 3), return -EINVAL); 318 + if (snd_BUG_ON((offset & 3) || (len & 3))) 319 + return -EINVAL; 320 320 dst = chip->region.idx[bank+1].remap_addr + offset; 321 321 len /= sizeof(u32); 322 322 ··· 345 343 unsigned int bank = offset >> 16; 346 344 offset = offset & 0xffff; 347 345 348 - snd_assert(!(offset & 3) && !(len & 3), return -EINVAL); 346 + if (snd_BUG_ON((offset & 3) || (len & 3))) 347 + return -EINVAL; 349 348 dst = chip->region.idx[bank+1].remap_addr + offset; 350 349 len /= sizeof(u32); 351 350 ··· 725 722 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); 726 723 size_t ptr; 727 724 struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data; 728 - snd_assert (cpcm->pcm_channel,return -ENXIO); 725 + 726 + if (snd_BUG_ON(!cpcm->pcm_channel)) 727 + return -ENXIO; 729 728 730 729 #ifdef CONFIG_SND_CS46XX_NEW_DSP 731 730 ptr = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 2) << 2); ··· 745 740 struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data; 746 741 747 742 #ifdef CONFIG_SND_CS46XX_NEW_DSP 748 - snd_assert (cpcm->pcm_channel,return -ENXIO); 743 + if (snd_BUG_ON(!cpcm->pcm_channel)) 744 + return -ENXIO; 749 745 ptr = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 2) << 2); 750 746 #else 751 747 ptr = snd_cs46xx_peek(chip, BA1_PBA); ··· 914 908 cpcm = runtime->private_data; 915 909 916 910 #ifdef CONFIG_SND_CS46XX_NEW_DSP 917 - snd_assert (sample_rate != 0, return -ENXIO); 911 + if (snd_BUG_ON(!sample_rate)) 912 + return -ENXIO; 918 913 919 914 mutex_lock(&chip->spos_mutex); 920 915 ··· 924 917 return -ENXIO; 925 918 } 926 919 927 - snd_assert (cpcm->pcm_channel != NULL); 920 + snd_BUG_ON(!cpcm->pcm_channel); 928 921 if (!cpcm->pcm_channel) { 929 922 mutex_unlock(&chip->spos_mutex); 930 923 return -ENXIO; ··· 959 952 } else if (cpcm->pcm_channel_id == DSP_IEC958_CHANNEL) { 960 953 substream->ops = &snd_cs46xx_playback_iec958_ops; 961 954 } else { 962 - snd_assert(0); 955 + snd_BUG(); 963 956 } 964 957 #else 965 958 substream->ops = &snd_cs46xx_playback_ops; ··· 988 981 } else if (cpcm->pcm_channel_id == DSP_IEC958_CHANNEL) { 989 982 substream->ops = &snd_cs46xx_playback_indirect_iec958_ops; 990 983 } else { 991 - snd_assert(0); 984 + snd_BUG(); 992 985 } 993 986 #else 994 987 substream->ops = &snd_cs46xx_playback_indirect_ops; ··· 1036 1029 cpcm = runtime->private_data; 1037 1030 1038 1031 #ifdef CONFIG_SND_CS46XX_NEW_DSP 1039 - snd_assert (cpcm->pcm_channel != NULL, return -ENXIO); 1032 + if (snd_BUG_ON(!cpcm->pcm_channel)) 1033 + return -ENXIO; 1040 1034 1041 1035 pfie = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 1) << 2 ); 1042 1036 pfie &= ~0x0000f03f; ··· 1722 1714 { 1723 1715 struct snd_cs46xx *chip = ac97->private_data; 1724 1716 1725 - snd_assert ((ac97 == chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]) || 1726 - (ac97 == chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]), 1727 - return); 1717 + if (snd_BUG_ON(ac97 != chip->ac97[CS46XX_PRIMARY_CODEC_INDEX] && 1718 + ac97 != chip->ac97[CS46XX_SECONDARY_CODEC_INDEX])) 1719 + return; 1728 1720 1729 1721 if (ac97 == chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]) { 1730 1722 chip->ac97[CS46XX_PRIMARY_CODEC_INDEX] = NULL; ··· 1872 1864 break; 1873 1865 default: 1874 1866 res = -EINVAL; 1875 - snd_assert(0, (void)0); 1867 + snd_BUG(); /* should never happen ... */ 1876 1868 } 1877 1869 1878 1870 return res; ··· 2244 2236 snd_printdd("cs46xx: CODOEC2 mode %04x\n",0x3); 2245 2237 snd_cs46xx_ac97_write(ac97,AC97_CSR_ACMODE,0x3); 2246 2238 } else { 2247 - snd_assert(0); /* should never happen ... */ 2239 + snd_BUG(); /* should never happen ... */ 2248 2240 } 2249 2241 2250 2242 udelay(50); ··· 2561 2553 { 2562 2554 struct snd_cs46xx *chip = gameport_get_port_data(gameport); 2563 2555 2564 - snd_assert(chip, return); 2556 + if (snd_BUG_ON(!chip)) 2557 + return; 2565 2558 snd_cs46xx_pokeBA0(chip, BA0_JSPT, 0xFF); //outb(gameport->io, 0xFF); 2566 2559 } 2567 2560 ··· 2570 2561 { 2571 2562 struct snd_cs46xx *chip = gameport_get_port_data(gameport); 2572 2563 2573 - snd_assert(chip, return 0); 2564 + if (snd_BUG_ON(!chip)) 2565 + return 0; 2574 2566 return snd_cs46xx_peekBA0(chip, BA0_JSPT); //inb(gameport->io); 2575 2567 } 2576 2568 ··· 2580 2570 struct snd_cs46xx *chip = gameport_get_port_data(gameport); 2581 2571 unsigned js1, js2, jst; 2582 2572 2583 - snd_assert(chip, return 0); 2573 + if (snd_BUG_ON(!chip)) 2574 + return 0; 2584 2575 2585 2576 js1 = snd_cs46xx_peekBA0(chip, BA0_JSC1); 2586 2577 js2 = snd_cs46xx_peekBA0(chip, BA0_JSC2); ··· 2765 2754 { 2766 2755 int idx; 2767 2756 2768 - snd_assert(chip != NULL, return -EINVAL); 2757 + if (snd_BUG_ON(!chip)) 2758 + return -EINVAL; 2769 2759 2770 2760 if (chip->active_ctrl) 2771 2761 chip->active_ctrl(chip, 1);
+34 -17
sound/pci/cs46xx/dsp_spos.c
··· 63 63 u32 mop_operands,mop_type,wide_op; 64 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 69 while (i < size) { 69 70 loval = data[i++]; ··· 290 289 int i; 291 290 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 292 291 293 - snd_assert(ins != NULL, return); 292 + if (snd_BUG_ON(!ins)) 293 + return; 294 294 295 295 mutex_lock(&chip->spos_mutex); 296 296 for (i = 0; i < ins->nscb; ++i) { ··· 406 404 407 405 /* if module has a code segment it must have 408 406 symbol table */ 409 - snd_assert(module->symbol_table.symbols != NULL ,return -ENOMEM); 407 + if (snd_BUG_ON(!module->symbol_table.symbols)) 408 + return -ENOMEM; 410 409 if (add_symbols(chip,module)) { 411 410 snd_printk(KERN_ERR "dsp_spos: failed to load symbol table\n"); 412 411 return -ENOMEM; ··· 1372 1369 1373 1370 valid_slots = snd_cs46xx_peekBA0(chip, BA0_ACOSV); 1374 1371 1375 - snd_assert (chip->nr_ac97_codecs == 1 || chip->nr_ac97_codecs == 2); 1372 + if (snd_BUG_ON(chip->nr_ac97_codecs != 1 && chip->nr_ac97_codecs != 2)) 1373 + goto _fail_end; 1376 1374 1377 1375 if (chip->nr_ac97_codecs == 1) { 1378 1376 /* output on slot 5 and 11 ··· 1613 1609 1614 1610 spdifo_scb_desc = cs46xx_dsp_create_scb(chip,"SPDIFOSCB",(u32 *)&spdifo_scb,SPDIFO_SCB_INST); 1615 1611 1616 - snd_assert(spdifo_scb_desc, return -EIO); 1612 + if (snd_BUG_ON(!spdifo_scb_desc)) 1613 + return -EIO; 1617 1614 spdifi_scb_desc = cs46xx_dsp_create_scb(chip,"SPDIFISCB",(u32 *)&spdifi_scb,SPDIFI_SCB_INST); 1618 - snd_assert(spdifi_scb_desc, return -EIO); 1615 + if (snd_BUG_ON(!spdifi_scb_desc)) 1616 + return -EIO; 1619 1617 async_codec_scb_desc = cs46xx_dsp_create_scb(chip,"AsynCodecInputSCB",(u32 *)&async_codec_input_scb, HFG_TREE_SCB); 1620 - snd_assert(async_codec_scb_desc, return -EIO); 1618 + if (snd_BUG_ON(!async_codec_scb_desc)) 1619 + return -EIO; 1621 1620 1622 1621 async_codec_scb_desc->parent_scb_ptr = NULL; 1623 1622 async_codec_scb_desc->next_scb_ptr = spdifi_scb_desc; ··· 1705 1698 chip->active_ctrl(chip, 1); 1706 1699 chip->amplifier_ctrl(chip, 1); 1707 1700 1708 - snd_assert (ins->asynch_rx_scb == NULL,return -EINVAL); 1709 - snd_assert (ins->spdif_in_src != NULL,return -EINVAL); 1701 + if (snd_BUG_ON(ins->asynch_rx_scb)) 1702 + return -EINVAL; 1703 + if (snd_BUG_ON(!ins->spdif_in_src)) 1704 + return -EINVAL; 1710 1705 1711 1706 mutex_lock(&chip->spos_mutex); 1712 1707 ··· 1763 1754 { 1764 1755 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1765 1756 1766 - snd_assert (ins->asynch_rx_scb != NULL, return -EINVAL); 1767 - snd_assert (ins->spdif_in_src != NULL,return -EINVAL); 1757 + if (snd_BUG_ON(!ins->asynch_rx_scb)) 1758 + return -EINVAL; 1759 + if (snd_BUG_ON(!ins->spdif_in_src)) 1760 + return -EINVAL; 1768 1761 1769 1762 mutex_lock(&chip->spos_mutex); 1770 1763 ··· 1791 1780 { 1792 1781 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1793 1782 1794 - snd_assert (ins->pcm_input == NULL,return -EINVAL); 1795 - snd_assert (ins->ref_snoop_scb != NULL,return -EINVAL); 1783 + if (snd_BUG_ON(ins->pcm_input)) 1784 + return -EINVAL; 1785 + if (snd_BUG_ON(!ins->ref_snoop_scb)) 1786 + return -EINVAL; 1796 1787 1797 1788 mutex_lock(&chip->spos_mutex); 1798 1789 ins->pcm_input = cs46xx_add_record_source(chip,ins->ref_snoop_scb,PCMSERIALIN_PCM_SCB_ADDR, ··· 1808 1795 { 1809 1796 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1810 1797 1811 - snd_assert (ins->pcm_input != NULL,return -EINVAL); 1798 + if (snd_BUG_ON(!ins->pcm_input)) 1799 + return -EINVAL; 1812 1800 1813 1801 mutex_lock(&chip->spos_mutex); 1814 1802 cs46xx_dsp_remove_scb (chip,ins->pcm_input); ··· 1823 1809 { 1824 1810 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1825 1811 1826 - snd_assert (ins->adc_input == NULL,return -EINVAL); 1827 - snd_assert (ins->codec_in_scb != NULL,return -EINVAL); 1812 + if (snd_BUG_ON(ins->adc_input)) 1813 + return -EINVAL; 1814 + if (snd_BUG_ON(!ins->codec_in_scb)) 1815 + return -EINVAL; 1828 1816 1829 1817 mutex_lock(&chip->spos_mutex); 1830 1818 ins->adc_input = cs46xx_add_record_source(chip,ins->codec_in_scb,PCMSERIALIN_SCB_ADDR, ··· 1840 1824 { 1841 1825 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1842 1826 1843 - snd_assert (ins->adc_input != NULL,return -EINVAL); 1827 + if (snd_BUG_ON(!ins->adc_input)) 1828 + return -EINVAL; 1844 1829 1845 1830 mutex_lock(&chip->spos_mutex); 1846 1831 cs46xx_dsp_remove_scb (chip,ins->adc_input);
+70 -45
sound/pci/cs46xx/dsp_spos_scb_lib.c
··· 46 46 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 47 47 int symbol_index = (int)(symbol - ins->symbol_table.symbols); 48 48 49 - snd_assert(ins->symbol_table.nsymbols > 0,return); 50 - snd_assert(symbol_index >= 0 && symbol_index < ins->symbol_table.nsymbols, return); 49 + if (snd_BUG_ON(ins->symbol_table.nsymbols <= 0)) 50 + return; 51 + if (snd_BUG_ON(symbol_index < 0 || 52 + symbol_index >= ins->symbol_table.nsymbols)) 53 + return; 51 54 52 55 ins->symbol_table.symbols[symbol_index].deleted = 1; 53 56 ··· 119 116 120 117 if ( scb->parent_scb_ptr ) { 121 118 /* unlink parent SCB */ 122 - snd_assert ((scb->parent_scb_ptr->sub_list_ptr == scb || 123 - scb->parent_scb_ptr->next_scb_ptr == scb),return); 119 + if (snd_BUG_ON(scb->parent_scb_ptr->sub_list_ptr != scb && 120 + scb->parent_scb_ptr->next_scb_ptr != scb)) 121 + return; 124 122 125 123 if (scb->parent_scb_ptr->sub_list_ptr == scb) { 126 124 ··· 144 140 scb->next_scb_ptr = ins->the_null_scb; 145 141 } 146 142 } else { 147 - /* snd_assert ( (scb->sub_list_ptr == ins->the_null_scb), return); */ 148 143 scb->parent_scb_ptr->next_scb_ptr = scb->next_scb_ptr; 149 144 150 145 if (scb->next_scb_ptr != ins->the_null_scb) { ··· 184 181 unsigned long flags; 185 182 186 183 /* check integrety */ 187 - snd_assert ( (scb->index >= 0 && 188 - scb->index < ins->nscb && 189 - (ins->scbs + scb->index) == scb), return ); 184 + if (snd_BUG_ON(scb->index < 0 || 185 + scb->index >= ins->nscb || 186 + (ins->scbs + scb->index) != scb)) 187 + return; 190 188 191 189 #if 0 192 190 /* can't remove a SCB with childs before 193 191 removing childs first */ 194 - snd_assert ( (scb->sub_list_ptr == ins->the_null_scb && 195 - scb->next_scb_ptr == ins->the_null_scb), 196 - goto _end); 192 + if (snd_BUG_ON(scb->sub_list_ptr != ins->the_null_scb || 193 + scb->next_scb_ptr != ins->the_null_scb)) 194 + goto _end; 197 195 #endif 198 196 199 197 spin_lock_irqsave(&scb->lock, flags); ··· 202 198 spin_unlock_irqrestore(&scb->lock, flags); 203 199 204 200 cs46xx_dsp_proc_free_scb_desc(scb); 205 - snd_assert (scb->scb_symbol != NULL, return ); 201 + if (snd_BUG_ON(!scb->scb_symbol)) 202 + return; 206 203 remove_symbol (chip,scb->scb_symbol); 207 204 208 205 ins->scbs[scb->index].deleted = 1; ··· 239 234 snd_info_free_entry(scb->proc_info); 240 235 scb->proc_info = NULL; 241 236 242 - snd_assert (scb_info != NULL, return); 243 237 kfree (scb_info); 244 238 } 245 239 } ··· 295 291 296 292 unsigned long flags; 297 293 298 - snd_assert (ins->the_null_scb != NULL,return NULL); 294 + if (snd_BUG_ON(!ins->the_null_scb)) 295 + return NULL; 299 296 300 297 /* fill the data that will be wroten to DSP */ 301 298 scb_data[SCBsubListPtr] = ··· 326 321 #endif 327 322 /* link to parent SCB */ 328 323 if (scb_child_type == SCB_ON_PARENT_NEXT_SCB) { 329 - snd_assert ( (scb->parent_scb_ptr->next_scb_ptr == ins->the_null_scb), 330 - return NULL); 324 + if (snd_BUG_ON(scb->parent_scb_ptr->next_scb_ptr != 325 + ins->the_null_scb)) 326 + return NULL; 331 327 332 328 scb->parent_scb_ptr->next_scb_ptr = scb; 333 329 334 330 } else if (scb_child_type == SCB_ON_PARENT_SUBLIST_SCB) { 335 - snd_assert ( (scb->parent_scb_ptr->sub_list_ptr == ins->the_null_scb), 336 - return NULL); 331 + if (snd_BUG_ON(scb->parent_scb_ptr->sub_list_ptr != 332 + ins->the_null_scb)) 333 + return NULL; 337 334 338 335 scb->parent_scb_ptr->sub_list_ptr = scb; 339 336 } else { 340 - snd_assert (0,return NULL); 337 + snd_BUG(); 341 338 } 342 339 343 340 spin_lock_irqsave(&chip->reg_lock, flags); ··· 682 675 if (pass_through) { 683 676 /* wont work with any other rate than 684 677 the native DSP rate */ 685 - snd_assert (rate == 48000); 678 + snd_BUG_ON(rate != 48000); 686 679 687 680 scb = cs46xx_dsp_create_generic_scb(chip,scb_name,(u32 *)&src_task_scb, 688 681 dest,"DMAREADER",parent_scb, ··· 1149 1142 struct dsp_scb_descriptor * scb = from; 1150 1143 1151 1144 while (scb->next_scb_ptr != ins->the_null_scb) { 1152 - snd_assert (scb->next_scb_ptr != NULL, return NULL); 1145 + if (snd_BUG_ON(!scb->next_scb_ptr)) 1146 + return NULL; 1153 1147 1154 1148 scb = scb->next_scb_ptr; 1155 1149 } ··· 1254 1246 break; 1255 1247 case DSP_PCM_S71_CHANNEL: 1256 1248 /* TODO */ 1257 - snd_assert(0); 1249 + snd_BUG(); 1258 1250 break; 1259 1251 case DSP_IEC958_CHANNEL: 1260 - snd_assert (ins->asynch_tx_scb != NULL, return NULL); 1252 + if (snd_BUG_ON(!ins->asynch_tx_scb)) 1253 + return NULL; 1261 1254 mixer_scb = ins->asynch_tx_scb; 1262 1255 1263 1256 /* if sample rate is set to 48khz we pass ··· 1271 1262 } 1272 1263 break; 1273 1264 default: 1274 - snd_assert (0); 1265 + snd_BUG(); 1275 1266 return NULL; 1276 1267 } 1277 1268 /* default sample rate is 44100 */ ··· 1317 1308 break; 1318 1309 } 1319 1310 } 1320 - snd_assert (src_index != -1,return NULL); 1311 + if (snd_BUG_ON(src_index == -1)) 1312 + return NULL; 1321 1313 1322 1314 /* we need to create a new SRC SCB */ 1323 1315 if (mixer_scb->sub_list_ptr == ins->the_null_scb) { ··· 1472 1462 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1473 1463 unsigned long flags; 1474 1464 1475 - snd_assert(pcm_channel->active, return ); 1476 - snd_assert(ins->npcm_channels > 0, return ); 1477 - snd_assert(pcm_channel->src_scb->ref_count > 0, return ); 1465 + if (snd_BUG_ON(!pcm_channel->active || 1466 + ins->npcm_channels <= 0 || 1467 + pcm_channel->src_scb->ref_count <= 0)) 1468 + return; 1478 1469 1479 1470 spin_lock_irqsave(&chip->reg_lock, flags); 1480 1471 pcm_channel->unlinked = 1; ··· 1490 1479 if (!pcm_channel->src_scb->ref_count) { 1491 1480 cs46xx_dsp_remove_scb(chip,pcm_channel->src_scb); 1492 1481 1493 - snd_assert (pcm_channel->src_slot >= 0 && pcm_channel->src_slot < DSP_MAX_SRC_NR, 1494 - return ); 1482 + if (snd_BUG_ON(pcm_channel->src_slot < 0 || 1483 + pcm_channel->src_slot >= DSP_MAX_SRC_NR)) 1484 + return; 1495 1485 1496 1486 ins->src_scb_slots[pcm_channel->src_slot] = 0; 1497 1487 ins->nsrc_scb --; ··· 1502 1490 int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip, 1503 1491 struct dsp_pcm_channel_descriptor * pcm_channel) 1504 1492 { 1505 - struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1506 1493 unsigned long flags; 1507 1494 1508 - snd_assert(pcm_channel->active,return -EIO); 1509 - snd_assert(ins->npcm_channels > 0,return -EIO); 1495 + if (snd_BUG_ON(!pcm_channel->active || 1496 + chip->dsp_spos_instance->npcm_channels <= 0)) 1497 + return -EIO; 1510 1498 1511 1499 spin_lock(&pcm_channel->src_scb->lock); 1512 1500 ··· 1549 1537 1550 1538 src_scb->sub_list_ptr = pcm_channel->pcm_reader_scb; 1551 1539 1552 - snd_assert (pcm_channel->pcm_reader_scb->parent_scb_ptr == NULL, ; ); 1540 + snd_BUG_ON(pcm_channel->pcm_reader_scb->parent_scb_ptr); 1553 1541 pcm_channel->pcm_reader_scb->parent_scb_ptr = parent_scb; 1554 1542 1555 1543 spin_lock_irqsave(&chip->reg_lock, flags); ··· 1576 1564 struct dsp_scb_descriptor * pcm_input; 1577 1565 int insert_point; 1578 1566 1579 - snd_assert (ins->record_mixer_scb != NULL,return NULL); 1567 + if (snd_BUG_ON(!ins->record_mixer_scb)) 1568 + return NULL; 1580 1569 1581 1570 if (ins->record_mixer_scb->sub_list_ptr != ins->the_null_scb) { 1582 1571 parent = find_next_free_scb (chip,ins->record_mixer_scb->sub_list_ptr); ··· 1596 1583 1597 1584 int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src) 1598 1585 { 1599 - snd_assert (src->parent_scb_ptr != NULL, return -EINVAL ); 1586 + if (snd_BUG_ON(!src->parent_scb_ptr)) 1587 + return -EINVAL; 1600 1588 1601 1589 /* mute SCB */ 1602 1590 cs46xx_dsp_scb_set_volume (chip,src,0,0); ··· 1612 1598 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1613 1599 struct dsp_scb_descriptor * parent_scb; 1614 1600 1615 - snd_assert (src->parent_scb_ptr == NULL, return -EINVAL ); 1616 - snd_assert(ins->master_mix_scb !=NULL, return -EINVAL ); 1601 + if (snd_BUG_ON(src->parent_scb_ptr)) 1602 + return -EINVAL; 1603 + if (snd_BUG_ON(!ins->master_mix_scb)) 1604 + return -EINVAL; 1617 1605 1618 1606 if (ins->master_mix_scb->sub_list_ptr != ins->the_null_scb) { 1619 1607 parent_scb = find_next_free_scb (chip,ins->master_mix_scb->sub_list_ptr); ··· 1651 1635 return -EBUSY; 1652 1636 } 1653 1637 1654 - snd_assert (ins->asynch_tx_scb == NULL, return -EINVAL); 1655 - snd_assert (ins->master_mix_scb->next_scb_ptr == ins->the_null_scb, return -EINVAL); 1638 + if (snd_BUG_ON(ins->asynch_tx_scb)) 1639 + return -EINVAL; 1640 + if (snd_BUG_ON(ins->master_mix_scb->next_scb_ptr != 1641 + ins->the_null_scb)) 1642 + return -EINVAL; 1656 1643 1657 1644 /* reset output snooper sample buffer pointer */ 1658 1645 snd_cs46xx_poke (chip, (ins->ref_snoop_scb->address + 2) << 2, ··· 1695 1676 } 1696 1677 1697 1678 /* check integrety */ 1698 - snd_assert (ins->asynch_tx_scb != NULL, return -EINVAL); 1699 - snd_assert (ins->spdif_pcm_input_scb != NULL,return -EINVAL); 1700 - snd_assert (ins->master_mix_scb->next_scb_ptr == ins->asynch_tx_scb, return -EINVAL); 1701 - snd_assert (ins->asynch_tx_scb->parent_scb_ptr == ins->master_mix_scb, return -EINVAL); 1679 + if (snd_BUG_ON(!ins->asynch_tx_scb)) 1680 + return -EINVAL; 1681 + if (snd_BUG_ON(!ins->spdif_pcm_input_scb)) 1682 + return -EINVAL; 1683 + if (snd_BUG_ON(ins->master_mix_scb->next_scb_ptr != ins->asynch_tx_scb)) 1684 + return -EINVAL; 1685 + if (snd_BUG_ON(ins->asynch_tx_scb->parent_scb_ptr != 1686 + ins->master_mix_scb)) 1687 + return -EINVAL; 1702 1688 1703 1689 cs46xx_dsp_remove_scb (chip,ins->spdif_pcm_input_scb); 1704 1690 cs46xx_dsp_remove_scb (chip,ins->asynch_tx_scb); ··· 1758 1734 { 1759 1735 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1760 1736 1761 - snd_assert (ins->asynch_tx_scb != NULL, return -EINVAL); 1737 + if (snd_BUG_ON(!ins->asynch_tx_scb)) 1738 + return -EINVAL; 1762 1739 1763 1740 ins->spdif_status_out &= ~DSP_SPDIF_STATUS_PLAYBACK_OPEN; 1764 1741
+2 -1
sound/pci/echoaudio/darla20_dsp.c
··· 34 34 int err; 35 35 36 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 40 if ((err = init_dsp_comm_page(chip))) { 40 41 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
+5 -3
sound/pci/echoaudio/darla24_dsp.c
··· 34 34 int err; 35 35 36 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 40 if ((err = init_dsp_comm_page(chip))) { 40 41 DE_INIT(("init_hw - could not initialize DSP comm page\n")); ··· 149 148 150 149 static int set_input_clock(struct echoaudio *chip, u16 clock) 151 150 { 152 - snd_assert(clock == ECHO_CLOCK_INTERNAL || 153 - clock == ECHO_CLOCK_ESYNC, return -EINVAL); 151 + if (snd_BUG_ON(clock != ECHO_CLOCK_INTERNAL && 152 + clock != ECHO_CLOCK_ESYNC)) 153 + return -EINVAL; 154 154 chip->input_clock = clock; 155 155 return set_sample_rate(chip, chip->sample_rate); 156 156 }
+6 -3
sound/pci/echoaudio/echo3g_dsp.c
··· 47 47 48 48 local_irq_enable(); 49 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 53 if ((err = init_dsp_comm_page(chip))) { 53 54 DE_INIT(("init_hw - could not initialize DSP comm page\n")); ··· 105 104 if ((err = init_line_levels(chip)) < 0) 106 105 return err; 107 106 err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA); 108 - snd_assert(err >= 0, return err); 107 + if (err < 0) 108 + return err; 109 109 err = set_phantom_power(chip, 0); 110 - snd_assert(err >= 0, return err); 110 + if (err < 0) 111 + return err; 111 112 err = set_professional_spdif(chip, TRUE); 112 113 113 114 DE_INIT(("init_hw done\n"));
+5 -3
sound/pci/echoaudio/echoaudio.c
··· 503 503 if (pipe->index >= 0) { 504 504 DE_HWP(("hwp_ie free(%d)\n", pipe->index)); 505 505 err = free_pipes(chip, pipe); 506 - snd_assert(!err); 506 + snd_BUG_ON(err); 507 507 chip->substream[pipe->index] = NULL; 508 508 } 509 509 ··· 690 690 return -EINVAL; 691 691 } 692 692 693 - snd_assert(pipe_index < px_num(chip), return -EINVAL); 694 - snd_assert(is_pipe_allocated(chip, pipe_index), return -EINVAL); 693 + if (snd_BUG_ON(pipe_index >= px_num(chip))) 694 + return -EINVAL; 695 + if (snd_BUG_ON(!is_pipe_allocated(chip, pipe_index))) 696 + return -EINVAL; 695 697 set_audio_format(chip, pipe_index, &format); 696 698 return 0; 697 699 }
+7 -4
sound/pci/echoaudio/echoaudio_3g.c
··· 103 103 int err, i, o; 104 104 105 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 112 previous_mode = chip->digital_mode; 111 113 err = dsp_set_digital_mode(chip, mode); ··· 269 267 return 0; 270 268 } 271 269 272 - snd_assert(rate < 50000 || chip->digital_mode != DIGITAL_MODE_ADAT, 273 - return -EINVAL); 270 + if (snd_BUG_ON(rate >= 50000 && 271 + chip->digital_mode == DIGITAL_MODE_ADAT)) 272 + return -EINVAL; 274 273 275 274 clock = 0; 276 275 control_reg = le32_to_cpu(chip->comm_page->control_register);
+13 -8
sound/pci/echoaudio/echoaudio_dsp.c
··· 474 474 const struct firmware *fw; 475 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 480 /* See if the ASIC is present and working - only if the DSP is already loaded */ 480 481 if (chip->dsp_code) { ··· 513 512 /* Set the nominal level for an input or output bus (true = -10dBV, false = +4dBu) */ 514 513 static int set_nominal_level(struct echoaudio *chip, u16 index, char consumer) 515 514 { 516 - snd_assert(index < num_busses_out(chip) + num_busses_in(chip), 517 - return -EINVAL); 515 + if (snd_BUG_ON(index >= num_busses_out(chip) + num_busses_in(chip))) 516 + return -EINVAL; 518 517 519 518 /* Wait for the handshake (OK even if ASIC is not loaded) */ 520 519 if (wait_handshake(chip)) ··· 537 536 /* Set the gain for a single physical output channel (dB). */ 538 537 static int set_output_gain(struct echoaudio *chip, u16 channel, s8 gain) 539 538 { 540 - snd_assert(channel < num_busses_out(chip), return -EINVAL); 539 + if (snd_BUG_ON(channel >= num_busses_out(chip))) 540 + return -EINVAL; 541 541 542 542 if (wait_handshake(chip)) 543 543 return -EIO; ··· 556 554 static int set_monitor_gain(struct echoaudio *chip, u16 output, u16 input, 557 555 s8 gain) 558 556 { 559 - snd_assert(output < num_busses_out(chip) && 560 - input < num_busses_in(chip), return -EINVAL); 557 + if (snd_BUG_ON(output >= num_busses_out(chip) || 558 + input >= num_busses_in(chip))) 559 + return -EINVAL; 561 560 562 561 if (wait_handshake(chip)) 563 562 return -EIO; ··· 1068 1065 int i; 1069 1066 1070 1067 DE_ACT(("free_pipes: Pipe %d\n", pipe->index)); 1071 - snd_assert(is_pipe_allocated(chip, pipe->index), return -EINVAL); 1072 - snd_assert(pipe->state == PIPE_STATE_STOPPED, return -EINVAL); 1068 + if (snd_BUG_ON(!is_pipe_allocated(chip, pipe->index))) 1069 + return -EINVAL; 1070 + if (snd_BUG_ON(pipe->state != PIPE_STATE_STOPPED)) 1071 + return -EINVAL; 1073 1072 1074 1073 for (channel_mask = i = 0; i < pipe->interleave; i++) 1075 1074 channel_mask |= 1 << (pipe->index + i);
+4 -2
sound/pci/echoaudio/echoaudio_gml.c
··· 112 112 return -EIO; 113 113 114 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 121 previous_mode = chip->digital_mode; 120 122 err = dsp_set_digital_mode(chip, mode);
+4 -2
sound/pci/echoaudio/gina20_dsp.c
··· 38 38 int err; 39 39 40 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 44 if ((err = init_dsp_comm_page(chip))) { 44 45 DE_INIT(("init_hw - could not initialize DSP comm page\n")); ··· 178 177 /* Set input bus gain (one unit is 0.5dB !) */ 179 178 static int set_input_gain(struct echoaudio *chip, u16 input, int gain) 180 179 { 181 - snd_assert(input < num_busses_in(chip), return -EINVAL); 180 + if (snd_BUG_ON(input >= num_busses_in(chip))) 181 + return -EINVAL; 182 182 183 183 if (wait_handshake(chip)) 184 184 return -EIO;
+7 -4
sound/pci/echoaudio/gina24_dsp.c
··· 43 43 int err; 44 44 45 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 49 if ((err = init_dsp_comm_page(chip))) { 49 50 DE_INIT(("init_hw - could not initialize DSP comm page\n")); ··· 85 84 if ((err = init_line_levels(chip)) < 0) 86 85 return err; 87 86 err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA); 88 - snd_assert(err >= 0, return err); 87 + if (err < 0) 88 + return err; 89 89 err = set_professional_spdif(chip, TRUE); 90 90 91 91 DE_INIT(("init_hw done\n")); ··· 165 163 { 166 164 u32 control_reg, clock; 167 165 168 - snd_assert(rate < 50000 || chip->digital_mode != DIGITAL_MODE_ADAT, 169 - return -EINVAL); 166 + if (snd_BUG_ON(rate >= 50000 && 167 + chip->digital_mode == DIGITAL_MODE_ADAT)) 168 + return -EINVAL; 170 169 171 170 /* Only set the clock for internal mode. */ 172 171 if (chip->input_clock != ECHO_CLOCK_INTERNAL) {
+5 -3
sound/pci/echoaudio/indigo_dsp.c
··· 39 39 int err; 40 40 41 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 45 if ((err = init_dsp_comm_page(chip))) { 45 46 DE_INIT(("init_hw - could not initialize DSP comm page\n")); ··· 144 143 { 145 144 int index; 146 145 147 - snd_assert(pipe < num_pipes_out(chip) && 148 - output < num_busses_out(chip), return -EINVAL); 146 + if (snd_BUG_ON(pipe >= num_pipes_out(chip) || 147 + output >= num_busses_out(chip))) 148 + return -EINVAL; 149 149 150 150 if (wait_handshake(chip)) 151 151 return -EIO;
+5 -3
sound/pci/echoaudio/indigodj_dsp.c
··· 39 39 int err; 40 40 41 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 45 if ((err = init_dsp_comm_page(chip))) { 45 46 DE_INIT(("init_hw - could not initialize DSP comm page\n")); ··· 144 143 { 145 144 int index; 146 145 147 - snd_assert(pipe < num_pipes_out(chip) && 148 - output < num_busses_out(chip), return -EINVAL); 146 + if (snd_BUG_ON(pipe >= num_pipes_out(chip) || 147 + output >= num_busses_out(chip))) 148 + return -EINVAL; 149 149 150 150 if (wait_handshake(chip)) 151 151 return -EIO;
+5 -3
sound/pci/echoaudio/indigoio_dsp.c
··· 39 39 int err; 40 40 41 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 45 if ((err = init_dsp_comm_page(chip))) { 45 46 DE_INIT(("init_hw - could not initialize DSP comm page\n")); ··· 115 114 { 116 115 int index; 117 116 118 - snd_assert(pipe < num_pipes_out(chip) && 119 - output < num_busses_out(chip), return -EINVAL); 117 + if (snd_BUG_ON(pipe >= num_pipes_out(chip) || 118 + output >= num_busses_out(chip))) 119 + return -EINVAL; 120 120 121 121 if (wait_handshake(chip)) 122 122 return -EIO;
+6 -3
sound/pci/echoaudio/layla20_dsp.c
··· 42 42 int err; 43 43 44 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 48 if ((err = init_dsp_comm_page(chip))) { 48 49 DE_INIT(("init_hw - could not initialize DSP comm page\n")); ··· 156 155 157 156 static int set_sample_rate(struct echoaudio *chip, u32 rate) 158 157 { 159 - snd_assert(rate >= 8000 && rate <= 50000, return -EINVAL); 158 + if (snd_BUG_ON(rate < 8000 || rate > 50000)) 159 + return -EINVAL; 160 160 161 161 /* Only set the clock for internal mode. Do not return failure, 162 162 simply treat it as a non-event. */ ··· 254 252 /* Set input bus gain (one unit is 0.5dB !) */ 255 253 static int set_input_gain(struct echoaudio *chip, u16 input, int gain) 256 254 { 257 - snd_assert(input < num_busses_in(chip), return -EINVAL); 255 + if (snd_BUG_ON(input >= num_busses_in(chip))) 256 + return -EINVAL; 258 257 259 258 if (wait_handshake(chip)) 260 259 return -EIO;
+7 -4
sound/pci/echoaudio/layla24_dsp.c
··· 42 42 int err; 43 43 44 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 48 if ((err = init_dsp_comm_page(chip))) { 48 49 DE_INIT(("init_hw - could not initialize DSP comm page\n")); ··· 74 73 return err; 75 74 76 75 err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA); 77 - snd_assert(err >= 0, return err); 76 + if (err < 0) 77 + return err; 78 78 err = set_professional_spdif(chip, TRUE); 79 79 80 80 DE_INIT(("init_hw done\n")); ··· 160 158 { 161 159 u32 control_reg, clock, base_rate; 162 160 163 - snd_assert(rate < 50000 || chip->digital_mode != DIGITAL_MODE_ADAT, 164 - return -EINVAL); 161 + if (snd_BUG_ON(rate >= 50000 && 162 + chip->digital_mode == DIGITAL_MODE_ADAT)) 163 + return -EINVAL; 165 164 166 165 /* Only set the clock for internal mode. */ 167 166 if (chip->input_clock != ECHO_CLOCK_INTERNAL) {
+8 -5
sound/pci/echoaudio/mia_dsp.c
··· 42 42 int err; 43 43 44 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 48 if ((err = init_dsp_comm_page(chip))) { 48 49 DE_INIT(("init_hw - could not initialize DSP comm page\n")); ··· 162 161 static int set_input_clock(struct echoaudio *chip, u16 clock) 163 162 { 164 163 DE_ACT(("set_input_clock(%d)\n", clock)); 165 - snd_assert(clock == ECHO_CLOCK_INTERNAL || clock == ECHO_CLOCK_SPDIF, 166 - return -EINVAL); 164 + if (snd_BUG_ON(clock != ECHO_CLOCK_INTERNAL && 165 + clock != ECHO_CLOCK_SPDIF)) 166 + return -EINVAL; 167 167 168 168 chip->input_clock = clock; 169 169 return set_sample_rate(chip, chip->sample_rate); ··· 178 176 { 179 177 int index; 180 178 181 - snd_assert(pipe < num_pipes_out(chip) && 182 - output < num_busses_out(chip), return -EINVAL); 179 + if (snd_BUG_ON(pipe >= num_pipes_out(chip) || 180 + output >= num_busses_out(chip))) 181 + return -EINVAL; 183 182 184 183 if (wait_handshake(chip)) 185 184 return -EIO;
+4 -2
sound/pci/echoaudio/midi.c
··· 59 59 Returns how many actually written or < 0 on error */ 60 60 static 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 65 if (wait_handshake(chip)) 65 66 return -EIO; ··· 120 119 /* The count is at index 0, followed by actual data */ 121 120 count = le16_to_cpu(chip->comm_page->midi_input[0]); 122 121 123 - snd_assert(count < MIDI_IN_BUFFER_SIZE, return 0); 122 + if (snd_BUG_ON(count >= MIDI_IN_BUFFER_SIZE)) 123 + return 0; 124 124 125 125 /* Get the MIDI data from the comm page */ 126 126 i = 1;
+4 -2
sound/pci/echoaudio/mona_dsp.c
··· 43 43 int err; 44 44 45 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 49 if ((err = init_dsp_comm_page(chip))) { 49 50 DE_INIT(("init_hw - could not initialize DSP comm page\n")); ··· 80 79 return err; 81 80 82 81 err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA); 83 - snd_assert(err >= 0, return err); 82 + if (err < 0) 83 + return err; 84 84 err = set_professional_spdif(chip, TRUE); 85 85 86 86 DE_INIT(("init_hw done\n"));
+4 -2
sound/pci/emu10k1/emu10k1_callback.c
··· 145 145 { 146 146 struct snd_emu10k1 *hw; 147 147 148 - snd_assert(vp, return); 148 + if (snd_BUG_ON(!vp)) 149 + return; 149 150 hw = vp->hw; 150 151 snd_emu10k1_ptr_write(hw, DCYSUSV, vp->ch, 0x807f | DCYSUSV_CHANNELENABLE_MASK); 151 152 if (vp->block) { ··· 326 325 327 326 hw = vp->hw; 328 327 ch = vp->ch; 329 - snd_assert(ch >= 0, return -EINVAL); 328 + if (snd_BUG_ON(ch < 0)) 329 + return -EINVAL; 330 330 chan = vp->chan; 331 331 332 332 emem = (struct snd_emu10k1_memblk *)vp->block;
+14 -9
sound/pci/emu10k1/emu10k1_patch.c
··· 46 46 struct snd_emu10k1 *emu; 47 47 48 48 emu = rec->hw; 49 - snd_assert(sp != NULL, return -EINVAL); 50 - snd_assert(hdr != NULL, return -EINVAL); 49 + if (snd_BUG_ON(!sp || !hdr)) 50 + return -EINVAL; 51 51 52 52 if (sp->v.size == 0) { 53 53 snd_printd("emu: rom font for sample %d\n", sp->v.sample); ··· 104 104 size = BLANK_HEAD_SIZE; 105 105 if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) 106 106 size *= 2; 107 - snd_assert(offset + size <= blocksize, return -EINVAL); 107 + if (offset + size > blocksize) 108 + return -EINVAL; 108 109 snd_emu10k1_synth_bzero(emu, sp->block, offset, size); 109 110 offset += size; 110 111 ··· 113 112 size = loopend; 114 113 if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) 115 114 size *= 2; 116 - snd_assert(offset + size <= blocksize, return -EINVAL); 115 + if (offset + size > blocksize) 116 + return -EINVAL; 117 117 if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size)) { 118 118 snd_emu10k1_synth_free(emu, sp->block); 119 119 sp->block = NULL; ··· 131 129 int woffset; 132 130 unsigned short *wblock = (unsigned short*)block; 133 131 woffset = offset / 2; 134 - snd_assert(offset + loopsize*2 <= blocksize, return -EINVAL); 132 + if (offset + loopsize * 2 > blocksize) 133 + return -EINVAL; 135 134 for (i = 0; i < loopsize; i++) 136 135 wblock[woffset + i] = wblock[woffset - i -1]; 137 136 offset += loopsize * 2; 138 137 } else { 139 - snd_assert(offset + loopsize <= blocksize, return -EINVAL); 138 + if (offset + loopsize > blocksize) 139 + return -EINVAL; 140 140 for (i = 0; i < loopsize; i++) 141 141 block[offset + i] = block[offset - i -1]; 142 142 offset += loopsize; ··· 158 154 159 155 /* loopend -> sample end */ 160 156 size = sp->v.size - loopend; 161 - snd_assert(size >= 0, return -EINVAL); 157 + if (size < 0) 158 + return -EINVAL; 162 159 if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) 163 160 size *= 2; 164 161 if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size)) { ··· 217 212 struct snd_emu10k1 *emu; 218 213 219 214 emu = rec->hw; 220 - snd_assert(sp != NULL, return -EINVAL); 221 - snd_assert(hdr != NULL, return -EINVAL); 215 + if (snd_BUG_ON(!sp || !hdr)) 216 + return -EINVAL; 222 217 223 218 if (sp->block) { 224 219 snd_emu10k1_synth_free(emu, sp->block);
+12 -6
sound/pci/emu10k1/emu10k1x.c
··· 1319 1319 unsigned long flags; 1320 1320 1321 1321 emu = midi->emu; 1322 - snd_assert(emu, return -ENXIO); 1322 + if (snd_BUG_ON(!emu)) 1323 + return -ENXIO; 1323 1324 spin_lock_irqsave(&midi->open_lock, flags); 1324 1325 midi->midi_mode |= EMU10K1X_MIDI_MODE_INPUT; 1325 1326 midi->substream_input = substream; ··· 1346 1345 unsigned long flags; 1347 1346 1348 1347 emu = midi->emu; 1349 - snd_assert(emu, return -ENXIO); 1348 + if (snd_BUG_ON(!emu)) 1349 + return -ENXIO; 1350 1350 spin_lock_irqsave(&midi->open_lock, flags); 1351 1351 midi->midi_mode |= EMU10K1X_MIDI_MODE_OUTPUT; 1352 1352 midi->substream_output = substream; ··· 1374 1372 int err = 0; 1375 1373 1376 1374 emu = midi->emu; 1377 - snd_assert(emu, return -ENXIO); 1375 + if (snd_BUG_ON(!emu)) 1376 + return -ENXIO; 1378 1377 spin_lock_irqsave(&midi->open_lock, flags); 1379 1378 snd_emu10k1x_intr_disable(emu, midi->rx_enable); 1380 1379 midi->midi_mode &= ~EMU10K1X_MIDI_MODE_INPUT; ··· 1397 1394 int err = 0; 1398 1395 1399 1396 emu = midi->emu; 1400 - snd_assert(emu, return -ENXIO); 1397 + if (snd_BUG_ON(!emu)) 1398 + return -ENXIO; 1401 1399 spin_lock_irqsave(&midi->open_lock, flags); 1402 1400 snd_emu10k1x_intr_disable(emu, midi->tx_enable); 1403 1401 midi->midi_mode &= ~EMU10K1X_MIDI_MODE_OUTPUT; ··· 1417 1413 struct emu10k1x *emu; 1418 1414 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1419 1415 emu = midi->emu; 1420 - snd_assert(emu, return); 1416 + if (snd_BUG_ON(!emu)) 1417 + return; 1421 1418 1422 1419 if (up) 1423 1420 snd_emu10k1x_intr_enable(emu, midi->rx_enable); ··· 1433 1428 unsigned long flags; 1434 1429 1435 1430 emu = midi->emu; 1436 - snd_assert(emu, return); 1431 + if (snd_BUG_ON(!emu)) 1432 + return; 1437 1433 1438 1434 if (up) { 1439 1435 int max = 4;
+4 -2
sound/pci/emu10k1/emufx.c
··· 487 487 u32 op, u32 r, u32 a, u32 x, u32 y) 488 488 { 489 489 u_int32_t *code; 490 - snd_assert(*ptr < 512, return); 490 + if (snd_BUG_ON(*ptr >= 512)) 491 + return; 491 492 code = (u_int32_t __force *)icode->code + (*ptr) * 2; 492 493 set_bit(*ptr, icode->code_valid); 493 494 code[0] = ((x & 0x3ff) << 10) | (y & 0x3ff); ··· 504 503 u32 op, u32 r, u32 a, u32 x, u32 y) 505 504 { 506 505 u_int32_t *code; 507 - snd_assert(*ptr < 1024, return); 506 + if (snd_BUG_ON(*ptr >= 1024)) 507 + return; 508 508 code = (u_int32_t __force *)icode->code + (*ptr) * 2; 509 509 set_bit(*ptr, icode->code_valid); 510 510 code[0] = ((x & 0x7ff) << 12) | (y & 0x7ff);
+12 -6
sound/pci/emu10k1/emumpu401.c
··· 157 157 unsigned long flags; 158 158 159 159 emu = midi->emu; 160 - snd_assert(emu, return -ENXIO); 160 + if (snd_BUG_ON(!emu)) 161 + return -ENXIO; 161 162 spin_lock_irqsave(&midi->open_lock, flags); 162 163 midi->midi_mode |= EMU10K1_MIDI_MODE_INPUT; 163 164 midi->substream_input = substream; ··· 184 183 unsigned long flags; 185 184 186 185 emu = midi->emu; 187 - snd_assert(emu, return -ENXIO); 186 + if (snd_BUG_ON(!emu)) 187 + return -ENXIO; 188 188 spin_lock_irqsave(&midi->open_lock, flags); 189 189 midi->midi_mode |= EMU10K1_MIDI_MODE_OUTPUT; 190 190 midi->substream_output = substream; ··· 212 210 int err = 0; 213 211 214 212 emu = midi->emu; 215 - snd_assert(emu, return -ENXIO); 213 + if (snd_BUG_ON(!emu)) 214 + return -ENXIO; 216 215 spin_lock_irqsave(&midi->open_lock, flags); 217 216 snd_emu10k1_intr_disable(emu, midi->rx_enable); 218 217 midi->midi_mode &= ~EMU10K1_MIDI_MODE_INPUT; ··· 235 232 int err = 0; 236 233 237 234 emu = midi->emu; 238 - snd_assert(emu, return -ENXIO); 235 + if (snd_BUG_ON(!emu)) 236 + return -ENXIO; 239 237 spin_lock_irqsave(&midi->open_lock, flags); 240 238 snd_emu10k1_intr_disable(emu, midi->tx_enable); 241 239 midi->midi_mode &= ~EMU10K1_MIDI_MODE_OUTPUT; ··· 255 251 struct snd_emu10k1 *emu; 256 252 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 257 253 emu = midi->emu; 258 - snd_assert(emu, return); 254 + if (snd_BUG_ON(!emu)) 255 + return; 259 256 260 257 if (up) 261 258 snd_emu10k1_intr_enable(emu, midi->rx_enable); ··· 271 266 unsigned long flags; 272 267 273 268 emu = midi->emu; 274 - snd_assert(emu, return); 269 + if (snd_BUG_ON(!emu)) 270 + return; 275 271 276 272 if (up) { 277 273 int max = 4;
+13 -6
sound/pci/emu10k1/memory.c
··· 107 107 108 108 list_for_each (pos, &emu->mapped_link_head) { 109 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 112 size = blk->mapped_page - page; 112 113 if (size == npages) { 113 114 *nextp = pos; ··· 301 300 struct snd_emu10k1_memblk *blk; 302 301 int page, err, idx; 303 302 304 - snd_assert(emu, return NULL); 305 - snd_assert(runtime->dma_bytes > 0 && runtime->dma_bytes < MAXPAGES * EMUPAGESIZE, return NULL); 303 + if (snd_BUG_ON(!emu)) 304 + return NULL; 305 + if (snd_BUG_ON(runtime->dma_bytes <= 0 || 306 + runtime->dma_bytes >= MAXPAGES * EMUPAGESIZE)) 307 + return NULL; 306 308 hdr = emu->memhdr; 307 - snd_assert(hdr, return NULL); 309 + if (snd_BUG_ON(!hdr)) 310 + return NULL; 308 311 309 312 mutex_lock(&hdr->block_mutex); 310 313 blk = search_empty(emu, runtime->dma_bytes); ··· 358 353 */ 359 354 int snd_emu10k1_free_pages(struct snd_emu10k1 *emu, struct snd_util_memblk *blk) 360 355 { 361 - snd_assert(emu && blk, return -EINVAL); 356 + if (snd_BUG_ON(!emu || !blk)) 357 + return -EINVAL; 362 358 return snd_emu10k1_synth_free(emu, blk); 363 359 } 364 360 ··· 504 498 static inline void *offset_ptr(struct snd_emu10k1 *emu, int page, int offset) 505 499 { 506 500 char *ptr; 507 - snd_assert(page >= 0 && page < emu->max_cache_pages, return NULL); 501 + if (snd_BUG_ON(page < 0 || page >= emu->max_cache_pages)) 502 + return NULL; 508 503 ptr = emu->page_ptr_table[page]; 509 504 if (! ptr) { 510 505 printk(KERN_ERR "emu10k1: access to NULL ptr: page = %d\n", page);
+6 -3
sound/pci/emu10k1/voice.c
··· 111 111 unsigned long flags; 112 112 int result; 113 113 114 - snd_assert(rvoice != NULL, return -EINVAL); 115 - snd_assert(number, return -EINVAL); 114 + if (snd_BUG_ON(!rvoice)) 115 + return -EINVAL; 116 + if (snd_BUG_ON(!number)) 117 + return -EINVAL; 116 118 117 119 spin_lock_irqsave(&emu->voice_lock, flags); 118 120 for (;;) { ··· 147 145 { 148 146 unsigned long flags; 149 147 150 - snd_assert(pvoice != NULL, return -EINVAL); 148 + if (snd_BUG_ON(!pvoice)) 149 + return -EINVAL; 151 150 spin_lock_irqsave(&emu->voice_lock, flags); 152 151 pvoice->interrupt = NULL; 153 152 pvoice->use = pvoice->pcm = pvoice->synth = pvoice->midi = pvoice->efx = 0;
+2 -1
sound/pci/es1938.c
··· 860 860 struct es1938 *chip = snd_pcm_substream_chip(substream); 861 861 pos <<= chip->dma1_shift; 862 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 865 if (pos + count < chip->dma1_size) { 865 866 if (copy_to_user(dst, runtime->dma_area + pos + 1, count)) 866 867 return -EFAULT;
+4 -2
sound/pci/es1968.c
··· 692 692 /* no spinlock */ 693 693 static 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 697 #ifdef CONFIG_PM 697 698 chip->apu_map[channel][reg] = data; 698 699 #endif ··· 712 711 713 712 static u16 __apu_get_register(struct es1968 *chip, u16 channel, u8 reg) 714 713 { 715 - snd_assert(channel < NR_APUS, return 0); 714 + if (snd_BUG_ON(channel >= NR_APUS)) 715 + return 0; 716 716 reg |= (channel << 4); 717 717 apu_index_set(chip, reg); 718 718 return __maestro_read(chip, IDR0_DATA_PORT);
+14 -7
sound/pci/hda/hda_codec.c
··· 211 211 unsigned int shift, num_elems, mask; 212 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 217 parm = snd_hda_param_read(codec, nid, AC_PAR_CONNLIST_LEN); 217 218 if (parm & AC_CLIST_LONG) { ··· 408 407 .dev_free = snd_hda_bus_dev_free, 409 408 }; 410 409 411 - snd_assert(temp, return -EINVAL); 412 - snd_assert(temp->ops.command && temp->ops.get_response, return -EINVAL); 410 + if (snd_BUG_ON(!temp)) 411 + return -EINVAL; 412 + if (snd_BUG_ON(!temp->ops.command || !temp->ops.get_response)) 413 + return -EINVAL; 413 414 414 415 if (busp) 415 416 *busp = NULL; ··· 591 588 char component[13]; 592 589 int err; 593 590 594 - snd_assert(bus, return -EINVAL); 595 - snd_assert(codec_addr <= HDA_MAX_CODEC_ADDRESS, return -EINVAL); 591 + if (snd_BUG_ON(!bus)) 592 + return -EINVAL; 593 + if (snd_BUG_ON(codec_addr > HDA_MAX_CODEC_ADDRESS)) 594 + return -EINVAL; 596 595 597 596 if (bus->caddr_tbl[codec_addr]) { 598 597 snd_printk(KERN_ERR "hda_codec: " ··· 2241 2236 if (info->ops.close == NULL) 2242 2237 info->ops.close = hda_pcm_default_open_close; 2243 2238 if (info->ops.prepare == NULL) { 2244 - snd_assert(info->nid, return -EINVAL); 2239 + if (snd_BUG_ON(!info->nid)) 2240 + return -EINVAL; 2245 2241 info->ops.prepare = hda_pcm_default_prepare; 2246 2242 } 2247 2243 if (info->ops.cleanup == NULL) { 2248 - snd_assert(info->nid, return -EINVAL); 2244 + if (snd_BUG_ON(!info->nid)) 2245 + return -EINVAL; 2249 2246 info->ops.cleanup = hda_pcm_default_cleanup; 2250 2247 } 2251 2248 return 0;
+2 -1
sound/pci/hda/hda_generic.c
··· 174 174 int i, nodes, err; 175 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 180 spec->def_amp_out_caps = snd_hda_param_read(codec, codec->afg, AC_PAR_AMP_OUT_CAP); 180 181 spec->def_amp_in_caps = snd_hda_param_read(codec, codec->afg, AC_PAR_AMP_IN_CAP);
+2 -1
sound/pci/hda/hda_intel.c
··· 1646 1646 if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams) 1647 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 1652 err = snd_pcm_new(chip->card, cpcm->name, cpcm->device, 1652 1653 cpcm->stream[0].substreams,
+4 -2
sound/pci/hda/patch_realtek.c
··· 2633 2633 2634 2634 info->name = spec->stream_name_analog; 2635 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 2638 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); 2638 2639 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; 2639 2640 } 2640 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 2644 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); 2643 2645 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 2644 2646 }
+2 -1
sound/pci/ice1712/ak4xxx.c
··· 59 59 struct snd_ak4xxx_private *priv = (void *)ak->private_value[0]; 60 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 65 tmp = snd_ice1712_gpio_read(ice); 65 66 tmp |= priv->add_flags;
+6 -3
sound/pci/ice1712/ews.c
··· 149 149 struct ews_spec *spec = ice->spec; 150 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 154 snd_i2c_lock(ice->i2c); 154 155 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF2], &data, 1) != 1) 155 156 goto __error; ··· 686 685 int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 687 686 unsigned char data; 688 687 689 - snd_assert(channel >= 0 && channel <= 7, return 0); 688 + if (snd_BUG_ON(channel < 0 || channel > 7)) 689 + return 0; 690 690 snd_i2c_lock(ice->i2c); 691 691 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) { 692 692 snd_i2c_unlock(ice->i2c); ··· 707 705 int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 708 706 unsigned char data, ndata; 709 707 710 - snd_assert(channel >= 0 && channel <= 7, return 0); 708 + if (snd_BUG_ON(channel < 0 || channel > 7)) 709 + return 0; 711 710 snd_i2c_lock(ice->i2c); 712 711 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) { 713 712 snd_i2c_unlock(ice->i2c);
+2 -1
sound/pci/ice1712/ice1712.c
··· 2416 2416 int err; 2417 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 2421 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_default, ice)); 2421 2422 if (err < 0) 2422 2423 return err;
+2 -1
sound/pci/ice1712/ice1724.c
··· 2250 2250 int err; 2251 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 2256 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_mixer_pro_spdif_route, ice)); 2256 2257 if (err < 0)
+2 -1
sound/pci/ice1712/juli.c
··· 208 208 { 209 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 213 snd_vt1724_write_i2c(ice, AK4358_ADDR, addr, data); 213 214 } 214 215
+2 -2
sound/pci/intel8x0.c
··· 2132 2132 snd_intel8x0_codec_read_test(chip, codecs); 2133 2133 chip->ac97_sdin[codecs] = 2134 2134 igetbyte(chip, ICHREG(SDM)) & ICH_LDI_MASK; 2135 - snd_assert(chip->ac97_sdin[codecs] < 3, 2136 - chip->ac97_sdin[codecs] = 0); 2135 + if (snd_BUG_ON(chip->ac97_sdin[codecs] >= 3)) 2136 + chip->ac97_sdin[codecs] = 0; 2137 2137 } else 2138 2138 chip->ac97_sdin[codecs] = i; 2139 2139 codecs++;
+2 -1
sound/pci/intel8x0m.c
··· 306 306 static unsigned int codec_bit[3] = { 307 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 311 return codec_bit[codec]; 311 312 } 312 313
+6 -3
sound/pci/korg1212/korg1212.c
··· 1281 1281 1282 1282 K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_silence pos=%d offset=%d size=%d count=%d\n", 1283 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 1287 for (i=0; i < count; i++) { 1287 1288 #if K1212_DEBUG_LEVEL > 0 ··· 1307 1306 1308 1307 K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_to pos=%d offset=%d size=%d\n", 1309 1308 pos, offset, size); 1310 - snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL); 1309 + if (snd_BUG_ON(pos + count > K1212_MAX_SAMPLES)) 1310 + return -EINVAL; 1311 1311 1312 1312 for (i=0; i < count; i++) { 1313 1313 #if K1212_DEBUG_LEVEL > 0 ··· 1338 1336 K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_from pos=%d offset=%d size=%d count=%d\n", 1339 1337 pos, offset, size, count); 1340 1338 1341 - snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL); 1339 + if (snd_BUG_ON(pos + count > K1212_MAX_SAMPLES)) 1340 + return -EINVAL; 1342 1341 1343 1342 for (i=0; i < count; i++) { 1344 1343 #if K1212_DEBUG_LEVEL > 0
+7 -3
sound/pci/maestro3.c
··· 1175 1175 struct m3_dma *s = subs->runtime->private_data; 1176 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 1181 spin_lock(&chip->reg_lock); 1181 1182 switch (cmd) { ··· 1488 1487 struct snd_pcm_runtime *runtime = subs->runtime; 1489 1488 struct m3_dma *s = runtime->private_data; 1490 1489 1491 - snd_assert(s != NULL, return -ENXIO); 1490 + if (snd_BUG_ON(!s)) 1491 + return -ENXIO; 1492 1492 1493 1493 if (runtime->format != SNDRV_PCM_FORMAT_U8 && 1494 1494 runtime->format != SNDRV_PCM_FORMAT_S16_LE) ··· 1548 1546 struct snd_m3 *chip = snd_pcm_substream_chip(subs); 1549 1547 unsigned int ptr; 1550 1548 struct m3_dma *s = subs->runtime->private_data; 1551 - snd_assert(s != NULL, return 0); 1549 + 1550 + if (snd_BUG_ON(!s)) 1551 + return 0; 1552 1552 1553 1553 spin_lock(&chip->reg_lock); 1554 1554 ptr = snd_m3_get_pointer(chip, s, subs);
+2 -2
sound/pci/mixart/mixart.c
··· 708 708 pcm_number = MIXART_PCM_ANALOG; 709 709 runtime->hw = snd_mixart_analog_caps; 710 710 } else { 711 - snd_assert ( pcm == chip->pcm_dig ); 711 + snd_BUG_ON(pcm != chip->pcm_dig); 712 712 pcm_number = MIXART_PCM_DIGITAL; 713 713 runtime->hw = snd_mixart_digital_caps; 714 714 } ··· 783 783 pcm_number = MIXART_PCM_ANALOG; 784 784 runtime->hw = snd_mixart_analog_caps; 785 785 } else { 786 - snd_assert ( pcm == chip->pcm_dig ); 786 + snd_BUG_ON(pcm != chip->pcm_dig); 787 787 pcm_number = MIXART_PCM_DIGITAL; 788 788 runtime->hw = snd_mixart_digital_caps; 789 789 }
+12 -6
sound/pci/mixart/mixart_core.c
··· 56 56 if (tailptr == headptr) 57 57 return 0; /* no message posted */ 58 58 59 - snd_assert( tailptr >= MSG_OUTBOUND_POST_STACK, return 0); /* error */ 60 - snd_assert( tailptr < (MSG_OUTBOUND_POST_STACK+MSG_BOUND_STACK_SIZE), return 0); /* error */ 59 + if (tailptr < MSG_OUTBOUND_POST_STACK) 60 + return 0; /* error */ 61 + if (tailptr >= MSG_OUTBOUND_POST_STACK + MSG_BOUND_STACK_SIZE) 62 + return 0; /* error */ 61 63 62 64 *msg_frame = readl_be(MIXART_MEM(mgr, tailptr)); 63 65 ··· 151 149 u32 msg_frame_address; 152 150 int err, i; 153 151 154 - snd_assert(msg->size % 4 == 0, return -EINVAL); 152 + if (snd_BUG_ON(msg->size % 4)) 153 + return -EINVAL; 155 154 156 155 err = 0; 157 156 ··· 292 289 wait_queue_t wait; 293 290 long timeout; 294 291 295 - snd_assert(notif_event != 0, return -EINVAL); 296 - snd_assert((notif_event & MSG_TYPE_MASK) == MSG_TYPE_NOTIFY, return -EINVAL); 297 - snd_assert((notif_event & MSG_CANCEL_NOTIFY_MASK) == 0, return -EINVAL); 292 + if (snd_BUG_ON(!notif_event)) 293 + return -EINVAL; 294 + if (snd_BUG_ON((notif_event & MSG_TYPE_MASK) != MSG_TYPE_NOTIFY)) 295 + return -EINVAL; 296 + if (snd_BUG_ON(notif_event & MSG_CANCEL_NOTIFY_MASK)) 297 + return -EINVAL; 298 298 299 299 mutex_lock(&mgr->msg_mutex); 300 300
+13 -6
sound/pci/mixart/mixart_hwdep.c
··· 288 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 295 for(k=0; k<mgr->num_cards; k++) { 294 296 mgr->chip[k]->uid_in_analog_physio = phys_io.uid[k]; ··· 365 363 } 366 364 367 365 /* check xilinx validity */ 368 - snd_assert(((u32*)(dsp->data))[0]==0xFFFFFFFF, return -EINVAL); 369 - snd_assert(dsp->size % 4 == 0, return -EINVAL); 366 + if (((u32*)(dsp->data))[0] == 0xffffffff) 367 + return -EINVAL; 368 + if (dsp->size % 4) 369 + return -EINVAL; 370 370 371 371 /* set xilinx status to copying */ 372 372 writel_be( 1, MIXART_MEM( mgr, MIXART_PSEUDOREG_MXLX_STATUS_OFFSET )); ··· 466 462 } 467 463 468 464 /* check daughterboard xilinx validity */ 469 - snd_assert(((u32*)(dsp->data))[0]==0xFFFFFFFF, return -EINVAL); 470 - snd_assert(dsp->size % 4 == 0, return -EINVAL); 465 + if (((u32*)(dsp->data))[0] == 0xffffffff) 466 + return -EINVAL; 467 + if (dsp->size % 4) 468 + return -EINVAL; 471 469 472 470 /* inform mixart about the size of the file */ 473 471 writel_be( dsp->size, MIXART_MEM( mgr, MIXART_PSEUDOREG_DXLX_SIZE_OFFSET )); ··· 486 480 487 481 /* get the address where to write the file */ 488 482 val = readl_be( MIXART_MEM( mgr, MIXART_PSEUDOREG_DXLX_BASE_ADDR_OFFSET )); 489 - snd_assert(val != 0, return -EINVAL); 483 + if (!val) 484 + return -EINVAL; 490 485 491 486 /* copy daughterboard xilinx code */ 492 487 memcpy_toio( MIXART_MEM( mgr, val), dsp->data, dsp->size);
+4 -4
sound/pci/mixart/mixart_mixer.c
··· 837 837 if(is_aes) stored_volume = chip->digital_capture_volume[1]; /* AES capture */ 838 838 else stored_volume = chip->digital_capture_volume[0]; /* analog capture */ 839 839 } else { 840 - snd_assert ( idx < MIXART_PLAYBACK_STREAMS ); 840 + snd_BUG_ON(idx >= MIXART_PLAYBACK_STREAMS); 841 841 if(is_aes) stored_volume = chip->digital_playback_volume[MIXART_PLAYBACK_STREAMS + idx]; /* AES playback */ 842 842 else stored_volume = chip->digital_playback_volume[idx]; /* analog playback */ 843 843 } ··· 863 863 else /* analog capture */ 864 864 stored_volume = chip->digital_capture_volume[0]; 865 865 } else { 866 - snd_assert ( idx < MIXART_PLAYBACK_STREAMS ); 866 + snd_BUG_ON(idx >= MIXART_PLAYBACK_STREAMS); 867 867 if (is_aes) /* AES playback */ 868 868 stored_volume = chip->digital_playback_volume[MIXART_PLAYBACK_STREAMS + idx]; 869 869 else /* analog playback */ ··· 909 909 { 910 910 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); 911 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 913 mutex_lock(&chip->mgr->mixer_mutex); 914 914 if(kcontrol->private_value & MIXART_VOL_AES_MASK) /* AES playback */ 915 915 idx += MIXART_PLAYBACK_STREAMS; ··· 926 926 int is_aes = kcontrol->private_value & MIXART_VOL_AES_MASK; 927 927 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ 928 928 int i, j; 929 - snd_assert ( idx < MIXART_PLAYBACK_STREAMS ); 929 + snd_BUG_ON(idx >= MIXART_PLAYBACK_STREAMS); 930 930 mutex_lock(&chip->mgr->mixer_mutex); 931 931 j = idx; 932 932 if (is_aes)
+10 -5
sound/pci/nm256/nm256.c
··· 562 562 struct nm256_stream *s = substream->runtime->private_data; 563 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 568 spin_lock(&chip->reg_lock); 568 569 switch (cmd) { ··· 600 599 struct nm256_stream *s = substream->runtime->private_data; 601 600 int err = 0; 602 601 603 - snd_assert(s != NULL, return -ENXIO); 602 + if (snd_BUG_ON(!s)) 603 + return -ENXIO; 604 604 605 605 spin_lock(&chip->reg_lock); 606 606 switch (cmd) { ··· 637 635 struct snd_pcm_runtime *runtime = substream->runtime; 638 636 struct nm256_stream *s = runtime->private_data; 639 637 640 - snd_assert(s, return -ENXIO); 638 + if (snd_BUG_ON(!s)) 639 + return -ENXIO; 641 640 s->dma_size = frames_to_bytes(runtime, substream->runtime->buffer_size); 642 641 s->period_size = frames_to_bytes(runtime, substream->runtime->period_size); 643 642 s->periods = substream->runtime->periods; ··· 663 660 struct nm256_stream *s = substream->runtime->private_data; 664 661 unsigned long curp; 665 662 666 - snd_assert(s, return 0); 663 + if (snd_BUG_ON(!s)) 664 + return 0; 667 665 curp = snd_nm256_readl(chip, NM_PBUFFER_CURRP) - (unsigned long)s->buf; 668 666 curp %= s->dma_size; 669 667 return bytes_to_frames(substream->runtime, curp); ··· 677 673 struct nm256_stream *s = substream->runtime->private_data; 678 674 unsigned long curp; 679 675 680 - snd_assert(s != NULL, return 0); 676 + if (snd_BUG_ON(!s)) 677 + return 0; 681 678 curp = snd_nm256_readl(chip, NM_RBUFFER_CURRP) - (unsigned long)s->buf; 682 679 curp %= s->dma_size; 683 680 return bytes_to_frames(substream->runtime, curp);
+4 -2
sound/pci/pcxhr/pcxhr.c
··· 464 464 pcxhr_init_rmh(&rmh, CMD_UPDATE_R_BUFFERS); 465 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 469 rmh.cmd[1] = subs->runtime->dma_bytes * 8; /* size in bits */ 469 470 rmh.cmd[2] = subs->runtime->dma_addr >> 24; /* most significant byte */ 470 471 rmh.cmd[2] |= 1<<19; /* this is a circular buffer */ ··· 1229 1228 return -ENOMEM; 1230 1229 } 1231 1230 1232 - snd_assert(pci_id->driver_data < PCI_ID_LAST, return -ENODEV); 1231 + if (snd_BUG_ON(pci_id->driver_data >= PCI_ID_LAST)) 1232 + return -ENODEV; 1233 1233 card_name = pcxhr_board_params[pci_id->driver_data].board_name; 1234 1234 mgr->playback_chips = pcxhr_board_params[pci_id->driver_data].playback_chips; 1235 1235 mgr->capture_chips = pcxhr_board_params[pci_id->driver_data].capture_chips;
+17 -10
sound/pci/pcxhr/pcxhr_core.c
··· 319 319 const unsigned char *data; 320 320 unsigned char dummy; 321 321 /* check the length of boot image */ 322 - snd_assert(dsp->size > 0, return -EINVAL); 323 - snd_assert(dsp->size % 3 == 0, return -EINVAL); 324 - snd_assert(dsp->data, return -EINVAL); 322 + if (dsp->size <= 0) 323 + return -EINVAL; 324 + if (dsp->size % 3) 325 + return -EINVAL; 326 + if (snd_BUG_ON(!dsp->data)) 327 + return -EINVAL; 325 328 /* transfert data buffer from PC to DSP */ 326 329 for (i = 0; i < dsp->size; i += 3) { 327 330 data = dsp->data + i; 328 331 if (i == 0) { 329 332 /* test data header consistency */ 330 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 337 /* wait DSP ready for new transfer */ 334 338 err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_TRDY, ··· 393 389 unsigned char dummy; 394 390 395 391 /* send the hostport address to the DSP (only the upper 24 bit !) */ 396 - snd_assert((physaddr & 0xff) == 0, return -EINVAL); 392 + if (snd_BUG_ON(physaddr & 0xff)) 393 + return -EINVAL; 397 394 PCXHR_OUTPL(mgr, PCXHR_PLX_MBOX1, (physaddr >> 8)); 398 395 399 396 err = pcxhr_send_it_dsp(mgr, PCXHR_IT_DOWNLOAD_BOOT, 0); ··· 575 570 u32 data; 576 571 unsigned char reg; 577 572 578 - snd_assert(rmh->cmd_len<PCXHR_SIZE_MAX_CMD, return -EINVAL); 573 + if (snd_BUG_ON(rmh->cmd_len >= PCXHR_SIZE_MAX_CMD)) 574 + return -EINVAL; 579 575 err = pcxhr_send_it_dsp(mgr, PCXHR_IT_MESSAGE, 1); 580 576 if (err) { 581 577 snd_printk(KERN_ERR "pcxhr_send_message : ED_DSP_CRASHED\n"); ··· 683 677 */ 684 678 void pcxhr_init_rmh(struct pcxhr_rmh *rmh, int cmd) 685 679 { 686 - snd_assert(cmd < CMD_LAST_INDEX, return); 680 + if (snd_BUG_ON(cmd >= CMD_LAST_INDEX)) 681 + return; 687 682 rmh->cmd[0] = pcxhr_dsp_cmds[cmd].opcode; 688 683 rmh->cmd_len = 1; 689 684 rmh->stat_len = pcxhr_dsp_cmds[cmd].st_length; ··· 697 690 unsigned int param1, unsigned int param2, 698 691 unsigned int param3) 699 692 { 700 - snd_assert(param1 <= MASK_FIRST_FIELD); 693 + snd_BUG_ON(param1 > MASK_FIRST_FIELD); 701 694 if (capture) 702 695 rmh->cmd[0] |= 0x800; /* COMMAND_RECORD_MASK */ 703 696 if (param1) 704 697 rmh->cmd[0] |= (param1 << FIELD_SIZE); 705 698 if (param2) { 706 - snd_assert(param2 <= MASK_FIRST_FIELD); 699 + snd_BUG_ON(param2 > MASK_FIRST_FIELD); 707 700 rmh->cmd[0] |= param2; 708 701 } 709 702 if(param3) { 710 - snd_assert(param3 <= MASK_DSP_WORD); 703 + snd_BUG_ON(param3 > MASK_DSP_WORD); 711 704 rmh->cmd[1] = param3; 712 705 rmh->cmd_len = 2; 713 706 }
+9 -6
sound/pci/pcxhr/pcxhr_hwdep.c
··· 65 65 if (err) 66 66 return err; 67 67 /* test 8 or 12 phys out */ 68 - snd_assert((rmh.stat[0] & MASK_FIRST_FIELD) == mgr->playback_chips*2, 69 - return -EINVAL); 68 + if ((rmh.stat[0] & MASK_FIRST_FIELD) != mgr->playback_chips * 2) 69 + return -EINVAL; 70 70 /* test 8 or 2 phys in */ 71 - snd_assert(((rmh.stat[0] >> (2*FIELD_SIZE)) & MASK_FIRST_FIELD) == 72 - mgr->capture_chips * 2, return -EINVAL); 71 + if (((rmh.stat[0] >> (2 * FIELD_SIZE)) & MASK_FIRST_FIELD) != 72 + mgr->capture_chips * 2) 73 + return -EINVAL; 73 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 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 81 pcxhr_init_rmh(&rmh, CMD_VERSION); 79 82 /* firmware num for DSP */
+12 -6
sound/pci/riptide/riptide.c
··· 865 865 struct riptideport *hwport; 866 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 871 hwport = cif->hwport; 871 872 if (cif->errcnt > MAX_ERROR_COUNT) { ··· 1491 1490 int err = 0; 1492 1491 snd_pcm_format_t format; 1493 1492 1494 - snd_assert(cif && data, return -EINVAL); 1493 + if (snd_BUG_ON(!cif || !data)) 1494 + return -EINVAL; 1495 1495 1496 1496 snd_printdd("prepare id %d ch: %d f:0x%x r:%d\n", data->id, 1497 1497 runtime->channels, runtime->format, runtime->rate); ··· 1774 1772 union cmdret rptr = CMDRET_ZERO; 1775 1773 int i = 0; 1776 1774 1777 - snd_assert(cif, return); 1775 + if (snd_BUG_ON(!cif)) 1776 + return; 1778 1777 1779 1778 snd_printdd("Write AC97 reg 0x%x 0x%x\n", reg, val); 1780 1779 do { ··· 1793 1790 struct cmdif *cif = chip->cif; 1794 1791 union cmdret rptr = CMDRET_ZERO; 1795 1792 1796 - snd_assert(cif, return 0); 1793 + if (snd_BUG_ON(!cif)) 1794 + return 0; 1797 1795 1798 1796 if (SEND_RACR(cif, reg, &rptr) != 0) 1799 1797 SEND_RACR(cif, reg, &rptr); ··· 1808 1804 unsigned int device_id; 1809 1805 int err; 1810 1806 1811 - snd_assert(chip, return -EINVAL); 1807 + if (snd_BUG_ON(!chip)) 1808 + return -EINVAL; 1812 1809 1813 1810 cif = chip->cif; 1814 1811 if (!cif) { ··· 1841 1836 { 1842 1837 struct cmdif *cif; 1843 1838 1844 - snd_assert(chip, return 0); 1839 + if (!chip) 1840 + return 0; 1845 1841 1846 1842 if ((cif = chip->cif)) { 1847 1843 SET_GRESET(cif->hwport);
+16 -9
sound/pci/rme9652/hdsp.c
··· 1036 1036 n = DDS_NUMERATOR; 1037 1037 div64_32(&n, rate, &r); 1038 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 1040 /* HDSP_freqReg and HDSP_resetPointer are the same, so keep the DDS 1041 1041 value to write it after a reset */ 1042 1042 hdsp->dds_value = n; ··· 3043 3043 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 3044 3044 3045 3045 offset = ucontrol->id.index - 1; 3046 - snd_assert(offset >= 0); 3046 + snd_BUG_ON(offset < 0); 3047 3047 3048 3048 switch (hdsp->io_type) { 3049 3049 case Digiface: ··· 3767 3767 { 3768 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 3773 if ((mapped_channel = hdsp->channel_map[channel]) < 0) 3773 3774 return NULL; ··· 3785 3784 struct hdsp *hdsp = snd_pcm_substream_chip(substream); 3786 3785 char *channel_buf; 3787 3786 3788 - snd_assert(pos + count <= HDSP_CHANNEL_BUFFER_BYTES / 4, return -EINVAL); 3787 + if (snd_BUG_ON(pos + count > HDSP_CHANNEL_BUFFER_BYTES / 4)) 3788 + return -EINVAL; 3789 3789 3790 3790 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); 3791 - snd_assert(channel_buf != NULL, return -EIO); 3791 + if (snd_BUG_ON(!channel_buf)) 3792 + return -EIO; 3792 3793 if (copy_from_user(channel_buf + pos * 4, src, count * 4)) 3793 3794 return -EFAULT; 3794 3795 return count; ··· 3802 3799 struct hdsp *hdsp = snd_pcm_substream_chip(substream); 3803 3800 char *channel_buf; 3804 3801 3805 - snd_assert(pos + count <= HDSP_CHANNEL_BUFFER_BYTES / 4, return -EINVAL); 3802 + if (snd_BUG_ON(pos + count > HDSP_CHANNEL_BUFFER_BYTES / 4)) 3803 + return -EINVAL; 3806 3804 3807 3805 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); 3808 - snd_assert(channel_buf != NULL, return -EIO); 3806 + if (snd_BUG_ON(!channel_buf)) 3807 + return -EIO; 3809 3808 if (copy_to_user(dst, channel_buf + pos * 4, count * 4)) 3810 3809 return -EFAULT; 3811 3810 return count; ··· 3820 3815 char *channel_buf; 3821 3816 3822 3817 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); 3823 - snd_assert(channel_buf != NULL, return -EIO); 3818 + if (snd_BUG_ON(!channel_buf)) 3819 + return -EIO; 3824 3820 memset(channel_buf + pos * 4, 0, count * 4); 3825 3821 return count; 3826 3822 } ··· 3933 3927 struct hdsp *hdsp = snd_pcm_substream_chip(substream); 3934 3928 int mapped_channel; 3935 3929 3936 - snd_assert(info->channel < hdsp->max_channels, return -EINVAL); 3930 + if (snd_BUG_ON(info->channel >= hdsp->max_channels)) 3931 + return -EINVAL; 3937 3932 3938 3933 if ((mapped_channel = hdsp->channel_map[info->channel]) < 0) 3939 3934 return -EINVAL;
+19 -15
sound/pci/rme9652/hdspm.c
··· 845 845 n = 110100480000000ULL; /* Value checked for AES32 and MADI */ 846 846 div64_32(&n, rate, &r); 847 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 849 hdspm_write(hdspm, HDSPM_freqReg, (u32)n); 850 850 } 851 851 ··· 2617 2617 2618 2618 channel = ucontrol->id.index - 1; 2619 2619 2620 - snd_assert(channel >= 0 2621 - || channel < HDSPM_MAX_CHANNELS, return -EINVAL); 2620 + if (snd_BUG_ON(channel < 0 || channel >= HDSPM_MAX_CHANNELS)) 2621 + return -EINVAL; 2622 2622 2623 2623 mapped_channel = hdspm->channel_map[channel]; 2624 2624 if (mapped_channel < 0) ··· 2652 2652 2653 2653 channel = ucontrol->id.index - 1; 2654 2654 2655 - snd_assert(channel >= 0 2656 - || channel < HDSPM_MAX_CHANNELS, return -EINVAL); 2655 + if (snd_BUG_ON(channel < 0 || channel >= HDSPM_MAX_CHANNELS)) 2656 + return -EINVAL; 2657 2657 2658 2658 mapped_channel = hdspm->channel_map[channel]; 2659 2659 if (mapped_channel < 0) ··· 3496 3496 { 3497 3497 int mapped_channel; 3498 3498 3499 - snd_assert(channel >= 0 3500 - || channel < HDSPM_MAX_CHANNELS, return NULL); 3499 + if (snd_BUG_ON(channel < 0 || channel >= HDSPM_MAX_CHANNELS)) 3500 + return NULL; 3501 3501 3502 3502 mapped_channel = hdspm->channel_map[channel]; 3503 3503 if (mapped_channel < 0) ··· 3520 3520 struct hdspm *hdspm = snd_pcm_substream_chip(substream); 3521 3521 char *channel_buf; 3522 3522 3523 - snd_assert(pos + count <= HDSPM_CHANNEL_BUFFER_BYTES / 4, 3524 - return -EINVAL); 3523 + if (snd_BUG_ON(pos + count > HDSPM_CHANNEL_BUFFER_BYTES / 4)) 3524 + return -EINVAL; 3525 3525 3526 3526 channel_buf = 3527 3527 hdspm_channel_buffer_location(hdspm, substream->pstr->stream, 3528 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 3533 return copy_from_user(channel_buf + pos * 4, src, count * 4); 3533 3534 } ··· 3540 3539 struct hdspm *hdspm = snd_pcm_substream_chip(substream); 3541 3540 char *channel_buf; 3542 3541 3543 - snd_assert(pos + count <= HDSPM_CHANNEL_BUFFER_BYTES / 4, 3544 - return -EINVAL); 3542 + if (snd_BUG_ON(pos + count > HDSPM_CHANNEL_BUFFER_BYTES / 4)) 3543 + return -EINVAL; 3545 3544 3546 3545 channel_buf = 3547 3546 hdspm_channel_buffer_location(hdspm, substream->pstr->stream, 3548 3547 channel); 3549 - snd_assert(channel_buf != NULL, return -EIO); 3548 + if (snd_BUG_ON(!channel_buf)) 3549 + return -EIO; 3550 3550 return copy_to_user(dst, channel_buf + pos * 4, count * 4); 3551 3551 } 3552 3552 ··· 3561 3559 channel_buf = 3562 3560 hdspm_channel_buffer_location(hdspm, substream->pstr->stream, 3563 3561 channel); 3564 - snd_assert(channel_buf != NULL, return -EIO); 3562 + if (snd_BUG_ON(!channel_buf)) 3563 + return -EIO; 3565 3564 memset(channel_buf + pos * 4, 0, count * 4); 3566 3565 return 0; 3567 3566 } ··· 3747 3744 struct hdspm *hdspm = snd_pcm_substream_chip(substream); 3748 3745 int mapped_channel; 3749 3746 3750 - snd_assert(info->channel < HDSPM_MAX_CHANNELS, return -EINVAL); 3747 + if (snd_BUG_ON(info->channel >= HDSPM_MAX_CHANNELS)) 3748 + return -EINVAL; 3751 3749 3752 3750 mapped_channel = hdspm->channel_map[info->channel]; 3753 3751 if (mapped_channel < 0)
+14 -9
sound/pci/rme9652/rme9652.c
··· 595 595 } else { 596 596 int mapped_channel; 597 597 598 - snd_assert(channel == RME9652_NCHANNELS, return); 599 - 600 598 mapped_channel = rme9652->channel_map[channel]; 601 599 602 600 if (enable) { ··· 1891 1893 { 1892 1894 int mapped_channel; 1893 1895 1894 - snd_assert(channel >= 0 || channel < RME9652_NCHANNELS, return NULL); 1896 + if (snd_BUG_ON(channel < 0 || channel >= RME9652_NCHANNELS)) 1897 + return NULL; 1895 1898 1896 1899 if ((mapped_channel = rme9652->channel_map[channel]) < 0) { 1897 1900 return NULL; ··· 1913 1914 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); 1914 1915 char *channel_buf; 1915 1916 1916 - snd_assert(pos + count <= RME9652_CHANNEL_BUFFER_BYTES / 4, return -EINVAL); 1917 + if (snd_BUG_ON(pos + count > RME9652_CHANNEL_BUFFER_BYTES / 4)) 1918 + return -EINVAL; 1917 1919 1918 1920 channel_buf = rme9652_channel_buffer_location (rme9652, 1919 1921 substream->pstr->stream, 1920 1922 channel); 1921 - snd_assert(channel_buf != NULL, return -EIO); 1923 + if (snd_BUG_ON(!channel_buf)) 1924 + return -EIO; 1922 1925 if (copy_from_user(channel_buf + pos * 4, src, count * 4)) 1923 1926 return -EFAULT; 1924 1927 return count; ··· 1932 1931 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); 1933 1932 char *channel_buf; 1934 1933 1935 - snd_assert(pos + count <= RME9652_CHANNEL_BUFFER_BYTES / 4, return -EINVAL); 1934 + if (snd_BUG_ON(pos + count > RME9652_CHANNEL_BUFFER_BYTES / 4)) 1935 + return -EINVAL; 1936 1936 1937 1937 channel_buf = rme9652_channel_buffer_location (rme9652, 1938 1938 substream->pstr->stream, 1939 1939 channel); 1940 - snd_assert(channel_buf != NULL, return -EIO); 1940 + if (snd_BUG_ON(!channel_buf)) 1941 + return -EIO; 1941 1942 if (copy_to_user(dst, channel_buf + pos * 4, count * 4)) 1942 1943 return -EFAULT; 1943 1944 return count; ··· 1954 1951 channel_buf = rme9652_channel_buffer_location (rme9652, 1955 1952 substream->pstr->stream, 1956 1953 channel); 1957 - snd_assert(channel_buf != NULL, return -EIO); 1954 + if (snd_BUG_ON(!channel_buf)) 1955 + return -EIO; 1958 1956 memset(channel_buf + pos * 4, 0, count * 4); 1959 1957 return count; 1960 1958 } ··· 2057 2053 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); 2058 2054 int chn; 2059 2055 2060 - snd_assert(info->channel < RME9652_NCHANNELS, return -EINVAL); 2056 + if (snd_BUG_ON(info->channel >= RME9652_NCHANNELS)) 2057 + return -EINVAL; 2061 2058 2062 2059 if ((chn = rme9652->channel_map[info->channel]) < 0) { 2063 2060 return -EINVAL;
+6 -4
sound/pci/sonicvibes.c
··· 534 534 params->rate_den = 1; 535 535 } else { 536 536 snd_sonicvibes_pll(rate, &r, &m, &n); 537 - snd_assert((SV_REFFREQUENCY % 16) == 0, return -EINVAL); 538 - snd_assert((SV_ADCMULT % 512) == 0, return -EINVAL); 537 + snd_BUG_ON(SV_REFFREQUENCY % 16); 538 + snd_BUG_ON(SV_ADCMULT % 512); 539 539 params->rate_num = (SV_REFFREQUENCY/16) * (n+2) * r; 540 540 params->rate_den = (SV_ADCMULT/512) * (m+2); 541 541 } ··· 849 849 850 850 if ((err = snd_pcm_new(sonic->card, "s3_86c617", device, 1, 1, &pcm)) < 0) 851 851 return err; 852 - snd_assert(pcm != NULL, return -EINVAL); 852 + if (snd_BUG_ON(!pcm)) 853 + return -EINVAL; 853 854 854 855 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sonicvibes_playback_ops); 855 856 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sonicvibes_capture_ops); ··· 1090 1089 unsigned int idx; 1091 1090 int err; 1092 1091 1093 - snd_assert(sonic != NULL && sonic->card != NULL, return -EINVAL); 1092 + if (snd_BUG_ON(!sonic || !sonic->card)) 1093 + return -EINVAL; 1094 1094 card = sonic->card; 1095 1095 strcpy(card->mixername, "S3 SonicVibes"); 1096 1096
+14 -8
sound/pci/trident/trident_main.c
··· 2931 2931 { 2932 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 2936 tmix = &trident->pcm_mixer[substream->number]; 2936 2937 tmix->voice = voice; 2937 2938 tmix->vol = T4D_DEFAULT_PCM_VOL; ··· 2947 2946 { 2948 2947 struct snd_trident_pcm_mixer *tmix; 2949 2948 2950 - snd_assert(trident != NULL && substream != NULL, return -EINVAL); 2949 + if (snd_BUG_ON(!trident || !substream)) 2950 + return -EINVAL; 2951 2951 tmix = &trident->pcm_mixer[substream->number]; 2952 2952 tmix->voice = NULL; 2953 2953 snd_trident_notify_pcm_change(trident, tmix, substream->number, 0); ··· 3133 3131 { 3134 3132 struct snd_trident *chip = gameport_get_port_data(gameport); 3135 3133 3136 - snd_assert(chip, return 0); 3134 + if (snd_BUG_ON(!chip)) 3135 + return 0; 3137 3136 return inb(TRID_REG(chip, GAMEPORT_LEGACY)); 3138 3137 } 3139 3138 ··· 3142 3139 { 3143 3140 struct snd_trident *chip = gameport_get_port_data(gameport); 3144 3141 3145 - snd_assert(chip, return); 3142 + if (snd_BUG_ON(!chip)) 3143 + return; 3146 3144 outb(0xff, TRID_REG(chip, GAMEPORT_LEGACY)); 3147 3145 } 3148 3146 ··· 3152 3148 struct snd_trident *chip = gameport_get_port_data(gameport); 3153 3149 int i; 3154 3150 3155 - snd_assert(chip, return 0); 3151 + if (snd_BUG_ON(!chip)) 3152 + return 0; 3156 3153 3157 3154 *buttons = (~inb(TRID_REG(chip, GAMEPORT_LEGACY)) >> 4) & 0xf; 3158 3155 ··· 3169 3164 { 3170 3165 struct snd_trident *chip = gameport_get_port_data(gameport); 3171 3166 3172 - snd_assert(chip, return 0); 3167 + if (snd_BUG_ON(!chip)) 3168 + return 0; 3173 3169 3174 3170 switch (mode) { 3175 3171 case GAMEPORT_MODE_COOKED: ··· 3897 3891 { 3898 3892 unsigned int i, val, mask[2] = { 0, 0 }; 3899 3893 3900 - snd_assert(v_min <= 63, return); 3901 - snd_assert(v_max <= 63, return); 3894 + if (snd_BUG_ON(v_min > 63 || v_max > 63)) 3895 + return; 3902 3896 for (i = v_min; i <= v_max; i++) 3903 3897 mask[i >> 5] |= 1 << (i & 0x1f); 3904 3898 if (mask[0]) {
+16 -8
sound/pci/trident/trident_memory.c
··· 196 196 int idx, page; 197 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 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 ··· 249 245 dma_addr_t addr; 250 246 unsigned long ptr; 251 247 252 - snd_assert(runtime->dma_bytes> 0 && runtime->dma_bytes <= SNDRV_TRIDENT_MAX_PAGES * SNDRV_TRIDENT_PAGE_SIZE, return NULL); 248 + if (snd_BUG_ON(runtime->dma_bytes <= 0 || 249 + runtime->dma_bytes > SNDRV_TRIDENT_MAX_PAGES * 250 + SNDRV_TRIDENT_PAGE_SIZE)) 251 + return NULL; 253 252 hdr = trident->tlb.memhdr; 254 - snd_assert(hdr != NULL, return NULL); 253 + if (snd_BUG_ON(!hdr)) 254 + return NULL; 255 255 256 256 mutex_lock(&hdr->block_mutex); 257 257 blk = search_empty(hdr, runtime->dma_bytes); ··· 287 279 snd_trident_alloc_pages(struct snd_trident *trident, 288 280 struct snd_pcm_substream *substream) 289 281 { 290 - snd_assert(trident != NULL, return NULL); 291 - snd_assert(substream != NULL, return NULL); 282 + if (snd_BUG_ON(!trident || !substream)) 283 + return NULL; 292 284 if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV_SG) 293 285 return snd_trident_alloc_sg_pages(trident, substream); 294 286 else ··· 305 297 struct snd_util_memhdr *hdr; 306 298 int page; 307 299 308 - snd_assert(trident != NULL, return -EINVAL); 309 - snd_assert(blk != NULL, return -EINVAL); 300 + if (snd_BUG_ON(!trident || !blk)) 301 + return -EINVAL; 310 302 311 303 hdr = trident->tlb.memhdr; 312 304 mutex_lock(&hdr->block_mutex);
+5 -3
sound/pci/via82xx.c
··· 824 824 struct viadev *viadev = substream->runtime->private_data; 825 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 829 if (!(inb(VIADEV_REG(viadev, OFFSET_STATUS)) & VIA_REG_STAT_ACTIVE)) 829 830 return 0; 830 831 ··· 856 855 unsigned int idx, count, res; 857 856 int status; 858 857 859 - snd_assert(viadev->tbl_entries, return 0); 858 + if (snd_BUG_ON(!viadev->tbl_entries)) 859 + return 0; 860 860 861 861 spin_lock(&chip->reg_lock); 862 862 count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT)); ··· 1039 1037 else 1040 1038 rbits = (0x100000 / 48000) * runtime->rate + 1041 1039 ((0x100000 % 48000) * runtime->rate) / 48000; 1042 - snd_assert((rbits & ~0xfffff) == 0, return -EINVAL); 1040 + snd_BUG_ON(rbits & ~0xfffff); 1043 1041 snd_via82xx_channel_reset(chip, viadev); 1044 1042 snd_via82xx_set_table_ptr(chip, viadev); 1045 1043 outb(chip->playback_volume[viadev->reg_offset / 0x10][0],
+2 -1
sound/pci/via82xx_modem.c
··· 612 612 struct viadev *viadev = substream->runtime->private_data; 613 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 617 if (!(inb(VIADEV_REG(viadev, OFFSET_STATUS)) & VIA_REG_STAT_ACTIVE)) 617 618 return 0; 618 619
+8 -4
sound/pci/vx222/vx222_ops.c
··· 253 253 int offset = pipe->hw_ptr; 254 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 259 vx2_setup_pseudo_dma(chip, 1); 259 260 ··· 292 291 u32 *addr = (u32 *)(runtime->dma_area + offset); 293 292 unsigned long port = vx2_reg_addr(chip, VX_DMA); 294 293 295 - snd_assert(count % 4 == 0, return); 294 + if (snd_BUG_ON(count % 4)) 295 + return; 296 296 297 297 vx2_setup_pseudo_dma(chip, 0); 298 298 /* Transfer using pseudo-dma. ··· 677 675 a look up table, as there is no linear matching between the driver codec values 678 676 and the real dBu value 679 677 */ 680 - snd_assert(data < sizeof(vx2_akm_gains_lut), return); 678 + if (snd_BUG_ON(data >= sizeof(vx2_akm_gains_lut))) 679 + return; 681 680 682 681 switch (reg) { 683 682 case XX_CODEC_LEVEL_LEFT_REGISTER: ··· 826 823 preamp++; /* raise pre ampli + 18dB */ 827 824 miclevel -= (18 * 2); /* lower level 18 dB (*2 because of 0.5 dB steps !) */ 828 825 } 829 - snd_assert(preamp < 4, return); 826 + if (snd_BUG_ON(preamp >= 4)) 827 + return; 830 828 831 829 /* set pre-amp level */ 832 830 chip->regSELMIC &= ~MICRO_SELECT_PREAMPLI_MASK;
+14 -7
sound/pci/ymfpci/ymfpci_main.c
··· 259 259 unsigned long flags; 260 260 int result; 261 261 262 - snd_assert(rvoice != NULL, return -EINVAL); 263 - snd_assert(!pair || type == YMFPCI_PCM, return -EINVAL); 262 + if (snd_BUG_ON(!rvoice)) 263 + return -EINVAL; 264 + if (snd_BUG_ON(pair && type != YMFPCI_PCM)) 265 + return -EINVAL; 264 266 265 267 spin_lock_irqsave(&chip->voice_lock, flags); 266 268 for (;;) { ··· 280 278 { 281 279 unsigned long flags; 282 280 283 - snd_assert(pvoice != NULL, return -EINVAL); 281 + if (snd_BUG_ON(!pvoice)) 282 + return -EINVAL; 284 283 snd_ymfpci_hw_stop(chip); 285 284 spin_lock_irqsave(&chip->voice_lock, flags); 286 285 if (pvoice->number == chip->src441_used) { ··· 497 494 u8 use_left, use_right; 498 495 unsigned long flags; 499 496 500 - snd_assert(voice != NULL, return); 497 + if (snd_BUG_ON(!voice)) 498 + return; 501 499 if (runtime->channels == 1) { 502 500 use_left = 1; 503 501 use_right = 1; ··· 1817 1813 } 1818 1814 1819 1815 /* add S/PDIF control */ 1820 - snd_assert(chip->pcm_spdif != NULL, return -EIO); 1816 + if (snd_BUG_ON(!chip->pcm_spdif)) 1817 + return -ENXIO; 1821 1818 if ((err = snd_ctl_add(chip->card, kctl = snd_ctl_new1(&snd_ymfpci_spdif_default, chip))) < 0) 1822 1819 return err; 1823 1820 kctl->id.device = chip->pcm_spdif->device; ··· 2138 2133 chip->work_base = ptr; 2139 2134 chip->work_base_addr = ptr_addr; 2140 2135 2141 - snd_assert(ptr + chip->work_size == chip->work_ptr.area + chip->work_ptr.bytes, ); 2136 + snd_BUG_ON(ptr + chip->work_size != 2137 + chip->work_ptr.area + chip->work_ptr.bytes); 2142 2138 2143 2139 snd_ymfpci_writel(chip, YDSXGR_PLAYCTRLBASE, chip->bank_base_playback_addr); 2144 2140 snd_ymfpci_writel(chip, YDSXGR_RECCTRLBASE, chip->bank_base_capture_addr); ··· 2174 2168 { 2175 2169 u16 ctrl; 2176 2170 2177 - snd_assert(chip != NULL, return -EINVAL); 2171 + if (snd_BUG_ON(!chip)) 2172 + return -EINVAL; 2178 2173 2179 2174 if (chip->res_reg_area) { /* don't touch busy hardware */ 2180 2175 snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0);