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

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.de


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 4327ad25
Loading
Loading
Loading
Loading
+53 −35
Original line number Diff line number Diff line
@@ -1087,9 +1087,15 @@ static irqreturn_t riptide_handleirq(int irq, void *dev_id)
		substream[i] = chip->playback_substream[i];
	substream[i] = chip->capture_substream;
	for (i = 0; i < PLAYBACK_SUBSTREAMS + 1; i++) {
		if (substream[i] &&
		    (runtime = substream[i]->runtime) &&
		    (data = runtime->private_data) && data->state != ST_STOP) {
		if (!substream[i])
			continue;
		runtime = substream[i]->runtime;
		if (!runtime)
			continue;
		data = runtime->private_data;
		if (!data)
			continue;
		if (data->state != ST_STOP) {
			pos = 0;
			for (j = 0; j < data->pages; j++) {
				c = &data->sgdbuf[j];
@@ -1549,10 +1555,10 @@ snd_riptide_hw_params(struct snd_pcm_substream *substream,
		    (int)sgdlist->bytes);
	if (sgdlist->area)
		snd_dma_free_pages(sgdlist);
	if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
				       &chip->pci->dev,
	err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev,
				  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",
			   (int)sizeof(struct sgd) * (DESC_MAX_MASK + 1));
		return err;
@@ -1677,9 +1683,9 @@ static int snd_riptide_pcm(struct snd_riptide *chip, int device)
	struct snd_pcm *pcm;
	int err;

	if ((err =
	     snd_pcm_new(chip->card, "RIPTIDE", device, PLAYBACK_SUBSTREAMS, 1,
			 &pcm)) < 0)
	err = snd_pcm_new(chip->card, "RIPTIDE", device, PLAYBACK_SUBSTREAMS, 1,
			  &pcm);
	if (err < 0)
		return err;
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
			&snd_riptide_playback_ops);
@@ -1766,14 +1772,16 @@ static int snd_riptide_initialize(struct snd_riptide *chip)

	cif = chip->cif;
	if (!cif) {
		if ((cif = kzalloc(sizeof(struct cmdif), GFP_KERNEL)) == NULL)
		cif = kzalloc(sizeof(struct cmdif), GFP_KERNEL);
		if (!cif)
			return -ENOMEM;
		cif->hwport = (struct riptideport *)chip->port;
		spin_lock_init(&cif->lock);
		chip->cif = cif;
	}
	cif->is_reset = 0;
	if ((err = riptide_reset(cif, chip)) != 0)
	err = riptide_reset(cif, chip);
	if (err)
		return err;
	device_id = chip->device_id;
	switch (device_id) {
@@ -1797,7 +1805,8 @@ static int snd_riptide_free(struct snd_riptide *chip)
	if (!chip)
		return 0;

	if ((cif = chip->cif)) {
	cif = chip->cif;
	if (cif) {
		SET_GRESET(cif->hwport);
		udelay(100);
		UNSET_GRESET(cif->hwport);
@@ -1830,9 +1839,11 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci,
	};

	*rchip = NULL;
	if ((err = pci_enable_device(pci)) < 0)
	err = pci_enable_device(pci);
	if (err < 0)
		return err;
	if (!(chip = kzalloc(sizeof(struct snd_riptide), GFP_KERNEL)))
	chip = kzalloc(sizeof(struct snd_riptide), GFP_KERNEL);
	if (!chip)
		return -ENOMEM;

	spin_lock_init(&chip->lock);
@@ -1845,8 +1856,8 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci,
	chip->handled_irqs = 0;
	chip->cif = NULL;

	if ((chip->res_port =
	     request_region(chip->port, 64, "RIPTIDE")) == NULL) {
	chip->res_port = request_region(chip->port, 64, "RIPTIDE");
	if (!chip->res_port) {
		snd_printk(KERN_ERR
			   "Riptide: unable to grab region 0x%lx-0x%lx\n",
			   chip->port, chip->port + 64 - 1);
@@ -1868,12 +1879,14 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci,
	card->sync_irq = chip->irq;
	chip->device_id = pci->device;
	pci_set_master(pci);
	if ((err = snd_riptide_initialize(chip)) < 0) {
	err = snd_riptide_initialize(chip);
	if (err < 0) {
		snd_riptide_free(chip);
		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);
		return err;
	}
@@ -1903,7 +1916,8 @@ snd_riptide_proc_read(struct snd_info_entry *entry,
	for (i = 0; i < 64; i += 4)
		snd_iprintf(buffer, "%c%02x: %08x",
			    (i % 16) ? ' ' : '\n', i, inl(chip->port + i));
	if ((cif = chip->cif)) {
	cif = chip->cif;
	if (cif) {
		snd_iprintf(buffer,
			    "\nVersion: ASIC: %d CODEC: %d AUXDSP: %d PROG: %d",
			    chip->firmware.firmware.ASIC,
@@ -1922,10 +1936,11 @@ snd_riptide_proc_read(struct snd_info_entry *entry,
	}
	snd_iprintf(buffer, "\nOpen streams %d:\n", chip->openstreams);
	for (i = 0; i < PLAYBACK_SUBSTREAMS; i++) {
		if (chip->playback_substream[i]
		    && chip->playback_substream[i]->runtime
		    && (data =
			chip->playback_substream[i]->runtime->private_data)) {
		if (!chip->playback_substream[i] ||
		    !chip->playback_substream[i]->runtime)
			continue;
		data = chip->playback_substream[i]->runtime->private_data;
		if (data) {
			snd_iprintf(buffer,
				    "stream: %d mixer: %d source: %d (%d,%d)\n",
				    data->id, data->mixer, data->source,
@@ -1934,9 +1949,9 @@ snd_riptide_proc_read(struct snd_info_entry *entry,
				snd_iprintf(buffer, "rate: %d\n", rate);
		}
	}
	if (chip->capture_substream
	    && chip->capture_substream->runtime
	    && (data = chip->capture_substream->runtime->private_data)) {
	if (chip->capture_substream && chip->capture_substream->runtime) {
		data = chip->capture_substream->runtime->private_data;
		if (data) {
			snd_iprintf(buffer,
				    "stream: %d mixer: %d source: %d (%d,%d)\n",
				    data->id, data->mixer,
@@ -1944,6 +1959,7 @@ snd_riptide_proc_read(struct snd_info_entry *entry,
			if (!(getsamplerate(cif, data->intdec, &rate)))
				snd_iprintf(buffer, "rate: %d\n", rate);
		}
	}
	snd_iprintf(buffer, "Paths:\n");
	i = getpaths(cif, p);
	while (i >= 2) {
@@ -1973,12 +1989,14 @@ static int snd_riptide_mixer(struct snd_riptide *chip)
	ac97.private_data = chip;
	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;

	chip->ac97_bus = pbus;
	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;
}