ALSA: ad1816a: Fix assignment in if condition

ISA AD1816A driver code contains lots of 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-6-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2021-06-08 16:04:39 +02:00
parent 310efd3aab
commit 5ab6d66013
2 changed files with 32 additions and 18 deletions

View file

@ -131,16 +131,18 @@ static int snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard,
return error;
chip = card->private_data;
if ((error = snd_card_ad1816a_pnp(dev, pcard, pid))) {
error = snd_card_ad1816a_pnp(dev, pcard, pid);
if (error) {
snd_card_free(card);
return error;
}
if ((error = snd_ad1816a_create(card, port[dev],
irq[dev],
dma1[dev],
dma2[dev],
chip)) < 0) {
error = snd_ad1816a_create(card, port[dev],
irq[dev],
dma1[dev],
dma2[dev],
chip);
if (error) {
snd_card_free(card);
return error;
}
@ -152,12 +154,14 @@ static int snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard,
sprintf(card->longname, "%s, SS at 0x%lx, irq %d, dma %d&%d",
card->shortname, chip->port, irq[dev], dma1[dev], dma2[dev]);
if ((error = snd_ad1816a_pcm(chip, 0)) < 0) {
error = snd_ad1816a_pcm(chip, 0);
if (error < 0) {
snd_card_free(card);
return error;
}
if ((error = snd_ad1816a_mixer(chip)) < 0) {
error = snd_ad1816a_mixer(chip);
if (error < 0) {
snd_card_free(card);
return error;
}
@ -189,7 +193,8 @@ static int snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard,
}
}
if ((error = snd_card_register(card)) < 0) {
error = snd_card_register(card);
if (error < 0) {
snd_card_free(card);
return error;
}

View file

@ -155,7 +155,8 @@ static void snd_ad1816a_close(struct snd_ad1816a *chip, unsigned int mode)
snd_ad1816a_write_mask(chip, AD1816A_INTERRUPT_ENABLE,
AD1816A_TIMER_IRQ_ENABLE, 0x0000);
}
if (!((chip->mode &= ~mode) & AD1816A_MODE_OPEN))
chip->mode &= ~mode;
if (!(chip->mode & AD1816A_MODE_OPEN))
chip->mode = 0;
spin_unlock_irqrestore(&chip->lock, flags);
@ -426,7 +427,8 @@ static int snd_ad1816a_playback_open(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime;
int error;
if ((error = snd_ad1816a_open(chip, AD1816A_MODE_PLAYBACK)) < 0)
error = snd_ad1816a_open(chip, AD1816A_MODE_PLAYBACK);
if (error < 0)
return error;
runtime->hw = snd_ad1816a_playback;
snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.buffer_bytes_max);
@ -441,7 +443,8 @@ static int snd_ad1816a_capture_open(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime;
int error;
if ((error = snd_ad1816a_open(chip, AD1816A_MODE_CAPTURE)) < 0)
error = snd_ad1816a_open(chip, AD1816A_MODE_CAPTURE);
if (error < 0)
return error;
runtime->hw = snd_ad1816a_capture;
snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.buffer_bytes_max);
@ -586,7 +589,8 @@ int snd_ad1816a_create(struct snd_card *card,
chip->dma1 = -1;
chip->dma2 = -1;
if ((chip->res_port = request_region(port, 16, "AD1816A")) == NULL) {
chip->res_port = request_region(port, 16, "AD1816A");
if (!chip->res_port) {
snd_printk(KERN_ERR "ad1816a: can't grab port 0x%lx\n", port);
snd_ad1816a_free(chip);
return -EBUSY;
@ -615,7 +619,8 @@ int snd_ad1816a_create(struct snd_card *card,
chip->port = port;
spin_lock_init(&chip->lock);
if ((error = snd_ad1816a_probe(chip))) {
error = snd_ad1816a_probe(chip);
if (error) {
snd_ad1816a_free(chip);
return error;
}
@ -623,7 +628,8 @@ int snd_ad1816a_create(struct snd_card *card,
snd_ad1816a_init(chip);
/* Register device */
if ((error = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
error = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
if (error < 0) {
snd_ad1816a_free(chip);
return error;
}
@ -652,7 +658,8 @@ int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device)
int error;
struct snd_pcm *pcm;
if ((error = snd_pcm_new(chip->card, "AD1816A", device, 1, 1, &pcm)))
error = snd_pcm_new(chip->card, "AD1816A", device, 1, 1, &pcm);
if (error)
return error;
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ad1816a_playback_ops);
@ -682,7 +689,8 @@ int snd_ad1816a_timer(struct snd_ad1816a *chip, int device)
tid.card = chip->card->number;
tid.device = device;
tid.subdevice = 0;
if ((error = snd_timer_new(chip->card, "AD1816A", &tid, &timer)) < 0)
error = snd_timer_new(chip->card, "AD1816A", &tid, &timer);
if (error < 0)
return error;
strcpy(timer->name, snd_ad1816a_chip_id(chip));
timer->private_data = chip;
@ -944,7 +952,8 @@ int snd_ad1816a_mixer(struct snd_ad1816a *chip)
strcpy(card->mixername, snd_ad1816a_chip_id(chip));
for (idx = 0; idx < ARRAY_SIZE(snd_ad1816a_controls); idx++) {
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_ad1816a_controls[idx], chip))) < 0)
err = snd_ctl_add(card, snd_ctl_new1(&snd_ad1816a_controls[idx], chip));
if (err < 0)
return err;
}
return 0;