Commit b83bea38 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: atiixp: Fix assignment in if condition

PCI ATIIXP driver code contains 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-20-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 61ea06e8
...@@ -1039,7 +1039,8 @@ static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream, ...@@ -1039,7 +1039,8 @@ static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream,
/* direct SPDIF */ /* direct SPDIF */
runtime->hw.formats = SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE; runtime->hw.formats = SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE;
} }
if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
if (err < 0)
return err; return err;
runtime->private_data = dma; runtime->private_data = dma;
...@@ -1415,7 +1416,8 @@ static int snd_atiixp_mixer_new(struct atiixp *chip, int clock, ...@@ -1415,7 +1416,8 @@ static int snd_atiixp_mixer_new(struct atiixp *chip, int clock,
if (snd_atiixp_codec_detect(chip) < 0) if (snd_atiixp_codec_detect(chip) < 0)
return -ENXIO; return -ENXIO;
if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &pbus)) < 0) err = snd_ac97_bus(chip->card, 0, &ops, chip, &pbus);
if (err < 0)
return err; return err;
pbus->clock = clock; pbus->clock = clock;
chip->ac97_bus = pbus; chip->ac97_bus = pbus;
...@@ -1431,7 +1433,8 @@ static int snd_atiixp_mixer_new(struct atiixp *chip, int clock, ...@@ -1431,7 +1433,8 @@ static int snd_atiixp_mixer_new(struct atiixp *chip, int clock,
ac97.scaps = AC97_SCAP_SKIP_MODEM | AC97_SCAP_POWER_SAVE; ac97.scaps = AC97_SCAP_SKIP_MODEM | AC97_SCAP_POWER_SAVE;
if (! chip->spdif_over_aclink) if (! chip->spdif_over_aclink)
ac97.scaps |= AC97_SCAP_NO_SPDIF; ac97.scaps |= AC97_SCAP_NO_SPDIF;
if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) { err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i]);
if (err < 0) {
chip->ac97[i] = NULL; /* to be sure */ chip->ac97[i] = NULL; /* to be sure */
dev_dbg(chip->card->dev, dev_dbg(chip->card->dev,
"codec %d not available for audio\n", i); "codec %d not available for audio\n", i);
...@@ -1562,7 +1565,8 @@ static int snd_atiixp_create(struct snd_card *card, ...@@ -1562,7 +1565,8 @@ static int snd_atiixp_create(struct snd_card *card,
struct atiixp *chip; struct atiixp *chip;
int err; int err;
if ((err = pci_enable_device(pci)) < 0) err = pci_enable_device(pci);
if (err < 0)
return err; return err;
chip = kzalloc(sizeof(*chip), GFP_KERNEL); chip = kzalloc(sizeof(*chip), GFP_KERNEL);
...@@ -1576,7 +1580,8 @@ static int snd_atiixp_create(struct snd_card *card, ...@@ -1576,7 +1580,8 @@ static int snd_atiixp_create(struct snd_card *card,
chip->card = card; chip->card = card;
chip->pci = pci; chip->pci = pci;
chip->irq = -1; chip->irq = -1;
if ((err = pci_request_regions(pci, "ATI IXP AC97")) < 0) { err = pci_request_regions(pci, "ATI IXP AC97");
if (err < 0) {
pci_disable_device(pci); pci_disable_device(pci);
kfree(chip); kfree(chip);
return err; return err;
...@@ -1599,7 +1604,8 @@ static int snd_atiixp_create(struct snd_card *card, ...@@ -1599,7 +1604,8 @@ static int snd_atiixp_create(struct snd_card *card,
card->sync_irq = chip->irq; card->sync_irq = chip->irq;
pci_set_master(pci); pci_set_master(pci);
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_atiixp_free(chip); snd_atiixp_free(chip);
return err; return err;
} }
...@@ -1622,19 +1628,23 @@ static int snd_atiixp_probe(struct pci_dev *pci, ...@@ -1622,19 +1628,23 @@ static int snd_atiixp_probe(struct pci_dev *pci,
strcpy(card->driver, spdif_aclink ? "ATIIXP" : "ATIIXP-SPDMA"); strcpy(card->driver, spdif_aclink ? "ATIIXP" : "ATIIXP-SPDMA");
strcpy(card->shortname, "ATI IXP"); strcpy(card->shortname, "ATI IXP");
if ((err = snd_atiixp_create(card, pci, &chip)) < 0) err = snd_atiixp_create(card, pci, &chip);
if (err < 0)
goto __error; goto __error;
card->private_data = chip; card->private_data = chip;
if ((err = snd_atiixp_aclink_reset(chip)) < 0) err = snd_atiixp_aclink_reset(chip);
if (err < 0)
goto __error; goto __error;
chip->spdif_over_aclink = spdif_aclink; chip->spdif_over_aclink = spdif_aclink;
if ((err = snd_atiixp_mixer_new(chip, ac97_clock, ac97_quirk)) < 0) err = snd_atiixp_mixer_new(chip, ac97_clock, ac97_quirk);
if (err < 0)
goto __error; goto __error;
if ((err = snd_atiixp_pcm_new(chip)) < 0) err = snd_atiixp_pcm_new(chip);
if (err < 0)
goto __error; goto __error;
snd_atiixp_proc_init(chip); snd_atiixp_proc_init(chip);
...@@ -1647,7 +1657,8 @@ static int snd_atiixp_probe(struct pci_dev *pci, ...@@ -1647,7 +1657,8 @@ static int snd_atiixp_probe(struct pci_dev *pci,
chip->ac97[0] ? snd_ac97_get_short_name(chip->ac97[0]) : "?", chip->ac97[0] ? snd_ac97_get_short_name(chip->ac97[0]) : "?",
chip->addr, chip->irq); chip->addr, chip->irq);
if ((err = snd_card_register(card)) < 0) err = snd_card_register(card);
if (err < 0)
goto __error; goto __error;
pci_set_drvdata(pci, card); pci_set_drvdata(pci, card);
......
...@@ -856,12 +856,12 @@ static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream, ...@@ -856,12 +856,12 @@ static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream,
dma->substream = substream; dma->substream = substream;
runtime->hw = snd_atiixp_pcm_hw; runtime->hw = snd_atiixp_pcm_hw;
dma->ac97_pcm_type = pcm_type; dma->ac97_pcm_type = pcm_type;
if ((err = snd_pcm_hw_constraint_list(runtime, 0, err = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates);
&hw_constraints_rates)) < 0) if (err < 0)
return err; return err;
if ((err = snd_pcm_hw_constraint_integer(runtime, err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
SNDRV_PCM_HW_PARAM_PERIODS)) < 0) if (err < 0)
return err; return err;
runtime->private_data = dma; runtime->private_data = dma;
...@@ -1058,7 +1058,8 @@ static int snd_atiixp_mixer_new(struct atiixp_modem *chip, int clock) ...@@ -1058,7 +1058,8 @@ static int snd_atiixp_mixer_new(struct atiixp_modem *chip, int clock)
if (snd_atiixp_codec_detect(chip) < 0) if (snd_atiixp_codec_detect(chip) < 0)
return -ENXIO; return -ENXIO;
if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &pbus)) < 0) err = snd_ac97_bus(chip->card, 0, &ops, chip, &pbus);
if (err < 0)
return err; return err;
pbus->clock = clock; pbus->clock = clock;
chip->ac97_bus = pbus; chip->ac97_bus = pbus;
...@@ -1072,7 +1073,8 @@ static int snd_atiixp_mixer_new(struct atiixp_modem *chip, int clock) ...@@ -1072,7 +1073,8 @@ static int snd_atiixp_mixer_new(struct atiixp_modem *chip, int clock)
ac97.pci = chip->pci; ac97.pci = chip->pci;
ac97.num = i; ac97.num = i;
ac97.scaps = AC97_SCAP_SKIP_AUDIO | AC97_SCAP_POWER_SAVE; ac97.scaps = AC97_SCAP_SKIP_AUDIO | AC97_SCAP_POWER_SAVE;
if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) { err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i]);
if (err < 0) {
chip->ac97[i] = NULL; /* to be sure */ chip->ac97[i] = NULL; /* to be sure */
dev_dbg(chip->card->dev, dev_dbg(chip->card->dev,
"codec %d not available for modem\n", i); "codec %d not available for modem\n", i);
...@@ -1192,7 +1194,8 @@ static int snd_atiixp_create(struct snd_card *card, ...@@ -1192,7 +1194,8 @@ static int snd_atiixp_create(struct snd_card *card,
struct atiixp_modem *chip; struct atiixp_modem *chip;
int err; int err;
if ((err = pci_enable_device(pci)) < 0) err = pci_enable_device(pci);
if (err < 0)
return err; return err;
chip = kzalloc(sizeof(*chip), GFP_KERNEL); chip = kzalloc(sizeof(*chip), GFP_KERNEL);
...@@ -1206,7 +1209,8 @@ static int snd_atiixp_create(struct snd_card *card, ...@@ -1206,7 +1209,8 @@ static int snd_atiixp_create(struct snd_card *card,
chip->card = card; chip->card = card;
chip->pci = pci; chip->pci = pci;
chip->irq = -1; chip->irq = -1;
if ((err = pci_request_regions(pci, "ATI IXP MC97")) < 0) { err = pci_request_regions(pci, "ATI IXP MC97");
if (err < 0) {
kfree(chip); kfree(chip);
pci_disable_device(pci); pci_disable_device(pci);
return err; return err;
...@@ -1229,7 +1233,8 @@ static int snd_atiixp_create(struct snd_card *card, ...@@ -1229,7 +1233,8 @@ static int snd_atiixp_create(struct snd_card *card,
card->sync_irq = chip->irq; card->sync_irq = chip->irq;
pci_set_master(pci); pci_set_master(pci);
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_atiixp_free(chip); snd_atiixp_free(chip);
return err; return err;
} }
...@@ -1252,17 +1257,21 @@ static int snd_atiixp_probe(struct pci_dev *pci, ...@@ -1252,17 +1257,21 @@ static int snd_atiixp_probe(struct pci_dev *pci,
strcpy(card->driver, "ATIIXP-MODEM"); strcpy(card->driver, "ATIIXP-MODEM");
strcpy(card->shortname, "ATI IXP Modem"); strcpy(card->shortname, "ATI IXP Modem");
if ((err = snd_atiixp_create(card, pci, &chip)) < 0) err = snd_atiixp_create(card, pci, &chip);
if (err < 0)
goto __error; goto __error;
card->private_data = chip; card->private_data = chip;
if ((err = snd_atiixp_aclink_reset(chip)) < 0) err = snd_atiixp_aclink_reset(chip);
if (err < 0)
goto __error; goto __error;
if ((err = snd_atiixp_mixer_new(chip, ac97_clock)) < 0) err = snd_atiixp_mixer_new(chip, ac97_clock);
if (err < 0)
goto __error; goto __error;
if ((err = snd_atiixp_pcm_new(chip)) < 0) err = snd_atiixp_pcm_new(chip);
if (err < 0)
goto __error; goto __error;
snd_atiixp_proc_init(chip); snd_atiixp_proc_init(chip);
...@@ -1272,7 +1281,8 @@ static int snd_atiixp_probe(struct pci_dev *pci, ...@@ -1272,7 +1281,8 @@ static int snd_atiixp_probe(struct pci_dev *pci,
sprintf(card->longname, "%s rev %x at 0x%lx, irq %i", sprintf(card->longname, "%s rev %x at 0x%lx, irq %i",
card->shortname, pci->revision, chip->addr, chip->irq); card->shortname, pci->revision, chip->addr, chip->irq);
if ((err = snd_card_register(card)) < 0) err = snd_card_register(card);
if (err < 0)
goto __error; goto __error;
pci_set_drvdata(pci, card); pci_set_drvdata(pci, card);
......
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