Commit 68f441ab authored by Takashi Iwai's avatar Takashi Iwai

ALSA: fm801: Fix assignment in if condition

PCI FM801 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-28-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 48cab474
...@@ -659,7 +659,8 @@ static int snd_fm801_playback_open(struct snd_pcm_substream *substream) ...@@ -659,7 +659,8 @@ static int snd_fm801_playback_open(struct snd_pcm_substream *substream)
SNDRV_PCM_HW_PARAM_CHANNELS, SNDRV_PCM_HW_PARAM_CHANNELS,
&hw_constraints_channels); &hw_constraints_channels);
} }
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;
return 0; return 0;
} }
...@@ -674,7 +675,8 @@ static int snd_fm801_capture_open(struct snd_pcm_substream *substream) ...@@ -674,7 +675,8 @@ static int snd_fm801_capture_open(struct snd_pcm_substream *substream)
runtime->hw = snd_fm801_capture; runtime->hw = snd_fm801_capture;
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
&hw_constraints_rates); &hw_constraints_rates);
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;
return 0; return 0;
} }
...@@ -717,7 +719,8 @@ static int snd_fm801_pcm(struct fm801 *chip, int device) ...@@ -717,7 +719,8 @@ static int snd_fm801_pcm(struct fm801 *chip, int device)
struct snd_pcm *pcm; struct snd_pcm *pcm;
int err; int err;
if ((err = snd_pcm_new(chip->card, "FM801", device, 1, 1, &pcm)) < 0) err = snd_pcm_new(chip->card, "FM801", device, 1, 1, &pcm);
if (err < 0)
return err; return err;
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_fm801_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_fm801_playback_ops);
...@@ -985,7 +988,8 @@ static int snd_fm801_put_mux(struct snd_kcontrol *kcontrol, ...@@ -985,7 +988,8 @@ static int snd_fm801_put_mux(struct snd_kcontrol *kcontrol,
struct fm801 *chip = snd_kcontrol_chip(kcontrol); struct fm801 *chip = snd_kcontrol_chip(kcontrol);
unsigned short val; unsigned short val;
if ((val = ucontrol->value.enumerated.item[0]) > 4) val = ucontrol->value.enumerated.item[0];
if (val > 4)
return -EINVAL; return -EINVAL;
return snd_fm801_update_bits(chip, FM801_REC_SRC, 7, val); return snd_fm801_update_bits(chip, FM801_REC_SRC, 7, val);
} }
...@@ -1050,19 +1054,22 @@ static int snd_fm801_mixer(struct fm801 *chip) ...@@ -1050,19 +1054,22 @@ static int snd_fm801_mixer(struct fm801 *chip)
.read = snd_fm801_codec_read, .read = snd_fm801_codec_read,
}; };
if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &chip->ac97_bus)) < 0) err = snd_ac97_bus(chip->card, 0, &ops, chip, &chip->ac97_bus);
if (err < 0)
return err; return err;
chip->ac97_bus->private_free = snd_fm801_mixer_free_ac97_bus; chip->ac97_bus->private_free = snd_fm801_mixer_free_ac97_bus;
memset(&ac97, 0, sizeof(ac97)); memset(&ac97, 0, sizeof(ac97));
ac97.private_data = chip; ac97.private_data = chip;
ac97.private_free = snd_fm801_mixer_free_ac97; ac97.private_free = snd_fm801_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; return err;
if (chip->secondary) { if (chip->secondary) {
ac97.num = 1; ac97.num = 1;
ac97.addr = chip->secondary_addr; ac97.addr = chip->secondary_addr;
if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97_sec)) < 0) err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97_sec);
if (err < 0)
return err; return err;
} }
for (i = 0; i < FM801_CONTROLS; i++) { for (i = 0; i < FM801_CONTROLS; i++) {
...@@ -1213,7 +1220,8 @@ static int snd_fm801_create(struct snd_card *card, ...@@ -1213,7 +1220,8 @@ static int snd_fm801_create(struct snd_card *card,
}; };
*rchip = NULL; *rchip = NULL;
if ((err = pcim_enable_device(pci)) < 0) err = pcim_enable_device(pci);
if (err < 0)
return err; return err;
chip = devm_kzalloc(&pci->dev, sizeof(*chip), GFP_KERNEL); chip = devm_kzalloc(&pci->dev, sizeof(*chip), GFP_KERNEL);
if (chip == NULL) if (chip == NULL)
...@@ -1223,7 +1231,8 @@ static int snd_fm801_create(struct snd_card *card, ...@@ -1223,7 +1231,8 @@ static int snd_fm801_create(struct snd_card *card,
chip->dev = &pci->dev; chip->dev = &pci->dev;
chip->irq = -1; chip->irq = -1;
chip->tea575x_tuner = tea575x_tuner; chip->tea575x_tuner = tea575x_tuner;
if ((err = pci_request_regions(pci, "FM801")) < 0) err = pci_request_regions(pci, "FM801");
if (err < 0)
return err; return err;
chip->port = pci_resource_start(pci, 0); chip->port = pci_resource_start(pci, 0);
...@@ -1254,7 +1263,8 @@ static int snd_fm801_create(struct snd_card *card, ...@@ -1254,7 +1263,8 @@ static int snd_fm801_create(struct snd_card *card,
snd_fm801_chip_init(chip); snd_fm801_chip_init(chip);
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_fm801_free(chip); snd_fm801_free(chip);
return err; return err;
} }
...@@ -1327,7 +1337,8 @@ static int snd_card_fm801_probe(struct pci_dev *pci, ...@@ -1327,7 +1337,8 @@ static int snd_card_fm801_probe(struct pci_dev *pci,
0, &card); 0, &card);
if (err < 0) if (err < 0)
return err; return err;
if ((err = snd_fm801_create(card, pci, tea575x_tuner[dev], radio_nr[dev], &chip)) < 0) { err = snd_fm801_create(card, pci, tea575x_tuner[dev], radio_nr[dev], &chip);
if (err < 0) {
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
...@@ -1342,35 +1353,41 @@ static int snd_card_fm801_probe(struct pci_dev *pci, ...@@ -1342,35 +1353,41 @@ static int snd_card_fm801_probe(struct pci_dev *pci,
if (chip->tea575x_tuner & TUNER_ONLY) if (chip->tea575x_tuner & TUNER_ONLY)
goto __fm801_tuner_only; goto __fm801_tuner_only;
if ((err = snd_fm801_pcm(chip, 0)) < 0) { err = snd_fm801_pcm(chip, 0);
if (err < 0) {
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
if ((err = snd_fm801_mixer(chip)) < 0) { err = snd_fm801_mixer(chip);
if (err < 0) {
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_FM801, err = snd_mpu401_uart_new(card, 0, MPU401_HW_FM801,
chip->port + FM801_MPU401_DATA, chip->port + FM801_MPU401_DATA,
MPU401_INFO_INTEGRATED | MPU401_INFO_INTEGRATED |
MPU401_INFO_IRQ_HOOK, MPU401_INFO_IRQ_HOOK,
-1, &chip->rmidi)) < 0) { -1, &chip->rmidi);
if (err < 0) {
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
if ((err = snd_opl3_create(card, chip->port + FM801_OPL3_BANK0, err = snd_opl3_create(card, chip->port + FM801_OPL3_BANK0,
chip->port + FM801_OPL3_BANK1, chip->port + FM801_OPL3_BANK1,
OPL3_HW_OPL3_FM801, 1, &opl3)) < 0) { OPL3_HW_OPL3_FM801, 1, &opl3);
if (err < 0) {
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
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); snd_card_free(card);
return err; return err;
} }
__fm801_tuner_only: __fm801_tuner_only:
if ((err = snd_card_register(card)) < 0) { err = snd_card_register(card);
if (err < 0) {
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
......
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