Commit 549717fc authored by Takashi Iwai's avatar Takashi Iwai

ALSA: echoaudio: Fix assignment in if condition

PCI echoaudio drivers contain a few assignments in if condition, which
is a bad coding style that may confuse readers and occasionally lead
to bugs.

This patch is merely for coding-style fixes, no functional changes.

Link: https://lore.kernel.org/r/20210608140540.17885-40-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 164b3dde
...@@ -36,7 +36,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -36,7 +36,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
if (snd_BUG_ON((subdevice_id & 0xfff0) != DARLA20)) if (snd_BUG_ON((subdevice_id & 0xfff0) != DARLA20))
return -ENODEV; return -ENODEV;
if ((err = init_dsp_comm_page(chip))) { err = init_dsp_comm_page(chip);
if (err) {
dev_err(chip->card->dev, dev_err(chip->card->dev,
"init_hw: could not initialize DSP comm page\n"); "init_hw: could not initialize DSP comm page\n");
return err; return err;
...@@ -53,7 +54,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -53,7 +54,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
chip->asic_loaded = true; chip->asic_loaded = true;
chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL; chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL;
if ((err = load_firmware(chip)) < 0) err = load_firmware(chip);
if (err < 0)
return err; return err;
chip->bad_board = false; chip->bad_board = false;
......
...@@ -36,7 +36,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -36,7 +36,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
if (snd_BUG_ON((subdevice_id & 0xfff0) != DARLA24)) if (snd_BUG_ON((subdevice_id & 0xfff0) != DARLA24))
return -ENODEV; return -ENODEV;
if ((err = init_dsp_comm_page(chip))) { err = init_dsp_comm_page(chip);
if (err) {
dev_err(chip->card->dev, dev_err(chip->card->dev,
"init_hw: could not initialize DSP comm page\n"); "init_hw: could not initialize DSP comm page\n");
return err; return err;
...@@ -52,7 +53,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -52,7 +53,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL | chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL |
ECHO_CLOCK_BIT_ESYNC; ECHO_CLOCK_BIT_ESYNC;
if ((err = load_firmware(chip)) < 0) err = load_firmware(chip);
if (err < 0)
return err; return err;
chip->bad_board = false; chip->bad_board = false;
......
...@@ -49,7 +49,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -49,7 +49,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
if (snd_BUG_ON((subdevice_id & 0xfff0) != ECHO3G)) if (snd_BUG_ON((subdevice_id & 0xfff0) != ECHO3G))
return -ENODEV; return -ENODEV;
if ((err = init_dsp_comm_page(chip))) { err = init_dsp_comm_page(chip);
if (err) {
dev_err(chip->card->dev, dev_err(chip->card->dev,
"init_hw - could not initialize DSP comm page\n"); "init_hw - could not initialize DSP comm page\n");
return err; return err;
......
...@@ -301,38 +301,42 @@ static int pcm_open(struct snd_pcm_substream *substream, ...@@ -301,38 +301,42 @@ static int pcm_open(struct snd_pcm_substream *substream,
snd_pcm_set_sync(substream); snd_pcm_set_sync(substream);
/* Only mono and any even number of channels are allowed */ /* Only mono and any even number of channels are allowed */
if ((err = snd_pcm_hw_constraint_list(runtime, 0, err = snd_pcm_hw_constraint_list(runtime, 0,
SNDRV_PCM_HW_PARAM_CHANNELS, SNDRV_PCM_HW_PARAM_CHANNELS,
&pipe->constr)) < 0) &pipe->constr);
if (err < 0)
return err; return err;
/* All periods should have the same size */ /* All periods should have the same size */
if ((err = snd_pcm_hw_constraint_integer(runtime, err = snd_pcm_hw_constraint_integer(runtime,
SNDRV_PCM_HW_PARAM_PERIODS)) < 0) SNDRV_PCM_HW_PARAM_PERIODS);
if (err < 0)
return err; return err;
/* The hw accesses memory in chunks 32 frames long and they should be /* The hw accesses memory in chunks 32 frames long and they should be
32-bytes-aligned. It's not a requirement, but it seems that IRQs are 32-bytes-aligned. It's not a requirement, but it seems that IRQs are
generated with a resolution of 32 frames. Thus we need the following */ generated with a resolution of 32 frames. Thus we need the following */
if ((err = snd_pcm_hw_constraint_step(runtime, 0, err = snd_pcm_hw_constraint_step(runtime, 0,
SNDRV_PCM_HW_PARAM_PERIOD_SIZE, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 32);
32)) < 0) if (err < 0)
return err; return err;
if ((err = snd_pcm_hw_constraint_step(runtime, 0, err = snd_pcm_hw_constraint_step(runtime, 0,
SNDRV_PCM_HW_PARAM_BUFFER_SIZE, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 32);
32)) < 0) if (err < 0)
return err; return err;
if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, err = snd_pcm_hw_rule_add(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE, SNDRV_PCM_HW_PARAM_RATE,
hw_rule_sample_rate, chip, hw_rule_sample_rate, chip,
SNDRV_PCM_HW_PARAM_RATE, -1)) < 0) SNDRV_PCM_HW_PARAM_RATE, -1);
if (err < 0)
return err; return err;
/* Allocate a page for the scatter-gather list */ /* Allocate a page for the scatter-gather list */
if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
&chip->pci->dev, &chip->pci->dev,
PAGE_SIZE, &pipe->sgpage)) < 0) { PAGE_SIZE, &pipe->sgpage);
if (err < 0) {
dev_err(chip->card->dev, "s-g list allocation failed\n"); dev_err(chip->card->dev, "s-g list allocation failed\n");
return err; return err;
} }
...@@ -358,18 +362,21 @@ static int pcm_analog_in_open(struct snd_pcm_substream *substream) ...@@ -358,18 +362,21 @@ static int pcm_analog_in_open(struct snd_pcm_substream *substream)
struct echoaudio *chip = snd_pcm_substream_chip(substream); struct echoaudio *chip = snd_pcm_substream_chip(substream);
int err; int err;
if ((err = pcm_open(substream, num_analog_busses_in(chip) - err = pcm_open(substream,
substream->number)) < 0) num_analog_busses_in(chip) - substream->number);
if (err < 0)
return err; return err;
if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, err = snd_pcm_hw_rule_add(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_CHANNELS, SNDRV_PCM_HW_PARAM_CHANNELS,
hw_rule_capture_channels_by_format, NULL, hw_rule_capture_channels_by_format, NULL,
SNDRV_PCM_HW_PARAM_FORMAT, -1)) < 0) SNDRV_PCM_HW_PARAM_FORMAT, -1);
if (err < 0)
return err; return err;
if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, err = snd_pcm_hw_rule_add(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_FORMAT, SNDRV_PCM_HW_PARAM_FORMAT,
hw_rule_capture_format_by_channels, NULL, hw_rule_capture_format_by_channels, NULL,
SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0) SNDRV_PCM_HW_PARAM_CHANNELS, -1);
if (err < 0)
return err; return err;
return 0; return 0;
...@@ -387,19 +394,22 @@ static int pcm_analog_out_open(struct snd_pcm_substream *substream) ...@@ -387,19 +394,22 @@ static int pcm_analog_out_open(struct snd_pcm_substream *substream)
#else #else
max_channels = num_analog_busses_out(chip); max_channels = num_analog_busses_out(chip);
#endif #endif
if ((err = pcm_open(substream, max_channels - substream->number)) < 0) err = pcm_open(substream, max_channels - substream->number);
if (err < 0)
return err; return err;
if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, err = snd_pcm_hw_rule_add(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_CHANNELS, SNDRV_PCM_HW_PARAM_CHANNELS,
hw_rule_playback_channels_by_format, hw_rule_playback_channels_by_format,
NULL, NULL,
SNDRV_PCM_HW_PARAM_FORMAT, -1)) < 0) SNDRV_PCM_HW_PARAM_FORMAT, -1);
if (err < 0)
return err; return err;
if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, err = snd_pcm_hw_rule_add(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_FORMAT, SNDRV_PCM_HW_PARAM_FORMAT,
hw_rule_playback_format_by_channels, hw_rule_playback_format_by_channels,
NULL, NULL,
SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0) SNDRV_PCM_HW_PARAM_CHANNELS, -1);
if (err < 0)
return err; return err;
return 0; return 0;
...@@ -426,15 +436,17 @@ static int pcm_digital_in_open(struct snd_pcm_substream *substream) ...@@ -426,15 +436,17 @@ static int pcm_digital_in_open(struct snd_pcm_substream *substream)
if (err < 0) if (err < 0)
goto din_exit; goto din_exit;
if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, err = snd_pcm_hw_rule_add(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_CHANNELS, SNDRV_PCM_HW_PARAM_CHANNELS,
hw_rule_capture_channels_by_format, NULL, hw_rule_capture_channels_by_format, NULL,
SNDRV_PCM_HW_PARAM_FORMAT, -1)) < 0) SNDRV_PCM_HW_PARAM_FORMAT, -1);
if (err < 0)
goto din_exit; goto din_exit;
if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, err = snd_pcm_hw_rule_add(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_FORMAT, SNDRV_PCM_HW_PARAM_FORMAT,
hw_rule_capture_format_by_channels, NULL, hw_rule_capture_format_by_channels, NULL,
SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0) SNDRV_PCM_HW_PARAM_CHANNELS, -1);
if (err < 0)
goto din_exit; goto din_exit;
din_exit: din_exit:
...@@ -463,17 +475,19 @@ static int pcm_digital_out_open(struct snd_pcm_substream *substream) ...@@ -463,17 +475,19 @@ static int pcm_digital_out_open(struct snd_pcm_substream *substream)
if (err < 0) if (err < 0)
goto dout_exit; goto dout_exit;
if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, err = snd_pcm_hw_rule_add(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_CHANNELS, SNDRV_PCM_HW_PARAM_CHANNELS,
hw_rule_playback_channels_by_format, hw_rule_playback_channels_by_format,
NULL, SNDRV_PCM_HW_PARAM_FORMAT, NULL, SNDRV_PCM_HW_PARAM_FORMAT,
-1)) < 0) -1);
if (err < 0)
goto dout_exit; goto dout_exit;
if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, err = snd_pcm_hw_rule_add(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_FORMAT, SNDRV_PCM_HW_PARAM_FORMAT,
hw_rule_playback_format_by_channels, hw_rule_playback_format_by_channels,
NULL, SNDRV_PCM_HW_PARAM_CHANNELS, NULL, SNDRV_PCM_HW_PARAM_CHANNELS,
-1)) < 0) -1);
if (err < 0)
goto dout_exit; goto dout_exit;
dout_exit: dout_exit:
...@@ -907,8 +921,9 @@ static int snd_echo_new_pcm(struct echoaudio *chip) ...@@ -907,8 +921,9 @@ static int snd_echo_new_pcm(struct echoaudio *chip)
separated */ separated */
/* PCM#0 Virtual outputs and analog inputs */ /* PCM#0 Virtual outputs and analog inputs */
if ((err = snd_pcm_new(chip->card, "PCM", 0, num_pipes_out(chip), err = snd_pcm_new(chip->card, "PCM", 0, num_pipes_out(chip),
num_analog_busses_in(chip), &pcm)) < 0) num_analog_busses_in(chip), &pcm);
if (err < 0)
return err; return err;
pcm->private_data = chip; pcm->private_data = chip;
chip->analog_pcm = pcm; chip->analog_pcm = pcm;
...@@ -919,8 +934,9 @@ static int snd_echo_new_pcm(struct echoaudio *chip) ...@@ -919,8 +934,9 @@ static int snd_echo_new_pcm(struct echoaudio *chip)
#ifdef ECHOCARD_HAS_DIGITAL_IO #ifdef ECHOCARD_HAS_DIGITAL_IO
/* PCM#1 Digital inputs, no outputs */ /* PCM#1 Digital inputs, no outputs */
if ((err = snd_pcm_new(chip->card, "Digital PCM", 1, 0, err = snd_pcm_new(chip->card, "Digital PCM", 1, 0,
num_digital_busses_in(chip), &pcm)) < 0) num_digital_busses_in(chip), &pcm);
if (err < 0)
return err; return err;
pcm->private_data = chip; pcm->private_data = chip;
chip->digital_pcm = pcm; chip->digital_pcm = pcm;
...@@ -937,9 +953,10 @@ static int snd_echo_new_pcm(struct echoaudio *chip) ...@@ -937,9 +953,10 @@ static int snd_echo_new_pcm(struct echoaudio *chip)
register two PCM devices: */ register two PCM devices: */
/* PCM#0 Analog i/o */ /* PCM#0 Analog i/o */
if ((err = snd_pcm_new(chip->card, "Analog PCM", 0, err = snd_pcm_new(chip->card, "Analog PCM", 0,
num_analog_busses_out(chip), num_analog_busses_out(chip),
num_analog_busses_in(chip), &pcm)) < 0) num_analog_busses_in(chip), &pcm);
if (err < 0)
return err; return err;
pcm->private_data = chip; pcm->private_data = chip;
chip->analog_pcm = pcm; chip->analog_pcm = pcm;
...@@ -950,9 +967,10 @@ static int snd_echo_new_pcm(struct echoaudio *chip) ...@@ -950,9 +967,10 @@ static int snd_echo_new_pcm(struct echoaudio *chip)
#ifdef ECHOCARD_HAS_DIGITAL_IO #ifdef ECHOCARD_HAS_DIGITAL_IO
/* PCM#1 Digital i/o */ /* PCM#1 Digital i/o */
if ((err = snd_pcm_new(chip->card, "Digital PCM", 1, err = snd_pcm_new(chip->card, "Digital PCM", 1,
num_digital_busses_out(chip), num_digital_busses_out(chip),
num_digital_busses_in(chip), &pcm)) < 0) num_digital_busses_in(chip), &pcm);
if (err < 0)
return err; return err;
pcm->private_data = chip; pcm->private_data = chip;
chip->digital_pcm = pcm; chip->digital_pcm = pcm;
...@@ -1567,7 +1585,8 @@ static int snd_echo_clock_source_put(struct snd_kcontrol *kcontrol, ...@@ -1567,7 +1585,8 @@ static int snd_echo_clock_source_put(struct snd_kcontrol *kcontrol,
if (chip->input_clock != dclock) { if (chip->input_clock != dclock) {
mutex_lock(&chip->mode_mutex); mutex_lock(&chip->mode_mutex);
spin_lock_irq(&chip->lock); spin_lock_irq(&chip->lock);
if ((changed = set_input_clock(chip, dclock)) == 0) changed = set_input_clock(chip, dclock);
if (!changed)
changed = 1; /* no errors */ changed = 1; /* no errors */
spin_unlock_irq(&chip->lock); spin_unlock_irq(&chip->lock);
mutex_unlock(&chip->mode_mutex); mutex_unlock(&chip->mode_mutex);
...@@ -1911,7 +1930,8 @@ static int snd_echo_create(struct snd_card *card, ...@@ -1911,7 +1930,8 @@ static int snd_echo_create(struct snd_card *card,
pci_write_config_byte(pci, PCI_LATENCY_TIMER, 0xC0); pci_write_config_byte(pci, PCI_LATENCY_TIMER, 0xC0);
if ((err = pci_enable_device(pci)) < 0) err = pci_enable_device(pci);
if (err < 0)
return err; return err;
pci_set_master(pci); pci_set_master(pci);
...@@ -1943,8 +1963,9 @@ static int snd_echo_create(struct snd_card *card, ...@@ -1943,8 +1963,9 @@ static int snd_echo_create(struct snd_card *card,
if (sz > PAGE_SIZE) if (sz > PAGE_SIZE)
sz = PAGE_SIZE; /* We map only the required part */ sz = PAGE_SIZE; /* We map only the required part */
if ((chip->iores = request_mem_region(chip->dsp_registers_phys, sz, chip->iores = request_mem_region(chip->dsp_registers_phys, sz,
ECHOCARD_NAME)) == NULL) { ECHOCARD_NAME);
if (!chip->iores) {
dev_err(chip->card->dev, "cannot get memory region\n"); dev_err(chip->card->dev, "cannot get memory region\n");
snd_echo_free(chip); snd_echo_free(chip);
return -EBUSY; return -EBUSY;
...@@ -1988,7 +2009,8 @@ static int snd_echo_create(struct snd_card *card, ...@@ -1988,7 +2009,8 @@ static int snd_echo_create(struct snd_card *card,
return err; return err;
} }
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
if (err < 0) {
snd_echo_free(chip); snd_echo_free(chip);
return err; return err;
} }
...@@ -2024,7 +2046,8 @@ static int snd_echo_probe(struct pci_dev *pci, ...@@ -2024,7 +2046,8 @@ static int snd_echo_probe(struct pci_dev *pci,
return err; return err;
chip = NULL; /* Tells snd_echo_create to allocate chip */ chip = NULL; /* Tells snd_echo_create to allocate chip */
if ((err = snd_echo_create(card, pci, &chip)) < 0) { err = snd_echo_create(card, pci, &chip);
if (err < 0) {
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
...@@ -2040,7 +2063,8 @@ static int snd_echo_probe(struct pci_dev *pci, ...@@ -2040,7 +2063,8 @@ static int snd_echo_probe(struct pci_dev *pci,
card->shortname, pci_id->subdevice & 0x000f, dsp, card->shortname, pci_id->subdevice & 0x000f, dsp,
chip->dsp_registers_phys, chip->irq); chip->dsp_registers_phys, chip->irq);
if ((err = snd_echo_new_pcm(chip)) < 0) { err = snd_echo_new_pcm(chip);
if (err < 0) {
dev_err(chip->card->dev, "new pcm error %d\n", err); dev_err(chip->card->dev, "new pcm error %d\n", err);
snd_card_free(card); snd_card_free(card);
return err; return err;
...@@ -2048,7 +2072,8 @@ static int snd_echo_probe(struct pci_dev *pci, ...@@ -2048,7 +2072,8 @@ static int snd_echo_probe(struct pci_dev *pci,
#ifdef ECHOCARD_HAS_MIDI #ifdef ECHOCARD_HAS_MIDI
if (chip->has_midi) { /* Some Mia's do not have midi */ if (chip->has_midi) { /* Some Mia's do not have midi */
if ((err = snd_echo_midi_create(card, chip)) < 0) { err = snd_echo_midi_create(card, chip);
if (err < 0) {
dev_err(chip->card->dev, "new midi error %d\n", err); dev_err(chip->card->dev, "new midi error %d\n", err);
snd_card_free(card); snd_card_free(card);
return err; return err;
...@@ -2058,7 +2083,8 @@ static int snd_echo_probe(struct pci_dev *pci, ...@@ -2058,7 +2083,8 @@ static int snd_echo_probe(struct pci_dev *pci,
#ifdef ECHOCARD_HAS_VMIXER #ifdef ECHOCARD_HAS_VMIXER
snd_echo_vmixer.count = num_pipes_out(chip) * num_busses_out(chip); snd_echo_vmixer.count = num_pipes_out(chip) * num_busses_out(chip);
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vmixer, chip))) < 0) err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vmixer, chip));
if (err < 0)
goto ctl_error; goto ctl_error;
#ifdef ECHOCARD_HAS_LINE_OUT_GAIN #ifdef ECHOCARD_HAS_LINE_OUT_GAIN
err = snd_ctl_add(chip->card, err = snd_ctl_add(chip->card,
...@@ -2074,39 +2100,48 @@ static int snd_echo_probe(struct pci_dev *pci, ...@@ -2074,39 +2100,48 @@ static int snd_echo_probe(struct pci_dev *pci,
#endif /* ECHOCARD_HAS_VMIXER */ #endif /* ECHOCARD_HAS_VMIXER */
#ifdef ECHOCARD_HAS_INPUT_GAIN #ifdef ECHOCARD_HAS_INPUT_GAIN
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_line_input_gain, chip))) < 0) err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_line_input_gain, chip));
if (err < 0)
goto ctl_error; goto ctl_error;
#endif #endif
#ifdef ECHOCARD_HAS_INPUT_NOMINAL_LEVEL #ifdef ECHOCARD_HAS_INPUT_NOMINAL_LEVEL
if (!chip->hasnt_input_nominal_level) if (!chip->hasnt_input_nominal_level) {
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_intput_nominal_level, chip))) < 0) err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_intput_nominal_level, chip));
if (err < 0)
goto ctl_error; goto ctl_error;
}
#endif #endif
#ifdef ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL #ifdef ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_output_nominal_level, chip))) < 0) err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_output_nominal_level, chip));
if (err < 0)
goto ctl_error; goto ctl_error;
#endif #endif
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vumeters_switch, chip))) < 0) err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vumeters_switch, chip));
if (err < 0)
goto ctl_error; goto ctl_error;
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vumeters, chip))) < 0) err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vumeters, chip));
if (err < 0)
goto ctl_error; goto ctl_error;
#ifdef ECHOCARD_HAS_MONITOR #ifdef ECHOCARD_HAS_MONITOR
snd_echo_monitor_mixer.count = num_busses_in(chip) * num_busses_out(chip); snd_echo_monitor_mixer.count = num_busses_in(chip) * num_busses_out(chip);
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_monitor_mixer, chip))) < 0) err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_monitor_mixer, chip));
if (err < 0)
goto ctl_error; goto ctl_error;
#endif #endif
#ifdef ECHOCARD_HAS_DIGITAL_IN_AUTOMUTE #ifdef ECHOCARD_HAS_DIGITAL_IN_AUTOMUTE
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_automute_switch, chip))) < 0) err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_automute_switch, chip));
if (err < 0)
goto ctl_error; goto ctl_error;
#endif #endif
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_channels_info, chip))) < 0) err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_channels_info, chip));
if (err < 0)
goto ctl_error; goto ctl_error;
#ifdef ECHOCARD_HAS_DIGITAL_MODE_SWITCH #ifdef ECHOCARD_HAS_DIGITAL_MODE_SWITCH
...@@ -2116,7 +2151,8 @@ static int snd_echo_probe(struct pci_dev *pci, ...@@ -2116,7 +2151,8 @@ static int snd_echo_probe(struct pci_dev *pci,
if (chip->digital_modes & (1 << i)) if (chip->digital_modes & (1 << i))
chip->digital_mode_list[chip->num_digital_modes++] = i; chip->digital_mode_list[chip->num_digital_modes++] = i;
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_digital_mode_switch, chip))) < 0) err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_digital_mode_switch, chip));
if (err < 0)
goto ctl_error; goto ctl_error;
#endif /* ECHOCARD_HAS_DIGITAL_MODE_SWITCH */ #endif /* ECHOCARD_HAS_DIGITAL_MODE_SWITCH */
...@@ -2129,20 +2165,24 @@ static int snd_echo_probe(struct pci_dev *pci, ...@@ -2129,20 +2165,24 @@ static int snd_echo_probe(struct pci_dev *pci,
if (chip->num_clock_sources > 1) { if (chip->num_clock_sources > 1) {
chip->clock_src_ctl = snd_ctl_new1(&snd_echo_clock_source_switch, chip); chip->clock_src_ctl = snd_ctl_new1(&snd_echo_clock_source_switch, chip);
if ((err = snd_ctl_add(chip->card, chip->clock_src_ctl)) < 0) err = snd_ctl_add(chip->card, chip->clock_src_ctl);
if (err < 0)
goto ctl_error; goto ctl_error;
} }
#endif /* ECHOCARD_HAS_EXTERNAL_CLOCK */ #endif /* ECHOCARD_HAS_EXTERNAL_CLOCK */
#ifdef ECHOCARD_HAS_DIGITAL_IO #ifdef ECHOCARD_HAS_DIGITAL_IO
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_spdif_mode_switch, chip))) < 0) err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_spdif_mode_switch, chip));
if (err < 0)
goto ctl_error; goto ctl_error;
#endif #endif
#ifdef ECHOCARD_HAS_PHANTOM_POWER #ifdef ECHOCARD_HAS_PHANTOM_POWER
if (chip->has_phantom_power) if (chip->has_phantom_power) {
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_phantom_power_switch, chip))) < 0) err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_phantom_power_switch, chip));
if (err < 0)
goto ctl_error; goto ctl_error;
}
#endif #endif
err = snd_card_register(card); err = snd_card_register(card);
......
...@@ -349,7 +349,8 @@ static int load_dsp(struct echoaudio *chip, u16 *code) ...@@ -349,7 +349,8 @@ static int load_dsp(struct echoaudio *chip, u16 *code)
/* If this board requires a resident loader, install it. */ /* If this board requires a resident loader, install it. */
#ifdef DSP_56361 #ifdef DSP_56361
if ((i = install_resident_loader(chip)) < 0) i = install_resident_loader(chip);
if (i < 0)
return i; return i;
#endif #endif
...@@ -495,7 +496,8 @@ static int load_firmware(struct echoaudio *chip) ...@@ -495,7 +496,8 @@ static int load_firmware(struct echoaudio *chip)
/* See if the ASIC is present and working - only if the DSP is already loaded */ /* See if the ASIC is present and working - only if the DSP is already loaded */
if (chip->dsp_code) { if (chip->dsp_code) {
if ((box_type = check_asic_status(chip)) >= 0) box_type = check_asic_status(chip);
if (box_type >= 0)
return box_type; return box_type;
/* ASIC check failed; force the DSP to reload */ /* ASIC check failed; force the DSP to reload */
chip->dsp_code = NULL; chip->dsp_code = NULL;
...@@ -509,7 +511,8 @@ static int load_firmware(struct echoaudio *chip) ...@@ -509,7 +511,8 @@ static int load_firmware(struct echoaudio *chip)
if (err < 0) if (err < 0)
return err; return err;
if ((box_type = load_asic(chip)) < 0) box_type = load_asic(chip);
if (box_type < 0)
return box_type; /* error */ return box_type; /* error */
return box_type; return box_type;
...@@ -667,7 +670,8 @@ static int restore_dsp_rettings(struct echoaudio *chip) ...@@ -667,7 +670,8 @@ static int restore_dsp_rettings(struct echoaudio *chip)
{ {
int i, o, err; int i, o, err;
if ((err = check_asic_status(chip)) < 0) err = check_asic_status(chip);
if (err < 0)
return err; return err;
/* Gina20/Darla20 only. Should be harmless for other cards. */ /* Gina20/Darla20 only. Should be harmless for other cards. */
......
...@@ -194,7 +194,8 @@ static int set_professional_spdif(struct echoaudio *chip, char prof) ...@@ -194,7 +194,8 @@ static int set_professional_spdif(struct echoaudio *chip, char prof)
} }
} }
if ((err = write_control_reg(chip, control_reg, false))) err = write_control_reg(chip, control_reg, false);
if (err)
return err; return err;
chip->professional_spdif = prof; chip->professional_spdif = prof;
dev_dbg(chip->card->dev, "set_professional_spdif to %s\n", dev_dbg(chip->card->dev, "set_professional_spdif to %s\n",
......
...@@ -40,7 +40,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -40,7 +40,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
if (snd_BUG_ON((subdevice_id & 0xfff0) != GINA20)) if (snd_BUG_ON((subdevice_id & 0xfff0) != GINA20))
return -ENODEV; return -ENODEV;
if ((err = init_dsp_comm_page(chip))) { err = init_dsp_comm_page(chip);
if (err) {
dev_err(chip->card->dev, dev_err(chip->card->dev,
"init_hw - could not initialize DSP comm page\n"); "init_hw - could not initialize DSP comm page\n");
return err; return err;
...@@ -58,7 +59,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -58,7 +59,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL | chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL |
ECHO_CLOCK_BIT_SPDIF; ECHO_CLOCK_BIT_SPDIF;
if ((err = load_firmware(chip)) < 0) err = load_firmware(chip);
if (err < 0)
return err; return err;
chip->bad_board = false; chip->bad_board = false;
......
...@@ -44,7 +44,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -44,7 +44,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
if (snd_BUG_ON((subdevice_id & 0xfff0) != GINA24)) if (snd_BUG_ON((subdevice_id & 0xfff0) != GINA24))
return -ENODEV; return -ENODEV;
if ((err = init_dsp_comm_page(chip))) { err = init_dsp_comm_page(chip);
if (err) {
dev_err(chip->card->dev, dev_err(chip->card->dev,
"init_hw - could not initialize DSP comm page\n"); "init_hw - could not initialize DSP comm page\n");
return err; return err;
...@@ -74,7 +75,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -74,7 +75,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_CDROM; ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_CDROM;
} }
if ((err = load_firmware(chip)) < 0) err = load_firmware(chip);
if (err < 0)
return err; return err;
chip->bad_board = false; chip->bad_board = false;
......
...@@ -41,7 +41,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -41,7 +41,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
if (snd_BUG_ON((subdevice_id & 0xfff0) != INDIGO)) if (snd_BUG_ON((subdevice_id & 0xfff0) != INDIGO))
return -ENODEV; return -ENODEV;
if ((err = init_dsp_comm_page(chip))) { err = init_dsp_comm_page(chip);
if (err) {
dev_err(chip->card->dev, dev_err(chip->card->dev,
"init_hw - could not initialize DSP comm page\n"); "init_hw - could not initialize DSP comm page\n");
return err; return err;
...@@ -56,7 +57,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -56,7 +57,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
chip->asic_loaded = true; chip->asic_loaded = true;
chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL; chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL;
if ((err = load_firmware(chip)) < 0) err = load_firmware(chip);
if (err < 0)
return err; return err;
chip->bad_board = false; chip->bad_board = false;
......
...@@ -41,7 +41,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -41,7 +41,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
if (snd_BUG_ON((subdevice_id & 0xfff0) != INDIGO_DJ)) if (snd_BUG_ON((subdevice_id & 0xfff0) != INDIGO_DJ))
return -ENODEV; return -ENODEV;
if ((err = init_dsp_comm_page(chip))) { err = init_dsp_comm_page(chip);
if (err) {
dev_err(chip->card->dev, dev_err(chip->card->dev,
"init_hw - could not initialize DSP comm page\n"); "init_hw - could not initialize DSP comm page\n");
return err; return err;
...@@ -56,7 +57,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -56,7 +57,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
chip->asic_loaded = true; chip->asic_loaded = true;
chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL; chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL;
if ((err = load_firmware(chip)) < 0) err = load_firmware(chip);
if (err < 0)
return err; return err;
chip->bad_board = false; chip->bad_board = false;
......
...@@ -41,7 +41,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -41,7 +41,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
if (snd_BUG_ON((subdevice_id & 0xfff0) != INDIGO_IO)) if (snd_BUG_ON((subdevice_id & 0xfff0) != INDIGO_IO))
return -ENODEV; return -ENODEV;
if ((err = init_dsp_comm_page(chip))) { err = init_dsp_comm_page(chip);
if (err) {
dev_err(chip->card->dev, dev_err(chip->card->dev,
"init_hw - could not initialize DSP comm page\n"); "init_hw - could not initialize DSP comm page\n");
return err; return err;
...@@ -56,7 +57,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -56,7 +57,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
chip->asic_loaded = true; chip->asic_loaded = true;
chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL; chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL;
if ((err = load_firmware(chip)) < 0) err = load_firmware(chip);
if (err < 0)
return err; return err;
chip->bad_board = false; chip->bad_board = false;
......
...@@ -43,7 +43,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -43,7 +43,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
if (snd_BUG_ON((subdevice_id & 0xfff0) != LAYLA20)) if (snd_BUG_ON((subdevice_id & 0xfff0) != LAYLA20))
return -ENODEV; return -ENODEV;
if ((err = init_dsp_comm_page(chip))) { err = init_dsp_comm_page(chip);
if (err) {
dev_err(chip->card->dev, dev_err(chip->card->dev,
"init_hw - could not initialize DSP comm page\n"); "init_hw - could not initialize DSP comm page\n");
return err; return err;
...@@ -60,7 +61,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -60,7 +61,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
chip->output_clock_types = chip->output_clock_types =
ECHO_CLOCK_BIT_WORD | ECHO_CLOCK_BIT_SUPER; ECHO_CLOCK_BIT_WORD | ECHO_CLOCK_BIT_SUPER;
if ((err = load_firmware(chip)) < 0) err = load_firmware(chip);
if (err < 0)
return err; return err;
chip->bad_board = false; chip->bad_board = false;
......
...@@ -43,7 +43,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -43,7 +43,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
if (snd_BUG_ON((subdevice_id & 0xfff0) != LAYLA24)) if (snd_BUG_ON((subdevice_id & 0xfff0) != LAYLA24))
return -ENODEV; return -ENODEV;
if ((err = init_dsp_comm_page(chip))) { err = init_dsp_comm_page(chip);
if (err) {
dev_err(chip->card->dev, dev_err(chip->card->dev,
"init_hw - could not initialize DSP comm page\n"); "init_hw - could not initialize DSP comm page\n");
return err; return err;
...@@ -62,11 +63,13 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -62,11 +63,13 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL | ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL |
ECHOCAPS_HAS_DIGITAL_MODE_ADAT; ECHOCAPS_HAS_DIGITAL_MODE_ADAT;
if ((err = load_firmware(chip)) < 0) err = load_firmware(chip);
if (err < 0)
return err; return err;
chip->bad_board = false; chip->bad_board = false;
if ((err = init_line_levels(chip)) < 0) err = init_line_levels(chip);
if (err < 0)
return err; return err;
return err; return err;
......
...@@ -44,7 +44,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -44,7 +44,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
if (snd_BUG_ON((subdevice_id & 0xfff0) != MIA)) if (snd_BUG_ON((subdevice_id & 0xfff0) != MIA))
return -ENODEV; return -ENODEV;
if ((err = init_dsp_comm_page(chip))) { err = init_dsp_comm_page(chip);
if (err) {
dev_err(chip->card->dev, dev_err(chip->card->dev,
"init_hw - could not initialize DSP comm page\n"); "init_hw - could not initialize DSP comm page\n");
return err; return err;
...@@ -62,7 +63,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -62,7 +63,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL | chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL |
ECHO_CLOCK_BIT_SPDIF; ECHO_CLOCK_BIT_SPDIF;
if ((err = load_firmware(chip)) < 0) err = load_firmware(chip);
if (err < 0)
return err; return err;
chip->bad_board = false; chip->bad_board = false;
......
...@@ -308,8 +308,8 @@ static int snd_echo_midi_create(struct snd_card *card, ...@@ -308,8 +308,8 @@ static int snd_echo_midi_create(struct snd_card *card,
{ {
int err; int err;
if ((err = snd_rawmidi_new(card, card->shortname, 0, 1, 1, err = snd_rawmidi_new(card, card->shortname, 0, 1, 1, &chip->rmidi);
&chip->rmidi)) < 0) if (err < 0)
return err; return err;
strcpy(chip->rmidi->name, card->shortname); strcpy(chip->rmidi->name, card->shortname);
......
...@@ -44,7 +44,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -44,7 +44,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
if (snd_BUG_ON((subdevice_id & 0xfff0) != MONA)) if (snd_BUG_ON((subdevice_id & 0xfff0) != MONA))
return -ENODEV; return -ENODEV;
if ((err = init_dsp_comm_page(chip))) { err = init_dsp_comm_page(chip);
if (err) {
dev_err(chip->card->dev, dev_err(chip->card->dev,
"init_hw - could not initialize DSP comm page\n"); "init_hw - could not initialize DSP comm page\n");
return err; return err;
...@@ -67,7 +68,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) ...@@ -67,7 +68,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
else else
chip->dsp_code_to_load = FW_MONA_301_DSP; chip->dsp_code_to_load = FW_MONA_301_DSP;
if ((err = load_firmware(chip)) < 0) err = load_firmware(chip);
if (err < 0)
return err; return err;
chip->bad_board = false; chip->bad_board = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment