alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH 44/66] ALSA: mixart: Fix assignment in if condition
Date: Tue,  8 Jun 2021 16:05:18 +0200	[thread overview]
Message-ID: <20210608140540.17885-45-tiwai@suse.de> (raw)
In-Reply-To: <20210608140540.17885-1-tiwai@suse.de>

PCI miXart 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.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/mixart/mixart.c       | 29 ++++++++++++++++++-----------
 sound/pci/mixart/mixart_hwdep.c | 17 ++++++++++++-----
 sound/pci/mixart/mixart_mixer.c | 33 ++++++++++++++++++++++-----------
 3 files changed, 52 insertions(+), 27 deletions(-)

diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index a0bbb386dc25..1b078b789604 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -954,9 +954,10 @@ static int snd_mixart_pcm_analog(struct snd_mixart *chip)
 	char name[32];
 
 	sprintf(name, "miXart analog %d", chip->chip_idx);
-	if ((err = snd_pcm_new(chip->card, name, MIXART_PCM_ANALOG,
-			       MIXART_PLAYBACK_STREAMS,
-			       MIXART_CAPTURE_STREAMS, &pcm)) < 0) {
+	err = snd_pcm_new(chip->card, name, MIXART_PCM_ANALOG,
+			  MIXART_PLAYBACK_STREAMS,
+			  MIXART_CAPTURE_STREAMS, &pcm);
+	if (err < 0) {
 		dev_err(chip->card->dev,
 			"cannot create the analog pcm %d\n", chip->chip_idx);
 		return err;
@@ -987,9 +988,10 @@ static int snd_mixart_pcm_digital(struct snd_mixart *chip)
 	char name[32];
 
 	sprintf(name, "miXart AES/EBU %d", chip->chip_idx);
-	if ((err = snd_pcm_new(chip->card, name, MIXART_PCM_DIGITAL,
-			       MIXART_PLAYBACK_STREAMS,
-			       MIXART_CAPTURE_STREAMS, &pcm)) < 0) {
+	err = snd_pcm_new(chip->card, name, MIXART_PCM_DIGITAL,
+			  MIXART_PLAYBACK_STREAMS,
+			  MIXART_CAPTURE_STREAMS, &pcm);
+	if (err < 0) {
 		dev_err(chip->card->dev,
 			"cannot create the digital pcm %d\n", chip->chip_idx);
 		return err;
@@ -1042,7 +1044,8 @@ static int snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *card, int
 	chip->mgr = mgr;
 	card->sync_irq = mgr->irq;
 
-	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_mixart_chip_free(chip);
 		return err;
 	}
@@ -1243,7 +1246,8 @@ static int snd_mixart_probe(struct pci_dev *pci,
 	}
 
 	/* enable PCI device */
-	if ((err = pci_enable_device(pci)) < 0)
+	err = pci_enable_device(pci);
+	if (err < 0)
 		return err;
 	pci_set_master(pci);
 
@@ -1267,7 +1271,8 @@ static int snd_mixart_probe(struct pci_dev *pci,
 	mgr->irq = -1;
 
 	/* resource assignment */
-	if ((err = pci_request_regions(pci, CARD_NAME)) < 0) {
+	err = pci_request_regions(pci, CARD_NAME);
+	if (err < 0) {
 		kfree(mgr);
 		pci_disable_device(pci);
 		return err;
@@ -1332,7 +1337,8 @@ static int snd_mixart_probe(struct pci_dev *pci,
 			"Digigram miXart at 0x%lx & 0x%lx, irq %i [PCM #%d]",
 			mgr->mem[0].phys, mgr->mem[1].phys, mgr->irq, i);
 
-		if ((err = snd_mixart_create(mgr, card, i)) < 0) {
+		err = snd_mixart_create(mgr, card, i);
+		if (err < 0) {
 			snd_card_free(card);
 			snd_mixart_free(mgr);
 			return err;
@@ -1343,7 +1349,8 @@ static int snd_mixart_probe(struct pci_dev *pci,
 			snd_mixart_proc_init(mgr->chip[i]);
 		}
 
-		if ((err = snd_card_register(card)) < 0) {
+		err = snd_card_register(card);
+		if (err < 0) {
 			snd_mixart_free(mgr);
 			return err;
 		}
diff --git a/sound/pci/mixart/mixart_hwdep.c b/sound/pci/mixart/mixart_hwdep.c
index f579f7698bba..689c0f995a9c 100644
--- a/sound/pci/mixart/mixart_hwdep.c
+++ b/sound/pci/mixart/mixart_hwdep.c
@@ -306,9 +306,13 @@ static int mixart_first_init(struct mixart_mgr *mgr)
 	int err;
 	struct mixart_msg request;
 
-	if((err = mixart_enum_connectors(mgr)) < 0) return err;
+	err = mixart_enum_connectors(mgr);
+	if (err < 0)
+		return err;
 
-	if((err = mixart_enum_physio(mgr)) < 0) return err;
+	err = mixart_enum_physio(mgr);
+	if (err < 0)
+		return err;
 
 	/* send a synchro command to card (necessary to do this before first MSG_STREAM_START_STREAM_GRP_PACKET) */
 	/* though why not here */
@@ -528,15 +532,18 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
         for (card_index = 0; card_index < mgr->num_cards; card_index++) {
 		struct snd_mixart *chip = mgr->chip[card_index];
 
-		if ((err = snd_mixart_create_pcm(chip)) < 0)
+		err = snd_mixart_create_pcm(chip);
+		if (err < 0)
 			return err;
 
 		if (card_index == 0) {
-			if ((err = snd_mixart_create_mixer(chip->mgr)) < 0)
+			err = snd_mixart_create_mixer(chip->mgr);
+			if (err < 0)
 	        		return err;
 		}
 
-		if ((err = snd_card_register(chip->card)) < 0)
+		err = snd_card_register(chip->card);
+		if (err < 0)
 			return err;
 	}
 
diff --git a/sound/pci/mixart/mixart_mixer.c b/sound/pci/mixart/mixart_mixer.c
index d2e7c3381267..2727f3345795 100644
--- a/sound/pci/mixart/mixart_mixer.c
+++ b/sound/pci/mixart/mixart_mixer.c
@@ -1114,10 +1114,12 @@ int snd_mixart_create_mixer(struct mixart_mgr *mgr)
 		temp = mixart_control_analog_level;
 		temp.name = "Master Playback Volume";
 		temp.private_value = 0; /* playback */
-		if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
+		err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip));
+		if (err < 0)
 			return err;
 		/* output mute controls */
-		if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&mixart_control_output_switch, chip))) < 0)
+		err = snd_ctl_add(chip->card, snd_ctl_new1(&mixart_control_output_switch, chip));
+		if (err < 0)
 			return err;
 
 		/* analog input level control only on first two chips !*/
@@ -1125,7 +1127,8 @@ int snd_mixart_create_mixer(struct mixart_mgr *mgr)
 			temp = mixart_control_analog_level;
 			temp.name = "Master Capture Volume";
 			temp.private_value = 1; /* capture */
-			if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
+			err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip));
+			if (err < 0)
 				return err;
 		}
 
