Commit 12bda107 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: emu10k1: Fix assignment in if condition

PCI EMU10k1 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-41-tiwai@suse.de


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 549717fc
Loading
Loading
Loading
Loading
+27 −15
Original line number Diff line number Diff line
@@ -107,18 +107,22 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci,
		max_buffer_size[dev] = 32;
	else if (max_buffer_size[dev] > 1024)
		max_buffer_size[dev] = 1024;
	if ((err = snd_emu10k1_create(card, pci, extin[dev], extout[dev],
	err = snd_emu10k1_create(card, pci, extin[dev], extout[dev],
				 (long)max_buffer_size[dev] * 1024 * 1024,
				 enable_ir[dev], subsystem[dev],
				      &emu)) < 0)
				 &emu);
	if (err < 0)
		goto error;
	card->private_data = emu;
	emu->delay_pcm_irq = delay_pcm_irq[dev] & 0x1f;
	if ((err = snd_emu10k1_pcm(emu, 0)) < 0)
	err = snd_emu10k1_pcm(emu, 0);
	if (err < 0)
		goto error;
	if ((err = snd_emu10k1_pcm_mic(emu, 1)) < 0)
	err = snd_emu10k1_pcm_mic(emu, 1);
	if (err < 0)
		goto error;
	if ((err = snd_emu10k1_pcm_efx(emu, 2)) < 0)
	err = snd_emu10k1_pcm_efx(emu, 2);
	if (err < 0)
		goto error;
	/* This stores the periods table. */
	if (emu->card_capabilities->ca0151_chip) { /* P16V */	
@@ -128,26 +132,33 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci,
			goto error;
	}

	if ((err = snd_emu10k1_mixer(emu, 0, 3)) < 0)
	err = snd_emu10k1_mixer(emu, 0, 3);
	if (err < 0)
		goto error;
	
	if ((err = snd_emu10k1_timer(emu, 0)) < 0)
	err = snd_emu10k1_timer(emu, 0);
	if (err < 0)
		goto error;

	if ((err = snd_emu10k1_pcm_multi(emu, 3)) < 0)
	err = snd_emu10k1_pcm_multi(emu, 3);
	if (err < 0)
		goto error;
	if (emu->card_capabilities->ca0151_chip) { /* P16V */
		if ((err = snd_p16v_pcm(emu, 4)) < 0)
		err = snd_p16v_pcm(emu, 4);
		if (err < 0)
			goto error;
	}
	if (emu->audigy) {
		if ((err = snd_emu10k1_audigy_midi(emu)) < 0)
		err = snd_emu10k1_audigy_midi(emu);
		if (err < 0)
			goto error;
	} else {
		if ((err = snd_emu10k1_midi(emu)) < 0)
		err = snd_emu10k1_midi(emu);
		if (err < 0)
			goto error;
	}
	if ((err = snd_emu10k1_fx8010_new(emu, 0)) < 0)
	err = snd_emu10k1_fx8010_new(emu, 0);
	if (err < 0)
		goto error;
