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>
diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c
index 2873cfe..dd7c41b 100644
--- a/sound/pci/cs46xx/dsp_spos_scb_lib.c
+++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c
@@ -46,8 +46,11 @@
struct dsp_spos_instance * ins = chip->dsp_spos_instance;
int symbol_index = (int)(symbol - ins->symbol_table.symbols);
- snd_assert(ins->symbol_table.nsymbols > 0,return);
- snd_assert(symbol_index >= 0 && symbol_index < ins->symbol_table.nsymbols, return);
+ if (snd_BUG_ON(ins->symbol_table.nsymbols <= 0))
+ return;
+ if (snd_BUG_ON(symbol_index < 0 ||
+ symbol_index >= ins->symbol_table.nsymbols))
+ return;
ins->symbol_table.symbols[symbol_index].deleted = 1;
@@ -116,8 +119,9 @@
if ( scb->parent_scb_ptr ) {
/* unlink parent SCB */
- snd_assert ((scb->parent_scb_ptr->sub_list_ptr == scb ||
- scb->parent_scb_ptr->next_scb_ptr == scb),return);
+ if (snd_BUG_ON(scb->parent_scb_ptr->sub_list_ptr != scb &&
+ scb->parent_scb_ptr->next_scb_ptr != scb))
+ return;
if (scb->parent_scb_ptr->sub_list_ptr == scb) {
@@ -140,7 +144,6 @@
scb->next_scb_ptr = ins->the_null_scb;
}
} else {
- /* snd_assert ( (scb->sub_list_ptr == ins->the_null_scb), return); */
scb->parent_scb_ptr->next_scb_ptr = scb->next_scb_ptr;
if (scb->next_scb_ptr != ins->the_null_scb) {
@@ -181,16 +184,17 @@
unsigned long flags;
/* check integrety */
- snd_assert ( (scb->index >= 0 &&
- scb->index < ins->nscb &&
- (ins->scbs + scb->index) == scb), return );
+ if (snd_BUG_ON(scb->index < 0 ||
+ scb->index >= ins->nscb ||
+ (ins->scbs + scb->index) != scb))
+ return;
#if 0
/* can't remove a SCB with childs before
removing childs first */
- snd_assert ( (scb->sub_list_ptr == ins->the_null_scb &&
- scb->next_scb_ptr == ins->the_null_scb),
- goto _end);
+ if (snd_BUG_ON(scb->sub_list_ptr != ins->the_null_scb ||
+ scb->next_scb_ptr != ins->the_null_scb))
+ goto _end;
#endif
spin_lock_irqsave(&scb->lock, flags);
@@ -198,7 +202,8 @@
spin_unlock_irqrestore(&scb->lock, flags);
cs46xx_dsp_proc_free_scb_desc(scb);
- snd_assert (scb->scb_symbol != NULL, return );
+ if (snd_BUG_ON(!scb->scb_symbol))
+ return;
remove_symbol (chip,scb->scb_symbol);
ins->scbs[scb->index].deleted = 1;
@@ -234,7 +239,6 @@
snd_info_free_entry(scb->proc_info);
scb->proc_info = NULL;
- snd_assert (scb_info != NULL, return);
kfree (scb_info);
}
}
@@ -291,7 +295,8 @@
unsigned long flags;
- snd_assert (ins->the_null_scb != NULL,return NULL);
+ if (snd_BUG_ON(!ins->the_null_scb))
+ return NULL;
/* fill the data that will be wroten to DSP */
scb_data[SCBsubListPtr] =
@@ -321,18 +326,20 @@
#endif
/* link to parent SCB */
if (scb_child_type == SCB_ON_PARENT_NEXT_SCB) {
- snd_assert ( (scb->parent_scb_ptr->next_scb_ptr == ins->the_null_scb),
- return NULL);
+ if (snd_BUG_ON(scb->parent_scb_ptr->next_scb_ptr !=
+ ins->the_null_scb))
+ return NULL;
scb->parent_scb_ptr->next_scb_ptr = scb;
} else if (scb_child_type == SCB_ON_PARENT_SUBLIST_SCB) {
- snd_assert ( (scb->parent_scb_ptr->sub_list_ptr == ins->the_null_scb),
- return NULL);
+ if (snd_BUG_ON(scb->parent_scb_ptr->sub_list_ptr !=
+ ins->the_null_scb))
+ return NULL;
scb->parent_scb_ptr->sub_list_ptr = scb;
} else {
- snd_assert (0,return NULL);
+ snd_BUG();
}
spin_lock_irqsave(&chip->reg_lock, flags);
@@ -675,7 +682,7 @@
if (pass_through) {
/* wont work with any other rate than
the native DSP rate */
- snd_assert (rate == 48000);
+ snd_BUG_ON(rate != 48000);
scb = cs46xx_dsp_create_generic_scb(chip,scb_name,(u32 *)&src_task_scb,
dest,"DMAREADER",parent_scb,
@@ -1142,7 +1149,8 @@
struct dsp_scb_descriptor * scb = from;
while (scb->next_scb_ptr != ins->the_null_scb) {
- snd_assert (scb->next_scb_ptr != NULL, return NULL);
+ if (snd_BUG_ON(!scb->next_scb_ptr))
+ return NULL;
scb = scb->next_scb_ptr;
}
@@ -1246,10 +1254,11 @@
break;
case DSP_PCM_S71_CHANNEL:
/* TODO */
- snd_assert(0);
+ snd_BUG();
break;
case DSP_IEC958_CHANNEL:
- snd_assert (ins->asynch_tx_scb != NULL, return NULL);
+ if (snd_BUG_ON(!ins->asynch_tx_scb))
+ return NULL;
mixer_scb = ins->asynch_tx_scb;
/* if sample rate is set to 48khz we pass
@@ -1262,7 +1271,7 @@
}
break;
default:
- snd_assert (0);
+ snd_BUG();
return NULL;
}
/* default sample rate is 44100 */
@@ -1308,7 +1317,8 @@
break;
}
}
- snd_assert (src_index != -1,return NULL);
+ if (snd_BUG_ON(src_index == -1))
+ return NULL;
/* we need to create a new SRC SCB */
if (mixer_scb->sub_list_ptr == ins->the_null_scb) {
@@ -1462,9 +1472,10 @@
struct dsp_spos_instance * ins = chip->dsp_spos_instance;
unsigned long flags;
- snd_assert(pcm_channel->active, return );
- snd_assert(ins->npcm_channels > 0, return );
- snd_assert(pcm_channel->src_scb->ref_count > 0, return );
+ if (snd_BUG_ON(!pcm_channel->active ||
+ ins->npcm_channels <= 0 ||
+ pcm_channel->src_scb->ref_count <= 0))
+ return;
spin_lock_irqsave(&chip->reg_lock, flags);
pcm_channel->unlinked = 1;
@@ -1479,8 +1490,9 @@
if (!pcm_channel->src_scb->ref_count) {
cs46xx_dsp_remove_scb(chip,pcm_channel->src_scb);
- snd_assert (pcm_channel->src_slot >= 0 && pcm_channel->src_slot < DSP_MAX_SRC_NR,
- return );
+ if (snd_BUG_ON(pcm_channel->src_slot < 0 ||
+ pcm_channel->src_slot >= DSP_MAX_SRC_NR))
+ return;
ins->src_scb_slots[pcm_channel->src_slot] = 0;
ins->nsrc_scb --;
@@ -1490,11 +1502,11 @@
int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip,
struct dsp_pcm_channel_descriptor * pcm_channel)
{
- struct dsp_spos_instance * ins = chip->dsp_spos_instance;
unsigned long flags;
- snd_assert(pcm_channel->active,return -EIO);
- snd_assert(ins->npcm_channels > 0,return -EIO);
+ if (snd_BUG_ON(!pcm_channel->active ||
+ chip->dsp_spos_instance->npcm_channels <= 0))
+ return -EIO;
spin_lock(&pcm_channel->src_scb->lock);
@@ -1537,7 +1549,7 @@
src_scb->sub_list_ptr = pcm_channel->pcm_reader_scb;
- snd_assert (pcm_channel->pcm_reader_scb->parent_scb_ptr == NULL, ; );
+ snd_BUG_ON(pcm_channel->pcm_reader_scb->parent_scb_ptr);
pcm_channel->pcm_reader_scb->parent_scb_ptr = parent_scb;
spin_lock_irqsave(&chip->reg_lock, flags);
@@ -1564,7 +1576,8 @@
struct dsp_scb_descriptor * pcm_input;
int insert_point;
- snd_assert (ins->record_mixer_scb != NULL,return NULL);
+ if (snd_BUG_ON(!ins->record_mixer_scb))
+ return NULL;
if (ins->record_mixer_scb->sub_list_ptr != ins->the_null_scb) {
parent = find_next_free_scb (chip,ins->record_mixer_scb->sub_list_ptr);
@@ -1583,7 +1596,8 @@
int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src)
{
- snd_assert (src->parent_scb_ptr != NULL, return -EINVAL );
+ if (snd_BUG_ON(!src->parent_scb_ptr))
+ return -EINVAL;
/* mute SCB */
cs46xx_dsp_scb_set_volume (chip,src,0,0);
@@ -1598,8 +1612,10 @@
struct dsp_spos_instance * ins = chip->dsp_spos_instance;
struct dsp_scb_descriptor * parent_scb;
- snd_assert (src->parent_scb_ptr == NULL, return -EINVAL );
- snd_assert(ins->master_mix_scb !=NULL, return -EINVAL );
+ if (snd_BUG_ON(src->parent_scb_ptr))
+ return -EINVAL;
+ if (snd_BUG_ON(!ins->master_mix_scb))
+ return -EINVAL;
if (ins->master_mix_scb->sub_list_ptr != ins->the_null_scb) {
parent_scb = find_next_free_scb (chip,ins->master_mix_scb->sub_list_ptr);
@@ -1635,8 +1651,11 @@
return -EBUSY;
}
- snd_assert (ins->asynch_tx_scb == NULL, return -EINVAL);
- snd_assert (ins->master_mix_scb->next_scb_ptr == ins->the_null_scb, return -EINVAL);
+ if (snd_BUG_ON(ins->asynch_tx_scb))
+ return -EINVAL;
+ if (snd_BUG_ON(ins->master_mix_scb->next_scb_ptr !=
+ ins->the_null_scb))
+ return -EINVAL;
/* reset output snooper sample buffer pointer */
snd_cs46xx_poke (chip, (ins->ref_snoop_scb->address + 2) << 2,
@@ -1676,10 +1695,15 @@
}
/* check integrety */
- snd_assert (ins->asynch_tx_scb != NULL, return -EINVAL);
- snd_assert (ins->spdif_pcm_input_scb != NULL,return -EINVAL);
- snd_assert (ins->master_mix_scb->next_scb_ptr == ins->asynch_tx_scb, return -EINVAL);
- snd_assert (ins->asynch_tx_scb->parent_scb_ptr == ins->master_mix_scb, return -EINVAL);
+ if (snd_BUG_ON(!ins->asynch_tx_scb))
+ return -EINVAL;
+ if (snd_BUG_ON(!ins->spdif_pcm_input_scb))
+ return -EINVAL;
+ if (snd_BUG_ON(ins->master_mix_scb->next_scb_ptr != ins->asynch_tx_scb))
+ return -EINVAL;
+ if (snd_BUG_ON(ins->asynch_tx_scb->parent_scb_ptr !=
+ ins->master_mix_scb))
+ return -EINVAL;
cs46xx_dsp_remove_scb (chip,ins->spdif_pcm_input_scb);
cs46xx_dsp_remove_scb (chip,ins->asynch_tx_scb);
@@ -1734,7 +1758,8 @@
{
struct dsp_spos_instance * ins = chip->dsp_spos_instance;
- snd_assert (ins->asynch_tx_scb != NULL, return -EINVAL);
+ if (snd_BUG_ON(!ins->asynch_tx_scb))
+ return -EINVAL;
ins->spdif_status_out &= ~DSP_SPDIF_STATUS_PLAYBACK_OPEN;