Skip to content

Commit da3cec3

Browse files
tiwaiperexg
authored andcommitted
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>
1 parent 622207d commit da3cec3

70 files changed

Lines changed: 632 additions & 361 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎sound/pci/ac97/ac97_codec.c‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,8 +1890,8 @@ int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops,
18901890
.dev_free = snd_ac97_bus_dev_free,
18911891
};
18921892

1893-
snd_assert(card != NULL, return -EINVAL);
1894-
snd_assert(rbus != NULL, return -EINVAL);
1893+
if (snd_BUG_ON(!card))
1894+
return -EINVAL;
18951895
bus = kzalloc(sizeof(*bus), GFP_KERNEL);
18961896
if (bus == NULL)
18971897
return -ENOMEM;
@@ -1906,7 +1906,8 @@ int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops,
19061906
snd_ac97_bus_free(bus);
19071907
return err;
19081908
}
1909-
*rbus = bus;
1909+
if (rbus)
1910+
*rbus = bus;
19101911
return 0;
19111912
}
19121913

@@ -1991,10 +1992,14 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
19911992
.dev_disconnect = snd_ac97_dev_disconnect,
19921993
};
19931994

1994-
snd_assert(rac97 != NULL, return -EINVAL);
1995-
*rac97 = NULL;
1996-
snd_assert(bus != NULL && template != NULL, return -EINVAL);
1997-
snd_assert(template->num < 4 && bus->codec[template->num] == NULL, return -EINVAL);
1995+
if (rac97)
1996+
*rac97 = NULL;
1997+
if (snd_BUG_ON(!bus || !template))
1998+
return -EINVAL;
1999+
if (snd_BUG_ON(template->num >= 4))
2000+
return -EINVAL;
2001+
if (bus->codec[template->num])
2002+
return -EBUSY;
19982003

19992004
card = bus->card;
20002005
ac97 = kzalloc(sizeof(*ac97), GFP_KERNEL);

‎sound/pci/ad1889.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,8 @@ snd_ad1889_playback_pointer(struct snd_pcm_substream *ss)
549549
ptr = ad1889_readl(chip, AD_DMA_WAVCA);
550550
ptr -= chip->wave.addr;
551551

552-
snd_assert((ptr >= 0) && (ptr < chip->wave.size), return 0);
552+
if (snd_BUG_ON(ptr >= chip->wave.size))
553+
return 0;
553554

554555
return bytes_to_frames(ss->runtime, ptr);
555556
}
@@ -567,7 +568,8 @@ snd_ad1889_capture_pointer(struct snd_pcm_substream *ss)
567568
ptr = ad1889_readl(chip, AD_DMA_ADCCA);
568569
ptr -= chip->ramc.addr;
569570

570-
snd_assert((ptr >= 0) && (ptr < chip->ramc.size), return 0);
571+
if (snd_BUG_ON(ptr >= chip->ramc.size))
572+
return 0;
571573

572574
return bytes_to_frames(ss->runtime, ptr);
573575
}

‎sound/pci/ak4531_codec.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,10 @@ int __devinit snd_ak4531_mixer(struct snd_card *card,
392392
.dev_free = snd_ak4531_dev_free,
393393
};
394394

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;
398399
ak4531 = kzalloc(sizeof(*ak4531), GFP_KERNEL);
399400
if (ak4531 == NULL)
400401
return -ENOMEM;
@@ -428,7 +429,8 @@ int __devinit snd_ak4531_mixer(struct snd_card *card,
428429
#if 0
429430
snd_ak4531_dump(ak4531);
430431
#endif
431-
*rak4531 = ak4531;
432+
if (rak4531)
433+
*rak4531 = ak4531;
432434
return 0;
433435
}
434436

‎sound/pci/atiixp.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,9 @@ static int snd_atiixp_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
722722
struct atiixp_dma *dma = substream->runtime->private_data;
723723
int err = 0;
724724

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;
726728

727729
spin_lock(&chip->reg_lock);
728730
switch (cmd) {
@@ -1032,7 +1034,8 @@ static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream,
10321034
struct snd_pcm_runtime *runtime = substream->runtime;
10331035
int err;
10341036

1035-
snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL);
1037+
if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
1038+
return -EINVAL;
10361039

