From patchwork Tue Sep 8 08:35:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Camel Guo X-Patchwork-Id: 251111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BEDCC43461 for ; Tue, 8 Sep 2020 08:37:35 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DB3EB215A4 for ; Tue, 8 Sep 2020 08:37:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="WzB6w5Fs"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=axis.com header.i=@axis.com header.b="X5FAnwM3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB3EB215A4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=axis.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 410141767; Tue, 8 Sep 2020 10:36:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 410141767 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1599554252; bh=EWL+OnuByHsHZDrwNm3gq93U2lfWAYJJnSQDa3mE2Rk=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=WzB6w5FszTBFHJyIzVJUi9DUEGryGMRU9WcYWsFSqJcGlgbxb1HqJEyRQbeGyqG5I VFTDz3QrcyWKoO+5Yx0Y25B5Vi1oRQOZa4aWbD5zIi6pKI3nrcTbEmVulDcB9OyvOc k9t/Sknl1sdSov2fTmRmJ2rqWjLaiYwHCdDfLAxk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0D71FF80277; Tue, 8 Sep 2020 10:35:51 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 78F00F80264; Tue, 8 Sep 2020 10:35:48 +0200 (CEST) Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0D356F800FD for ; Tue, 8 Sep 2020 10:35:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0D356F800FD Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=axis.com header.i=@axis.com header.b="X5FAnwM3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; l=1085; q=dns/txt; s=axis-central1; t=1599554143; x=1631090143; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=gTwpcPl1kFBU+63Hn6Z1DD9u9CbnXsIkdWpPX9XgDYw=; b=X5FAnwM35QTTUbhtCDm7GLEW1lPiCSBqtRMY33prv/GefFETP6vm1ZAm haLHm9WeOwNfA4YAzD4F6GuA35dte2Bl3QOCeNG8k0JGiWJ0EsvO5zAao NAGUNL8j6ECbkFL2G5NQvUyGbqmSvXL5+livbj9iMviXV81lVP3tnNGMv 9n0x6DRgdx9LN9nSlf+Ur43OyPaWOomgob4NMA0jS5D2SCqifcbcJGXfZ 4ushOcyOFxGwzbYYkWiZIdmFRezVAZj4gFSICDP6yVnL5A3mava44dkSj b/n85B7dtrREG2ESI4OB+4Gsdv30g1ISn7YYVMLOF/xehyhomrWbR+dHz A==; IronPort-SDR: A7seHGq6UizqtY69aiZX4KZ3Zu6mGxvUchvWKDjdzIPhdJ9OtVV/8Ul2TCAIemDAi/3aWCFDLh u2WJSVdU7ksbuH0Z3i/gSLQdZ3NQrh2zZRK3dElRCbP5PXWYdr0QWbATS+ihsP5DuwsXg7+JhW Aq7xV2pNpFWph5pzc8D9HbXOhAaj49SFJVdkBi4iYjP5/DbCOtIGQbBygKYNNPWOoBk6y1U5Hb kYjQBabhRKBIKtZ0+39/YVXRJgHV4pLGM1c/BoYuzVoVjoFWDitPWb8zjvqMK7Bwrz1ZZ+lm7c 0lo= X-IronPort-AV: E=Sophos;i="5.76,405,1592863200"; d="scan'208";a="12651999" From: Camel Guo To: , , , Subject: [PATCH 1/2] ASoC: tlv320adcx140: Avoid accessing invalid gpio_reset Date: Tue, 8 Sep 2020 10:35:20 +0200 Message-ID: <20200908083521.14105-1-camel.guo@axis.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, kernel@axis.com, linux-kernel@vger.kernel.org, Camel Guo X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" From: Camel Guo When gpio_reset is not well defined in devicetree, the adcx140->gpio_reset is an error code instead of NULL. In this case, adcx140->gpio_reset should not be used by adcx140_reset. This commit sets it NULL to avoid accessing an invalid variable. Signed-off-by: Camel Guo Acked-by: Dan Murphy --- sound/soc/codecs/tlv320adcx140.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c index 7ae6ec374be3..597dd1062943 100644 --- a/sound/soc/codecs/tlv320adcx140.c +++ b/sound/soc/codecs/tlv320adcx140.c @@ -984,8 +984,10 @@ static int adcx140_i2c_probe(struct i2c_client *i2c, adcx140->gpio_reset = devm_gpiod_get_optional(adcx140->dev, "reset", GPIOD_OUT_LOW); - if (IS_ERR(adcx140->gpio_reset)) + if (IS_ERR(adcx140->gpio_reset) || adcx140->gpio_reset == NULL) { dev_info(&i2c->dev, "Reset GPIO not defined\n"); + adcx140->gpio_reset = NULL; + } adcx140->supply_areg = devm_regulator_get_optional(adcx140->dev, "areg"); From patchwork Tue Sep 8 08:35:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Camel Guo X-Patchwork-Id: 291800 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 042FFC43461 for ; Tue, 8 Sep 2020 08:36:43 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2EE5221741 for ; Tue, 8 Sep 2020 08:36:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="P1ZvetnP"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=axis.com header.i=@axis.com header.b="gtebpoEt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2EE5221741 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=axis.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 563E01756; Tue, 8 Sep 2020 10:35:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 563E01756 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1599554199; bh=lU1JYhFjtS9w80IITJi3DKI5Ng4lNFjHQndMQlFhDEE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=P1ZvetnPsKCaMui7i9sY76bi9MNf6HkHxk3+PbwbWk0VXDmrbQMONmfG6EO7sQy7s nzoKw0hbPV14+VWGkPbYKt+VSZskIQhDGO+ZeNqlNMTZUPg3x3NpHhAlZ3j+wZb62R MnrKrT8s8eYhqZYqnZ37OQgScfiE8O4/SE26pMJ0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C617FF801F2; Tue, 8 Sep 2020 10:35:48 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B71FCF80264; Tue, 8 Sep 2020 10:35:46 +0200 (CEST) Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 607BFF8015F for ; Tue, 8 Sep 2020 10:35:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 607BFF8015F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=axis.com header.i=@axis.com header.b="gtebpoEt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; l=1856; q=dns/txt; s=axis-central1; t=1599554141; x=1631090141; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xp2jtEwWlIVWqx9i65+JtXtOEPvP+lssrgvRxVi0wCI=; b=gtebpoEtsfn4axqr8EQRKbAwawjMX3QPVVJpQ+Ub9hU5DVV+k0GuFNGW bNQA+Aq5B8X+pQZru82h5a//8XorOxtANDiT90vf1w3H/sCYGO1muEZX5 EHib6eXp3nFFa0XhamWqCW3YTLei2M0hV5BAdJFbAUiguZLfh7XmOskG1 aXvj2gMMCSGTVa8eNaU2FdRmvC+4+8/FChhKB77fw6B7w2tTf38HYvglu 8FfeCwBPuVpnrRTRn7p0rd+ZTwK8y3qEuzsgpirODiemV+fCtctzp8iN7 vF3A7beM++lbcPSsl2Qu/KivZDlFKVeWtneTjOwR7aH7OZzddec5G315h A==; IronPort-SDR: SUM5QoENwhtyx2B6qE8P7GTzyoyjJY/j3tg8kW/LjcD9A9JjlDi8579OLER5ex99nYk/jFJQiZ 71ngP+kiNNrKNgMVcvLmi2Q9teAg86SsJtZk7szJhtFQ6y7GuXbizqNStR5BLurjxR2VZLy1cN JOkQZma0/nTQuUC1vdIECEpZNKsXpLViSrZJcQ4XoyvCe6bAyHSvvFKe9Oa8I+DskxYlRFeE3k jDm19QdWRfM4un6np6SmHs0zXO7qHJaK/KwtAQzaCbnIH6pv8zotoXnBVsl+F4rgAJ36UMTkHq nr4= X-IronPort-AV: E=Sophos;i="5.76,405,1592863200"; d="scan'208";a="12651992" From: Camel Guo To: , , , Subject: [PATCH 2/2] ASoC: tlv320adcx140: Wake up codec before accessing register Date: Tue, 8 Sep 2020 10:35:21 +0200 Message-ID: <20200908083521.14105-2-camel.guo@axis.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200908083521.14105-1-camel.guo@axis.com> References: <20200908083521.14105-1-camel.guo@axis.com> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, kernel@axis.com, linux-kernel@vger.kernel.org, Camel Guo X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" From: Camel Guo According to its datasheet, after reset this codec goes into sleep mode. In this mode, any register accessing should be avoided except for exiting sleep mode. Hence this commit moves SLEEP_CFG access before any register accessing. Signed-off-by: Camel Guo --- sound/soc/codecs/tlv320adcx140.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c index 597dd1062943..6d456aa269ad 100644 --- a/sound/soc/codecs/tlv320adcx140.c +++ b/sound/soc/codecs/tlv320adcx140.c @@ -842,6 +842,18 @@ static int adcx140_codec_probe(struct snd_soc_component *component) if (ret) goto out; + if (adcx140->supply_areg == NULL) + sleep_cfg_val |= ADCX140_AREG_INTERNAL; + + ret = regmap_write(adcx140->regmap, ADCX140_SLEEP_CFG, sleep_cfg_val); + if (ret) { + dev_err(adcx140->dev, "setting sleep config failed %d\n", ret); + goto out; + } + + /* 8.4.3: Wait >= 1ms after entering active mode. */ + usleep_range(1000, 100000); + pdm_count = device_property_count_u32(adcx140->dev, "ti,pdm-edge-select"); if (pdm_count <= ADCX140_NUM_PDM_EDGES && pdm_count > 0) { @@ -889,18 +901,6 @@ static int adcx140_codec_probe(struct snd_soc_component *component) if (ret) goto out; - if (adcx140->supply_areg == NULL) - sleep_cfg_val |= ADCX140_AREG_INTERNAL; - - ret = regmap_write(adcx140->regmap, ADCX140_SLEEP_CFG, sleep_cfg_val); - if (ret) { - dev_err(adcx140->dev, "setting sleep config failed %d\n", ret); - goto out; - } - - /* 8.4.3: Wait >= 1ms after entering active mode. */ - usleep_range(1000, 100000); - ret = regmap_update_bits(adcx140->regmap, ADCX140_BIAS_CFG, ADCX140_MIC_BIAS_VAL_MSK | ADCX140_MIC_BIAS_VREF_MSK, bias_cfg);