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>
Cc: kernel-janitors@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/2] ALSA: vx222: Use common error handling code in two functions
Date: Sat, 18 Nov 2017 21:40:55 +0100 [thread overview]
Message-ID: <7d7de279-baaa-d41c-d5d3-af8eb3fc5948@users.sourceforge.net> (raw)
In-Reply-To: <e961ecef-9f03-0c2a-ad64-64102bbc1389@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Nov 2017 21:23:27 +0100
Add jump targets so that a bit of exception handling can be better reused
at the end of these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/pci/vx222/vx222.c | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c
index 1f866a810a98..672b8f190777 100644
--- a/sound/pci/vx222/vx222.c
+++ b/sound/pci/vx222/vx222.c
@@ -163,10 +163,9 @@ static int snd_vx222_create(struct snd_card *card, struct pci_dev *pci,
vx->pci = pci;
err = pci_request_regions(pci, CARD_NAME);
- if (err < 0) {
- snd_vx222_free(chip);
- return err;
- }
+ if (err < 0)
+ goto free_sound_chip;
+
for (i = 0; i < 2; i++)
vx->port[i] = pci_resource_start(pci, i + 1);
@@ -174,19 +173,21 @@ static int snd_vx222_create(struct snd_card *card, struct pci_dev *pci,
snd_vx_threaded_irq_handler, IRQF_SHARED,
KBUILD_MODNAME, chip)) {
dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
- snd_vx222_free(chip);
- return -EBUSY;
+ err = -EBUSY;
+ goto free_sound_chip;
}
chip->irq = pci->irq;
err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
- if (err < 0) {
- snd_vx222_free(chip);
- return err;
- }
+ if (err < 0)
+ goto free_sound_chip;
*rchip = vx;
return 0;
+
+free_sound_chip:
+ snd_vx222_free(chip);
+ return err;
}
@@ -225,10 +226,9 @@ static int snd_vx222_probe(struct pci_dev *pci,
}
err = snd_vx222_create(card, pci, hw, &vx);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;
+
card->private_data = vx;
vx->core.ibl.size = ibl[dev];
@@ -242,20 +242,20 @@ static int snd_vx222_probe(struct pci_dev *pci,
#endif
err = snd_vx_setup_firmware(&vx->core);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;
err = snd_card_register(card);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;
pci_set_drvdata(pci, card);
dev++;
return 0;
+
+free_card:
+ snd_card_free(card);
+ return err;
}
static void snd_vx222_remove(struct pci_dev *pci)
--
2.15.0
prev parent reply other threads:[~2017-11-18 20:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-18 20:38 [PATCH 0/2] ALSA-Digigram VX222: Fine-tuning for four function implementations SF Markus Elfring
2017-11-18 20:39 ` [PATCH 1/2] ALSA: vx222: Adjust ten function calls together with a variable assignment SF Markus Elfring
2017-11-18 20:40 ` 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=7d7de279-baaa-d41c-d5d3-af8eb3fc5948@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=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;
as well as URLs for NNTP newsgroup(s).