Commit 48cab474 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: es1968: Fix assignment in if condition

PCI ES1968 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-27-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 3dc52815
...@@ -1600,7 +1600,8 @@ static int snd_es1968_capture_open(struct snd_pcm_substream *substream) ...@@ -1600,7 +1600,8 @@ static int snd_es1968_capture_open(struct snd_pcm_substream *substream)
es->mode = ESM_MODE_CAPTURE; es->mode = ESM_MODE_CAPTURE;
/* get mixbuffer */ /* get mixbuffer */
if ((es->mixbuf = snd_es1968_new_memory(chip, ESM_MIXBUF_SIZE)) == NULL) { es->mixbuf = snd_es1968_new_memory(chip, ESM_MIXBUF_SIZE);
if (!es->mixbuf) {
snd_es1968_free_apu_pair(chip, apu1); snd_es1968_free_apu_pair(chip, apu1);
snd_es1968_free_apu_pair(chip, apu2); snd_es1968_free_apu_pair(chip, apu2);
kfree(es); kfree(es);
...@@ -1695,11 +1696,13 @@ static void es1968_measure_clock(struct es1968 *chip) ...@@ -1695,11 +1696,13 @@ static void es1968_measure_clock(struct es1968 *chip)
chip->clock = 48000; /* default clock value */ chip->clock = 48000; /* default clock value */
/* search 2 APUs (although one apu is enough) */ /* search 2 APUs (although one apu is enough) */
if ((apu = snd_es1968_alloc_apu_pair(chip, ESM_APU_PCM_PLAY)) < 0) { apu = snd_es1968_alloc_apu_pair(chip, ESM_APU_PCM_PLAY);
if (apu < 0) {
dev_err(chip->card->dev, "Hmm, cannot find empty APU pair!?\n"); dev_err(chip->card->dev, "Hmm, cannot find empty APU pair!?\n");
return; return;
} }
if ((memory = snd_es1968_new_memory(chip, CLOCK_MEASURE_BUFSIZE)) == NULL) { memory = snd_es1968_new_memory(chip, CLOCK_MEASURE_BUFSIZE);
if (!memory) {
dev_warn(chip->card->dev, dev_warn(chip->card->dev,
"cannot allocate dma buffer - using default clock %d\n", "cannot allocate dma buffer - using default clock %d\n",
chip->clock); chip->clock);
...@@ -1791,7 +1794,8 @@ snd_es1968_pcm(struct es1968 *chip, int device) ...@@ -1791,7 +1794,8 @@ snd_es1968_pcm(struct es1968 *chip, int device)
int err; int err;
/* get DMA buffer */ /* get DMA buffer */
if ((err = snd_es1968_init_dmabuf(chip)) < 0) err = snd_es1968_init_dmabuf(chip);
if (err < 0)
return err; return err;
/* set PCMBAR */ /* set PCMBAR */
...@@ -1800,9 +1804,10 @@ snd_es1968_pcm(struct es1968 *chip, int device) ...@@ -1800,9 +1804,10 @@ snd_es1968_pcm(struct es1968 *chip, int device)
wave_set_register(chip, 0x01FE, chip->dma.addr >> 12); wave_set_register(chip, 0x01FE, chip->dma.addr >> 12);
wave_set_register(chip, 0x01FF, chip->dma.addr >> 12); wave_set_register(chip, 0x01FF, chip->dma.addr >> 12);
if ((err = snd_pcm_new(chip->card, "ESS Maestro", device, err = snd_pcm_new(chip->card, "ESS Maestro", device,
chip->playback_streams, chip->playback_streams,
chip->capture_streams, &pcm)) < 0) chip->capture_streams, &pcm);
if (err < 0)
return err; return err;
pcm->private_data = chip; pcm->private_data = chip;
...@@ -1953,7 +1958,8 @@ static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id) ...@@ -1953,7 +1958,8 @@ static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id)
struct es1968 *chip = dev_id; struct es1968 *chip = dev_id;
u32 event; u32 event;
if (!(event = inb(chip->io_port + 0x1A))) event = inb(chip->io_port + 0x1A);
if (!event)
return IRQ_NONE; return IRQ_NONE;
outw(inw(chip->io_port + 4) & 1, chip->io_port + 4); outw(inw(chip->io_port + 4) & 1, chip->io_port + 4);
...@@ -2008,13 +2014,15 @@ snd_es1968_mixer(struct es1968 *chip) ...@@ -2008,13 +2014,15 @@ snd_es1968_mixer(struct es1968 *chip)
.read = snd_es1968_ac97_read, .read = snd_es1968_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; return err;
pbus->no_vra = 1; /* ES1968 doesn't need VRA */ pbus->no_vra = 1; /* ES1968 doesn't need VRA */
memset(&ac97, 0, sizeof(ac97)); memset(&ac97, 0, sizeof(ac97));
ac97.private_data = chip; ac97.private_data = chip;
if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97)) < 0) err = snd_ac97_mixer(pbus, &ac97, &chip->ac97);
if (err < 0)
return err; return err;
#ifndef CONFIG_SND_ES1968_INPUT #ifndef CONFIG_SND_ES1968_INPUT
...@@ -2661,7 +2669,8 @@ static int snd_es1968_create(struct snd_card *card, ...@@ -2661,7 +2669,8 @@ static int snd_es1968_create(struct snd_card *card,
*chip_ret = NULL; *chip_ret = NULL;
/* enable PCI device */ /* enable PCI device */
if ((err = pci_enable_device(pci)) < 0) err = pci_enable_device(pci);
if (err < 0)
return err; return err;
/* check, if we can restrict PCI DMA transfers to 28 bits */ /* check, if we can restrict PCI DMA transfers to 28 bits */
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) { if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) {
...@@ -2692,7 +2701,8 @@ static int snd_es1968_create(struct snd_card *card, ...@@ -2692,7 +2701,8 @@ static int snd_es1968_create(struct snd_card *card,
chip->playback_streams = play_streams; chip->playback_streams = play_streams;
chip->capture_streams = capt_streams; chip->capture_streams = capt_streams;
if ((err = pci_request_regions(pci, "ESS Maestro")) < 0) { err = pci_request_regions(pci, "ESS Maestro");
if (err < 0) {
kfree(chip); kfree(chip);
pci_disable_device(pci); pci_disable_device(pci);
return err; return err;
...@@ -2739,7 +2749,8 @@ static int snd_es1968_create(struct snd_card *card, ...@@ -2739,7 +2749,8 @@ static int snd_es1968_create(struct snd_card *card,
snd_es1968_chip_init(chip); snd_es1968_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_es1968_free(chip); snd_es1968_free(chip);
return err; return err;
} }
...@@ -2804,14 +2815,15 @@ static int snd_es1968_probe(struct pci_dev *pci, ...@@ -2804,14 +2815,15 @@ static int snd_es1968_probe(struct pci_dev *pci,
total_bufsize[dev] = 128; total_bufsize[dev] = 128;
if (total_bufsize[dev] > 4096) if (total_bufsize[dev] > 4096)
total_bufsize[dev] = 4096; total_bufsize[dev] = 4096;
if ((err = snd_es1968_create(card, pci, err = snd_es1968_create(card, pci,
total_bufsize[dev] * 1024, /* in bytes */ total_bufsize[dev] * 1024, /* in bytes */
pcm_substreams_p[dev], pcm_substreams_p[dev],
pcm_substreams_c[dev], pcm_substreams_c[dev],
pci_id->driver_data, pci_id->driver_data,
use_pm[dev], use_pm[dev],
radio_nr[dev], radio_nr[dev],
&chip)) < 0) { &chip);
if (err < 0) {
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
...@@ -2832,12 +2844,14 @@ static int snd_es1968_probe(struct pci_dev *pci, ...@@ -2832,12 +2844,14 @@ static int snd_es1968_probe(struct pci_dev *pci,
break; break;
} }
if ((err = snd_es1968_pcm(chip, 0)) < 0) { err = snd_es1968_pcm(chip, 0);
if (err < 0) {
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
if ((err = snd_es1968_mixer(chip)) < 0) { err = snd_es1968_mixer(chip);
if (err < 0) {
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
...@@ -2855,13 +2869,13 @@ static int snd_es1968_probe(struct pci_dev *pci, ...@@ -2855,13 +2869,13 @@ static int snd_es1968_probe(struct pci_dev *pci,
} }
} }
if (enable_mpu[dev]) { if (enable_mpu[dev]) {
if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
chip->io_port + ESM_MPU401_PORT, chip->io_port + ESM_MPU401_PORT,
MPU401_INFO_INTEGRATED | MPU401_INFO_INTEGRATED |
MPU401_INFO_IRQ_HOOK, MPU401_INFO_IRQ_HOOK,
-1, &chip->rmidi)) < 0) { -1, &chip->rmidi);
if (err < 0)
dev_warn(card->dev, "skipping MPU-401 MIDI support..\n"); dev_warn(card->dev, "skipping MPU-401 MIDI support..\n");
}
} }
snd_es1968_create_gameport(chip, dev); snd_es1968_create_gameport(chip, dev);
...@@ -2882,7 +2896,8 @@ static int snd_es1968_probe(struct pci_dev *pci, ...@@ -2882,7 +2896,8 @@ static int snd_es1968_probe(struct pci_dev *pci,
sprintf(card->longname, "%s at 0x%lx, irq %i", sprintf(card->longname, "%s at 0x%lx, irq %i",
card->shortname, chip->io_port, chip->irq); card->shortname, chip->io_port, chip->irq);
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