From patchwork Sun Nov 12 09:26:58 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: 10054693 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 BCB55602A7 for ; Sun, 12 Nov 2017 09:28:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B101C29948 for ; Sun, 12 Nov 2017 09:28:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5BEA2995D; Sun, 12 Nov 2017 09:28:17 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57ECE29948 for ; Sun, 12 Nov 2017 09:28:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753106AbdKLJ15 (ORCPT ); Sun, 12 Nov 2017 04:27:57 -0500 Received: from mout.web.de ([212.227.15.3]:64399 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752082AbdKLJ1x (ORCPT ); Sun, 12 Nov 2017 04:27:53 -0500 Received: from [192.168.1.3] ([77.182.62.6]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Mbdf3-1eWrMd3dyv-00J42d; Sun, 12 Nov 2017 10:27:06 +0100 To: alsa-devel@alsa-project.org, linux-parisc@vger.kernel.org, Jaroslav Kysela , Takashi Iwai , Thibaut Varene Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Subject: [PATCH] ALSA: ad1889: Use common error handling code in snd_ad1889_create() Message-ID: <252c71ed-af89-ed5f-d75f-c09292e68bd5@users.sourceforge.net> Date: Sun, 12 Nov 2017 10:26:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:/91XVp5+Z7AjGqNTRqeM/+HOpXzJ3GihMhOEknuK3J2fb20CXEq S66YP3x/E/OfEnOYJyMTT+16UGtwBsz7eWIjDjPRqWevNXPM43rJ7YiwefoXMS46z4BivQz GOfFCdCrURBTilC5onKQdkFRvEkRRpX5AnsE5HY33M5cT/HlyQpMUgwc7lzgrfw/VRrpiAI p9zxqKF7A6ZX5+NVCtFWA== X-UI-Out-Filterresults: notjunk:1; V01:K0:eStSBCqVnks=:8mxNAJKkrFVHjpxkgz10Vp DznYoGWLc2ojzFR/bv9W9NLGIfBdj3A0dDvZT32bfzSC6i/KLqafGz5uf7GanZlGVYN+2PN48 vR2lY5Aeah8U5eWjCHTJOEuDWJ5cFMsRh1gHU/14HiSQcLihQp04xbXHSRR1ke4S/qIoRkTm1 ep8HE8eFcfSeGyLMv6/7t4a4oLTXt26etLEZabRA/Jv2GcHpYlBhGmn+dQUmjC0D6HgGC0rJz AXbmdN++FMm0rfEl1nnB2gJDqFluCC2LrP3krrL+FJK6DWXfakNFRwrQfvugZz6MyIUffaUI/ z3y/dLZCS08e/QxAW4T2YH8qsXieTsWqk517SHd7aDg2WCNEHN95dO+dSw2iuxJTocPFsJxF2 D44ZZVtggdCMPE8nKkizXxr0b6feRw7lek9YcXYgCHAEDPkbhRZjwbc5mmwa0TdE5I/uX2Lrr MSzFNUrqAZYl/RpdDSzRlFEzT0z4Rp7rRBk2xUFYUlMdgtA+BpbtSkAzzA8T/KiWwK9DTTElM jqU62Ky+EG1obH343VM08RadFecjgTZqTy/ouT+5K0sJ/NrktCp5EgvPAMjtciEXfgbJtMiWI +8I1Q45GzZ5WPibGiskgGaAJNHiplh9/hrAlufJvZgbUqsesDHKykxAzwUHnglFkWK6atTD0Y B91xKhLBwDar2IQV4z+TbbFNDcyhdyV655vapUIQoIF/p4p+6b5ubAN/R1TL0a2zsfpsq/NkR 2aPymGFIv0yyzzhsCCRLctrAtZF865CIghUKNhHC8HopzU3l5xp68INy97MFuKbZa9oNmUUOm AohpcD/b2Acgte++EOVxumiuS+qfbbpz6TleqwHWiNbat+IADE= Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 12 Nov 2017 10:10:53 +0100 * Adjust jump targets so that a bit of exception handling can be better reused at the end of this function. This issue was detected by using the Coccinelle software. * The script "checkpatch.pl" pointed information out like the following. ERROR: do not use assignment in if condition Thus fix five affected source code places. Signed-off-by: Markus Elfring --- sound/pci/ad1889.c | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 0bf2c04eeada..9f00e63937a5 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -894,21 +894,23 @@ snd_ad1889_create(struct snd_card *card, *rchip = NULL; - if ((err = pci_enable_device(pci)) < 0) + err = pci_enable_device(pci); + if (err < 0) return err; /* check PCI availability (32bit DMA) */ if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 || dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) { dev_err(card->dev, "error setting 32-bit DMA mask.\n"); - pci_disable_device(pci); - return -ENXIO; + err = -ENXIO; + goto disable_device; } /* allocate chip specific data with zero-filled memory */ - if ((chip = kzalloc(sizeof(*chip), GFP_KERNEL)) == NULL) { - pci_disable_device(pci); - return -ENOMEM; + chip = kzalloc(sizeof(*chip), GFP_KERNEL); + if (!chip) { + err = -ENOMEM; + goto disable_device; } chip->card = card; @@ -917,15 +919,16 @@ snd_ad1889_create(struct snd_card *card, chip->irq = -1; /* (1) PCI resource allocation */ - if ((err = pci_request_regions(pci, card->driver)) < 0) - goto free_and_ret; + err = pci_request_regions(pci, card->driver); + if (err < 0) + goto free_data; chip->bar = pci_resource_start(pci, 0); chip->iobase = pci_ioremap_bar(pci, 0); if (chip->iobase == NULL) { dev_err(card->dev, "unable to reserve region.\n"); err = -EBUSY; - goto free_and_ret; + goto free_data; } pci_set_master(pci); @@ -935,32 +938,34 @@ snd_ad1889_create(struct snd_card *card, if (request_irq(pci->irq, snd_ad1889_interrupt, IRQF_SHARED, KBUILD_MODNAME, chip)) { dev_err(card->dev, "cannot obtain IRQ %d\n", pci->irq); - snd_ad1889_free(chip); - return -EBUSY; + err = -EBUSY; + goto free_sound_chip; } chip->irq = pci->irq; synchronize_irq(chip->irq); /* (2) initialization of the chip hardware */ - if ((err = snd_ad1889_init(chip)) < 0) { - snd_ad1889_free(chip); - return err; - } + err = snd_ad1889_init(chip); + if (err < 0) + goto free_sound_chip; - if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { - snd_ad1889_free(chip); - return err; - } + err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); + if (err < 0) + goto free_sound_chip; *rchip = chip; return 0; -free_and_ret: +free_data: kfree(chip); +disable_device: pci_disable_device(pci); + return err; +free_sound_chip: + snd_ad1889_free(chip); return err; }