10371040
if (dma->opened)
10381041
return -EBUSY;
@@ -1064,7 +1067,8 @@ static int snd_atiixp_pcm_close(struct snd_pcm_substream *substream,
10641067
{
10651068
struct atiixp *chip = snd_pcm_substream_chip(substream);
10661069
/* disable DMA bits */
1067-
snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL);
1070+
if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
1071+
return -EINVAL;
10681072
spin_lock_irq(&chip->reg_lock);
10691073
dma->ops->enable_dma(chip, 0);
10701074
spin_unlock_irq(&chip->reg_lock);

‎sound/pci/atiixp_modem.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,9 @@ static int snd_atiixp_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
674674
struct atiixp_dma *dma = substream->runtime->private_data;
675675
int err = 0;
676676

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;
678680

679681
spin_lock(&chip->reg_lock);
680682
switch(cmd) {
@@ -865,7 +867,8 @@ static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream,
865867
.mask = 0,
866868
};
867869

868-
snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL);
870+
if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
871+
return -EINVAL;
869872

870873
if (dma->opened)
871874
return -EBUSY;
@@ -895,7 +898,8 @@ static int snd_atiixp_pcm_close(struct snd_pcm_substream *substream,
895898
{
896899
struct atiixp_modem *chip = snd_pcm_substream_chip(substream);
897900
/* disable DMA bits */
898-
snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL);
901+
if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
902+
return -EINVAL;
899903
spin_lock_irq(&chip->reg_lock);
900904
dma->ops->enable_dma(chip, 0);
901905
spin_unlock_irq(&chip->reg_lock);

‎sound/pci/azt3328.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,8 @@ snd_azf3328_mixer_new(struct snd_azf3328 *chip)
816816
int err;
817817

818818
snd_azf3328_dbgcallenter();
819-
snd_assert(chip != NULL && chip->card != NULL, return -EINVAL);
819+
if (snd_BUG_ON(!chip || !chip->card))
820+
return -EINVAL;
820821

821822
card = chip->card;
822823

@@ -1471,7 +1472,8 @@ snd_azf3328_gameport_cooked_read(struct gameport *gameport,
14711472
u8 val;
14721473
unsigned long flags;
14731474

1474-
snd_assert(chip, return 0);
1475+
if (snd_BUG_ON(!chip))
1476+
return 0;
14751477

14761478
spin_lock_irqsave(&chip->reg_lock, flags);
14771479
val = snd_azf3328_game_inb(chip, IDX_GAME_LEGACY_COMPATIBLE);

‎sound/pci/ca0106/ca_midi.c‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ static int ca_midi_input_open(struct snd_rawmidi_substream *substream)
125125
struct snd_ca_midi *midi = substream->rmidi->private_data;
126126
unsigned long flags;
127127

128-
snd_assert(midi->dev_id, return -ENXIO);
128+
if (snd_BUG_ON(!midi->dev_id))
129+
return -ENXIO;
129130
spin_lock_irqsave(&midi->open_lock, flags);
130131
midi->midi_mode |= CA_MIDI_MODE_INPUT;
131132
midi->substream_input = substream;
@@ -144,7 +145,8 @@ static int ca_midi_output_open(struct snd_rawmidi_substream *substream)
144145
struct snd_ca_midi *midi = substream->rmidi->private_data;
145146
unsigned long flags;
146147

147-
snd_assert(midi->dev_id, return -ENXIO);
148+
if (snd_BUG_ON(!midi->dev_id))
149+
return -ENXIO;
148150
spin_lock_irqsave(&midi->open_lock, flags);
149151
midi->midi_mode |= CA_MIDI_MODE_OUTPUT;
150152
midi->substream_output = substream;
@@ -163,7 +165,8 @@ static int ca_midi_input_close(struct snd_rawmidi_substream *substream)
163165
struct snd_ca_midi *midi = substream->rmidi->private_data;
164166
unsigned long flags;
165167

166-
snd_assert(midi->dev_id, return -ENXIO);
168+
if (snd_BUG_ON(!midi->dev_id))
169+
return -ENXIO;
167170
spin_lock_irqsave(&midi->open_lock, flags);
168171
midi->interrupt_disable(midi,midi->rx_enable);
169172
midi->midi_mode &= ~CA_MIDI_MODE_INPUT;
@@ -181,7 +184,9 @@ static int ca_midi_output_close(struct snd_rawmidi_substream *substream)
181184
{
182185
struct snd_ca_midi *midi = substream->rmidi->private_data;
183186
unsigned long flags;
184-
snd_assert(midi->dev_id, return -ENXIO);
187+
188+
if (snd_BUG_ON(!midi->dev_id))
189+
return -ENXIO;
185190

186191
spin_lock_irqsave(&midi->open_lock, flags);
187192

@@ -201,7 +206,9 @@ static int ca_midi_output_close(struct snd_rawmidi_substream *substream)
201206
static void ca_midi_input_trigger(struct snd_rawmidi_substream *substream, int up)
202207
{
203208
struct snd_ca_midi *midi = substream->rmidi->private_data;
204-
snd_assert(midi->dev_id, return);
209+
210+
if (snd_BUG_ON(!midi->dev_id))
211+
return;
205212

206213
if (up) {
207214
midi->interrupt_enable(midi,midi->rx_enable);
@@ -215,7 +222,8 @@ static void ca_midi_output_trigger(struct snd_rawmidi_substream *substream, int
215222
struct snd_ca_midi *midi = substream->rmidi->private_data;
216223
unsigned long flags;
217224

218-
snd_assert(midi->dev_id, return);
225+
if (snd_BUG_ON(!midi->dev_id))
226+
return;
219227

220228
if (up) {
221229
int max = 4;

‎sound/pci/cmipci.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,7 +2357,8 @@ static int snd_cmipci_uswitch_get(struct snd_kcontrol *kcontrol,
23572357
{
23582358
struct cmipci_switch_args *args;
23592359
args = (struct cmipci_switch_args *)kcontrol->private_value;
2360-
snd_assert(args != NULL, return -EINVAL);
2360+
if (snd_BUG_ON(!args))
2361+
return -EINVAL;
23612362
return _snd_cmipci_uswitch_get(kcontrol, ucontrol, args);
23622363
}
23632364

@@ -2401,7 +2402,8 @@ static int snd_cmipci_uswitch_put(struct snd_kcontrol *kcontrol,
24012402
{
24022403
struct cmipci_switch_args *args;
24032404
args = (struct cmipci_switch_args *)kcontrol->private_value;
2404-
snd_assert(args != NULL, return -EINVAL);
2405+
if (snd_BUG_ON(!args))
2406+
return -EINVAL;
24052407
return _snd_cmipci_uswitch_put(kcontrol, ucontrol, args);
24062408
}
24072409

@@ -2662,7 +2664,8 @@ static int __devinit snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_devic
26622664
unsigned int idx;
26632665
int err;
26642666

2665-
snd_assert(cm != NULL && cm->card != NULL, return -EINVAL);
2667+
if (snd_BUG_ON(!cm || !cm->card))
2668+
return -EINVAL;
26662669

26672670
card = cm->card;
26682671

‎sound/pci/cs4281.c‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -766,13 +766,13 @@ static void snd_cs4281_mode(struct cs4281 *chip, struct cs4281_dma *dma,
766766
if (!capture) {
767767
if (dma->left_slot == chip->src_left_play_slot) {
768768
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);
770770
snd_cs4281_pokeBA0(chip, BA0_DACSR, val);
771771
}
772772
} else {
773773
if (dma->left_slot == chip->src_left_rec_slot) {
774774
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);
776776
snd_cs4281_pokeBA0(chip, BA0_ADCSR, val);
777777
}
778778
}
@@ -1209,15 +1209,17 @@ static void snd_cs4281_gameport_trigger(struct gameport *gameport)
12091209
{
12101210
struct cs4281 *chip = gameport_get_port_data(gameport);
12111211

1212-
snd_assert(chip, return);
1212+
if (snd_BUG_ON(!chip))
1213+
return;
12131214
snd_cs4281_pokeBA0(chip, BA0_JSPT, 0xff);
12141215
}
12151216

12161217
static unsigned char snd_cs4281_gameport_read(struct gameport *gameport)
12171218
{
12181219
struct cs4281 *chip = gameport_get_port_data(gameport);
12191220

1220-
snd_assert(chip, return 0);
1221+
if (snd_BUG_ON(!chip))
1222+
return 0;
12211223
return snd_cs4281_peekBA0(chip, BA0_JSPT);
12221224
}
12231225

@@ -1228,7 +1230,8 @@ static int snd_cs4281_gameport_cooked_read(struct gameport *gameport,
12281230
struct cs4281 *chip = gameport_get_port_data(gameport);
12291231
unsigned js1, js2, jst;
12301232

1231-
snd_assert(chip, return 0);
1233+
if (snd_BUG_ON(!chip))
1234+
return 0;
12321235

12331236
js1 = snd_cs4281_peekBA0(chip, BA0_JSC1);
12341237
js2 = snd_cs4281_peekBA0(chip, BA0_JSC2);

0 commit comments

Comments
 (0)