Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1717358 > unrolled thread

[PATCH] ALSA: pcsp: Use common error handling code in snd_card_pcsp_probe()

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2017-08-22 14:20 +0200
Last post2017-08-22 14:20 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] ALSA: pcsp: Use common error handling code in  snd_card_pcsp_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-22 14:20 +0200

#1717358 — [PATCH] ALSA: pcsp: Use common error handling code in snd_card_pcsp_probe()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-08-22 14:20 +0200
Subject[PATCH] ALSA: pcsp: Use common error handling code in snd_card_pcsp_probe()
Message-ID<uhgk1-2fN-5@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 22 Aug 2017 14:00:21 +0200

Add a jump target so that a bit of exception handling can be better reused
in this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/drivers/pcsp/pcsp.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c
index 72e2d0012084..c8ea4fed3905 100644
--- a/sound/drivers/pcsp/pcsp.c
+++ b/sound/drivers/pcsp/pcsp.c
@@ -108,22 +108,17 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev)
 		return err;
 
 	err = snd_pcsp_create(card);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err)
+		goto free_card;
+
 	if (!nopcm) {
 		err = snd_pcsp_new_pcm(&pcsp_chip);
-		if (err < 0) {
-			snd_card_free(card);
-			return err;
-		}
+		if (err)
+			goto free_card;
 	}
 	err = snd_pcsp_new_mixer(&pcsp_chip, nopcm);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err)
+		goto free_card;
 
 	strcpy(card->driver, "PC-Speaker");
 	strcpy(card->shortname, "pcsp");
@@ -131,7 +126,8 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev)
 		pcsp_chip.port);
 
 	err = snd_card_register(card);
-	if (err < 0) {
+	if (err) {
+free_card:
 		snd_card_free(card);
 		return err;
 	}
-- 
2.14.0

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web