From patchwork Wed Nov 9 16:37:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 17673 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp440301wru; Wed, 9 Nov 2022 08:41:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf5cp2Ul+RjhIJLYSGPgseq/0GtxD2W9sF2epUrOYKGc5C14HYmLw9uMT/TZfF0YuUs+wFkl X-Received: by 2002:a17:902:728b:b0:188:6baf:1fe7 with SMTP id d11-20020a170902728b00b001886baf1fe7mr26398162pll.123.1668012098756; Wed, 09 Nov 2022 08:41:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668012098; cv=none; d=google.com; s=arc-20160816; b=xy7UYhLXzWS+27/MB8iWxWTxveg1KdrHD1yoGCR0tDrGLCqRxSYqiziUrxUOEhSvTi VQ90IKGVATqRVgskAn7hpahkZq55CkohbLGiC8Lx/HtrQPrEVEN9Odj6NBz3e5jrHz+M qa/I+MogNa+7/M8NULVR/Lq5WWzc7E9l/iA6cUHRuGO/pPlZ1BPUWzLmLCD829mjk6gh nINtucjhiTF8KQjWvCJnxGpkKc63BNMtnQXadwas50YjHgraVnLhmgk9dXJzDSQXBzwP BvRfach2e1Z0181YxyFr6XoqGG5oi1LKnDmhK/kErSBehCPP3zZldi53nSUU68emp43i Dh9A== 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:dkim-signature; bh=bpXTzzsTu20XPUGJ5DoFqQgTxzAySWmD/o0USIl4Q7c=; b=e2iQIAwqpEpvw4VRkFmYhCwtpeitCCXikMgyy/SI60TCGuF7TVB098nCiIkvUXY5qz JVDGXC++0VBdW5jVD2olE4vYVYDgfzxNfmXabNgjj7gAK/EISi1mhx6te0bDbPeVqa31 FtjTSa5WXkcQk9afBsVQfUGMbu/yXjl/PalSjBrikIZlCJ+eMkscGTk5fm68N975xUJJ yRSFMznXMcVRL2NBHlvx3FAQubRUzAGGITWem7BBhzvRaGkHaKwCN0szppii1Ala2NRY eNCDgLWu0e1J9hXb5wU9lk4fVkGZEUrkQO3WIvSX7cRD80K41EsExSyJMbu1SeKXV785 8zFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZvmKRSgp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g36-20020a631124000000b00469e1f7dcbesi17759824pgl.603.2022.11.09.08.41.25; Wed, 09 Nov 2022 08:41:38 -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; dkim=pass header.i=@linaro.org header.s=google header.b=ZvmKRSgp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230133AbiKIQii (ORCPT + 99 others); Wed, 9 Nov 2022 11:38:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229678AbiKIQiF (ORCPT ); Wed, 9 Nov 2022 11:38:05 -0500 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D48C81AF39 for ; Wed, 9 Nov 2022 08:38:04 -0800 (PST) Received: by mail-lf1-x130.google.com with SMTP id be13so26525038lfb.4 for ; Wed, 09 Nov 2022 08:38:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bpXTzzsTu20XPUGJ5DoFqQgTxzAySWmD/o0USIl4Q7c=; b=ZvmKRSgpm7xR3LbQLB9UZw/n530C2QqBOI/9v6N5LETt1ngFIBejP+mEzFJPgBhQaG paQ8cqq3p5gMPdWmRllFXhEjVe6pmT1cZZU7jMZIjJdgUEiHIMbzkJp6JbC0tOuZkQAN JQpvhqxk+L2rx2r3HKE4sI9tT2earIcgutXI02JEuXkpVDsoiAV5hr/odCSKuD5HYCsX EzYlHM9zUsx94X1xcMtDjkCcZCh+Ejn3AKVmnQiddR17VniiqLnnT9LJJKrT7ndsvIHV jt21gUslJDNK3+L5Vrzcf7HpqJJboiJ4GW7cDZxQM1TG7YNFFpqXFgFftVxZsCM6KNGi mYVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bpXTzzsTu20XPUGJ5DoFqQgTxzAySWmD/o0USIl4Q7c=; b=NDRnBH3IHxZkYx3FcUNMtFl7zA7Ba2rsgcW2VVgqNMexGLk9nk0xKGIsGU/uBvFC1n GadEA6Akobuv5OY4ro1L3vjzgK87dO70/MqfrbCU9mcxNhcP2KEBPa+OTZTfatexE2IJ yWckH2jC45NZ+lG+YsnXdPnW9G/rcwLVoJT91N9UmEMDbyck6gvaWJ0juMuzvjgUGb8l oiuzpIUId9cLCUrvATRn7k4/2G2BfwWK/UENicnh7ESgI++TuCuiS9AjocHWmmaWICKv Vi6ZIij8qxRkPTDOTHcgfCfPouxTJlwRr45cSEiVVmtIW8vDczh2aSkM7dWSgDkyYi1v tihQ== X-Gm-Message-State: ACrzQf1+/8+HkJuco63sZWU4c32K2+VM+q91T4K+E06bVQbpef6qNOVs SK5C48RoFFykSNPl6a4sSJj9zQ== X-Received: by 2002:a05:6512:3086:b0:4a2:406d:47b8 with SMTP id z6-20020a056512308600b004a2406d47b8mr638107lfd.249.1668011883221; Wed, 09 Nov 2022 08:38:03 -0800 (PST) Received: from krzk-bin.NAT.warszawa.vectranet.pl (088156142199.dynamic-2-waw-k-3-2-0.vectranet.pl. [88.156.142.199]) by smtp.gmail.com with ESMTPSA id c15-20020a056512074f00b0049476667228sm2309168lfs.65.2022.11.09.08.38.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 08:38:02 -0800 (PST) From: Krzysztof Kozlowski To: Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [PATCH 1/2] ASoC: codecs: wsa883x: Shutdown on error path Date: Wed, 9 Nov 2022 17:37:58 +0100 Message-Id: <20221109163759.1158837-1-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749037454721536320?= X-GMAIL-MSGID: =?utf-8?q?1749037454721536320?= If probe fails, toggle shutdown via GPIO to save power and reverse probe actions. Signed-off-by: Krzysztof Kozlowski --- sound/soc/codecs/wsa883x.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/wsa883x.c b/sound/soc/codecs/wsa883x.c index 77a7dd3cf495..4ad8b875eb8f 100644 --- a/sound/soc/codecs/wsa883x.c +++ b/sound/soc/codecs/wsa883x.c @@ -1415,6 +1415,7 @@ static int wsa883x_probe(struct sdw_slave *pdev, wsa883x->regmap = devm_regmap_init_sdw(pdev, &wsa883x_regmap_config); if (IS_ERR(wsa883x->regmap)) { + gpiod_direction_output(wsa883x->sd_n, 1); dev_err(&pdev->dev, "regmap_init failed\n"); ret = PTR_ERR(wsa883x->regmap); goto err; From patchwork Wed Nov 9 16:37:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 17676 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp440688wru; Wed, 9 Nov 2022 08:42:25 -0800 (PST) X-Google-Smtp-Source: AMsMyM647FoFf1UyqZimZ/2lYKVgfKi6x6qDzyep2J8WSHXfEJbQvzPkj4tk0kidvF3IoDbyp6Y5 X-Received: by 2002:a63:d00e:0:b0:46f:8462:6222 with SMTP id z14-20020a63d00e000000b0046f84626222mr51238063pgf.285.1668012145345; Wed, 09 Nov 2022 08:42:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668012145; cv=none; d=google.com; s=arc-20160816; b=iNdOLgelrJrzvDC9aiWlBz/GHPHVJRqZCw87IXryG6EkVAKH9XboS4CqwFsvxz1TuN z1fTVWdE7vlVw7yi92yxE4J6yHKshkEbQ4neoIoElXNsEKEd2aSWwU/hQ0bLOGg535IG rS/nhzPi7/PmdJthq96mAVKSytttk9+ZZq2ixuVjNpSRY06Y4wHlrYeYp/xSLzOLVOMR kA/0LszM8GtFF50gLailseT1Tcvblq7Ze9pOlxyTwdT+2O1JfH3uEq4qFU63vmZx1fTL /KGgw8oIgYbMo0vTg3zYrJJPOU/MrwbByni/+IzfmqmzMLbO6NtONCkIMvNyUpqRdrWF WZhw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=M7C2hHnfI1uYNjIWJLHD9FrtHQvprfeg/2R452u0Yvw=; b=s3QxxRcAnPDQFg/lf2TJChJ7LFefj9ZwolnIu4/LX33AFOoX2j9PXghkTUicRxtgGM KTGKv7tPjGSBoW8tHszjujJ1wvkKTew0+AzjFLiTcaGkt6IuqzEnAjEs3NKyG+biUv7U aQvMJqcmm3WCu4yHGUn1yCPVAqDbPKPCDbtRXrOTprDvu08LryanYMoINJ2vOmJHNITB mi0O3zBgynSWL8Wi0sgReAzfn5RXCKQzVdAX6ZPbvhKLl7PfLl5ivXAuBZ+H6gQzRjU7 FXXifwkHtnki7x/S3WB8OAD0OmYCn40d/lOEh5+bLPCACaqKXR1K/1zQzmytCWkkD9RR 92KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="KUe0/9ra"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n2-20020a170902d2c200b001871c762263si6981873plc.185.2022.11.09.08.42.12; Wed, 09 Nov 2022 08:42:25 -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; dkim=pass header.i=@linaro.org header.s=google header.b="KUe0/9ra"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229956AbiKIQig (ORCPT + 99 others); Wed, 9 Nov 2022 11:38:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229967AbiKIQiH (ORCPT ); Wed, 9 Nov 2022 11:38:07 -0500 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71067205ED for ; Wed, 9 Nov 2022 08:38:06 -0800 (PST) Received: by mail-lj1-x22d.google.com with SMTP id z24so26470383ljn.4 for ; Wed, 09 Nov 2022 08:38:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M7C2hHnfI1uYNjIWJLHD9FrtHQvprfeg/2R452u0Yvw=; b=KUe0/9raCDsxcD15jNaoHEKQGY1/z3OYfBstsqbbVT0/dTZxxlTFOP7vThUbFzgweK wKugzPaXOIsI8vcmjF78XPW8V1wzRqrh5vsdKK4h6RyMV03ReqPKUrnU6l2xZNv7PnW+ z60fruvLAa+BQWl199mTBWEmipiZ/6Vj1L3VuvC9mFuZUzABF5Ssvu5nianwySzBUx49 Us5PwbT86nEgP//Oq8Qo+Omv9uK8ys0RVQeEuKVU9/In3rfFRhz2cvHl0dAup9ChQl6k JhrIx/DpNSts9N+FanVuzj5AMI2K/pAOFZK6z/rbR0bemlDVlF5FuPMNGJ5VEceZ/XiD vCGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M7C2hHnfI1uYNjIWJLHD9FrtHQvprfeg/2R452u0Yvw=; b=J9q4mlpNNzNBggQFSW7QfRFqYr1jO4IXhjc2bi45KyxwjKM7aMO0Y1aqQ0gLMUGRoO xzfNr4/Ir23nuBWdLhXCAJyHE/Ri7rIpu+cWR0uDkR6DHzH0w8k8tzNhUZgYf+aIKb+z Ik5zV4ioqmz/0Q7uzoQIXEYWw8q98hjcvt6Ikw1xalGJHUsv0EchmZ47RI/GI+4sVrk8 0bul6Ym5ib0/Ox2SPneHkvMGF00RKleyXpcXep58wS8T1P64qoUYZhx9McjHHiFejxMs UTIdahnwO62gLfiO/j4hx4SCIm3m8Mjcg1t+b1K6iCkCD/bFldNUO6lutSXmjo6jUz/m gz8Q== X-Gm-Message-State: ACrzQf2KTdqRSjle4zSpVvgzkOnkB/wMxLNeaqxHQ3s4XClnIYZnRWo8 izbj2y5fmyrDoBhTLu5B5o5d6Q== X-Received: by 2002:a2e:b626:0:b0:26e:6fb:4845 with SMTP id s6-20020a2eb626000000b0026e06fb4845mr7796442ljn.120.1668011884830; Wed, 09 Nov 2022 08:38:04 -0800 (PST) Received: from krzk-bin.NAT.warszawa.vectranet.pl (088156142199.dynamic-2-waw-k-3-2-0.vectranet.pl. [88.156.142.199]) by smtp.gmail.com with ESMTPSA id c15-20020a056512074f00b0049476667228sm2309168lfs.65.2022.11.09.08.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 08:38:03 -0800 (PST) From: Krzysztof Kozlowski To: Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [PATCH 2/2] ASoC: codecs: wsa883x: Simplify with dev_err_probe Date: Wed, 9 Nov 2022 17:37:59 +0100 Message-Id: <20221109163759.1158837-2-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109163759.1158837-1-krzysztof.kozlowski@linaro.org> References: <20221109163759.1158837-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749037503242943119?= X-GMAIL-MSGID: =?utf-8?q?1749037503242943119?= Code can be a bit simpler with dev_err_probe(). Signed-off-by: Krzysztof Kozlowski --- sound/soc/codecs/wsa883x.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/sound/soc/codecs/wsa883x.c b/sound/soc/codecs/wsa883x.c index 4ad8b875eb8f..85a2d928db13 100644 --- a/sound/soc/codecs/wsa883x.c +++ b/sound/soc/codecs/wsa883x.c @@ -1380,22 +1380,19 @@ static int wsa883x_probe(struct sdw_slave *pdev, return -ENOMEM; wsa883x->vdd = devm_regulator_get(dev, "vdd"); - if (IS_ERR(wsa883x->vdd)) { - dev_err(dev, "No vdd regulator found\n"); - return PTR_ERR(wsa883x->vdd); - } + if (IS_ERR(wsa883x->vdd)) + return dev_err_probe(dev, PTR_ERR(wsa883x->vdd), + "No vdd regulator found\n"); ret = regulator_enable(wsa883x->vdd); - if (ret) { - dev_err(dev, "Failed to enable vdd regulator (%d)\n", ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "Failed to enable vdd regulator\n"); wsa883x->sd_n = devm_gpiod_get_optional(&pdev->dev, "powerdown", GPIOD_FLAGS_BIT_NONEXCLUSIVE | GPIOD_OUT_HIGH); if (IS_ERR(wsa883x->sd_n)) { - dev_err(&pdev->dev, "Shutdown Control GPIO not found\n"); - ret = PTR_ERR(wsa883x->sd_n); + ret = dev_err_probe(&pdev->dev, PTR_ERR(wsa883x->sd_n), + "Shutdown Control GPIO not found\n"); goto err; } @@ -1416,8 +1413,8 @@ static int wsa883x_probe(struct sdw_slave *pdev, wsa883x->regmap = devm_regmap_init_sdw(pdev, &wsa883x_regmap_config); if (IS_ERR(wsa883x->regmap)) { gpiod_direction_output(wsa883x->sd_n, 1); - dev_err(&pdev->dev, "regmap_init failed\n"); - ret = PTR_ERR(wsa883x->regmap); + ret = dev_err_probe(&pdev->dev, PTR_ERR(wsa883x->regmap), + "regmap_init failed\n"); goto err; } pm_runtime_set_autosuspend_delay(dev, 3000);