From patchwork Tue Aug 22 12:10:30 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: 9915033 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 B120D600C5 for ; Tue, 22 Aug 2017 12:11:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF9ED2869D for ; Tue, 22 Aug 2017 12:11:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A45D128883; Tue, 22 Aug 2017 12:11:15 +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 050D52869D for ; Tue, 22 Aug 2017 12:11:14 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id D5546266DBE; Tue, 22 Aug 2017 14:11:10 +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 6F52C266F01; Tue, 22 Aug 2017 14:11:10 +0200 (CEST) Received: from mout.web.de (mout.web.de [212.227.15.3]) by alsa0.perex.cz (Postfix) with ESMTP id B7594266D1A for ; Tue, 22 Aug 2017 14:11:08 +0200 (CEST) Received: from [192.168.1.2] ([77.181.75.183]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MAvZs-1drrEy0o5c-009yiR; Tue, 22 Aug 2017 14:10:32 +0200 To: alsa-devel@alsa-project.org, Jaroslav Kysela , Takashi Iwai From: SF Markus Elfring Message-ID: <08ee0d6b-788b-2845-6964-e1e55c2d2292@users.sourceforge.net> Date: Tue, 22 Aug 2017 14:10:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:O5XSvfUv6lBV6FmeIq/TZLL7uIA60w/h6skAE8Ndl3F7p0ffSCb pHVMMG3D+npq6XP9xXJWpBvYjlRcanVbGyFE8w9ierW0Jml/tNhyVDHZQvzYOLTu17Z9X0e YvGPUBmhIwucaFh/UGT8W23HQhuOj09LhUqIRecpWCeIvrvgYEiriOXRx1HNKhWMtxXPYVs +VMY2cfFd3fO9PYH48g2w== X-UI-Out-Filterresults: notjunk:1; V01:K0:XDm37h1YbI0=:5uSakJx2q4qJSiOC2xuor6 32BPBxHd16HBr96jclruDevGbcxHdz6g3cLvwhRHLxVikyAVlpIJW7QOl2aiDRxj+BMwyA3eZ CBi09N1m0pPnIVxXujd8f3CEhkcdFTwWoUiGOJA2ttiU44mBpQQ2rBSdjdQKFI024p1vWm6Ng CquPcLryGDwcu4Ty/CHqs/xpifJNufSEYSwIsknePEtHfJodvAFfuEV/N4hys6wqsXmkD3YN3 dVbBDtvceFvQK1ZTy+qUyLhUqnoHdDmaoR8sk/IZzr0sQEoKnXYofKk73XdNMd/V6hCxZAXKH WV1Ks2bF6sGGJw0zlcUSEyGUj/ofni+SwKAz/y2OrdcGMWtqeR8pCvhD/Ockehbo0Yu8RTPsi 83MoEW7YlW+uei0/5b9FMgcYgbF8nC6N4EiXjk39fXrKUDZt0EgWKv4fX7i3SluwP0NYyh97d 5juqdDGtGWRrvmbJztDSnYeQ7acowWPrbSGozVEoCNEMAljhhFUdKACnqVfQftGD5Lf2a0pa0 Vocq1AtlWmdB5X97xZYEEkc6bnxfNhoG46IZfTGS83H9bLSMmi0NvwkfmmBKu6A1I2k3QUksm H5K6CKo++wG6zW52RSCqbCGuicop2oR7wkAiJfysMM1fTbqE8hGR94rG20osLx8zInhK8Gb7B ZmmuqZAdUBHXWcUAlrNlLP2l2QLuVrdLPL5cM8rd9+ABFRk0Jvx2UC6oQT4itFopxe+S61t2g heOc6qljNnKWoMEKsEJLoPZUK7KiTskUu3WpF5mpVBmcy7QpGR7vvy7YkfA4EQDl/6LRoPJnH Y76rAh69DR0G1aH6UoIk4wKvIG3qsUuZZiPgvpu10Zbq0hGchg0MeszMTmc+Uy2gP+aJSs/ Cc: kernel-janitors@vger.kernel.org, LKML Subject: [alsa-devel] [PATCH] ALSA: pcsp: Use common error handling code in snd_card_pcsp_probe() 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: Tue, 22 Aug 2017 14:00:21 +0200 Add a jump target so that a bit of exception handling can be better reused in this function. Signed-off-by: Markus Elfring --- sound/drivers/pcsp/pcsp.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c index 72e2d0012084..c8ea4fed3905 100644 --- a/sound/drivers/pcsp/pcsp.c +++ b/sound/drivers/pcsp/pcsp.c @@ -108,22 +108,17 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev) return err; err = snd_pcsp_create(card); - if (err < 0) { - snd_card_free(card); - return err; - } + if (err) + goto free_card; + if (!nopcm) { err = snd_pcsp_new_pcm(&pcsp_chip); - if (err < 0) { - snd_card_free(card); - return err; - } + if (err) + goto free_card; } err = snd_pcsp_new_mixer(&pcsp_chip, nopcm); - if (err < 0) { - snd_card_free(card); - return err; - } + if (err) + goto free_card; strcpy(card->driver, "PC-Speaker"); strcpy(card->shortname, "pcsp"); @@ -131,7 +126,8 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev) pcsp_chip.port); err = snd_card_register(card); - if (err < 0) { + if (err) { +free_card: snd_card_free(card); return err; }