From patchwork Wed Sep 6 19:48:11 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: 9941225 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 5665F602CC for ; Wed, 6 Sep 2017 19:48:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44E2B1FF81 for ; Wed, 6 Sep 2017 19:48:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 382731FF83; Wed, 6 Sep 2017 19:48:26 +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 5E2461FF81 for ; Wed, 6 Sep 2017 19:48:25 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id F2115267403; Wed, 6 Sep 2017 21:48:23 +0200 (CEST) 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 7E80C267408; Wed, 6 Sep 2017 21:48:22 +0200 (CEST) Received: from mout.web.de (mout.web.de [212.227.15.14]) by alsa0.perex.cz (Postfix) with ESMTP id D698F266A8A for ; Wed, 6 Sep 2017 21:48:20 +0200 (CEST) Received: from [192.168.1.2] ([77.182.162.119]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MTPjb-1e0NWU1fqp-00SO9a; Wed, 06 Sep 2017 21:48:13 +0200 From: SF Markus Elfring To: alsa-devel@alsa-project.org, Bhumika Goyal , David Howells , Ingo Molnar , Jaroslav Kysela , Takashi Iwai References: Message-ID: Date: Wed, 6 Sep 2017 21:48:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-Provags-ID: V03:K0:s0V1SsO0aWJUHMXrQ9UgnZ44y6qlOWdecfGPa0u0gRPTxnw3y8C anaOihwoA3UQwT14A7C94MGiTI5CBQIaUkgrqO3afTvCYO96qOAQipaZYOBE6O+4qvzWkbM 5hLNFhkUy79Ig0PEt6X8Wv7LzSx5qfzEhNBAjfq9y6rd3O0/24zsQyyx76lXSzpsKYlLzvP gj155STc+CEg/7TqUa3Gw== X-UI-Out-Filterresults: notjunk:1; V01:K0:aNNCSKL40i4=:TKruwB3GHOTw5OHjlLdbNT 9Z2Om/zI0IvFcvEbppD3OfHW2LbPPSthvDsyDi249/iGx8hnxd0zJj9OakSzkANGw9mely1zT ikFa0n2zlMCTPlgWxg61u+vyEybc9NuHsH/KkV3wwuN2u6wozoAy2Lb9D2SSQpsoHCCA+9WWT o29SW2TGXps63lPV8ZcmpiMyACnlN+rzm0rLTlhrxvSVKw/wBwcXGIHS0jatzkDgrGGFF8MlU +bhn7/ay2WEhueXIcCQV6mq4JFSTSYJZpU2yqR2o24u5nAtgWg5/VkTySjPkDp70dCzZL9uu/ A7+1kccCJ3mvd08GDvb5rAdAjw/w/GbqxDN9x8ecdtUP4qd3Opqfork/saA+8ksISTNKQg7u3 p3TXlGLtbeFzA6sfhOmH0VTnF+eLc6HQhH7phQjuxWiiAryFE7vlQG/JjlrfeDHCU9U7puQLv 5ad8QfoPAx26IyjjrE2lzNuaCpYIayCpvx23DYkL9Vho9mId/DxpZYYKCU5Z/dAb8rxZr7Uy+ x8wrSoaRF8zXMdlGb0loL8eqQKQH7/1sboqp4yko9LgGpukrA5sZ19ZNhQQ+1xjBN4MV3m39O GG6NjjeQuTfTc/xQeUdS96mQZE/qf94XVqgsTU/a/5JLeu2QwNWQp2AOs6a7x4NCLrq99em3B j9FffiY0bA8/Yi0K0m8wUIAbKhBI4MWiU1NSm6jBig4TDY0IEjMM48xeSLJs1gkO/LQNNzXpf SiFEDA0BkKkhbF/R8xVQpoIZyu8fM7HGpp6dTllI8BJgiMxJkoFZdJpVUfehk19nq8jKP4xu6 687QAVrudch6HKUQIpmZ8m2UsUV2LoM5/5iexwmPSnZ1J0xzqw= Cc: kernel-janitors@vger.kernel.org, LKML Subject: [alsa-devel] [PATCH 2/3] ALSA: ymfpci: Use common error handling code in snd_ymfpci_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: Wed, 6 Sep 2017 21:12:51 +0200 * Add a jump target 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 a few source code places. Signed-off-by: Markus Elfring --- sound/pci/ymfpci/ymfpci_main.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index edfd58248082..8ca2e41e5827 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -2399,59 +2399,60 @@ int snd_ymfpci_create(struct snd_card *card, dev_err(chip->card->dev, "unable to grab memory region 0x%lx-0x%lx\n", chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1); - snd_ymfpci_free(chip); - return -EBUSY; + err = -EBUSY; + goto free_chip; } if (request_irq(pci->irq, snd_ymfpci_interrupt, IRQF_SHARED, KBUILD_MODNAME, chip)) { dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq); - snd_ymfpci_free(chip); - return -EBUSY; + err = -EBUSY; + goto free_chip; } chip->irq = pci->irq; snd_ymfpci_aclink_reset(pci); if (snd_ymfpci_codec_ready(chip, 0) < 0) { - snd_ymfpci_free(chip); - return -EIO; + err = -EIO; + goto free_chip; } err = snd_ymfpci_request_firmware(chip); if (err < 0) { dev_err(chip->card->dev, "firmware request failed: %d\n", err); - snd_ymfpci_free(chip); - return err; + goto free_chip; } snd_ymfpci_download_image(chip); udelay(100); /* seems we need a delay after downloading image.. */ if (snd_ymfpci_memalloc(chip) < 0) { - snd_ymfpci_free(chip); - return -EIO; + err = -EIO; + goto free_chip; } - if ((err = snd_ymfpci_ac3_init(chip)) < 0) { - snd_ymfpci_free(chip); - return err; - } + err = snd_ymfpci_ac3_init(chip); + if (err < 0) + goto free_chip; #ifdef CONFIG_PM_SLEEP chip->saved_regs = kmalloc(YDSXGR_NUM_SAVED_REGS * sizeof(u32), GFP_KERNEL); if (chip->saved_regs == NULL) { - snd_ymfpci_free(chip); - return -ENOMEM; + err = -ENOMEM; + goto free_chip; } #endif - if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { - snd_ymfpci_free(chip); - return err; - } + err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); + if (err < 0) + goto free_chip; snd_ymfpci_proc_init(card, chip); *rchip = chip; return 0; + +free_chip: + snd_ymfpci_free(chip); + return err; }