Skip to content

Commit

Permalink
ALSA: emu10k1x: Fix assignment in if condition
Browse files Browse the repository at this point in the history
PCI EMU10k1X 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/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Jun 9, 2021
1 parent 12bda10 commit 9031f93
Showing 1 changed file with 54 additions and 31 deletions.
85 changes: 54 additions & 31 deletions sound/pci/emu10k1/emu10k1x.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ static void snd_emu10k1x_pcm_interrupt(struct emu10k1x *emu, struct emu10k1x_voi
{
struct emu10k1x_pcm *epcm;

if ((epcm = voice->epcm) == NULL)
epcm = voice->epcm;
if (!epcm)
return;
if (epcm->substream == NULL)
return;
Expand All @@ -371,10 +372,11 @@ static int snd_emu10k1x_playback_open(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime;
int err;

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;
}
if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0)
err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64);
if (err < 0)
return err;

epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
Expand Down Expand Up @@ -550,10 +552,12 @@ static int snd_emu10k1x_pcm_open_capture(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime;
int err;

if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
return err;
if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0)
return err;
err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
if (err < 0)
return err;
err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64);
if (err < 0)
return err;

epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
if (epcm == NULL)
Expand Down Expand Up @@ -722,7 +726,8 @@ static int snd_emu10k1x_ac97(struct emu10k1x *chip)
.read = snd_emu10k1x_ac97_read,
};

if ((err = snd_ac97_bus(chip->card, 0, &ops, NULL, &pbus)) < 0)
err = snd_ac97_bus(chip->card, 0, &ops, NULL, &pbus);
if (err < 0)
return err;
pbus->no_vra = 1; /* we don't need VRA */

Expand Down Expand Up @@ -838,7 +843,8 @@ static int snd_emu10k1x_pcm(struct emu10k1x *emu, int device)
if (device == 0)
capture = 1;

if ((err = snd_pcm_new(emu->card, "emu10k1x", device, 1, capture, &pcm)) < 0)
err = snd_pcm_new(emu->card, "emu10k1x", device, 1, capture, &pcm);
if (err < 0)
return err;

pcm->private_data = emu;
Expand Down Expand Up @@ -891,7 +897,8 @@ static int snd_emu10k1x_create(struct snd_card *card,

*rchip = NULL;

if ((err = pci_enable_device(pci)) < 0)
err = pci_enable_device(pci);
if (err < 0)
return err;

if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28)) < 0) {
Expand All @@ -914,8 +921,8 @@ static int snd_emu10k1x_create(struct snd_card *card,
spin_lock_init(&chip->voice_lock);

chip->port = pci_resource_start(pci, 0);
if ((chip->res_port = request_region(chip->port, 8,
"EMU10K1X")) == NULL) {
chip->res_port = request_region(chip->port, 8, "EMU10K1X");
if (!chip->res_port) {
dev_err(card->dev, "cannot allocate the port 0x%lx\n",
chip->port);
snd_emu10k1x_free(chip);
Expand Down Expand Up @@ -991,8 +998,8 @@ static int snd_emu10k1x_create(struct snd_card *card,

outl(HCFG_LOCKSOUNDCACHE|HCFG_AUDIOENABLE, chip->port+HCFG);

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_emu10k1x_free(chip);
return err;
}
Expand Down Expand Up @@ -1171,17 +1178,23 @@ static int snd_emu10k1x_mixer(struct emu10k1x *emu)
struct snd_kcontrol *kctl;
struct snd_card *card = emu->card;

if ((kctl = snd_ctl_new1(&snd_emu10k1x_spdif_mask_control, emu)) == NULL)
kctl = snd_ctl_new1(&snd_emu10k1x_spdif_mask_control, emu);
if (!kctl)
return -ENOMEM;
if ((err = snd_ctl_add(card, kctl)))
err = snd_ctl_add(card, kctl);
if (err)
return err;
if ((kctl = snd_ctl_new1(&snd_emu10k1x_shared_spdif, emu)) == NULL)
kctl = snd_ctl_new1(&snd_emu10k1x_shared_spdif, emu);
if (!kctl)
return -ENOMEM;
if ((err = snd_ctl_add(card, kctl)))
err = snd_ctl_add(card, kctl);
if (err)
return err;
if ((kctl = snd_ctl_new1(&snd_emu10k1x_spdif_control, emu)) == NULL)
kctl = snd_ctl_new1(&snd_emu10k1x_spdif_control, emu);
if (!kctl)
return -ENOMEM;
if ((err = snd_ctl_add(card, kctl)))
err = snd_ctl_add(card, kctl);
if (err)
return err;

return 0;
Expand Down Expand Up @@ -1488,7 +1501,8 @@ static int emu10k1x_midi_init(struct emu10k1x *emu,
struct snd_rawmidi *rmidi;
int err;

if ((err = snd_rawmidi_new(emu->card, name, device, 1, 1, &rmidi)) < 0)
err = snd_rawmidi_new(emu->card, name, device, 1, 1, &rmidi);
if (err < 0)
return err;
midi->emu = emu;
spin_lock_init(&midi->open_lock);
Expand All @@ -1511,7 +1525,8 @@ static int snd_emu10k1x_midi(struct emu10k1x *emu)
struct emu10k1x_midi *midi = &emu->midi;
int err;

if ((err = emu10k1x_midi_init(emu, midi, 0, "EMU10K1X MPU-401 (UART)")) < 0)
err = emu10k1x_midi_init(emu, midi, 0, "EMU10K1X MPU-401 (UART)");
if (err < 0)
return err;

midi->tx_enable = INTE_MIDITXENABLE;
Expand Down Expand Up @@ -1543,35 +1558,42 @@ static int snd_emu10k1x_probe(struct pci_dev *pci,
if (err < 0)
return err;

if ((err = snd_emu10k1x_create(card, pci, &chip)) < 0) {
err = snd_emu10k1x_create(card, pci, &chip);
if (err < 0) {
snd_card_free(card);
return err;
}

if ((err = snd_emu10k1x_pcm(chip, 0)) < 0) {
err = snd_emu10k1x_pcm(chip, 0);
if (err < 0) {
snd_card_free(card);
return err;
}
if ((err = snd_emu10k1x_pcm(chip, 1)) < 0) {
err = snd_emu10k1x_pcm(chip, 1);
if (err < 0) {
snd_card_free(card);
return err;
}
if ((err = snd_emu10k1x_pcm(chip, 2)) < 0) {
err = snd_emu10k1x_pcm(chip, 2);
if (err < 0) {
snd_card_free(card);
return err;
}

if ((err = snd_emu10k1x_ac97(chip)) < 0) {
err = snd_emu10k1x_ac97(chip);
if (err < 0) {
snd_card_free(card);
return err;
}

if ((err = snd_emu10k1x_mixer(chip)) < 0) {
err = snd_emu10k1x_mixer(chip);
if (err < 0) {
snd_card_free(card);
return err;
}

if ((err = snd_emu10k1x_midi(chip)) < 0) {
err = snd_emu10k1x_midi(chip);
if (err < 0) {
snd_card_free(card);
return err;
}
Expand All @@ -1583,7 +1605,8 @@ static int snd_emu10k1x_probe(struct pci_dev *pci,
sprintf(card->longname, "%s at 0x%lx irq %i",
card->shortname, chip->port, chip->irq);

if ((err = snd_card_register(card)) < 0) {
err = snd_card_register(card);
if (err < 0) {
snd_card_free(card);
return err;
}
Expand Down

0 comments on commit 9031f93

Please sign in to comment.