@@ -1133,45 +1136,53 @@ int snd_mixart_create_mixer(struct mixart_mgr *mgr)
 		temp.name = "PCM Playback Volume";
 		temp.count = MIXART_PLAYBACK_STREAMS;
 		temp.private_value = 0; /* playback analog */
-		if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
+		err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip));
+		if (err < 0)
 			return err;
 
 		temp.name = "PCM Capture Volume";
 		temp.count = 1;
 		temp.private_value = MIXART_VOL_REC_MASK; /* capture analog */
-		if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
+		err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip));
+		if (err < 0)
 			return err;
 
 		if(mgr->board_type == MIXART_DAUGHTER_TYPE_AES) {
 			temp.name = "AES Playback Volume";
 			temp.count = MIXART_PLAYBACK_STREAMS;
 			temp.private_value = MIXART_VOL_AES_MASK; /* playback AES/EBU */
-			if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
+			err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip));
+			if (err < 0)
 				return err;
 
 			temp.name = "AES Capture Volume";
 			temp.count = 0;
 			temp.private_value = MIXART_VOL_REC_MASK | MIXART_VOL_AES_MASK; /* capture AES/EBU */
-			if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
+			err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip));
+			if (err < 0)
 				return err;
 		}
 		temp = mixart_control_pcm_switch;
 		temp.name = "PCM Playback Switch";
 		temp.private_value = 0; /* playback analog */
