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, Bhumika Goyal <bhumirks@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 3/3] ALSA: es1938: Use common error handling code in snd_es1938_create()
Date: Tue, 14 Nov 2017 21:38:28 +0100	[thread overview]
Message-ID: <08c88cad-b4cf-948a-e990-390617503ffd@users.sourceforge.net> (raw)
In-Reply-To: <afd9d456-ae8e-b2f6-a682-a27c1fa4209b@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 14 Nov 2017 21:25:55 +0100

Add 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/es1938.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index b19e611345d1..2b4dd1297bbc 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -1606,14 +1606,14 @@ static int snd_es1938_create(struct snd_card *card,
 	    dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
 		dev_err(card->dev,
 			"architecture does not support 24bit PCI busmaster DMA\n");
-		pci_disable_device(pci);
-                return -ENXIO;
+		err = -ENXIO;
+		goto disable_device;
         }
 
 	chip = kzalloc(sizeof(*chip), GFP_KERNEL);
 	if (chip == NULL) {
-		pci_disable_device(pci);
-		return -ENOMEM;
+		err = -ENOMEM;
+		goto disable_device;
 	}
 	spin_lock_init(&chip->reg_lock);
 	spin_lock_init(&chip->mixer_lock);
@@ -1623,8 +1623,7 @@ static int snd_es1938_create(struct snd_card *card,
 	err = pci_request_regions(pci, "ESS Solo-1");
 	if (err < 0) {
 		kfree(chip);
-		pci_disable_device(pci);
-		return err;
+		goto disable_device;
 	}
 	chip->io_port = pci_resource_start(pci, 0);
 	chip->sb_port = pci_resource_start(pci, 1);
@@ -1634,8 +1633,8 @@ static int snd_es1938_create(struct snd_card *card,
 	if (request_irq(pci->irq, snd_es1938_interrupt, IRQF_SHARED,
 			KBUILD_MODNAME, chip)) {
 		dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
-		snd_es1938_free(chip);
-		return -EBUSY;
+		err = -EBUSY;
+		goto free_sound_chip;
 	}
 	chip->irq = pci->irq;
 	dev_dbg(card->dev,
@@ -1647,13 +1646,19 @@ static int snd_es1938_create(struct snd_card *card,
 	snd_es1938_chip_init(chip);
 
 	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
-	if (err < 0) {
-		snd_es1938_free(chip);
-		return err;
-	}
+	if (err < 0)
+		goto free_sound_chip;
 
 	*rchip = chip;
 	return 0;
+
+disable_device:
+	pci_disable_device(pci);
+	return err;
+
+free_sound_chip:
+	snd_es1938_free(chip);
+	return err;
 }
 
 /* --------------------------------------------------------------------
-- 
2.15.0

      parent reply	other threads:[~2017-11-14 20:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-14 20:34 [PATCH 0/3] ALSA: es1938: Fine-tuning for seven function implementations SF Markus Elfring
2017-11-14 20:36 ` [PATCH 1/3] ALSA: es1938: Adjust 14 function calls together with a variable assignment SF Markus Elfring
2017-11-14 20:37 ` [PATCH 2/3] ALSA: es1938: Use common error handling code in snd_es1938_probe() SF Markus Elfring
2017-11-14 20:38 ` 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=08c88cad-b4cf-948a-e990-390617503ffd@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=alsa-devel@alsa-project.org \
    --cc=bhumirks@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=o-takashi@sakamocchi.jp \
    --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