2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-26 22:24:09 +08:00

ALSA: cs4281: Fix assignment in if condition

PCI CS4281 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-24-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2021-06-08 16:04:57 +02:00
parent 4379588272
commit 393e95cda0

View File

@ -1068,23 +1068,28 @@ static int snd_cs4281_mixer(struct cs4281 *chip)
.read = snd_cs4281_ac97_read,
};
if ((err = snd_ac97_bus(card, 0, &ops, chip, &chip->ac97_bus)) < 0)
err = snd_ac97_bus(card, 0, &ops, chip, &chip->ac97_bus);
if (err < 0)
return err;
chip->ac97_bus->private_free = snd_cs4281_mixer_free_ac97_bus;
memset(&ac97, 0, sizeof(ac97));
ac97.private_data = chip;
ac97.private_free = snd_cs4281_mixer_free_ac97;
if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97)) < 0)
err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97);
if (err < 0)
return err;
if (chip->dual_codec) {
ac97.num = 1;
if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97_secondary)) < 0)
err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97_secondary);
if (err < 0)
return err;
}
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_cs4281_fm_vol, chip))) < 0)
err = snd_ctl_add(card, snd_ctl_new1(&snd_cs4281_fm_vol, chip));
if (err < 0)
return err;
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_cs4281_pcm_vol, chip))) < 0)
err = snd_ctl_add(card, snd_ctl_new1(&snd_cs4281_pcm_vol, chip));
if (err < 0)
return err;
return 0;
}
@ -1308,7 +1313,8 @@ static int snd_cs4281_create(struct snd_card *card,
};
*rchip = NULL;
if ((err = pci_enable_device(pci)) < 0)
err = pci_enable_device(pci);
if (err < 0)
return err;
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
if (chip == NULL) {
@ -1326,7 +1332,8 @@ static int snd_cs4281_create(struct snd_card *card,
}
chip->dual_codec = dual_codec;
if ((err = pci_request_regions(pci, "CS4281")) < 0) {
err = pci_request_regions(pci, "CS4281");
if (err < 0) {
kfree(chip);
pci_disable_device(pci);
return err;
@ -1356,7 +1363,8 @@ static int snd_cs4281_create(struct snd_card *card,
return tmp;
}
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_cs4281_free(chip);
return err;
}
@ -1395,12 +1403,14 @@ static int snd_cs4281_chip_init(struct cs4281 *chip)
* space between 0e4h and 0ffh to be written. */
snd_cs4281_pokeBA0(chip, BA0_CWPR, 0x4281);
if ((tmp = snd_cs4281_peekBA0(chip, BA0_SERC1)) != (BA0_SERC1_SO1EN | BA0_SERC1_AC97)) {
tmp = snd_cs4281_peekBA0(chip, BA0_SERC1);
if (tmp != (BA0_SERC1_SO1EN | BA0_SERC1_AC97)) {
dev_err(chip->card->dev,
"SERC1 AC'97 check failed (0x%x)\n", tmp);
return -EIO;
}
if ((tmp = snd_cs4281_peekBA0(chip, BA0_SERC2)) != (BA0_SERC2_SI1EN | BA0_SERC2_AC97)) {
tmp = snd_cs4281_peekBA0(chip, BA0_SERC2);
if (tmp != (BA0_SERC2_SI1EN | BA0_SERC2_AC97)) {
dev_err(chip->card->dev,
"SERC2 AC'97 check failed (0x%x)\n", tmp);
return -EIO;
@ -1748,7 +1758,8 @@ static int snd_cs4281_midi(struct cs4281 *chip, int device)
struct snd_rawmidi *rmidi;
int err;
if ((err = snd_rawmidi_new(chip->card, "CS4281", device, 1, 1, &rmidi)) < 0)
err = snd_rawmidi_new(chip->card, "CS4281", device, 1, 1, &rmidi);
if (err < 0)
return err;
strcpy(rmidi->name, "CS4281");
snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_cs4281_midi_output);
@ -1881,32 +1892,38 @@ static int snd_cs4281_probe(struct pci_dev *pci,
if (err < 0)
return err;
if ((err = snd_cs4281_create(card, pci, &chip, dual_codec[dev])) < 0) {
err = snd_cs4281_create(card, pci, &chip, dual_codec[dev]);
if (err < 0) {
snd_card_free(card);
return err;
}
card->private_data = chip;
if ((err = snd_cs4281_mixer(chip)) < 0) {
err = snd_cs4281_mixer(chip);
if (err < 0) {
snd_card_free(card);
return err;
}
if ((err = snd_cs4281_pcm(chip, 0)) < 0) {
err = snd_cs4281_pcm(chip, 0);
if (err < 0) {
snd_card_free(card);
return err;
}
if ((err = snd_cs4281_midi(chip, 0)) < 0) {
err = snd_cs4281_midi(chip, 0);
if (err < 0) {
snd_card_free(card);
return err;
}
if ((err = snd_opl3_new(card, OPL3_HW_OPL3_CS4281, &opl3)) < 0) {
err = snd_opl3_new(card, OPL3_HW_OPL3_CS4281, &opl3);
if (err < 0) {
snd_card_free(card);
return err;
}
opl3->private_data = chip;
opl3->command = snd_cs4281_opl3_command;
snd_opl3_init(opl3);
if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
err = snd_opl3_hwdep_new(opl3, 0, 1, NULL);
if (err < 0) {
snd_card_free(card);
return err;
}
@ -1918,7 +1935,8 @@ static int snd_cs4281_probe(struct pci_dev *pci,
chip->ba0_addr,
chip->irq);
if ((err = snd_card_register(card)) < 0) {
err = snd_card_register(card);
if (err < 0) {
snd_card_free(card);
return err;
}