Skip to content

Commit 5e246b8

Browse files
tiwaiperexg
authored andcommitted
ALSA: Kill snd_assert() in other places
Kill snd_assert() in other places, either removed or replaced with if () with snd_BUG_ON(). Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
1 parent da3cec3 commit 5e246b8

38 files changed

Lines changed: 217 additions & 168 deletions

‎drivers/media/video/saa7134/saa7134-alsa.c‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,12 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream,
488488
period_size = params_period_bytes(hw_params);
489489
periods = params_periods(hw_params);
490490

491-
snd_assert(period_size >= 0x100 && period_size <= 0x10000,
492-
return -EINVAL);
493-
snd_assert(periods >= 4, return -EINVAL);
494-
snd_assert(period_size * periods <= 1024 * 1024, return -EINVAL);
491+
if (period_size < 0x100 || period_size > 0x10000)
492+
return -EINVAL;
493+
if (periods < 4)
494+
return -EINVAL;
495+
if (period_size * periods > 1024 * 1024)
496+
return -EINVAL;
495497

496498
dev = saa7134->dev;
497499

@@ -942,7 +944,8 @@ static int snd_card_saa7134_new_mixer(snd_card_saa7134_t * chip)
942944
unsigned int idx;
943945
int err;
944946

945-
snd_assert(chip != NULL, return -EINVAL);
947+
if (snd_BUG_ON(!chip))
948+
return -EINVAL;
946949
strcpy(card->mixername, "SAA7134 Mixer");
947950

