From: SF Markus Elfring <elfring@users.sourceforge.net>
To: alsa-devel@alsa-project.org, Bhumika Goyal <bhumirks@gmail.com>,
Colin Ian King <colin.king@canonical.com>,
David Howells <dhowells@redhat.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: ens1370: Use common error handling code in snd_ensoniq_create()
Date: Tue, 14 Nov 2017 18:48:23 +0100 [thread overview]
Message-ID: <0cec4a4f-5ba5-d88b-ae04-b2a4be948dfe@users.sourceforge.net> (raw)
In-Reply-To: <8bcf1ada-f44c-cb83-0890-adc8ae8edda0@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 14 Nov 2017 18:28:30 +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/ens1370.c | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index 55c5173036d3..4b4ca772cafb 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -2097,8 +2097,8 @@ static int snd_ensoniq_create(struct snd_card *card,
return err;
ensoniq = kzalloc(sizeof(*ensoniq), GFP_KERNEL);
if (ensoniq == NULL) {
- pci_disable_device(pci);
- return -ENOMEM;
+ err = -ENOMEM;
+ goto disable_device;
}
spin_lock_init(&ensoniq->reg_lock);
mutex_init(&ensoniq->src_mutex);
@@ -2108,23 +2108,20 @@ static int snd_ensoniq_create(struct snd_card *card,
err = pci_request_regions(pci, "Ensoniq AudioPCI");
if (err < 0) {
kfree(ensoniq);
- pci_disable_device(pci);
- return err;
+ goto disable_device;
}
ensoniq->port = pci_resource_start(pci, 0);
if (request_irq(pci->irq, snd_audiopci_interrupt, IRQF_SHARED,
KBUILD_MODNAME, ensoniq)) {
dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
- snd_ensoniq_free(ensoniq);
- return -EBUSY;
+ goto e_busy;
}
ensoniq->irq = pci->irq;
#ifdef CHIP1370
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
16, &ensoniq->dma_bug) < 0) {
dev_err(card->dev, "unable to allocate space for phantom area - dma_bug\n");
- snd_ensoniq_free(ensoniq);
- return -EBUSY;
+ goto e_busy;
}
#endif
pci_set_master(pci);
@@ -2150,15 +2147,23 @@ static int snd_ensoniq_create(struct snd_card *card,
snd_ensoniq_chip_init(ensoniq);
err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ensoniq, &ops);
- if (err < 0) {
- snd_ensoniq_free(ensoniq);
- return err;
- }
+ if (err < 0)
+ goto free_sound_chip;
snd_ensoniq_proc_init(ensoniq);
*rensoniq = ensoniq;
return 0;
+
+disable_device:
+ pci_disable_device(pci);
+ return err;
+
+e_busy:
+ err = -EBUSY;
+free_sound_chip:
+ snd_ensoniq_free(ensoniq);
+ return err;
}
/*
--
2.15.0
prev parent reply other threads:[~2017-11-14 17:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-14 17:43 [PATCH 0/3] ALSA: ens1370: Fine-tuning for six function implementations SF Markus Elfring
2017-11-14 17:44 ` [PATCH 1/3] ALSA: ens1370: Adjust 15 function calls together with a variable assignment SF Markus Elfring
2017-11-14 17:45 ` [PATCH 2/3] ALSA: ens1370: Use common error handling code in snd_audiopci_probe() SF Markus Elfring
2017-11-14 17:48 ` 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=0cec4a4f-5ba5-d88b-ae04-b2a4be948dfe@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=alsa-devel@alsa-project.org \
--cc=bhumirks@gmail.com \
--cc=colin.king@canonical.com \
--cc=dhowells@redhat.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