mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: alsa-devel@alsa-project.org,
	Arvind Yadav <arvind.yadav.cs@gmail.com>,
	Bhumika Goyal <bhumirks@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 3/3] ALSA: trident: Use common error handling code in snd_trident_mixer()
Date: Sat, 18 Nov 2017 20:13:31 +0100	[thread overview]
Message-ID: <e00a1980-2558-baa4-d8fb-7e39f833a7d8@users.sourceforge.net> (raw)
In-Reply-To: <498d6d73-2c62-178a-3c7a-b0fcb092d81e@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Nov 2017 19:49:50 +0100

Adjust jump targets so that a bit of exception handling can be better
reused at the end of this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/trident/trident_main.c | 71 +++++++++++++++++++---------------------
 1 file changed, 33 insertions(+), 38 deletions(-)

diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index 9843a61a8ead..2cb5da02ad9b 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -2980,7 +2980,7 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device)
 
 	err = snd_ac97_bus(trident->card, 0, &ops, NULL, &trident->ac97_bus);
 	if (err < 0)
-		goto __out;
+		goto free_control;
 
 	memset(&_ac97, 0, sizeof(_ac97));
 	_ac97.private_data = trident;
@@ -2992,12 +2992,12 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device)
 		if (trident->device == TRIDENT_DEVICE_ID_SI7018) {
 			err = snd_trident_sis_reset(trident);
 			if (err < 0)
-				goto __out;
+				goto free_control;
 			if (retries-- > 0)
 				goto __again;
 			err = -EIO;
 		}
-		goto __out;
+		goto free_control;
 	}
 	
 	/* secondary codec? */
@@ -3025,12 +3025,12 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device)
 		kctl = snd_ctl_new1(&snd_trident_vol_wave_control, trident);
 		err = snd_ctl_add(card, kctl);
 		if (err < 0)
-			goto __out;
+			goto free_control;
 		kctl->put(kctl, uctl);
 		kctl = snd_ctl_new1(&snd_trident_vol_music_control, trident);
 		err = snd_ctl_add(card, kctl);
 		if (err < 0)
-			goto __out;
+			goto free_control;
 		kctl->put(kctl, uctl);
 		outl(trident->musicvol_wavevol = 0x00000000, TRID_REG(trident, T4D_MUSICVOL_WAVEVOL));
 	} else {
@@ -3046,52 +3046,51 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device)
 
 	trident->ctl_vol = snd_ctl_new1(&snd_trident_pcm_vol_control, trident);
 	if (!trident->ctl_vol)
-		goto __nomem;
+		goto e_nomem;
 
 	err = snd_ctl_add(card, trident->ctl_vol);
 	if (err)
-		goto __out;
+		goto free_control;
 		
 	trident->ctl_pan = snd_ctl_new1(&snd_trident_pcm_pan_control, trident);
 	if (!trident->ctl_pan)
-		goto __nomem;
+		goto e_nomem;
 
 	err = snd_ctl_add(card, trident->ctl_pan);
 	if (err)
-		goto __out;
+		goto free_control;
 
 	trident->ctl_rvol = snd_ctl_new1(&snd_trident_pcm_rvol_control,
 					 trident);
 	if (!trident->ctl_rvol)
-		goto __nomem;
+		goto e_nomem;
 
 	err = snd_ctl_add(card, trident->ctl_rvol);
 	if (err)
-		goto __out;
+		goto free_control;
 
 	trident->ctl_cvol = snd_ctl_new1(&snd_trident_pcm_cvol_control,
 					 trident);
 	if (!trident->ctl_cvol)
-		goto __nomem;
+		goto e_nomem;
 
 	err = snd_ctl_add(card, trident->ctl_cvol);
 	if (err)
-		goto __out;
+		goto free_control;
 
 	if (trident->device == TRIDENT_DEVICE_ID_NX) {
 		kctl = snd_ctl_new1(&snd_trident_ac97_rear_control, trident);
 		err = snd_ctl_add(card, kctl);
 		if (err < 0)
-			goto __out;
+			goto free_control;
 		kctl->put(kctl, uctl);
 	}
 	if (trident->device == TRIDENT_DEVICE_ID_NX || trident->device == TRIDENT_DEVICE_ID_SI7018) {
 
 		kctl = snd_ctl_new1(&snd_trident_spdif_control, trident);
-		if (kctl == NULL) {
-			err = -ENOMEM;
-			goto __out;
-		}
+		if (!kctl)
+			goto e_nomem;
+
 		if (trident->ac97->ext_id & AC97_EI_SPDIF)
 			kctl->id.index++;
 		if (trident->ac97_sec && (trident->ac97_sec->ext_id & AC97_EI_SPDIF))
@@ -3099,51 +3098,47 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device)
 		idx = kctl->id.index;
 		err = snd_ctl_add(card, kctl);
 		if (err < 0)
-			goto __out;
+			goto free_control;
 		kctl->put(kctl, uctl);
 
 		kctl = snd_ctl_new1(&snd_trident_spdif_default, trident);
-		if (kctl == NULL) {
-			err = -ENOMEM;
-			goto __out;
-		}
+		if (!kctl)
+			goto e_nomem;
+
 		kctl->id.index = idx;
 		kctl->id.device = pcm_spdif_device;
 		err = snd_ctl_add(card, kctl);
 		if (err < 0)
-			goto __out;
+			goto free_control;
 
 		kctl = snd_ctl_new1(&snd_trident_spdif_mask, trident);
-		if (kctl == NULL) {
-			err = -ENOMEM;
-			goto __out;
-		}
+		if (!kctl)
+			goto e_nomem;
+
 		kctl->id.index = idx;
 		kctl->id.device = pcm_spdif_device;
 		err = snd_ctl_add(card, kctl);
 		if (err < 0)
-			goto __out;
+			goto free_control;
 
 		kctl = snd_ctl_new1(&snd_trident_spdif_stream, trident);
-		if (kctl == NULL) {
-			err = -ENOMEM;
-			goto __out;
-		}
+		if (!kctl)
+			goto e_nomem;
+
 		kctl->id.index = idx;
 		kctl->id.device = pcm_spdif_device;
 		err = snd_ctl_add(card, kctl);
 		if (err < 0)
-			goto __out;
+			goto free_control;
 		trident->spdif_pcm_ctl = kctl;
 	}
 
 	err = 0;
-	goto __out;
+	goto free_control;
 
- __nomem:
+e_nomem:
 	err = -ENOMEM;
-
- __out:
+free_control:
 	kfree(uctl);
 
 	return err;
-- 
2.15.0

      parent reply	other threads:[~2017-11-18 19:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-18 19:10 [PATCH 0/3] ALSA-Trident 4DWave: Fine-tuning for nine function implementations SF Markus Elfring
2017-11-18 19:11 ` [PATCH 1/3] ALSA: trident: Adjust 34 function calls together with a variable assignment SF Markus Elfring
2017-11-18 19:12 ` [PATCH 2/3] ALSA: trident: Use common error handling code in two functions SF Markus Elfring
2017-11-18 19:13 ` SF Markus Elfring [this message]

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=e00a1980-2558-baa4-d8fb-7e39f833a7d8@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=alsa-devel@alsa-project.org \
    --cc=arvind.yadav.cs@gmail.com \
    --cc=bhumirks@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /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

Powered by JetHome