948951
for (idx = 0; idx < ARRAY_SIZE(snd_saa7134_controls); idx++) {

‎include/sound/vx_core.h‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,37 +235,31 @@ irqreturn_t snd_vx_irq_handler(int irq, void *dev);
235235
*/
236236
static inline int vx_test_and_ack(struct vx_core *chip)
237237
{
238-
snd_assert(chip->ops->test_and_ack, return -ENXIO);
239238
return chip->ops->test_and_ack(chip);
240239
}
241240

242241
static inline void vx_validate_irq(struct vx_core *chip, int enable)
243242
{
244-
snd_assert(chip->ops->validate_irq, return);
245243
chip->ops->validate_irq(chip, enable);
246244
}
247245

248246
static inline unsigned char snd_vx_inb(struct vx_core *chip, int reg)
249247
{
250-
snd_assert(chip->ops->in8, return 0);
251248
return chip->ops->in8(chip, reg);
252249
}
253250

254251
static inline unsigned int snd_vx_inl(struct vx_core *chip, int reg)
255252
{
256-
snd_assert(chip->ops->in32, return 0);
257253
return chip->ops->in32(chip, reg);
258254
}
259255

260256
static inline void snd_vx_outb(struct vx_core *chip, int reg, unsigned char val)
261257
{
262-
snd_assert(chip->ops->out8, return);
263258
chip->ops->out8(chip, reg, val);
264259
}
265260

266261
static inline void snd_vx_outl(struct vx_core *chip, int reg, unsigned int val)
267262
{
268-
snd_assert(chip->ops->out32, return);
269263
chip->ops->out32(chip, reg, val);
270264
}
271265

@@ -276,7 +270,6 @@ static inline void snd_vx_outl(struct vx_core *chip, int reg, unsigned int val)
276270

277271
static inline void vx_reset_dsp(struct vx_core *chip)
278272
{
279-
snd_assert(chip->ops->reset_dsp, return);
280273
chip->ops->reset_dsp(chip);
281274
}
282275

@@ -304,14 +297,12 @@ int snd_vx_check_reg_bit(struct vx_core *chip, int reg, int mask, int bit, int t
304297
static inline void vx_pseudo_dma_write(struct vx_core *chip, struct snd_pcm_runtime *runtime,
305298
struct vx_pipe *pipe, int count)
306299
{
307-
snd_assert(chip->ops->dma_write, return);
308300
chip->ops->dma_write(chip, runtime, pipe, count);
309301
}
310302

311303
static inline void vx_pseudo_dma_read(struct vx_core *chip, struct snd_pcm_runtime *runtime,
312304
struct vx_pipe *pipe, int count)
313305
{
314-
snd_assert(chip->ops->dma_read, return);
315306
chip->ops->dma_read(chip, runtime, pipe, count);
316307
}
317308

‎sound/arm/sa11xx-uda1341.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,8 @@ static void audio_process_dma(struct audio_stream *s)
442442

443443
/* we are requested to process synchronization DMA transfer */
444444
if (s->tx_spin) {
445-
snd_assert(s->stream_id == SNDRV_PCM_STREAM_PLAYBACK, return);
445+
if (snd_BUG_ON(s->stream_id != SNDRV_PCM_STREAM_PLAYBACK))
446+
return;
446447
/* fill the xmit dma buffers and return */
447448
#ifdef HH_VERSION
448449
sa1100_dma_set_spin(s->dmach, FORCE_CLOCK_ADDR, FORCE_CLOCK_SIZE);
@@ -472,7 +473,7 @@ static void audio_process_dma(struct audio_stream *s)
472473
continue; /* special case */
473474
} else {
474475
offset = dma_size * s->period;
475-
snd_assert(dma_size <= DMA_BUF_SIZE, );
476+
snd_BUG_ON(dma_size > DMA_BUF_SIZE);
476477
}
477478
#ifdef HH_VERSION
478479
ret = sa1100_dma_queue_buffer(s->dmach, s, runtime->dma_addr + offset, dma_size);

‎sound/drivers/dummy.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,8 @@ static int __devinit snd_card_dummy_new_mixer(struct snd_dummy *dummy)
565565
unsigned int idx;
566566
int err;
567567

568-
snd_assert(dummy != NULL, return -EINVAL);
568+
if (snd_BUG_ON(!dummy))
569+
return -EINVAL;
569570
spin_lock_init(&dummy->mixer_lock);
570571
strcpy(card->mixername, "Dummy Mixer");
571572

‎sound/drivers/opl3/opl3_lib.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ static int snd_opl3_detect(struct snd_opl3 * opl3)
139139
* If we had an OPL4 chip, opl3->hardware would have been set
140140
* by the OPL4 driver; so we can assume OPL3 here.
141141
*/
142-
snd_assert(opl3->r_port != 0, return -ENODEV);
142+
if (snd_BUG_ON(!opl3->r_port))
143+
return -ENODEV;
143144
opl3->hardware = OPL3_HW_OPL3;
144145
}
145146
return 0;
@@ -324,7 +325,8 @@ EXPORT_SYMBOL(snd_opl3_interrupt);
324325

325326
static int snd_opl3_free(struct snd_opl3 *opl3)
326327
{
327-
snd_assert(opl3 != NULL, return -ENXIO);
328+
if (snd_BUG_ON(!opl3))
329+
return -ENXIO;
328330
if (opl3->private_free)
329331
opl3->private_free(opl3);
330332
snd_opl3_clear_patches(opl3);

‎sound/drivers/opl3/opl3_midi.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,8 @@ static void snd_opl3_kill_voice(struct snd_opl3 *opl3, int voice)
617617

618618
struct snd_opl3_voice *vp, *vp2;
619619

620-
snd_assert(voice < MAX_OPL3_VOICES, return);
620+
if (snd_BUG_ON(voice >= MAX_OPL3_VOICES))
621+
return;
621622

622623
vp = &opl3->voices[voice];
623624
if (voice < MAX_OPL2_VOICES) {
@@ -737,7 +738,8 @@ static void snd_opl3_update_pitch(struct snd_opl3 *opl3, int voice)
737738

738739
struct snd_opl3_voice *vp;
739740

740-
snd_assert(voice < MAX_OPL3_VOICES, return);
741+
if (snd_BUG_ON(voice >= MAX_OPL3_VOICES))
742+
return;
741743

742744
vp = &opl3->voices[voice];
743745
if (vp->chan == NULL)

‎sound/drivers/opl3/opl3_oss.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ static int snd_opl3_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure)
162162
struct snd_opl3 *opl3 = closure;
163163
int err;
164164

165-
snd_assert(arg != NULL, return -ENXIO);
165+
if (snd_BUG_ON(!arg))
166+
return -ENXIO;
166167

167168
if ((err = snd_opl3_synth_setup(opl3)) < 0)
168169
return err;
@@ -184,7 +185,8 @@ static int snd_opl3_close_seq_oss(struct snd_seq_oss_arg *arg)
184185
{
185186
struct snd_opl3 *opl3;
186187

187-
snd_assert(arg != NULL, return -ENXIO);
188+
if (snd_BUG_ON(!arg))
189+
return -ENXIO;
188190
opl3 = arg->private_data;
189191

190192
snd_opl3_synth_cleanup(opl3);
@@ -206,7 +208,8 @@ static int snd_opl3_load_patch_seq_oss(struct snd_seq_oss_arg *arg, int format,
206208
char name[32];
207209
int err, type;
208210

209-
snd_assert(arg != NULL, return -ENXIO);
211+
if (snd_BUG_ON(!arg))
212+
return -ENXIO;
210213
opl3 = arg->private_data;
211214

212215
if (format == FM_PATCH)
@@ -246,7 +249,8 @@ static int snd_opl3_ioctl_seq_oss(struct snd_seq_oss_arg *arg, unsigned int cmd,
246249
{
247250
struct snd_opl3 *opl3;
248251

249-
snd_assert(arg != NULL, return -ENXIO);
252+
if (snd_BUG_ON(!arg))
253+
return -ENXIO;
250254
opl3 = arg->private_data;
251255
switch (cmd) {
252256
case SNDCTL_FM_LOAD_INSTR:
@@ -271,7 +275,8 @@ static int snd_opl3_reset_seq_oss(struct snd_seq_oss_arg *arg)
271275
{
272276
struct snd_opl3 *opl3;
273277

274-
snd_assert(arg != NULL, return -ENXIO);
278+
if (snd_BUG_ON(!arg))
279+
return -ENXIO;
275280
opl3 = arg->private_data;
276281

277282
return 0;

‎sound/drivers/opl3/opl3_synth.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ int snd_opl3_ioctl(struct snd_hwdep * hw, struct file *file,
9292
struct snd_opl3 *opl3 = hw->private_data;
9393
void __user *argp = (void __user *)arg;
9494

95-
snd_assert(opl3 != NULL, return -EINVAL);
95+
if (snd_BUG_ON(!opl3))
96+
return -EINVAL;
9697

9798
switch (cmd) {
9899
/* get information */

‎sound/drivers/opl4/opl4_synth.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ static struct opl4_voice *snd_opl4_get_voice(struct snd_opl4 *opl4)
467467
if (!list_empty(&opl4->off_voices))
468468
return list_entry(opl4->off_voices.next, struct opl4_voice, list);
469469
/* then get the oldest key-on voice */
470-
snd_assert(!list_empty(&opl4->on_voices), );
470+
snd_BUG_ON(list_empty(&opl4->on_voices));
471471
return list_entry(opl4->on_voices.next, struct opl4_voice, list);
472472
}
473473

‎sound/drivers/vx/vx_cmd.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ static struct vx_cmd_info vx_dsp_cmds[] = {
9999
*/
100100
void vx_init_rmh(struct vx_rmh *rmh, unsigned int cmd)
101101
{
102-
snd_assert(cmd < CMD_LAST_INDEX, return);
102+
if (snd_BUG_ON(cmd >= CMD_LAST_INDEX))
103+
return;
103104
rmh->LgCmd = vx_dsp_cmds[cmd].length;
104105
rmh->LgStat = vx_dsp_cmds[cmd].st_length;
105106
rmh->DspStat = vx_dsp_cmds[cmd].st_type;

0 commit comments

Comments
 (0)