-		if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
+		err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip));
+		if (err < 0)
 			return err;
 
 		if(mgr->board_type == MIXART_DAUGHTER_TYPE_AES) {
 			temp.name = "AES Playback Switch";
 			temp.private_value = MIXART_VOL_AES_MASK; /* playback AES/EBU */
-			if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
+			err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip));
+			if (err < 0)
 				return err;
 		}
 
 		/* monitoring */
-		if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&mixart_control_monitor_vol, chip))) < 0)
+		err = snd_ctl_add(chip->card, snd_ctl_new1(&mixart_control_monitor_vol, chip));
+		if (err < 0)
 			return err;
-		if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&mixart_control_monitor_sw, chip))) < 0)
+		err = snd_ctl_add(chip->card, snd_ctl_new1(&mixart_control_monitor_sw, chip));
+		if (err < 0)
 			return err;
 
 		/* init all mixer data and program the master volumes/switches */
-- 
2.26.2


  parent reply	other threads:[~2021-06-08 14:27 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-08 14:04 [PATCH 00/66] ALSA: Fix assignment in if condition Takashi Iwai
2021-06-08 14:04 ` [PATCH 01/66] ALSA: sb: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 02/66] ALSA: sb: Minor coding style fixes Takashi Iwai
2021-06-08 14:04 ` [PATCH 03/66] ALSA: sb: Fix potential double-free of CSP mixer elements Takashi Iwai
2021-06-08 14:04 ` [PATCH 04/66] ALSA: gus: Fix assignment in if condition Takashi Iwai
2021-06-08 14:04 ` [PATCH 05/66] ALSA: ad1816a: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 06/66] ALSA: wavefront: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 07/66] ALSA: cs423x: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 08/66] ALSA: opti9xx: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 09/66] ALSA: opl3sa2: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 10/66] ALSA: es18xx: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 11/66] ALSA: cmi8330: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 12/66] ALSA: als100: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 13/66] ALSA: azt2320: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 14/66] ALSA: isa: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 15/66] ALSA: ad1889: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 16/66] ALSA: ak4531: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 17/66] ALSA: als300: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 18/66] ALSA: als4000: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 19/66] ALSA: atiixp: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 20/66] ALSA: azt3328: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 21/66] ALSA: bt87x: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 22/66] ALSA: cmipci: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 23/66] ALSA: cs4281: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 24/66] ALSA: ens137x: " Takashi Iwai
2021-06-08 14:04 ` [PATCH 25/66] ALSA: es1938: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 26/66] ALSA: es1968: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 27/66] ALSA: fm801: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 28/66] ALSA: intel8x0: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 29/66] ALSA: maestro3: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 30/66] ALSA: rme32: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 31/66] ALSA: rme96: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 32/66] ALSA: sonicvibes: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 33/66] ALSA: via82xx: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 34/66] ALSA: ac97: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 35/66] ALSA: au88x0: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 36/66] ALSA: ca0106: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 37/66] ALSA: cs46xx: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 38/66] ALSA: cs5535audio: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 39/66] ALSA: echoaudio: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 40/66] ALSA: emu10k1: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 41/66] ALSA: emu10k1x: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 42/66] ALSA: ice1712: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 43/66] ALSA: korg1212: " Takashi Iwai
2021-06-08 14:05 ` Takashi Iwai [this message]
2021-06-08 14:05 ` [PATCH 45/66] ALSA: nm256: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 46/66] ALSA: pcxhr: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 47/66] ALSA: riptide: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 48/66] ALSA: hdsp: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 49/66] ALSA: rme9652: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 50/66] ALSA: trident: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 51/66] ALSA: vx222: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 52/66] ALSA: ymfpci: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 53/66] ALSA: core: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 54/66] ALSA: pcm: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 55/66] ALSA: oss: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 56/66] ALSA: seq: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 57/66] ALSA: pcmcia: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 58/66] ALSA: sparc: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 59/66] ALSA: mpu401: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 60/66] ALSA: vx: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 61/66] ALSA: opl3: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 62/66] ALSA: serial: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 63/66] ALSA: synth: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 64/66] ALSA: poewrmac: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 65/66] ALSA: i2c: " Takashi Iwai
2021-06-08 14:05 ` [PATCH 66/66] ALSA: parisc: " Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210608140540.17885-45-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).