Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp615821pxm; Thu, 3 Mar 2022 00:43:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJfbrdpxL32j0KH4DlqswDUub2qPNzGKm2lzYz9zXJhBODcjyhKOn/eaHqeHwJm3V1gGp+ X-Received: by 2002:a05:6a00:c90:b0:4bd:22a:bb1d with SMTP id a16-20020a056a000c9000b004bd022abb1dmr36812836pfv.32.1646297022850; Thu, 03 Mar 2022 00:43:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646297022; cv=none; d=google.com; s=arc-20160816; b=Woch6qjYwaZUj+k3/g9QWxC6ZYO5VMv6Gr3zBJKuRw+8LM0w/r4J8zWb/+YgfVWXQM gEBX3L77DiKbhART8NCq+wM7EXQnJNnAnDq3d52TWBWUJJmAxfcSAjVcstKAdHRZhUb3 eZffm3tI/DskdX7jBMCoIv+Yo0L2+DARq392bfcGjQ+7oD15mB6pcCV/3wTODwPR1RbB jRkAPds20+wlU0LrpITPYqqv/5LuFJkk7IC5bai4J+KZvruOLIpoIczAFcnAfhpn7wJk TOm5y0TVipGzuChbIsdJaSumfvUy/oelr17nDdp9b3HEcwI3JkllJwOjE55wq22JZ2Uc A4Ig== 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=qmo3Qi8XUCS1tuFNi7z9MBFqWEHF9FDpQh3EUIc9xEI=; b=QU59ZmXEPhUGknq7+BeS5GifOC5thtwTq/T3Ee4r7LCYgnVRgdEOw+60ViYhOjQmHw R+zPewh3PiwTLK6HTaVbknyWkwQjrvu5pbLb/PWNkEn78uyu0vfw36zObRBV+SuO+m+y WaMmhNmWbCWTMwW3OcC78SOidG+sJHyFpk0l92OOIm4WvkjGS2Bv6bE5uhSTsucvKgyT eplngXcSIGlMaiH4BtTIuucKr36hVEm061WT/9saWwdODDD53QVDSgkYVXJUbgOK0nMh nmQlGWbSfkk2aapicXLc8YwWDWV2mZLoJCKiCFHiP5aBZKqdCxahiNteIh/XESBDLU01 +RPQ== 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 b17-20020a17090a8c9100b001bd0a56f8f8si7514201pjo.85.2022.03.03.00.43.27; Thu, 03 Mar 2022 00:43:42 -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 S231381AbiCCIXG (ORCPT + 99 others); Thu, 3 Mar 2022 03:23:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231418AbiCCIW7 (ORCPT ); Thu, 3 Mar 2022 03:22:59 -0500 Received: from cstnet.cn (smtp23.cstnet.cn [159.226.251.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7DFB7171ECF for ; Thu, 3 Mar 2022 00:22:13 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.126]) by APP-03 (Coremail) with SMTP id rQCowADn78OjeiBiasmpAQ--.62570S2; Thu, 03 Mar 2022 16:21:56 +0800 (CST) From: Jiasheng Jiang To: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] ASoC: wm8350: Handle error for wm8350_register_irq Date: Thu, 3 Mar 2022 16:21:54 +0800 Message-Id: <20220303082154.264114-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: rQCowADn78OjeiBiasmpAQ--.62570S2 X-Coremail-Antispam: 1UD129KBjvJXoW7KF1ftr1kKF18Zry8uF45Wrg_yoW5JrW5pr WIkrW3WryYg3y3uF1furykXr1DJFyxKF4Dury2yr17XryakrykWr4jvF1jqF18JFW0q3ZF krW2v3yruw4rWFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUyG14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVWxJr 0_GcWle2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1l42xK82IYc2Ij64vI r41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8Gjc xK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0 cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8V AvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7Cj xVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7VUbXdbUUUUUU== X-Originating-IP: [124.16.138.126] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 --- sound/soc/codecs/wm8350.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index 15d42ce3b21d..0c70bbfbedb5 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -1483,7 +1483,7 @@ static int wm8350_component_probe(struct snd_soc_component *component) ret = devm_regulator_bulk_get(wm8350->dev, ARRAY_SIZE(priv->supplies), priv->supplies); if (ret != 0) - return ret; + goto err; /* Put the codec into reset if it wasn't already */ wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA); @@ -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