Commit 28c07099 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: riptide: Fix assignment in if condition

PCI riptide 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-48-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 4327ad25
...@@ -1087,9 +1087,15 @@ static irqreturn_t riptide_handleirq(int irq, void *dev_id) ...@@ -1087,9 +1087,15 @@ static irqreturn_t riptide_handleirq(int irq, void *dev_id)
substream[i] = chip->playback_substream[i]; substream[i] = chip->playback_substream[i];
substream[i] = chip->capture_substream; substream[i] = chip->capture_substream;
for (i = 0; i < PLAYBACK_SUBSTREAMS + 1; i++) { for (i = 0; i < PLAYBACK_SUBSTREAMS + 1; i++) {
if (substream[i] && if (!substream[i])
(runtime = substream[i]->runtime) && continue;
(data = runtime->private_data) && data->state != ST_STOP) { runtime = substream[i]->runtime;
if (!runtime)
continue;
data = runtime->private_data;
if (!data)
continue;
if (data->state != ST_STOP) {
pos = 0; pos = 0;
for (j = 0; j < data->pages; j++) { for (j = 0; j < data->pages; j++) {
c = &data->sgdbuf[j]; c = &data->sgdbuf[j];
...@@ -1549,10 +1555,10 @@ snd_riptide_hw_params(struct snd_pcm_substream *substream, ...@@ -1549,10 +1555,10 @@ snd_riptide_hw_params(struct snd_pcm_substream *substream,
(int)sgdlist->bytes); (int)sgdlist->bytes);
if (sgdlist->area) if (sgdlist->area)
snd_dma_free_pages(sgdlist); snd_dma_free_pages(sgdlist);
if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev,
&chip->pci->dev,
sizeof(struct sgd) * (DESC_MAX_MASK + 1), sizeof(struct sgd) * (DESC_MAX_MASK + 1),
sgdlist)) < 0) { sgdlist);
if (err < 0) {
snd_printk(KERN_ERR "Riptide: failed to alloc %d dma bytes\n", snd_printk(KERN_ERR "Riptide: failed to alloc %d dma bytes\n",
(int)sizeof(struct sgd) * (DESC_MAX_MASK + 1)); (int)sizeof(struct sgd) * (DESC_MAX_MASK + 1));
return err; return err;
...@@ -1677,9 +1683,9 @@ static int snd_riptide_pcm(struct snd_riptide *chip, int device) ...@@ -1677,9 +1683,9 @@ static int snd_riptide_pcm(struct snd_riptide *chip, int device)
struct snd_pcm *pcm; struct snd_pcm *pcm;
int err; int err;
if ((err = err = snd_pcm_new(chip->card, "RIPTIDE", device, PLAYBACK_SUBSTREAMS, 1,
snd_pcm_new(chip->card, "RIPTIDE", device, PLAYBACK_SUBSTREAMS, 1, &pcm);
&pcm)) < 0) if (err < 0)
return err; return err;
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
&snd_riptide_playback_ops); &snd_riptide_playback_ops);
...@@ -1766,14 +1772,16 @@ static int snd_riptide_initialize(struct snd_riptide *chip) ...@@ -1766,14 +1772,16 @@ static int snd_riptide_initialize(struct snd_riptide *chip)
cif = chip->cif; cif = chip->cif;
if (!cif) { if (!cif) {
if ((cif = kzalloc(sizeof(struct cmdif), GFP_KERNEL)) == NULL) cif = kzalloc(sizeof(struct cmdif), GFP_KERNEL);
if (!cif)
return -ENOMEM; return -ENOMEM;
cif->hwport = (struct riptideport *)chip->port; cif->hwport = (struct riptideport *)chip->port;
spin_lock_init(&cif->lock); spin_lock_init(&cif->lock);
chip->cif = cif; chip->cif = cif;
} }
cif->is_reset = 0; cif->is_reset = 0;
if ((err = riptide_reset(cif, chip)) != 0) err = riptide_reset(cif, chip);
if (err)
return err; return err;
device_id = chip->device_id; device_id = chip->device_id;
switch (device_id) { switch (device_id) {
...@@ -1797,7 +1805,8 @@ static int snd_riptide_free(struct snd_riptide *chip) ...@@ -1797,7 +1805,8 @@ static int snd_riptide_free(struct snd_riptide *chip)
if (!chip) if (!chip)
return 0; return 0;
if ((cif = chip->cif)) { cif = chip->cif;
if (cif) {
SET_GRESET(cif->hwport); SET_GRESET(cif->hwport);
udelay(100); udelay(100);
UNSET_GRESET(cif->hwport); UNSET_GRESET(cif->hwport);
...@@ -1830,9 +1839,11 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci, ...@@ -1830,9 +1839,11 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci,
}; };
*rchip = NULL; *rchip = NULL;
if ((err = pci_enable_device(pci)) < 0) err = pci_enable_device(pci);
if (err < 0)
return err; return err;
if (!(chip = kzalloc(sizeof(struct snd_riptide), GFP_KERNEL))) chip = kzalloc(sizeof(struct snd_riptide), GFP_KERNEL);
if (!chip)
return -ENOMEM; return -ENOMEM;
spin_lock_init(&chip->lock); spin_lock_init(&chip->lock);
...@@ -1845,8 +1856,8 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci, ...@@ -1845,8 +1856,8 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci,
chip->handled_irqs = 0; chip->handled_irqs = 0;
chip->cif = NULL; chip->cif = NULL;
if ((chip->res_port = chip->res_port = request_region(chip->port, 64, "RIPTIDE");
request_region(chip->port, 64, "RIPTIDE")) == NULL) { if (!chip->res_port) {
snd_printk(KERN_ERR snd_printk(KERN_ERR
"Riptide: unable to grab region 0x%lx-0x%lx\n", "Riptide: unable to grab region 0x%lx-0x%lx\n",
chip->port, chip->port + 64 - 1); chip->port, chip->port + 64 - 1);
...@@ -1868,12 +1879,14 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci, ...@@ -1868,12 +1879,14 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci,
card->sync_irq = chip->irq; card->sync_irq = chip->irq;
chip->device_id = pci->device; chip->device_id = pci->device;
pci_set_master(pci); pci_set_master(pci);
if ((err = snd_riptide_initialize(chip)) < 0) { err = snd_riptide_initialize(chip);
if (err < 0) {
snd_riptide_free(chip); snd_riptide_free(chip);
return err; return err;
} }
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_riptide_free(chip); snd_riptide_free(chip);
return err; return err;
} }
...@@ -1903,7 +1916,8 @@ snd_riptide_proc_read(struct snd_info_entry *entry, ...@@ -1903,7 +1916,8 @@ snd_riptide_proc_read(struct snd_info_entry *entry,
for (i = 0; i < 64; i += 4) for (i = 0; i < 64; i += 4)
snd_iprintf(buffer, "%c%02x: %08x", snd_iprintf(buffer, "%c%02x: %08x",
(i % 16) ? ' ' : '\n', i, inl(chip->port + i)); (i % 16) ? ' ' : '\n', i, inl(chip->port + i));
if ((cif = chip->cif)) { cif = chip->cif;
if (cif) {
snd_iprintf(buffer, snd_iprintf(buffer,
"\nVersion: ASIC: %d CODEC: %d AUXDSP: %d PROG: %d", "\nVersion: ASIC: %d CODEC: %d AUXDSP: %d PROG: %d",
chip->firmware.firmware.ASIC, chip->firmware.firmware.ASIC,
...@@ -1922,10 +1936,11 @@ snd_riptide_proc_read(struct snd_info_entry *entry, ...@@ -1922,10 +1936,11 @@ snd_riptide_proc_read(struct snd_info_entry *entry,
} }
snd_iprintf(buffer, "\nOpen streams %d:\n", chip->openstreams); snd_iprintf(buffer, "\nOpen streams %d:\n", chip->openstreams);
for (i = 0; i < PLAYBACK_SUBSTREAMS; i++) { for (i = 0; i < PLAYBACK_SUBSTREAMS; i++) {
if (chip->playback_substream[i] if (!chip->playback_substream[i] ||
&& chip->playback_substream[i]->runtime !chip->playback_substream[i]->runtime)
&& (data = continue;
chip->playback_substream[i]->runtime->private_data)) { data = chip->playback_substream[i]->runtime->private_data;
if (data) {
snd_iprintf(buffer, snd_iprintf(buffer,
"stream: %d mixer: %d source: %d (%d,%d)\n", "stream: %d mixer: %d source: %d (%d,%d)\n",
data->id, data->mixer, data->source, data->id, data->mixer, data->source,
...@@ -1934,9 +1949,9 @@ snd_riptide_proc_read(struct snd_info_entry *entry, ...@@ -1934,9 +1949,9 @@ snd_riptide_proc_read(struct snd_info_entry *entry,
snd_iprintf(buffer, "rate: %d\n", rate); snd_iprintf(buffer, "rate: %d\n", rate);
} }
} }
if (chip->capture_substream if (chip->capture_substream && chip->capture_substream->runtime) {
&& chip->capture_substream->runtime data = chip->capture_substream->runtime->private_data;
&& (data = chip->capture_substream->runtime->private_data)) { if (data) {
snd_iprintf(buffer, snd_iprintf(buffer,
"stream: %d mixer: %d source: %d (%d,%d)\n", "stream: %d mixer: %d source: %d (%d,%d)\n",
data->id, data->mixer, data->id, data->mixer,
...@@ -1944,6 +1959,7 @@ snd_riptide_proc_read(struct snd_info_entry *entry, ...@@ -1944,6 +1959,7 @@ snd_riptide_proc_read(struct snd_info_entry *entry,
if (!(getsamplerate(cif, data->intdec, &rate))) if (!(getsamplerate(cif, data->intdec, &rate)))
snd_iprintf(buffer, "rate: %d\n", rate); snd_iprintf(buffer, "rate: %d\n", rate);
} }
}
snd_iprintf(buffer, "Paths:\n"); snd_iprintf(buffer, "Paths:\n");
i = getpaths(cif, p); i = getpaths(cif, p);
while (i >= 2) { while (i >= 2) {
...@@ -1973,12 +1989,14 @@ static int snd_riptide_mixer(struct snd_riptide *chip) ...@@ -1973,12 +1989,14 @@ static int snd_riptide_mixer(struct snd_riptide *chip)
ac97.private_data = chip; ac97.private_data = chip;
ac97.scaps = AC97_SCAP_SKIP_MODEM; ac97.scaps = AC97_SCAP_SKIP_MODEM;
if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &pbus)) < 0) err = snd_ac97_bus(chip->card, 0, &ops, chip, &pbus);
if (err < 0)
return err; return err;
chip->ac97_bus = pbus; chip->ac97_bus = pbus;
ac97.pci = chip->pci; ac97.pci = chip->pci;
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;
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