Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1611799pxm; Thu, 3 Mar 2022 23:20:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+79NcPhra1Yj1syngAkgDIMgsLzBxagxtvFcCrYyOr+dREsYGGay873LaJQOsUD5ktNSs X-Received: by 2002:a17:90b:384b:b0:1bf:12d8:62c0 with SMTP id nl11-20020a17090b384b00b001bf12d862c0mr5904771pjb.142.1646378409923; Thu, 03 Mar 2022 23:20:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646378409; cv=none; d=google.com; s=arc-20160816; b=G5QJfH/whnNF5NbjmIH5TH8e1x4BAhsQ6ShuN9+e3PeWgjBm47pRexAOkjAnPy+yDs Fv8xAZ+Ubf8OEfB//5Z3lQtv02ab4qlaOuQrjtK6YDSuNqFYqOhGxBRBfjDyk26ajL39 PG0xxCDqg/mVAYeX69JzKopsj9P0UgC5Kiawot7u7SUblISsbZhr0pSFEqkEropUnQOo /KndMihNc8zuEI/1teJQ6RuEIoQ45+K04fYF2zVOKAmuAJBy/aeL/aKWRGsC9LJNUBQ2 lnBS+48YxM9W7ts6ZdWgDttfV/tleAs8xIiS/G5iblAhStEQYA/PAoWylHAoAc42OboM jBVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=4sBsev4s6gRqmjKvP2iZaPsAUWt2KEPx6SzXCtKxITo=; b=xITC5lXmEpuuoSGO3A9U1SRlsU416pghMbzrdR7tZtzj2E34U55N2F4RRhXwZXwIWm dHICi8zBcDoafViQcv8MWq0aUeMa+KahIl9NknE2poW4XPzPjUw/N2aclmFnqgBL8hGm DJO7xk6/ltztT6KtVCnsp9zKcPFEcOfndsCWUIb5rpy6hr6EhInfkZR+9RI3jnXfbsqg BeEbO6irhCRhP1f4kkj96aFBJmvKnD7drkhdDQUE5ZRTnsD310O8miFnhMaQGFDm2S9O 2KrXZx3utdCqY6yWUPkH6Kubz7CRbXScFzL5R9V3n1x4ummiRC3YpmfuXBvOkN5Lmvlq hKIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o34-20020a635d62000000b0037843b03417si4049554pgm.501.2022.03.03.23.19.54; Thu, 03 Mar 2022 23:20:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232340AbiCDCjc (ORCPT + 99 others); Thu, 3 Mar 2022 21:39:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229752AbiCDCjb (ORCPT ); Thu, 3 Mar 2022 21:39:31 -0500 Received: from cstnet.cn (smtp84.cstnet.cn [159.226.251.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2E4D44579F for ; Thu, 3 Mar 2022 18:38:43 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.126]) by APP-05 (Coremail) with SMTP id zQCowAAnCfKeeyFiBBwYAg--.9896S2; Fri, 04 Mar 2022 10:38:23 +0800 (CST) From: Jiasheng Jiang To: ckeepax@opensource.cirrus.com Cc: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, patches@opensource.cirrus.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH v2] ASoC: wm8350: Handle error for wm8350_register_irq Date: Fri, 4 Mar 2022 10:38:21 +0800 Message-Id: <20220304023821.391936-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: zQCowAAnCfKeeyFiBBwYAg--.9896S2 X-Coremail-Antispam: 1UD129KBjvJXoW7KF1DXry7XF4DZr1fXrykAFb_yoW8tr45pr WIkry3WryFg3y3uF1fCrykJF1DJFyxKr4vvry2kr17Xrya9ry0gr4jvFyjqF18JFW0q3Zr KrW2v3yruw1ruFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkC14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVWxJr0_GcWl84ACjcxK6I8E87Iv6xkF7I0E14v26F 4UJVW0owAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv 7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r 1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE14v_ Gr1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxV WUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI 7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r 1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWrJr0_WFyUJwCI42IY6I8E87Iv67AKxVWUJVW8 JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUO_MaUU UUU X-Originating-IP: [124.16.138.126] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As the potential failure of the wm8350_register_irq(), it should be better to check it and return error if fails. Also, use 'free_' in order to avoid the same code. Fixes: a6ba2b2dabb5 ("ASoC: Implement WM8350 headphone jack detection") Signed-off-by: Jiasheng Jiang --- Changelog: v1 -> v2 * Change 1. Change to non-caps labels and remove the revert to 'return ret;'. --- sound/soc/codecs/wm8350.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index 15d42ce3b21d..41504ce2a682 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -1537,18 +1537,38 @@ static int wm8350_component_probe(struct snd_soc_component *component) wm8350_clear_bits(wm8350, WM8350_JACK_DETECT, WM8350_JDL_ENA | WM8350_JDR_ENA); - wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, wm8350_hpl_jack_handler, 0, "Left jack detect", priv); - wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, + if (ret != 0) + goto err; + + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, wm8350_hpr_jack_handler, 0, "Right jack detect", priv); - wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICSCD, + if (ret != 0) + goto free_jck_det_l; + + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICSCD, wm8350_mic_handler, 0, "Microphone short", priv); - wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICD, + if (ret != 0) + goto free_jck_det_r; + + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICD, wm8350_mic_handler, 0, "Microphone detect", priv); + if (ret != 0) + goto free_micscd; return 0; + +free_micscd: + wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_MICSCD, priv); +free_jck_det_r: + wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, priv); +free_jck_det_l: + wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, priv); +err: + return ret; } static void wm8350_component_remove(struct snd_soc_component *component) -- 2.25.1