From patchwork Sat Nov 18 19:13:31 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: 10064925 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 B5D3A602B8 for ; Sat, 18 Nov 2017 19:13:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A571729CA7 for ; Sat, 18 Nov 2017 19:13:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A45729CB1; Sat, 18 Nov 2017 19:13: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 D8C0229CA7 for ; Sat, 18 Nov 2017 19:13:37 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id BBAB22673A0; Sat, 18 Nov 2017 20:13: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 561C22673A1; Sat, 18 Nov 2017 20:13:36 +0100 (CET) Received: from mout.web.de (mout.web.de [212.227.17.11]) by alsa0.perex.cz (Postfix) with ESMTP id C9149266EFA for ; Sat, 18 Nov 2017 20:13:34 +0100 (CET) Received: from [192.168.1.3] ([78.49.245.81]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LoYjO-1enZUV1k3m-00gZqK; Sat, 18 Nov 2017 20:13:33 +0100 From: SF Markus Elfring To: alsa-devel@alsa-project.org, Arvind Yadav , Bhumika Goyal , Jaroslav Kysela , Takashi Iwai References: <498d6d73-2c62-178a-3c7a-b0fcb092d81e@users.sourceforge.net> Message-ID: Date: Sat, 18 Nov 2017 20:13:31 +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: <498d6d73-2c62-178a-3c7a-b0fcb092d81e@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:P+ICDikGld3b5TRLfWf1+J3JtHl7RKTe3/TLk1diGC+N+0HISAa M8+I+OQM0k7nAA/E6nLD4c47/QWZ0OC1adPxEhtAPAfQqOo6vYrKtkVLfqNRIAXXVB0v4so s/7vIBaivFpX1+SwVrrHUMe8JszubJ2l9oeuJVcNrDnbZPwJ0C+XEjWkHUMO3+dVONi35sn 3V1QmeWd+DR7hcTTaMsng== X-UI-Out-Filterresults: notjunk:1; V01:K0:83cWyG89ysA=:P2HHsr30UA6OAIybj6GItf s/tM3RZgEFeO3j6sqM55Ns5BM5E5AltAQroiA73QmK7ZzFEiKQckAO9JbUnVax3V+YvVDPE9p rkuRIK/zQOG6nuzWOLIG/UOuaoZQ6LKiOESrdFo/yt+DNhml97jogqz76hPiypMVafokFM7r/ Nx2mSO2YbU95s7RytP5R/DdMG5QnicZHx0p3w/oQ7CscqbMtYGDtCBMbIi+6/ObZHA2BY7Wl5 /K51Jo6GSQRG8/dZ4oVhyoLd0GfM5F19QAxK8BwOIwzv0TL7j6K/KMACBE++KEE9tAJpwYKHz mU3PnyaQfshOc9sCMDL7n+oC44vIAmuU8jEeyXqM5PfzZ2Lod/M8GazDBdfWzsL9AA51pWHAk zT1xc1g/NaipyEa9VMq5JQxGCPFML/d3/6nH2+ODcp0oOMsqzbxBfiITfz1vUHltrt8kZB13Z 3yRApNle2PSUEND8Hcf51P3YbFQ+SXky6iE3W0TLJKFfxS12T+qWI1lnLwrSvPqD5CgQZbzyn +jEZbOACgEoVXUiXSTLUsalbLi3camvllYPzdvGgY9Yu583x+AgWPessfDXNccMJOvPVo3Y/9 ZRGYkKSosuwIhMoj/kzdTeG7Oca/TiCGpvJU8QBA0vTtg6d1QpvBhj5AzjqQggGfglIaGxETa rvfQY7z4W77pNOrvxuBnnz05WwX1QYdfLxEqmTUh1huU6P8pssrcv0K3XSFdpPa4QrsaA6AT5 q02G7I+Os3cC3QMXlMh1YXmemwQPlXNqDpWSZ4QKF3BDwbxP15xDDFHvbIKQO0T9Y8eEuKFr8 e+J+c/seJerbRYmQDmLww6oJBA+eXC6BfNMnTxDSDlJ8GcL4RM= Cc: kernel-janitors@vger.kernel.org, LKML Subject: [alsa-devel] [PATCH 3/3] ALSA: trident: Use common error handling code in snd_trident_mixer() 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: Sat, 18 Nov 2017 19:49:50 +0100 Adjust jump targets so that a bit of exception handling can be better reused at the end of this function. Signed-off-by: Markus Elfring --- sound/pci/trident/trident_main.c | 71 +++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 38 deletions(-) diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 9843a61a8ead..2cb5da02ad9b 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -2980,7 +2980,7 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device) err = snd_ac97_bus(trident->card, 0, &ops, NULL, &trident->ac97_bus); if (err < 0) - goto __out; + goto free_control; memset(&_ac97, 0, sizeof(_ac97)); _ac97.private_data = trident; @@ -2992,12 +2992,12 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device) if (trident->device == TRIDENT_DEVICE_ID_SI7018) { err = snd_trident_sis_reset(trident); if (err < 0) - goto __out; + goto free_control; if (retries-- > 0) goto __again; err = -EIO; } - goto __out; + goto free_control; } /* secondary codec? */ @@ -3025,12 +3025,12 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device) kctl = snd_ctl_new1(&snd_trident_vol_wave_control, trident); err = snd_ctl_add(card, kctl); if (err < 0) - goto __out; + goto free_control; kctl->put(kctl, uctl); kctl = snd_ctl_new1(&snd_trident_vol_music_control, trident); err = snd_ctl_add(card, kctl); if (err < 0) - goto __out; + goto free_control; kctl->put(kctl, uctl); outl(trident->musicvol_wavevol = 0x00000000, TRID_REG(trident, T4D_MUSICVOL_WAVEVOL)); } else { @@ -3046,52 +3046,51 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device) trident->ctl_vol = snd_ctl_new1(&snd_trident_pcm_vol_control, trident); if (!trident->ctl_vol) - goto __nomem; + goto e_nomem; err = snd_ctl_add(card, trident->ctl_vol); if (err) - goto __out; + goto free_control; trident->ctl_pan = snd_ctl_new1(&snd_trident_pcm_pan_control, trident); if (!trident->ctl_pan) - goto __nomem; + goto e_nomem; err = snd_ctl_add(card, trident->ctl_pan); if (err) - goto __out; + goto free_control; trident->ctl_rvol = snd_ctl_new1(&snd_trident_pcm_rvol_control, trident); if (!trident->ctl_rvol) - goto __nomem; + goto e_nomem; err = snd_ctl_add(card, trident->ctl_rvol); if (err) - goto __out; + goto free_control; trident->ctl_cvol = snd_ctl_new1(&snd_trident_pcm_cvol_control, trident); if (!trident->ctl_cvol) - goto __nomem; + goto e_nomem; err = snd_ctl_add(card, trident->ctl_cvol); if (err) - goto __out; + goto free_control; if (trident->device == TRIDENT_DEVICE_ID_NX) { kctl = snd_ctl_new1(&snd_trident_ac97_rear_control, trident); err = snd_ctl_add(card, kctl); if (err < 0) - goto __out; + goto free_control; kctl->put(kctl, uctl); } if (trident->device == TRIDENT_DEVICE_ID_NX || trident->device == TRIDENT_DEVICE_ID_SI7018) { kctl = snd_ctl_new1(&snd_trident_spdif_control, trident); - if (kctl == NULL) { - err = -ENOMEM; - goto __out; - } + if (!kctl) + goto e_nomem; + if (trident->ac97->ext_id & AC97_EI_SPDIF) kctl->id.index++; if (trident->ac97_sec && (trident->ac97_sec->ext_id & AC97_EI_SPDIF)) @@ -3099,51 +3098,47 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device) idx = kctl->id.index; err = snd_ctl_add(card, kctl); if (err < 0) - goto __out; + goto free_control; kctl->put(kctl, uctl); kctl = snd_ctl_new1(&snd_trident_spdif_default, trident); - if (kctl == NULL) { - err = -ENOMEM; - goto __out; - } + if (!kctl) + goto e_nomem; + kctl->id.index = idx; kctl->id.device = pcm_spdif_device; err = snd_ctl_add(card, kctl); if (err < 0) - goto __out; + goto free_control; kctl = snd_ctl_new1(&snd_trident_spdif_mask, trident); - if (kctl == NULL) { - err = -ENOMEM; - goto __out; - } + if (!kctl) + goto e_nomem; + kctl->id.index = idx; kctl->id.device = pcm_spdif_device; err = snd_ctl_add(card, kctl); if (err < 0) - goto __out; + goto free_control; kctl = snd_ctl_new1(&snd_trident_spdif_stream, trident); - if (kctl == NULL) { - err = -ENOMEM; - goto __out; - } + if (!kctl) + goto e_nomem; + kctl->id.index = idx; kctl->id.device = pcm_spdif_device; err = snd_ctl_add(card, kctl); if (err < 0) - goto __out; + goto free_control; trident->spdif_pcm_ctl = kctl; } err = 0; - goto __out; + goto free_control; - __nomem: +e_nomem: err = -ENOMEM; - - __out: +free_control: kfree(uctl); return err;