#ifdef ENABLE_SYNTH
	if (snd_seq_device_new(card, 1, SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH,
@@ -174,7 +185,8 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci,
		 "%s (rev.%d, serial:0x%x) at 0x%lx, irq %i",
		 card->shortname, emu->revision, emu->serial, emu->port, emu->irq);

	if ((err = snd_card_register(card)) < 0)
	err = snd_card_register(card);
	if (err < 0)
		goto error;

	if (emu->card_capabilities->emu_model)
+2 −1
Original line number Diff line number Diff line
@@ -90,7 +90,8 @@ snd_emu10k1_synth_get_voice(struct snd_emu10k1 *hw)
		if (best[i].voice >= 0) {
			int ch;
			vp = &emu->voices[best[i].voice];
			if ((ch = vp->ch) < 0) {
			ch = vp->ch;
			if (ch < 0) {
				/*
				dev_warn(emu->card->dev,
				       "synth_get_voice: ch < 0 (%d) ??", i);
+9 −4
Original line number Diff line number Diff line
@@ -436,7 +436,8 @@ int snd_emu10k1_fx8010_unregister_irq_handler(struct snd_emu10k1 *emu,
	unsigned long flags;
	
	spin_lock_irqsave(&emu->fx8010.irq_lock, flags);
	if ((tmp = emu->fx8010.irq_handlers) == irq) {
	tmp = emu->fx8010.irq_handlers;
	if (tmp == irq) {
		emu->fx8010.irq_handlers = tmp->next;
		if (emu->fx8010.irq_handlers == NULL) {
			snd_emu10k1_intr_disable(emu, INTE_FXDSPENABLE);
@@ -871,7 +872,9 @@ static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
			}
			knew.private_value = (unsigned long)ctl;
			*ctl = *nctl;
			if ((err = snd_ctl_add(emu->card, kctl = snd_ctl_new1(&knew, emu))) < 0) {
			kctl = snd_ctl_new1(&knew, emu);
			err = snd_ctl_add(emu->card, kctl);
			if (err < 0) {
				kfree(ctl);
				kfree(knew.tlv.p);
				goto __error;
@@ -2403,7 +2406,8 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
	while (ptr < 0x200)
		OP(icode, &ptr, iACC3, C_00000000, C_00000000, C_00000000, C_00000000);

	if ((err = snd_emu10k1_fx8010_tram_setup(emu, ipcm->buffer_size)) < 0)
	err = snd_emu10k1_fx8010_tram_setup(emu, ipcm->buffer_size);
	if (err < 0)
		goto __err;
	icode->gpr_add_control_count = i;
	icode->gpr_add_controls = controls;
@@ -2681,7 +2685,8 @@ int snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device)
	struct snd_hwdep *hw;
	int err;
	
	if ((err = snd_hwdep_new(emu->card, "FX8010", device, &hw)) < 0)
	err = snd_hwdep_new(emu->card, "FX8010", device, &hw);
	if (err < 0)
		return err;
	strcpy(hw->name, "EMU10K1 (FX8010)");
	hw->iface = SNDRV_HWDEP_IFACE_EMU10K1;
+52 −26
Original line number Diff line number Diff line
@@ -1119,7 +1119,8 @@ static int snd_audigy_spdif_output_rate_put(struct snd_kcontrol *kcontrol,
	reg = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0);
	tmp = reg & ~A_SPDIF_RATE_MASK;
	tmp |= val;
	if ((change = (tmp != reg)))
	change = (tmp != reg);
	if (change)
		snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, 0, tmp);
	spin_unlock_irqrestore(&emu->reg_lock, flags);
	return change;
@@ -1903,7 +1904,8 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu,
			.read = snd_emu10k1_ac97_read,
		};

		if ((err = snd_ac97_bus(emu->card, 0, &ops, NULL, &pbus)) < 0)
		err = snd_ac97_bus(emu->card, 0, &ops, NULL, &pbus);
		if (err < 0)
			return err;
		pbus->no_vra = 1; /* we don't need VRA */
		
@@ -1911,7 +1913,8 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu,
		ac97.private_data = emu;
		ac97.private_free = snd_emu10k1_mixer_free_ac97;
		ac97.scaps = AC97_SCAP_NO_SPDIF;
		if ((err = snd_ac97_mixer(pbus, &ac97, &emu->ac97)) < 0) {
		err = snd_ac97_mixer(pbus, &ac97, &emu->ac97);
		if (err < 0) {
			if (emu->card_capabilities->ac97_chip == 1)
				return err;
			dev_info(emu->card->dev,
@@ -1991,38 +1994,50 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu,
		rename_ctl(card, "Aux2 Capture Volume", "Line3 Capture Volume");
		rename_ctl(card, "Mic Capture Volume", "Unknown1 Capture Volume");
	}
	if ((kctl = emu->ctl_send_routing = snd_ctl_new1(&snd_emu10k1_send_routing_control, emu)) == NULL)
	kctl = emu->ctl_send_routing = snd_ctl_new1(&snd_emu10k1_send_routing_control, emu);
	if (!kctl)
		return -ENOMEM;
	kctl->id.device = pcm_device;
	if ((err = snd_ctl_add(card, kctl)))
	err = snd_ctl_add(card, kctl);
	if (err)
		return err;
	if ((kctl = emu->ctl_send_volume = snd_ctl_new1(&snd_emu10k1_send_volume_control, emu)) == NULL)
	kctl = emu->ctl_send_volume = snd_ctl_new1(&snd_emu10k1_send_volume_control, emu);
	if (!kctl)
		return -ENOMEM;
	kctl->id.device = pcm_device;
	if ((err = snd_ctl_add(card, kctl)))
	err = snd_ctl_add(card, kctl);
	if (err)
		return err;
	if ((kctl = emu->ctl_attn = snd_ctl_new1(&snd_emu10k1_attn_control, emu)) == NULL)
	kctl = emu->ctl_attn = snd_ctl_new1(&snd_emu10k1_attn_control, emu);
	if (!kctl)
		return -ENOMEM;
	kctl->id.device = pcm_device;
	if ((err = snd_ctl_add(card, kctl)))
	err = snd_ctl_add(card, kctl);
	if (err)
		return err;

	if ((kctl = emu->ctl_efx_send_routing = snd_ctl_new1(&snd_emu10k1_efx_send_routing_control, emu)) == NULL)
	kctl = emu->ctl_efx_send_routing = snd_ctl_new1(&snd_emu10k1_efx_send_routing_control, emu);
	if (!kctl)
		return -ENOMEM;
	kctl->id.device = multi_device;
	if ((err = snd_ctl_add(card, kctl)))
	err = snd_ctl_add(card, kctl);
	if (err)
		return err;
	
	if ((kctl = emu->ctl_efx_send_volume = snd_ctl_new1(&snd_emu10k1_efx_send_volume_control, emu)) == NULL)
	kctl = emu->ctl_efx_send_volume = snd_ctl_new1(&snd_emu10k1_efx_send_volume_control, emu);
	if (!kctl)
		return -ENOMEM;
	kctl->id.device = multi_device;
	if ((err = snd_ctl_add(card, kctl)))
	err = snd_ctl_add(card, kctl);
	if (err)
		return err;
	
	if ((kctl = emu->ctl_efx_attn = snd_ctl_new1(&snd_emu10k1_efx_attn_control, emu)) == NULL)
	kctl = emu->ctl_efx_attn = snd_ctl_new1(&snd_emu10k1_efx_attn_control, emu);
	if (!kctl)
		return -ENOMEM;
	kctl->id.device = multi_device;
	if ((err = snd_ctl_add(card, kctl)))
	err = snd_ctl_add(card, kctl);
	if (err)
		return err;

	/* initialize the routing and volume table for each pcm playback stream */
@@ -2069,42 +2084,53 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu,
	
	if (! emu->card_capabilities->ecard) { /* FIXME: APS has these controls? */
		/* sb live! and audigy */
		if ((kctl = snd_ctl_new1(&snd_emu10k1_spdif_mask_control, emu)) == NULL)
		kctl = snd_ctl_new1(&snd_emu10k1_spdif_mask_control, emu);
		if (!kctl)
			return -ENOMEM;
		if (!emu->audigy)
			kctl->id.device = emu->pcm_efx->device;
		if ((err = snd_ctl_add(card, kctl)))
		err = snd_ctl_add(card, kctl);
		if (err)
			return err;
		if ((kctl = snd_ctl_new1(&snd_emu10k1_spdif_control, emu)) == NULL)
		kctl = snd_ctl_new1(&snd_emu10k1_spdif_control, emu);
		if (!kctl)
			return -ENOMEM;
		if (!emu->audigy)
			kctl->id.device = emu->pcm_efx->device;
		if ((err = snd_ctl_add(card, kctl)))
		err = snd_ctl_add(card, kctl);
		if (err)
			return err;
	}

	if (emu->card_capabilities->emu_model) {
		;  /* Disable the snd_audigy_spdif_shared_spdif */
	} else if (emu->audigy) {
		if ((kctl = snd_ctl_new1(&snd_audigy_shared_spdif, emu)) == NULL)
		kctl = snd_ctl_new1(&snd_audigy_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 0
		if ((kctl = snd_ctl_new1(&snd_audigy_spdif_output_rate, emu)) == NULL)
		kctl = snd_ctl_new1(&snd_audigy_spdif_output_rate, emu);
		if (!kctl)
			return -ENOMEM;
		if ((err = snd_ctl_add(card, kctl)))
		err = snd_ctl_add(card, kctl);
		if (err)
			return err;
#endif
	} else if (! emu->card_capabilities->ecard) {
		/* sb live! */
		if ((kctl = snd_ctl_new1(&snd_emu10k1_shared_spdif, emu)) == NULL)
		kctl = snd_ctl_new1(&snd_emu10k1_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 (emu->card_capabilities->ca0151_chip) { /* P16V */
		if ((err = snd_p16v_mixer(emu)))
		err = snd_p16v_mixer(emu);
		if (err)
			return err;
	}

+8 −4
Original line number Diff line number Diff line
@@ -319,7 +319,8 @@ static int emu10k1_midi_init(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *m
	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);
@@ -342,7 +343,8 @@ int snd_emu10k1_midi(struct snd_emu10k1 *emu)
	struct snd_emu10k1_midi *midi = &emu->midi;
	int err;

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

	midi->tx_enable = INTE_MIDITXENABLE;
@@ -360,7 +362,8 @@ int snd_emu10k1_audigy_midi(struct snd_emu10k1 *emu)
	int err;

	midi = &emu->midi;
	if ((err = emu10k1_midi_init(emu, midi, 0, "Audigy MPU-401 (UART)")) < 0)
	err = emu10k1_midi_init(emu, midi, 0, "Audigy MPU-401 (UART)");
	if (err < 0)
		return err;

	midi->tx_enable = INTE_MIDITXENABLE;
@@ -371,7 +374,8 @@ int snd_emu10k1_audigy_midi(struct snd_emu10k1 *emu)
	midi->interrupt = snd_emu10k1_midi_interrupt;

	midi = &emu->midi2;
	if ((err = emu10k1_midi_init(emu, midi, 1, "Audigy MPU-401 #2")) < 0)
	err = emu10k1_midi_init(emu, midi, 1, "Audigy MPU-401 #2");
	if (err < 0)
		return err;

	midi->tx_enable = INTE_A_MIDITXENABLE2;
Loading