aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/cs46xx
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-08-08 11:12:14 -0400
committerJaroslav Kysela <perex@perex.cz>2008-08-13 05:46:38 -0400
commitda3cec35dd3c31d8706db4bf379372ce70d92118 (patch)
tree9379edebb1c7abc7a7a92ce3be30a35b77d9aa1d /sound/pci/cs46xx
parent622207dc31895b4e82c39100db8635d885c795e2 (diff)
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>
Diffstat (limited to 'sound/pci/cs46xx')
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c72
-rw-r--r--sound/pci/cs46xx/dsp_spos.c51
-rw-r--r--sound/pci/cs46xx/dsp_spos_scb_lib.c115
3 files changed, 146 insertions, 92 deletions
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index e214e567dec8..a10ab8283f9a 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -90,9 +90,10 @@ static unsigned short snd_cs46xx_codec_read(struct snd_cs46xx *chip,
90 int count; 90 int count;
91 unsigned short result,tmp; 91 unsigned short result,tmp;
92 u32 offset = 0; 92 u32 offset = 0;
93 snd_assert ( (codec_index == CS46XX_PRIMARY_CODEC_INDEX) || 93
94 (codec_index == CS46XX_SECONDARY_CODEC_INDEX), 94 if (snd_BUG_ON(codec_index != CS46XX_PRIMARY_CODEC_INDEX &&
95 return -EINVAL); 95 codec_index != CS46XX_SECONDARY_CODEC_INDEX))
96 return -EINVAL;
96 97
97 chip->active_ctrl(chip, 1); 98 chip->active_ctrl(chip, 1);
98 99
@@ -212,9 +213,9 @@ static unsigned short snd_cs46xx_ac97_read(struct snd_ac97 * ac97,
212 unsigned short val; 213 unsigned short val;
213 int codec_index = ac97->num; 214 int codec_index = ac97->num;
214 215
215 snd_assert(codec_index == CS46XX_PRIMARY_CODEC_INDEX || 216 if (snd_BUG_ON(codec_index != CS46XX_PRIMARY_CODEC_INDEX &&
216 codec_index == CS46XX_SECONDARY_CODEC_INDEX, 217 codec_index != CS46XX_SECONDARY_CODEC_INDEX))
217 return 0xffff); 218 return 0xffff;
218 219
219 val = snd_cs46xx_codec_read(chip, reg, codec_index); 220 val = snd_cs46xx_codec_read(chip, reg, codec_index);
220 221
@@ -229,9 +230,9 @@ static void snd_cs46xx_codec_write(struct snd_cs46xx *chip,
229{ 230{
230 int count; 231 int count;
231 232
232 snd_assert ((codec_index == CS46XX_PRIMARY_CODEC_INDEX) || 233 if (snd_BUG_ON(codec_index != CS46XX_PRIMARY_CODEC_INDEX &&
233 (codec_index == CS46XX_SECONDARY_CODEC_INDEX), 234 codec_index != CS46XX_SECONDARY_CODEC_INDEX))
234 return); 235 return;
235 236
236 chip->active_ctrl(chip, 1); 237 chip->active_ctrl(chip, 1);
237 238
@@ -294,9 +295,9 @@ static void snd_cs46xx_ac97_write(struct snd_ac97 *ac97,
294 struct snd_cs46xx *chip = ac97->private_data; 295 struct snd_cs46xx *chip = ac97->private_data;
295 int codec_index = ac97->num; 296 int codec_index = ac97->num;
296 297
297 snd_assert(codec_index == CS46XX_PRIMARY_CODEC_INDEX || 298 if (snd_BUG_ON(codec_index != CS46XX_PRIMARY_CODEC_INDEX &&
298 codec_index == CS46XX_SECONDARY_CODEC_INDEX, 299 codec_index != CS46XX_SECONDARY_CODEC_INDEX))
299 return); 300 return;
300 301
301 snd_cs46xx_codec_write(chip, reg, val, codec_index); 302 snd_cs46xx_codec_write(chip, reg, val, codec_index);
302} 303}
@@ -315,7 +316,8 @@ int snd_cs46xx_download(struct snd_cs46xx *chip,
315 unsigned int bank = offset >> 16; 316 unsigned int bank = offset >> 16;
316 offset = offset & 0xffff; 317 offset = offset & 0xffff;
317 318
318 snd_assert(!(offset & 3) && !(len & 3), return -EINVAL); 319 if (snd_BUG_ON((offset & 3) || (len & 3)))
320 return -EINVAL;
319 dst = chip->region.idx[bank+1].remap_addr + offset; 321 dst = chip->region.idx[bank+1].remap_addr + offset;
320 len /= sizeof(u32); 322 len /= sizeof(u32);
321 323
@@ -343,7 +345,8 @@ int snd_cs46xx_clear_BA1(struct snd_cs46xx *chip,
343 unsigned int bank = offset >> 16; 345 unsigned int bank = offset >> 16;
344 offset = offset & 0xffff; 346 offset = offset & 0xffff;
345 347
346 snd_assert(!(offset & 3) && !(len & 3), return -EINVAL); 348 if (snd_BUG_ON((offset & 3) || (len & 3)))
349 return -EINVAL;
347 dst = chip->region.idx[bank+1].remap_addr + offset; 350 dst = chip->region.idx[bank+1].remap_addr + offset;
348 len /= sizeof(u32); 351 len /= sizeof(u32);
349 352
@@ -722,7 +725,9 @@ static snd_pcm_uframes_t snd_cs46xx_playback_direct_pointer(struct snd_pcm_subst
722 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); 725 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream);
723 size_t ptr; 726 size_t ptr;
724 struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data; 727 struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data;
725 snd_assert (cpcm->pcm_channel,return -ENXIO); 728
729 if (snd_BUG_ON(!cpcm->pcm_channel))
730 return -ENXIO;
726 731
727#ifdef CONFIG_SND_CS46XX_NEW_DSP 732#ifdef CONFIG_SND_CS46XX_NEW_DSP
728 ptr = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 2) << 2); 733 ptr = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 2) << 2);
@@ -740,7 +745,8 @@ static snd_pcm_uframes_t snd_cs46xx_playback_indirect_pointer(struct snd_pcm_sub
740 struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data; 745 struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data;
741 746
742#ifdef CONFIG_SND_CS46XX_NEW_DSP 747#ifdef CONFIG_SND_CS46XX_NEW_DSP
743 snd_assert (cpcm->pcm_channel,return -ENXIO); 748 if (snd_BUG_ON(!cpcm->pcm_channel))
749 return -ENXIO;
744 ptr = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 2) << 2); 750 ptr = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 2) << 2);
745#else 751#else
746 ptr = snd_cs46xx_peek(chip, BA1_PBA); 752 ptr = snd_cs46xx_peek(chip, BA1_PBA);
@@ -908,7 +914,8 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream,
908 cpcm = runtime->private_data; 914 cpcm = runtime->private_data;
909 915
910#ifdef CONFIG_SND_CS46XX_NEW_DSP 916#ifdef CONFIG_SND_CS46XX_NEW_DSP
911 snd_assert (sample_rate != 0, return -ENXIO); 917 if (snd_BUG_ON(!sample_rate))
918 return -ENXIO;
912 919
913 mutex_lock(&chip->spos_mutex); 920 mutex_lock(&chip->spos_mutex);
914 921
@@ -917,7 +924,7 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream,
917 return -ENXIO; 924 return -ENXIO;
918 } 925 }
919 926
920 snd_assert (cpcm->pcm_channel != NULL); 927 snd_BUG_ON(!cpcm->pcm_channel);
921 if (!cpcm->pcm_channel) { 928 if (!cpcm->pcm_channel) {
922 mutex_unlock(&chip->spos_mutex); 929 mutex_unlock(&chip->spos_mutex);
923 return -ENXIO; 930 return -ENXIO;
@@ -952,7 +959,7 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream,
952 } else if (cpcm->pcm_channel_id == DSP_IEC958_CHANNEL) { 959 } else if (cpcm->pcm_channel_id == DSP_IEC958_CHANNEL) {
953 substream->ops = &snd_cs46xx_playback_iec958_ops; 960 substream->ops = &snd_cs46xx_playback_iec958_ops;
954 } else { 961 } else {
955 snd_assert(0); 962 snd_BUG();
956 } 963 }
957#else 964#else
958 substream->ops = &snd_cs46xx_playback_ops; 965 substream->ops = &snd_cs46xx_playback_ops;
@@ -981,7 +988,7 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream,
981 } else if (cpcm->pcm_channel_id == DSP_IEC958_CHANNEL) { 988 } else if (cpcm->pcm_channel_id == DSP_IEC958_CHANNEL) {
982 substream->ops = &snd_cs46xx_playback_indirect_iec958_ops; 989 substream->ops = &snd_cs46xx_playback_indirect_iec958_ops;
983 } else { 990 } else {
984 snd_assert(0); 991 snd_BUG();
985 } 992 }
986#else 993#else
987 substream->ops = &snd_cs46xx_playback_indirect_ops; 994 substream->ops = &snd_cs46xx_playback_indirect_ops;
@@ -1029,7 +1036,8 @@ static int snd_cs46xx_playback_prepare(struct snd_pcm_substream *substream)
1029 cpcm = runtime->private_data; 1036 cpcm = runtime->private_data;
1030 1037
1031#ifdef CONFIG_SND_CS46XX_NEW_DSP 1038#ifdef CONFIG_SND_CS46XX_NEW_DSP
1032 snd_assert (cpcm->pcm_channel != NULL, return -ENXIO); 1039 if (snd_BUG_ON(!cpcm->pcm_channel))
1040 return -ENXIO;
1033 1041
1034 pfie = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 1) << 2 ); 1042 pfie = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 1) << 2 );
1035 pfie &= ~0x0000f03f; 1043 pfie &= ~0x0000f03f;
@@ -1714,9 +1722,9 @@ static void snd_cs46xx_mixer_free_ac97(struct snd_ac97 *ac97)
1714{ 1722{
1715 struct snd_cs46xx *chip = ac97->private_data; 1723 struct snd_cs46xx *chip = ac97->private_data;
1716 1724
1717 snd_assert ((ac97 == chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]) || 1725 if (snd_BUG_ON(ac97 != chip->ac97[CS46XX_PRIMARY_CODEC_INDEX] &&
1718 (ac97 == chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]), 1726 ac97 != chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]))
1719 return); 1727 return;
1720 1728
1721 if (ac97 == chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]) { 1729 if (ac97 == chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]) {
1722 chip->ac97[CS46XX_PRIMARY_CODEC_INDEX] = NULL; 1730 chip->ac97[CS46XX_PRIMARY_CODEC_INDEX] = NULL;
@@ -1864,7 +1872,7 @@ static int snd_cs46xx_iec958_put(struct snd_kcontrol *kcontrol,
1864 break; 1872 break;
1865 default: 1873 default:
1866 res = -EINVAL; 1874 res = -EINVAL;
1867 snd_assert(0, (void)0); 1875 snd_BUG(); /* should never happen ... */
1868 } 1876 }
1869 1877
1870 return res; 1878 return res;
@@ -2236,7 +2244,7 @@ static void snd_cs46xx_codec_reset (struct snd_ac97 * ac97)
2236 snd_printdd("cs46xx: CODOEC2 mode %04x\n",0x3); 2244 snd_printdd("cs46xx: CODOEC2 mode %04x\n",0x3);
2237 snd_cs46xx_ac97_write(ac97,AC97_CSR_ACMODE,0x3); 2245 snd_cs46xx_ac97_write(ac97,AC97_CSR_ACMODE,0x3);
2238 } else { 2246 } else {
2239 snd_assert(0); /* should never happen ... */ 2247 snd_BUG(); /* should never happen ... */
2240 } 2248 }
2241 2249
2242 udelay(50); 2250 udelay(50);
@@ -2553,7 +2561,8 @@ static void snd_cs46xx_gameport_trigger(struct gameport *gameport)
2553{ 2561{
2554 struct snd_cs46xx *chip = gameport_get_port_data(gameport); 2562 struct snd_cs46xx *chip = gameport_get_port_data(gameport);
2555 2563
2556 snd_assert(chip, return); 2564 if (snd_BUG_ON(!chip))
2565 return;
2557 snd_cs46xx_pokeBA0(chip, BA0_JSPT, 0xFF); //outb(gameport->io, 0xFF); 2566 snd_cs46xx_pokeBA0(chip, BA0_JSPT, 0xFF); //outb(gameport->io, 0xFF);
2558} 2567}
2559 2568
@@ -2561,7 +2570,8 @@ static unsigned char snd_cs46xx_gameport_read(struct gameport *gameport)
2561{ 2570{
2562 struct snd_cs46xx *chip = gameport_get_port_data(gameport); 2571 struct snd_cs46xx *chip = gameport_get_port_data(gameport);
2563 2572
2564 snd_assert(chip, return 0); 2573 if (snd_BUG_ON(!chip))
2574 return 0;
2565 return snd_cs46xx_peekBA0(chip, BA0_JSPT); //inb(gameport->io); 2575 return snd_cs46xx_peekBA0(chip, BA0_JSPT); //inb(gameport->io);
2566} 2576}
2567 2577
@@ -2570,7 +2580,8 @@ static int snd_cs46xx_gameport_cooked_read(struct gameport *gameport, int *axes,
2570 struct snd_cs46xx *chip = gameport_get_port_data(gameport); 2580 struct snd_cs46xx *chip = gameport_get_port_data(gameport);
2571 unsigned js1, js2, jst; 2581 unsigned js1, js2, jst;
2572 2582
2573 snd_assert(chip, return 0); 2583 if (snd_BUG_ON(!chip))
2584 return 0;
2574 2585
2575 js1 = snd_cs46xx_peekBA0(chip, BA0_JSC1); 2586 js1 = snd_cs46xx_peekBA0(chip, BA0_JSC1);
2576 js2 = snd_cs46xx_peekBA0(chip, BA0_JSC2); 2587 js2 = snd_cs46xx_peekBA0(chip, BA0_JSC2);
@@ -2754,7 +2765,8 @@ static int snd_cs46xx_free(struct snd_cs46xx *chip)
2754{ 2765{
2755 int idx; 2766 int idx;
2756 2767
2757 snd_assert(chip != NULL, return -EINVAL); 2768 if (snd_BUG_ON(!chip))
2769 return -EINVAL;
2758 2770
2759 if (chip->active_ctrl) 2771 if (chip->active_ctrl)
2760 chip->active_ctrl(chip, 1); 2772 chip->active_ctrl(chip, 1);
diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c
index ccc8bedb5b1a..f4f0c8f5dad7 100644
--- a/sound/pci/cs46xx/dsp_spos.c
+++ b/sound/pci/cs46xx/dsp_spos.c
@@ -63,7 +63,8 @@ static int shadow_and_reallocate_code (struct snd_cs46xx * chip, u32 * data, u32
63 u32 mop_operands,mop_type,wide_op; 63 u32 mop_operands,mop_type,wide_op;
64 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 64 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
65 65
66 snd_assert( ((size % 2) == 0), return -EINVAL); 66 if (snd_BUG_ON(size %2))
67 return -EINVAL;
67 68
68 while (i < size) { 69 while (i < size) {
69 loval = data[i++]; 70 loval = data[i++];
@@ -289,7 +290,8 @@ void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip)
289 int i; 290 int i;
290 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 291 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
291 292
292 snd_assert(ins != NULL, return); 293 if (snd_BUG_ON(!ins))
294 return;
293 295
294 mutex_lock(&chip->spos_mutex); 296 mutex_lock(&chip->spos_mutex);
295 for (i = 0; i < ins->nscb; ++i) { 297 for (i = 0; i < ins->nscb; ++i) {
@@ -404,7 +406,8 @@ int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * m
404 406
405 /* if module has a code segment it must have 407 /* if module has a code segment it must have
406 symbol table */ 408 symbol table */
407 snd_assert(module->symbol_table.symbols != NULL ,return -ENOMEM); 409 if (snd_BUG_ON(!module->symbol_table.symbols))
410 return -ENOMEM;
408 if (add_symbols(chip,module)) { 411 if (add_symbols(chip,module)) {
409 snd_printk(KERN_ERR "dsp_spos: failed to load symbol table\n"); 412 snd_printk(KERN_ERR "dsp_spos: failed to load symbol table\n");
410 return -ENOMEM; 413 return -ENOMEM;
@@ -1369,7 +1372,8 @@ int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip)
1369 1372
1370 valid_slots = snd_cs46xx_peekBA0(chip, BA0_ACOSV); 1373 valid_slots = snd_cs46xx_peekBA0(chip, BA0_ACOSV);
1371 1374
1372 snd_assert (chip->nr_ac97_codecs == 1 || chip->nr_ac97_codecs == 2); 1375 if (snd_BUG_ON(chip->nr_ac97_codecs != 1 && chip->nr_ac97_codecs != 2))
1376 goto _fail_end;
1373 1377
1374 if (chip->nr_ac97_codecs == 1) { 1378 if (chip->nr_ac97_codecs == 1) {
1375 /* output on slot 5 and 11 1379 /* output on slot 5 and 11
@@ -1609,11 +1613,14 @@ static int cs46xx_dsp_async_init (struct snd_cs46xx *chip,
1609 1613
1610 spdifo_scb_desc = cs46xx_dsp_create_scb(chip,"SPDIFOSCB",(u32 *)&spdifo_scb,SPDIFO_SCB_INST); 1614 spdifo_scb_desc = cs46xx_dsp_create_scb(chip,"SPDIFOSCB",(u32 *)&spdifo_scb,SPDIFO_SCB_INST);
1611 1615
1612 snd_assert(spdifo_scb_desc, return -EIO); 1616 if (snd_BUG_ON(!spdifo_scb_desc))
1617 return -EIO;
1613 spdifi_scb_desc = cs46xx_dsp_create_scb(chip,"SPDIFISCB",(u32 *)&spdifi_scb,SPDIFI_SCB_INST); 1618 spdifi_scb_desc = cs46xx_dsp_create_scb(chip,"SPDIFISCB",(u32 *)&spdifi_scb,SPDIFI_SCB_INST);
1614 snd_assert(spdifi_scb_desc, return -EIO); 1619 if (snd_BUG_ON(!spdifi_scb_desc))
1620 return -EIO;
1615 async_codec_scb_desc = cs46xx_dsp_create_scb(chip,"AsynCodecInputSCB",(u32 *)&async_codec_input_scb, HFG_TREE_SCB); 1621 async_codec_scb_desc = cs46xx_dsp_create_scb(chip,"AsynCodecInputSCB",(u32 *)&async_codec_input_scb, HFG_TREE_SCB);
1616 snd_assert(async_codec_scb_desc, return -EIO); 1622 if (snd_BUG_ON(!async_codec_scb_desc))
1623 return -EIO;
1617 1624
1618 async_codec_scb_desc->parent_scb_ptr = NULL; 1625 async_codec_scb_desc->parent_scb_ptr = NULL;
1619 async_codec_scb_desc->next_scb_ptr = spdifi_scb_desc; 1626 async_codec_scb_desc->next_scb_ptr = spdifi_scb_desc;
@@ -1698,8 +1705,10 @@ int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip)
1698 chip->active_ctrl(chip, 1); 1705 chip->active_ctrl(chip, 1);
1699 chip->amplifier_ctrl(chip, 1); 1706 chip->amplifier_ctrl(chip, 1);
1700 1707
1701 snd_assert (ins->asynch_rx_scb == NULL,return -EINVAL); 1708 if (snd_BUG_ON(ins->asynch_rx_scb))
1702 snd_assert (ins->spdif_in_src != NULL,return -EINVAL); 1709 return -EINVAL;
1710 if (snd_BUG_ON(!ins->spdif_in_src))
1711 return -EINVAL;
1703 1712
1704 mutex_lock(&chip->spos_mutex); 1713 mutex_lock(&chip->spos_mutex);
1705 1714
@@ -1754,8 +1763,10 @@ int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip)
1754{ 1763{
1755 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1764 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1756 1765
1757 snd_assert (ins->asynch_rx_scb != NULL, return -EINVAL); 1766 if (snd_BUG_ON(!ins->asynch_rx_scb))
1758 snd_assert (ins->spdif_in_src != NULL,return -EINVAL); 1767 return -EINVAL;
1768 if (snd_BUG_ON(!ins->spdif_in_src))
1769 return -EINVAL;
1759 1770
1760 mutex_lock(&chip->spos_mutex); 1771 mutex_lock(&chip->spos_mutex);
1761 1772
@@ -1780,8 +1791,10 @@ int cs46xx_dsp_enable_pcm_capture (struct snd_cs46xx *chip)
1780{ 1791{
1781 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1792 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1782 1793
1783 snd_assert (ins->pcm_input == NULL,return -EINVAL); 1794 if (snd_BUG_ON(ins->pcm_input))
1784 snd_assert (ins->ref_snoop_scb != NULL,return -EINVAL); 1795 return -EINVAL;
1796 if (snd_BUG_ON(!ins->ref_snoop_scb))
1797 return -EINVAL;
1785 1798
1786 mutex_lock(&chip->spos_mutex); 1799 mutex_lock(&chip->spos_mutex);
1787 ins->pcm_input = cs46xx_add_record_source(chip,ins->ref_snoop_scb,PCMSERIALIN_PCM_SCB_ADDR, 1800 ins->pcm_input = cs46xx_add_record_source(chip,ins->ref_snoop_scb,PCMSERIALIN_PCM_SCB_ADDR,
@@ -1795,7 +1808,8 @@ int cs46xx_dsp_disable_pcm_capture (struct snd_cs46xx *chip)
1795{ 1808{
1796 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1809 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1797 1810
1798 snd_assert (ins->pcm_input != NULL,return -EINVAL); 1811 if (snd_BUG_ON(!ins->pcm_input))
1812 return -EINVAL;
1799 1813
1800 mutex_lock(&chip->spos_mutex); 1814 mutex_lock(&chip->spos_mutex);
1801 cs46xx_dsp_remove_scb (chip,ins->pcm_input); 1815 cs46xx_dsp_remove_scb (chip,ins->pcm_input);
@@ -1809,8 +1823,10 @@ int cs46xx_dsp_enable_adc_capture (struct snd_cs46xx *chip)
1809{ 1823{
1810 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1824 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1811 1825
1812 snd_assert (ins->adc_input == NULL,return -EINVAL); 1826 if (snd_BUG_ON(ins->adc_input))
1813 snd_assert (ins->codec_in_scb != NULL,return -EINVAL); 1827 return -EINVAL;
1828 if (snd_BUG_ON(!ins->codec_in_scb))
1829 return -EINVAL;
1814 1830
1815 mutex_lock(&chip->spos_mutex); 1831 mutex_lock(&chip->spos_mutex);
1816 ins->adc_input = cs46xx_add_record_source(chip,ins->codec_in_scb,PCMSERIALIN_SCB_ADDR, 1832 ins->adc_input = cs46xx_add_record_source(chip,ins->codec_in_scb,PCMSERIALIN_SCB_ADDR,
@@ -1824,7 +1840,8 @@ int cs46xx_dsp_disable_adc_capture (struct snd_cs46xx *chip)
1824{ 1840{
1825 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1841 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1826 1842
1827 snd_assert (ins->adc_input != NULL,return -EINVAL); 1843 if (snd_BUG_ON(!ins->adc_input))
1844 return -EINVAL;
1828 1845
1829 mutex_lock(&chip->spos_mutex); 1846 mutex_lock(&chip->spos_mutex);
1830 cs46xx_dsp_remove_scb (chip,ins->adc_input); 1847 cs46xx_dsp_remove_scb (chip,ins->adc_input);
diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c
index 2873cfe48c33..dd7c41b037b4 100644
--- a/sound/pci/cs46xx/dsp_spos_scb_lib.c
+++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c
@@ -46,8 +46,11 @@ static void remove_symbol (struct snd_cs46xx * chip, struct dsp_symbol_entry * s
46 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 46 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
47 int symbol_index = (int)(symbol - ins->symbol_table.symbols); 47 int symbol_index = (int)(symbol - ins->symbol_table.symbols);
48 48
49 snd_assert(ins->symbol_table.nsymbols > 0,return); 49 if (snd_BUG_ON(ins->symbol_table.nsymbols <= 0))
50 snd_assert(symbol_index >= 0 && symbol_index < ins->symbol_table.nsymbols, return); 50 return;
51 if (snd_BUG_ON(symbol_index < 0 ||
52 symbol_index >= ins->symbol_table.nsymbols))
53 return;
51 54
52 ins->symbol_table.symbols[symbol_index].deleted = 1; 55 ins->symbol_table.symbols[symbol_index].deleted = 1;
53 56
@@ -116,8 +119,9 @@ static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor
116 119
117 if ( scb->parent_scb_ptr ) { 120 if ( scb->parent_scb_ptr ) {
118 /* unlink parent SCB */ 121 /* unlink parent SCB */
119 snd_assert ((scb->parent_scb_ptr->sub_list_ptr == scb || 122 if (snd_BUG_ON(scb->parent_scb_ptr->sub_list_ptr != scb &&
120 scb->parent_scb_ptr->next_scb_ptr == scb),return); 123 scb->parent_scb_ptr->next_scb_ptr != scb))
124 return;
121 125
122 if (scb->parent_scb_ptr->sub_list_ptr == scb) { 126 if (scb->parent_scb_ptr->sub_list_ptr == scb) {
123 127
@@ -140,7 +144,6 @@ static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor
140 scb->next_scb_ptr = ins->the_null_scb; 144 scb->next_scb_ptr = ins->the_null_scb;
141 } 145 }
142 } else { 146 } else {
143 /* snd_assert ( (scb->sub_list_ptr == ins->the_null_scb), return); */
144 scb->parent_scb_ptr->next_scb_ptr = scb->next_scb_ptr; 147 scb->parent_scb_ptr->next_scb_ptr = scb->next_scb_ptr;
145 148
146 if (scb->next_scb_ptr != ins->the_null_scb) { 149 if (scb->next_scb_ptr != ins->the_null_scb) {
@@ -181,16 +184,17 @@ void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor *
181 unsigned long flags; 184 unsigned long flags;
182 185
183 /* check integrety */ 186 /* check integrety */
184 snd_assert ( (scb->index >= 0 && 187 if (snd_BUG_ON(scb->index < 0 ||
185 scb->index < ins->nscb && 188 scb->index >= ins->nscb ||
186 (ins->scbs + scb->index) == scb), return ); 189 (ins->scbs + scb->index) != scb))
190 return;
187 191
188#if 0 192#if 0
189 /* can't remove a SCB with childs before 193 /* can't remove a SCB with childs before
190 removing childs first */ 194 removing childs first */
191 snd_assert ( (scb->sub_list_ptr == ins->the_null_scb && 195 if (snd_BUG_ON(scb->sub_list_ptr != ins->the_null_scb ||
192 scb->next_scb_ptr == ins->the_null_scb), 196 scb->next_scb_ptr != ins->the_null_scb))
193 goto _end); 197 goto _end;
194#endif 198#endif
195 199
196 spin_lock_irqsave(&scb->lock, flags); 200 spin_lock_irqsave(&scb->lock, flags);
@@ -198,7 +202,8 @@ void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor *
198 spin_unlock_irqrestore(&scb->lock, flags); 202 spin_unlock_irqrestore(&scb->lock, flags);
199 203
200 cs46xx_dsp_proc_free_scb_desc(scb); 204 cs46xx_dsp_proc_free_scb_desc(scb);
201 snd_assert (scb->scb_symbol != NULL, return ); 205 if (snd_BUG_ON(!scb->scb_symbol))
206 return;
202 remove_symbol (chip,scb->scb_symbol); 207 remove_symbol (chip,scb->scb_symbol);
203 208
204 ins->scbs[scb->index].deleted = 1; 209 ins->scbs[scb->index].deleted = 1;
@@ -234,7 +239,6 @@ void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb)
234 snd_info_free_entry(scb->proc_info); 239 snd_info_free_entry(scb->proc_info);
235 scb->proc_info = NULL; 240 scb->proc_info = NULL;
236 241
237 snd_assert (scb_info != NULL, return);
238 kfree (scb_info); 242 kfree (scb_info);
239 } 243 }
240} 244}
@@ -291,7 +295,8 @@ _dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u
291 295
292 unsigned long flags; 296 unsigned long flags;
293 297
294 snd_assert (ins->the_null_scb != NULL,return NULL); 298 if (snd_BUG_ON(!ins->the_null_scb))
299 return NULL;
295 300
296 /* fill the data that will be wroten to DSP */ 301 /* fill the data that will be wroten to DSP */
297 scb_data[SCBsubListPtr] = 302 scb_data[SCBsubListPtr] =
@@ -321,18 +326,20 @@ _dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u
321#endif 326#endif
322 /* link to parent SCB */ 327 /* link to parent SCB */
323 if (scb_child_type == SCB_ON_PARENT_NEXT_SCB) { 328 if (scb_child_type == SCB_ON_PARENT_NEXT_SCB) {
324 snd_assert ( (scb->parent_scb_ptr->next_scb_ptr == ins->the_null_scb), 329 if (snd_BUG_ON(scb->parent_scb_ptr->next_scb_ptr !=
325 return NULL); 330 ins->the_null_scb))
331 return NULL;
326 332
327 scb->parent_scb_ptr->next_scb_ptr = scb; 333 scb->parent_scb_ptr->next_scb_ptr = scb;
328 334
329 } else if (scb_child_type == SCB_ON_PARENT_SUBLIST_SCB) { 335 } else if (scb_child_type == SCB_ON_PARENT_SUBLIST_SCB) {
330 snd_assert ( (scb->parent_scb_ptr->sub_list_ptr == ins->the_null_scb), 336 if (snd_BUG_ON(scb->parent_scb_ptr->sub_list_ptr !=
331 return NULL); 337 ins->the_null_scb))
338 return NULL;
332 339
333 scb->parent_scb_ptr->sub_list_ptr = scb; 340 scb->parent_scb_ptr->sub_list_ptr = scb;
334 } else { 341 } else {
335 snd_assert (0,return NULL); 342 snd_BUG();
336 } 343 }
337 344
338 spin_lock_irqsave(&chip->reg_lock, flags); 345 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -675,7 +682,7 @@ cs46xx_dsp_create_src_task_scb(struct snd_cs46xx * chip, char * scb_name,
675 if (pass_through) { 682 if (pass_through) {
676 /* wont work with any other rate than 683 /* wont work with any other rate than
677 the native DSP rate */ 684 the native DSP rate */
678 snd_assert (rate == 48000); 685 snd_BUG_ON(rate != 48000);
679 686
680 scb = cs46xx_dsp_create_generic_scb(chip,scb_name,(u32 *)&src_task_scb, 687 scb = cs46xx_dsp_create_generic_scb(chip,scb_name,(u32 *)&src_task_scb,
681 dest,"DMAREADER",parent_scb, 688 dest,"DMAREADER",parent_scb,
@@ -1142,7 +1149,8 @@ find_next_free_scb (struct snd_cs46xx * chip, struct dsp_scb_descriptor * from)
1142 struct dsp_scb_descriptor * scb = from; 1149 struct dsp_scb_descriptor * scb = from;
1143 1150
1144 while (scb->next_scb_ptr != ins->the_null_scb) { 1151 while (scb->next_scb_ptr != ins->the_null_scb) {
1145 snd_assert (scb->next_scb_ptr != NULL, return NULL); 1152 if (snd_BUG_ON(!scb->next_scb_ptr))
1153 return NULL;
1146 1154
1147 scb = scb->next_scb_ptr; 1155 scb = scb->next_scb_ptr;
1148 } 1156 }
@@ -1246,10 +1254,11 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
1246 break; 1254 break;
1247 case DSP_PCM_S71_CHANNEL: 1255 case DSP_PCM_S71_CHANNEL:
1248 /* TODO */ 1256 /* TODO */
1249 snd_assert(0); 1257 snd_BUG();
1250 break; 1258 break;
1251 case DSP_IEC958_CHANNEL: 1259 case DSP_IEC958_CHANNEL:
1252 snd_assert (ins->asynch_tx_scb != NULL, return NULL); 1260 if (snd_BUG_ON(!ins->asynch_tx_scb))
1261 return NULL;
1253 mixer_scb = ins->asynch_tx_scb; 1262 mixer_scb = ins->asynch_tx_scb;
1254 1263
1255 /* if sample rate is set to 48khz we pass 1264 /* if sample rate is set to 48khz we pass
@@ -1262,7 +1271,7 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
1262 } 1271 }
1263 break; 1272 break;
1264 default: 1273 default:
1265 snd_assert (0); 1274 snd_BUG();
1266 return NULL; 1275 return NULL;
1267 } 1276 }
1268 /* default sample rate is 44100 */ 1277 /* default sample rate is 44100 */
@@ -1308,7 +1317,8 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
1308 break; 1317 break;
1309 } 1318 }
1310 } 1319 }
1311 snd_assert (src_index != -1,return NULL); 1320 if (snd_BUG_ON(src_index == -1))
1321 return NULL;
1312 1322
1313 /* we need to create a new SRC SCB */ 1323 /* we need to create a new SRC SCB */
1314 if (mixer_scb->sub_list_ptr == ins->the_null_scb) { 1324 if (mixer_scb->sub_list_ptr == ins->the_null_scb) {
@@ -1462,9 +1472,10 @@ void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip,
1462 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1472 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1463 unsigned long flags; 1473 unsigned long flags;
1464 1474
1465 snd_assert(pcm_channel->active, return ); 1475 if (snd_BUG_ON(!pcm_channel->active ||
1466 snd_assert(ins->npcm_channels > 0, return ); 1476 ins->npcm_channels <= 0 ||
1467 snd_assert(pcm_channel->src_scb->ref_count > 0, return ); 1477 pcm_channel->src_scb->ref_count <= 0))
1478 return;
1468 1479
1469 spin_lock_irqsave(&chip->reg_lock, flags); 1480 spin_lock_irqsave(&chip->reg_lock, flags);
1470 pcm_channel->unlinked = 1; 1481 pcm_channel->unlinked = 1;
@@ -1479,8 +1490,9 @@ void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip,
1479 if (!pcm_channel->src_scb->ref_count) { 1490 if (!pcm_channel->src_scb->ref_count) {
1480 cs46xx_dsp_remove_scb(chip,pcm_channel->src_scb); 1491 cs46xx_dsp_remove_scb(chip,pcm_channel->src_scb);
1481 1492
1482 snd_assert (pcm_channel->src_slot >= 0 && pcm_channel->src_slot < DSP_MAX_SRC_NR, 1493 if (snd_BUG_ON(pcm_channel->src_slot < 0 ||
1483 return ); 1494 pcm_channel->src_slot >= DSP_MAX_SRC_NR))
1495 return;
1484 1496
1485 ins->src_scb_slots[pcm_channel->src_slot] = 0; 1497 ins->src_scb_slots[pcm_channel->src_slot] = 0;
1486 ins->nsrc_scb --; 1498 ins->nsrc_scb --;
@@ -1490,11 +1502,11 @@ void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip,
1490int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip, 1502int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip,
1491 struct dsp_pcm_channel_descriptor * pcm_channel) 1503 struct dsp_pcm_channel_descriptor * pcm_channel)
1492{ 1504{
1493 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1494 unsigned long flags; 1505 unsigned long flags;
1495 1506
1496 snd_assert(pcm_channel->active,return -EIO); 1507 if (snd_BUG_ON(!pcm_channel->active ||
1497 snd_assert(ins->npcm_channels > 0,return -EIO); 1508 chip->dsp_spos_instance->npcm_channels <= 0))
1509 return -EIO;
1498 1510
1499 spin_lock(&pcm_channel->src_scb->lock); 1511 spin_lock(&pcm_channel->src_scb->lock);
1500 1512
@@ -1537,7 +1549,7 @@ int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip,
1537 1549
1538 src_scb->sub_list_ptr = pcm_channel->pcm_reader_scb; 1550 src_scb->sub_list_ptr = pcm_channel->pcm_reader_scb;
1539 1551
1540 snd_assert (pcm_channel->pcm_reader_scb->parent_scb_ptr == NULL, ; ); 1552 snd_BUG_ON(pcm_channel->pcm_reader_scb->parent_scb_ptr);
1541 pcm_channel->pcm_reader_scb->parent_scb_ptr = parent_scb; 1553 pcm_channel->pcm_reader_scb->parent_scb_ptr = parent_scb;
1542 1554
1543 spin_lock_irqsave(&chip->reg_lock, flags); 1555 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -1564,7 +1576,8 @@ cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * s
1564 struct dsp_scb_descriptor * pcm_input; 1576 struct dsp_scb_descriptor * pcm_input;
1565 int insert_point; 1577 int insert_point;
1566 1578
1567 snd_assert (ins->record_mixer_scb != NULL,return NULL); 1579 if (snd_BUG_ON(!ins->record_mixer_scb))
1580 return NULL;
1568 1581
1569 if (ins->record_mixer_scb->sub_list_ptr != ins->the_null_scb) { 1582 if (ins->record_mixer_scb->sub_list_ptr != ins->the_null_scb) {
1570 parent = find_next_free_scb (chip,ins->record_mixer_scb->sub_list_ptr); 1583 parent = find_next_free_scb (chip,ins->record_mixer_scb->sub_list_ptr);
@@ -1583,7 +1596,8 @@ cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * s
1583 1596
1584int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src) 1597int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src)
1585{ 1598{
1586 snd_assert (src->parent_scb_ptr != NULL, return -EINVAL ); 1599 if (snd_BUG_ON(!src->parent_scb_ptr))
1600 return -EINVAL;
1587 1601
1588 /* mute SCB */ 1602 /* mute SCB */
1589 cs46xx_dsp_scb_set_volume (chip,src,0,0); 1603 cs46xx_dsp_scb_set_volume (chip,src,0,0);
@@ -1598,8 +1612,10 @@ int cs46xx_src_link(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src)
1598 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1612 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1599 struct dsp_scb_descriptor * parent_scb; 1613 struct dsp_scb_descriptor * parent_scb;
1600 1614
1601 snd_assert (src->parent_scb_ptr == NULL, return -EINVAL ); 1615 if (snd_BUG_ON(src->parent_scb_ptr))
1602 snd_assert(ins->master_mix_scb !=NULL, return -EINVAL ); 1616 return -EINVAL;
1617 if (snd_BUG_ON(!ins->master_mix_scb))
1618 return -EINVAL;
1603 1619
1604 if (ins->master_mix_scb->sub_list_ptr != ins->the_null_scb) { 1620 if (ins->master_mix_scb->sub_list_ptr != ins->the_null_scb) {
1605 parent_scb = find_next_free_scb (chip,ins->master_mix_scb->sub_list_ptr); 1621 parent_scb = find_next_free_scb (chip,ins->master_mix_scb->sub_list_ptr);
@@ -1635,8 +1651,11 @@ int cs46xx_dsp_enable_spdif_out (struct snd_cs46xx *chip)
1635 return -EBUSY; 1651 return -EBUSY;
1636 } 1652 }
1637 1653
1638 snd_assert (ins->asynch_tx_scb == NULL, return -EINVAL); 1654 if (snd_BUG_ON(ins->asynch_tx_scb))
1639 snd_assert (ins->master_mix_scb->next_scb_ptr == ins->the_null_scb, return -EINVAL); 1655 return -EINVAL;
1656 if (snd_BUG_ON(ins->master_mix_scb->next_scb_ptr !=
1657 ins->the_null_scb))
1658 return -EINVAL;
1640 1659
1641 /* reset output snooper sample buffer pointer */ 1660 /* reset output snooper sample buffer pointer */
1642 snd_cs46xx_poke (chip, (ins->ref_snoop_scb->address + 2) << 2, 1661 snd_cs46xx_poke (chip, (ins->ref_snoop_scb->address + 2) << 2,
@@ -1676,10 +1695,15 @@ int cs46xx_dsp_disable_spdif_out (struct snd_cs46xx *chip)
1676 } 1695 }
1677 1696
1678 /* check integrety */ 1697 /* check integrety */
1679 snd_assert (ins->asynch_tx_scb != NULL, return -EINVAL); 1698 if (snd_BUG_ON(!ins->asynch_tx_scb))
1680 snd_assert (ins->spdif_pcm_input_scb != NULL,return -EINVAL); 1699 return -EINVAL;
1681 snd_assert (ins->master_mix_scb->next_scb_ptr == ins->asynch_tx_scb, return -EINVAL); 1700 if (snd_BUG_ON(!ins->spdif_pcm_input_scb))
1682 snd_assert (ins->asynch_tx_scb->parent_scb_ptr == ins->master_mix_scb, return -EINVAL); 1701 return -EINVAL;
1702 if (snd_BUG_ON(ins->master_mix_scb->next_scb_ptr != ins->asynch_tx_scb))
1703 return -EINVAL;
1704 if (snd_BUG_ON(ins->asynch_tx_scb->parent_scb_ptr !=
1705 ins->master_mix_scb))
1706 return -EINVAL;
1683 1707
1684 cs46xx_dsp_remove_scb (chip,ins->spdif_pcm_input_scb); 1708 cs46xx_dsp_remove_scb (chip,ins->spdif_pcm_input_scb);
1685 cs46xx_dsp_remove_scb (chip,ins->asynch_tx_scb); 1709 cs46xx_dsp_remove_scb (chip,ins->asynch_tx_scb);
@@ -1734,7 +1758,8 @@ int cs46xx_iec958_post_close (struct snd_cs46xx *chip)
1734{ 1758{
1735 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1759 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1736 1760
1737 snd_assert (ins->asynch_tx_scb != NULL, return -EINVAL); 1761 if (snd_BUG_ON(!ins->asynch_tx_scb))
1762 return -EINVAL;
1738 1763
1739 ins->spdif_status_out &= ~DSP_SPDIF_STATUS_PLAYBACK_OPEN; 1764 ins->spdif_status_out &= ~DSP_SPDIF_STATUS_PLAYBACK_OPEN;
1740 1765