From patchwork Mon Nov 13 12:53:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 10055655 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D2ED460365 for ; Mon, 13 Nov 2017 12:54:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D810429330 for ; Mon, 13 Nov 2017 12:54:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA186294C2; Mon, 13 Nov 2017 12:54:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9DA129330 for ; Mon, 13 Nov 2017 12:54:37 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 566E626736F; Mon, 13 Nov 2017 13:54:36 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C742E267371; Mon, 13 Nov 2017 13:54:35 +0100 (CET) Received: from mout.web.de (mout.web.de [217.72.192.78]) by alsa0.perex.cz (Postfix) with ESMTP id 119C4266D86 for ; Mon, 13 Nov 2017 13:54:33 +0100 (CET) Received: from [192.168.1.3] ([92.228.193.202]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MUWBb-1ef0QX2Ast-00RHO4; Mon, 13 Nov 2017 13:53:58 +0100 From: SF Markus Elfring To: alsa-devel@alsa-project.org, Bhumika Goyal , Fabian Frederick , Jaroslav Kysela , Takashi Iwai , Takashi Sakamoto References: Message-ID: Date: Mon, 13 Nov 2017 13:53:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-Provags-ID: V03:K0:RszLxpzkZ/1aIs9bH5kVconeXuReQHD0ylNz+SfDTAglyU+ZFV+ 9mW12unad4kUc8QJyrtf3+UkgaHKZEbV0HyXBiPJtEMbqIV5lt9bUHS/oLLA7bemwStN/aP t/EfeFi4Fbd5wiJVCLbI5qoBAC8Z2MbN5e3K//h9ku+9Se/d97oeHTqqEP6AFjfrCzIcZgx jj7U2ZE2bmRP3RLzDxrPA== X-UI-Out-Filterresults: notjunk:1; V01:K0:4oL8h4+vlds=:V6C1sjdCkX2j9vHFevXh7B H8GQuhZkn2SBSj7U9S0g1Ilvv1EyXr/GFLxtVG2zfG1S7GRkahcqsbMZ5WZcv2w4mwzQAJj4N /p5x7dyTCgadml2lvnC469cybvwIvc011ddy3a+DtDcJPgt4fdZQmhh/VpNCKdZZ0zpOiGEtU k+l1k8KR7OYlVwZWQI+GQBJic0N2A+GC0Rkuua6EpRxDmJFthFaaESedyTDVH+/8B/rMLksA8 EWnYCljI01QHuQV77QLK/YO/nnUttQdYoUh/WW/JPq5Gq/9YGKYvtME8xJipTVA4GENSd1JwA wxEZOvOm71oK3uBsKTdoVkYlQcfXvG48+ZfpDwdgeHC13QxsLSXYwPCsCEeAPwmjfjhjPpy73 i4gVuIJxBlJbIoue6cyL+b0tFPiJXRpmvdX9104mSPNhxA+MjE8/HKwqGw/sAg1UL+bRS7t1i 3Dg9aKPO5NIPtJ3kZFaHeXcla1I1F29hmJcOQ1SIEUoTN7+VbKr5hYsQ/SyOQpUHe80NyuIYV TXrhgco77u1DTRYHDO5SZQlW/Hec5SvtoGV6eVGhR3rfZgZN8UGy49djG41cLq3T7pfasMkj2 l/+nP2z8OxEwQ2OVQ7AJseYL7gfUZ0JvJzF34KfU5gNJCdJHj3FHlcN5jQmjzUBiQU8PL1esq zdRHTRvB4+SWF1245C5HxfF4nGX1CDYuri1u1YzQuiaucE6ryXcKkH3o9GjsPjlLJOVzjQMBh nbpXu/kCI9lfXe/kTwkcnypaVrLDzGBFeA4BlVDnmMa/iVoH8SVn/HFllrof7FDxTgVUDg68T Us04c3jc3uYNPAyL7yyOBDxWezNACoht6bYR8jgumL22W8adJ8= Cc: kernel-janitors@vger.kernel.org, LKML Subject: [alsa-devel] [PATCH 3/3] ALSA: cs4281: Use common error handling code in snd_cs4281_create() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Mon, 13 Nov 2017 13:34:57 +0100 * Add jump targets so that a bit of exception handling can be better reused at the end of this function. * Delete the local variable "tmp" which was unnecessary because the variable "err" could be used at this place again. Signed-off-by: Markus Elfring --- sound/pci/cs4281.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index ed6b97dbd1cc..6cd7300a0182 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -1347,7 +1347,6 @@ static int snd_cs4281_create(struct snd_card *card, int dual_codec) { struct cs4281 *chip; - unsigned int tmp; int err; static struct snd_device_ops ops = { .dev_free = snd_cs4281_dev_free, @@ -1359,8 +1358,8 @@ static int snd_cs4281_create(struct snd_card *card, return err; 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); chip->card = card; @@ -1376,43 +1375,45 @@ static int snd_cs4281_create(struct snd_card *card, err = pci_request_regions(pci, "CS4281"); if (err < 0) { kfree(chip); - pci_disable_device(pci); - return err; + goto disable_device; } chip->ba0_addr = pci_resource_start(pci, 0); chip->ba1_addr = pci_resource_start(pci, 1); chip->ba0 = pci_ioremap_bar(pci, 0); chip->ba1 = pci_ioremap_bar(pci, 1); - if (!chip->ba0 || !chip->ba1) { - snd_cs4281_free(chip); - return -ENOMEM; - } + if (!chip->ba0 || !chip->ba1) + goto e_nomem; if (request_irq(pci->irq, snd_cs4281_interrupt, IRQF_SHARED, KBUILD_MODNAME, chip)) { dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); - snd_cs4281_free(chip); - return -ENOMEM; + goto e_nomem; } chip->irq = pci->irq; - tmp = snd_cs4281_chip_init(chip); - if (tmp) { - snd_cs4281_free(chip); - return tmp; - } + err = snd_cs4281_chip_init(chip); + if (err) + goto free_sound_chip; err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); - if (err < 0) { - snd_cs4281_free(chip); - return err; - } + if (err < 0) + goto free_sound_chip; snd_cs4281_proc_init(chip); *rchip = chip; return 0; + +disable_device: + pci_disable_device(pci); + return err; + +e_nomem: + err = -ENOMEM; +free_sound_chip: + snd_cs4281_free(chip); + return err; } static int snd_cs4281_chip_init(struct cs4281 *chip)