From patchwork Mon May 10 13:13:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 12248025 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 B374FC433B4 for ; Mon, 10 May 2021 13:16: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 874C16121E for ; Mon, 10 May 2021 13:16:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 874C16121E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=opensource.cirrus.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 BA50516D5; Mon, 10 May 2021 15:15:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BA50516D5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1620652592; bh=bkdAd+cRbTXglInEvNYnZOiNLvY5q780gBpuM+rFjcc=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=A6VRDke21Bgw3b5OnSXBzkYZfv+krIYS6BS7As18/tEo6M2kFSrgiKuhEvjS7Ii5z HKByN4XSFFWLQmzJU5c/RUc4kzXGBW9451aI+OS9nF7Ve2J8DjttnItatj89K/Ozqa hU01VIu5k30dAixSIzkf6OjoNMhQE5LSxQsnIMd4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 49C1EF8026B; Mon, 10 May 2021 15:14:18 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D2162F804A9; Mon, 10 May 2021 15:14:14 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (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 717F9F80240 for ; Mon, 10 May 2021 15:14:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 717F9F80240 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="ccqQehHx" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14ADDl49002119; Mon, 10 May 2021 08:14:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=tQ2oR7hqoATBSzTidVbnDzFBTAtg7iw2LpmB6WOJXJk=; b=ccqQehHxXypmv2/UuZZXYw2NORhyjw4nEE3pstCzPPe1cqLBj3oIlJuaGXNvQv9IKrYl TM50N32vMgc3AjeECIHnWX0sYqUnlG+OofgMEoyjNBNxwzqMErOwnOgKmycXv2v+MW0V HooSDElWFHoeJKcfUs7Hb8W/5SRbMwcddG/wHVnLh1HYIYiUBGjBhxbxzBFWwhqWXlBy n7bjMO/+fRDroX5zuJ1ELwHHQ/pzQxPxRS0Fg4hXHuK8/M2NJjgB2rz0jLTBRncQQ+ke W6LqH27xoFO4Pg+hCK0u+BIrna0RE3mB98+N5zOMEV/98229Iw5DeGUUWpOZtdaLqZ4W vw== Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0b-001ae601.pphosted.com with ESMTP id 38f2d4r60v-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 10 May 2021 08:14:01 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 10 May 2021 14:13:57 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Mon, 10 May 2021 14:13:57 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id B4B5F11D7; Mon, 10 May 2021 13:13:57 +0000 (UTC) From: Charles Keepax To: Subject: [PATCH 01/10] ASoC: cirrus: Add helper function for reading the device ID Date: Mon, 10 May 2021 14:13:48 +0100 Message-ID: <20210510131357.17170-2-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> References: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: CsZQVDbzha1DrAYF5kNFtx7p18nrQXPX X-Proofpoint-ORIG-GUID: CsZQVDbzha1DrAYF5kNFtx7p18nrQXPX X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 spamscore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 adultscore=0 impostorscore=0 malwarescore=0 mlxscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105100092 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, patches@opensource.cirrus.com, lgirdwood@gmail.com, james.schulman@cirrus.com, david.rhodes@cirrus.com 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" Many of the older Cirrus devices share very similar code for reading the device ID, and frequently this code is generating cppcheck warnings such as: sound/soc/codecs/cs42l42.c:1886:6: style: Variable 'ret' is reassigned a value before the old one has been used. [redundantAssignment] ret = regmap_read(cs42l42->regmap, CS42L42_DEVID_CD, ®); Add a small helper function that older Cirrus devices can use to read the device ID, which should help correct these issues. Reported-by: Pierre-Louis Bossart Signed-off-by: Charles Keepax --- sound/soc/codecs/cirrus_legacy.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 sound/soc/codecs/cirrus_legacy.h diff --git a/sound/soc/codecs/cirrus_legacy.h b/sound/soc/codecs/cirrus_legacy.h new file mode 100644 index 0000000000000..87c6fd79290d4 --- /dev/null +++ b/sound/soc/codecs/cirrus_legacy.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Some small helpers for older Cirrus Logic parts. + * + * Copyright (C) 2021 Cirrus Logic, Inc. and + * Cirrus Logic International Semiconductor Ltd. + */ + +static inline int cirrus_read_device_id(struct regmap *regmap, unsigned int reg) +{ + u8 devid[3]; + int ret; + + ret = regmap_bulk_read(regmap, reg, devid, ARRAY_SIZE(devid)); + if (ret < 0) + return ret; + + return ((devid[0] & 0xFF) << 12) | + ((devid[1] & 0xFF) << 4) | + ((devid[2] & 0xF0) >> 4); +} From patchwork Mon May 10 13:13:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 12248027 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 814F0C433ED for ; Mon, 10 May 2021 13:16:47 +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 D84D9611C2 for ; Mon, 10 May 2021 13:16:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D84D9611C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=opensource.cirrus.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 51FF216E9; Mon, 10 May 2021 15:15:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 51FF216E9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1620652605; bh=5RdqgsBZH1/baxkumnfA3ybcQwPpO80ssMJzaTbFYGQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=G5LUf/deP1Am/ixgaj2VFhuR56FkmDlW1TulYpElrPiPpjZl4ic+yxiog4aRF7Whz kvzkpghFGPySFm/Opvc8TlkrukEWGF0jp3KzrxEhSJEXEzimHzw/6VfpEY0qMWvZ1K +2ow6ujqXqMEVNxL318wDx8mgMwUftbxZnXQAG5g= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 279B1F80431; Mon, 10 May 2021 15:14:21 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5CF47F804AB; Mon, 10 May 2021 15:14:17 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 B40DBF80272 for ; Mon, 10 May 2021 15:14:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B40DBF80272 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="KzxLf3o4" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14ADD5ck017163; Mon, 10 May 2021 08:14:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=8cL2nfKK7y3xbXO8zHyfzojzhEMs0Q9EfFInsEAVUPw=; b=KzxLf3o4/1Xr/imX3ioYU7vjC3DQ/2aKV/8zrOgqneUHD2RJC9MSNzEZDDDlz1/AvwFZ 8NHl0qLLfKLGc7Rj6zJY6TzKbQDf9jjayVZ4h0Trx7T7KHjs2U6L+PwJsDTFuL4Lq0aU FM3lUxMphdncIz49fZHTUtLLnbbhZgoSHlRt4rUQsg6hT+yFSFZWAjJRmehySIcRKVp0 D2KwjE71aRzsI8I6+2G/CzhXg8qhwolBl8fgWW/DoJ+IrqdZC2zSgnq16Fd029KnxnWD TJ+cjVQK6m+eSn3XZ4btp/Q1Bt/nAXeIeF873jkP6455dTMOBhtZzgB/TGx0uYYsnmoz rA== Received: from ediex02.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 38f4x181h2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 10 May 2021 08:14:00 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 10 May 2021 14:13:57 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Mon, 10 May 2021 14:13:57 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id B8C2E11CF; Mon, 10 May 2021 13:13:57 +0000 (UTC) From: Charles Keepax To: Subject: [PATCH 02/10] ASoC: cs35l32: Minor error paths fixups Date: Mon, 10 May 2021 14:13:49 +0100 Message-ID: <20210510131357.17170-3-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> References: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: orlbzvhQYxlD4xOIprftaW1HTQixjebw X-Proofpoint-ORIG-GUID: orlbzvhQYxlD4xOIprftaW1HTQixjebw X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 bulkscore=0 mlxscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105100092 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, patches@opensource.cirrus.com, lgirdwood@gmail.com, james.schulman@cirrus.com, david.rhodes@cirrus.com 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" Correct some unchecked re-allocations of ret whilst reading the device ID and ensure the hardware state is returned to off on the error paths. Reported-by: Pierre-Louis Bossart Signed-off-by: Charles Keepax --- sound/soc/codecs/cs35l32.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/sound/soc/codecs/cs35l32.c b/sound/soc/codecs/cs35l32.c index f4067230ac425..7e1047362a901 100644 --- a/sound/soc/codecs/cs35l32.c +++ b/sound/soc/codecs/cs35l32.c @@ -30,6 +30,7 @@ #include #include "cs35l32.h" +#include "cirrus_legacy.h" #define CS35L32_NUM_SUPPLIES 2 static const char *const cs35l32_supply_names[CS35L32_NUM_SUPPLIES] = { @@ -348,8 +349,7 @@ static int cs35l32_i2c_probe(struct i2c_client *i2c_client, struct cs35l32_private *cs35l32; struct cs35l32_platform_data *pdata = dev_get_platdata(&i2c_client->dev); - int ret, i; - unsigned int devid = 0; + int ret, i, devid; unsigned int reg; cs35l32 = devm_kzalloc(&i2c_client->dev, sizeof(*cs35l32), GFP_KERNEL); @@ -404,40 +404,40 @@ static int cs35l32_i2c_probe(struct i2c_client *i2c_client, /* Reset the Device */ cs35l32->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev, "reset", GPIOD_OUT_LOW); - if (IS_ERR(cs35l32->reset_gpio)) - return PTR_ERR(cs35l32->reset_gpio); + if (IS_ERR(cs35l32->reset_gpio)) { + ret = PTR_ERR(cs35l32->reset_gpio); + goto err_supplies; + } gpiod_set_value_cansleep(cs35l32->reset_gpio, 1); /* initialize codec */ - ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_AB, ®); - devid = (reg & 0xFF) << 12; - - ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_CD, ®); - devid |= (reg & 0xFF) << 4; - - ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_E, ®); - devid |= (reg & 0xF0) >> 4; + devid = cirrus_read_device_id(cs35l32->regmap, CS35L32_DEVID_AB); + if (devid < 0) { + ret = devid; + dev_err(&i2c_client->dev, "Failed to read device ID: %d\n", ret); + goto err_disable; + } if (devid != CS35L32_CHIP_ID) { ret = -ENODEV; dev_err(&i2c_client->dev, "CS35L32 Device ID (%X). Expected %X\n", devid, CS35L32_CHIP_ID); - return ret; + goto err_disable; } ret = regmap_read(cs35l32->regmap, CS35L32_REV_ID, ®); if (ret < 0) { dev_err(&i2c_client->dev, "Get Revision ID failed\n"); - return ret; + goto err_disable; } ret = regmap_register_patch(cs35l32->regmap, cs35l32_monitor_patch, ARRAY_SIZE(cs35l32_monitor_patch)); if (ret < 0) { dev_err(&i2c_client->dev, "Failed to apply errata patch\n"); - return ret; + goto err_disable; } dev_info(&i2c_client->dev, @@ -478,7 +478,7 @@ static int cs35l32_i2c_probe(struct i2c_client *i2c_client, CS35L32_PDN_AMP); /* Clear MCLK Error Bit since we don't have the clock yet */ - ret = regmap_read(cs35l32->regmap, CS35L32_INT_STATUS_1, ®); + regmap_read(cs35l32->regmap, CS35L32_INT_STATUS_1, ®); ret = devm_snd_soc_register_component(&i2c_client->dev, &soc_component_dev_cs35l32, cs35l32_dai, @@ -489,6 +489,8 @@ static int cs35l32_i2c_probe(struct i2c_client *i2c_client, return 0; err_disable: + gpiod_set_value_cansleep(cs35l32->reset_gpio, 0); +err_supplies: regulator_bulk_disable(ARRAY_SIZE(cs35l32->supplies), cs35l32->supplies); return ret; From patchwork Mon May 10 13:13:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 12248045 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 400E0C433ED for ; Mon, 10 May 2021 13:18:59 +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 9B1986121E for ; Mon, 10 May 2021 13:18:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B1986121E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=opensource.cirrus.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 188AD174F; Mon, 10 May 2021 15:18:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 188AD174F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1620652737; bh=5bNt1GUuKaf3QMML9d3bY+V+o5IhvKV/3K0l7XL8GwA=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OH0O5rAf19LlmLhobdN0FxxnZQEw4AfdyQg6rTBwM6XM55C6I7IuVePO/Jl+Alp9o PhInCgeWpUg47Jx7vOJAAeIPcGC9tXEvS6I+4bKndRq+Q0rTpTA+HImIXuLAWtg9k5 kJRRxgO+2G1R046md6e/o2gqbFaM32ZROLe9+gDU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EDCF1F804E7; Mon, 10 May 2021 15:14:25 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A0FFAF804D8; Mon, 10 May 2021 15:14:23 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 C20FBF8026F for ; Mon, 10 May 2021 15:14:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C20FBF8026F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="eh9e0Tt2" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14ADD5cj017163; Mon, 10 May 2021 08:13:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=9ApaxVdIsLOhMV/cbqW4Miy64EVxRdnn/+s8uSdnpBA=; b=eh9e0Tt2fE5BK4lRZ8iuWoD50R+l8k5vfPh+OrsEcP4Vkmkyf4rzrzHSaW10EueTTxu6 7f4UVW5W3FdCFCRr7ehriDeCvCswREVMsbUlENGnUKumMP/ajq1E5MsvXlKQVKvgUEbj tzvCg8kMOVHTEy0wVUQGDeWeU70gOE9C7KBQH7S9DfGTyCpcZAxd8TkGHiMYeRt3FokB mJToNBJ8f6Ftdw7Ys2qSD8ZDF1GtkQVeZgB8MRvsk0UJL0tt4IjtjIMyQxgRxHc3iyGG EqYnbNHx65RhDmXHxsJ1L1jIouSZxnY6qxLPLgER1485Ojp/BWXVqTcSJH+d6NrLXv44 bw== Received: from ediex02.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 38f4x181h2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 10 May 2021 08:13:59 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 10 May 2021 14:13:57 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Mon, 10 May 2021 14:13:57 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id BD16611D9; Mon, 10 May 2021 13:13:57 +0000 (UTC) From: Charles Keepax To: Subject: [PATCH 03/10] ASoC: cs35l33: Minor error paths fixups Date: Mon, 10 May 2021 14:13:50 +0100 Message-ID: <20210510131357.17170-4-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> References: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: fs_H-RSG48UtUjE8nlafZYwxWYyTa5j2 X-Proofpoint-ORIG-GUID: fs_H-RSG48UtUjE8nlafZYwxWYyTa5j2 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 clxscore=1011 bulkscore=0 mlxscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105100092 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, patches@opensource.cirrus.com, lgirdwood@gmail.com, james.schulman@cirrus.com, david.rhodes@cirrus.com 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" Correct some unchecked re-allocations of ret whilst reading the device ID and ensure the hardware state is returned to off on the error paths. Reported-by: Pierre-Louis Bossart Signed-off-by: Charles Keepax --- sound/soc/codecs/cs35l33.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/cs35l33.c b/sound/soc/codecs/cs35l33.c index 7ad7b733af9b6..6f6b3c0c88b78 100644 --- a/sound/soc/codecs/cs35l33.c +++ b/sound/soc/codecs/cs35l33.c @@ -34,6 +34,7 @@ #include #include "cs35l33.h" +#include "cirrus_legacy.h" #define CS35L33_BOOT_DELAY 50 @@ -1190,12 +1191,12 @@ static int cs35l33_i2c_probe(struct i2c_client *i2c_client, regcache_cache_only(cs35l33->regmap, false); /* initialize codec */ - ret = regmap_read(cs35l33->regmap, CS35L33_DEVID_AB, ®); - devid = (reg & 0xFF) << 12; - ret = regmap_read(cs35l33->regmap, CS35L33_DEVID_CD, ®); - devid |= (reg & 0xFF) << 4; - ret = regmap_read(cs35l33->regmap, CS35L33_DEVID_E, ®); - devid |= (reg & 0xF0) >> 4; + devid = cirrus_read_device_id(cs35l33->regmap, CS35L33_DEVID_AB); + if (devid < 0) { + ret = devid; + dev_err(&i2c_client->dev, "Failed to read device ID: %d\n", ret); + goto err_enable; + } if (devid != CS35L33_CHIP_ID) { dev_err(&i2c_client->dev, @@ -1242,6 +1243,8 @@ static int cs35l33_i2c_probe(struct i2c_client *i2c_client, return 0; err_enable: + gpiod_set_value_cansleep(cs35l33->reset_gpio, 0); + regulator_bulk_disable(cs35l33->num_core_supplies, cs35l33->core_supplies); From patchwork Mon May 10 13:13:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 12248023 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 95772C433B4 for ; Mon, 10 May 2021 13:15:59 +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 C2C53611CA for ; Mon, 10 May 2021 13:15:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C2C53611CA Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=opensource.cirrus.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 4A42216C1; Mon, 10 May 2021 15:15:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4A42216C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1620652557; bh=VcnxZRm+Qslu/ehAKaXmNujuaXr2CLUQRypPOK3Oz84=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=oCj3/W5WYzoioXZFUXgQfcZ1nQDTAobG8BXv4Xi7KBQajph7deXOwmazk21/6gcPJ GsWXnsnnWMZQASM3k0hvBGzFl2NtVtB942NJaJrU/RxwUNXxdrOynARNJFu7gv7SOi jEJPQ6Gw/xYxUmt7YTgZG9sjEGw29clxeQPe+aG4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DEB02F800EA; Mon, 10 May 2021 15:14:14 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4C89FF80475; Mon, 10 May 2021 15:14:13 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (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 56B9CF800B4 for ; Mon, 10 May 2021 15:14:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 56B9CF800B4 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="ExnqgGEO" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14ADDl48002119; Mon, 10 May 2021 08:14:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=YuLDh0segeWIEOUBUtCj3Z2I6mIpBis58Kmy1qEUyeI=; b=ExnqgGEOESvHlJVESRcjkPqGoW85h7uhXV4Z1xqzpZFUJ9jZgRV799RmlrekttukwD0O Zx8HqBT3VtlXViU865Lz96qE7GQ1pmzEaNF3cQamdZVRiibsVIN6HVSazeN98qqypc8M urU0BBWrqjyx+XB8I5s32c2XDpPAuQiNuNlfL7XHd40KF+q4qqKG5u8fR6tXjNuR2Lp9 TbjZd9lSwHG3PoMLiP9ElWaEIGFIPsm4c4eHG4KenZDjgzM+xhyTIL5/+kRw1SDyCxoX zX/vi1m/ESbzWCGPFkFunuaQHLeQZgDfUNna8VPFDOAvV+Mm8Tz6di02mKX0dUXNAGF1 pA== Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0b-001ae601.pphosted.com with ESMTP id 38f2d4r60v-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 10 May 2021 08:14:00 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 10 May 2021 14:13:57 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Mon, 10 May 2021 14:13:57 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id C0EB711D8; Mon, 10 May 2021 13:13:57 +0000 (UTC) From: Charles Keepax To: Subject: [PATCH 04/10] ASoC: cs35l34: Minor error paths fixups Date: Mon, 10 May 2021 14:13:51 +0100 Message-ID: <20210510131357.17170-5-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> References: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: q2UHp9g65vhtNeuJOLWS5AopwETgVsRP X-Proofpoint-ORIG-GUID: q2UHp9g65vhtNeuJOLWS5AopwETgVsRP X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 spamscore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 adultscore=0 impostorscore=0 malwarescore=0 mlxscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105100092 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, patches@opensource.cirrus.com, lgirdwood@gmail.com, james.schulman@cirrus.com, david.rhodes@cirrus.com 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" Correct some unchecked re-allocations of ret whilst reading the device ID and ensure the hardware state is returned to off on the error paths. Reported-by: Pierre-Louis Bossart Signed-off-by: Charles Keepax --- sound/soc/codecs/cs35l34.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/sound/soc/codecs/cs35l34.c b/sound/soc/codecs/cs35l34.c index 110ee2d063581..6657cc5db3e87 100644 --- a/sound/soc/codecs/cs35l34.c +++ b/sound/soc/codecs/cs35l34.c @@ -34,6 +34,7 @@ #include #include "cs35l34.h" +#include "cirrus_legacy.h" #define PDN_DONE_ATTEMPTS 10 #define CS35L34_START_DELAY 50 @@ -996,9 +997,8 @@ static int cs35l34_i2c_probe(struct i2c_client *i2c_client, struct cs35l34_private *cs35l34; struct cs35l34_platform_data *pdata = dev_get_platdata(&i2c_client->dev); - int i; + int i, devid; int ret; - unsigned int devid = 0; unsigned int reg; cs35l34 = devm_kzalloc(&i2c_client->dev, sizeof(*cs35l34), GFP_KERNEL); @@ -1039,13 +1039,15 @@ static int cs35l34_i2c_probe(struct i2c_client *i2c_client, } else { pdata = devm_kzalloc(&i2c_client->dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return -ENOMEM; + if (!pdata) { + ret = -ENOMEM; + goto err_regulator; + } if (i2c_client->dev.of_node) { ret = cs35l34_handle_of_data(i2c_client, pdata); if (ret != 0) - return ret; + goto err_regulator; } cs35l34->pdata = *pdata; @@ -1059,33 +1061,34 @@ static int cs35l34_i2c_probe(struct i2c_client *i2c_client, cs35l34->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev, "reset-gpios", GPIOD_OUT_LOW); - if (IS_ERR(cs35l34->reset_gpio)) - return PTR_ERR(cs35l34->reset_gpio); + if (IS_ERR(cs35l34->reset_gpio)) { + ret = PTR_ERR(cs35l34->reset_gpio); + goto err_regulator; + } gpiod_set_value_cansleep(cs35l34->reset_gpio, 1); msleep(CS35L34_START_DELAY); - ret = regmap_read(cs35l34->regmap, CS35L34_DEVID_AB, ®); - - devid = (reg & 0xFF) << 12; - ret = regmap_read(cs35l34->regmap, CS35L34_DEVID_CD, ®); - devid |= (reg & 0xFF) << 4; - ret = regmap_read(cs35l34->regmap, CS35L34_DEVID_E, ®); - devid |= (reg & 0xF0) >> 4; + devid = cirrus_read_device_id(cs35l34->regmap, CS35L34_DEVID_AB); + if (devid < 0) { + ret = devid; + dev_err(&i2c_client->dev, "Failed to read device ID: %d\n", ret); + goto err_reset; + } if (devid != CS35L34_CHIP_ID) { dev_err(&i2c_client->dev, "CS35l34 Device ID (%X). Expected ID %X\n", devid, CS35L34_CHIP_ID); ret = -ENODEV; - goto err_regulator; + goto err_reset; } ret = regmap_read(cs35l34->regmap, CS35L34_REV_ID, ®); if (ret < 0) { dev_err(&i2c_client->dev, "Get Revision ID failed\n"); - goto err_regulator; + goto err_reset; } dev_info(&i2c_client->dev, @@ -1110,11 +1113,13 @@ static int cs35l34_i2c_probe(struct i2c_client *i2c_client, if (ret < 0) { dev_err(&i2c_client->dev, "%s: Register component failed\n", __func__); - goto err_regulator; + goto err_reset; } return 0; +err_reset: + gpiod_set_value_cansleep(cs35l34->reset_gpio, 0); err_regulator: regulator_bulk_disable(cs35l34->num_core_supplies, cs35l34->core_supplies); From patchwork Mon May 10 13:13:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 12248043 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 77EA8C433ED for ; Mon, 10 May 2021 13:18:38 +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 C3790611CA for ; Mon, 10 May 2021 13:18:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C3790611CA Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=opensource.cirrus.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 50821173D; Mon, 10 May 2021 15:17:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 50821173D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1620652716; bh=3PrZEQYeYzwsmdStyPTUGC801O1yp/X5AXu7veB97G4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=bpuM8gBZ0Dd/JHyFLHGyzugQ+4BVXEHloUguV/xafo/TPZ0CReeIPUTPoB6otXxlM 6mDCXP7cIGY8gaGvA1ZTVmKxk4zFoaZtdi98UbY+jRSVhlRGOWQS2BILwlz7NU9HN5 nyyOEeBw8BsF8hzgTVy0u5pxg/KsuAWU7USj4XMY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3A6D8F804E3; Mon, 10 May 2021 15:14:25 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 06EFBF802E7; Mon, 10 May 2021 15:14:21 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (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 BBAFCF80431 for ; Mon, 10 May 2021 15:14:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BBAFCF80431 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="GfqfoUpz" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14ADDl4B002119; Mon, 10 May 2021 08:14:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=5Xz2X9kwZsmC+57mVq+jQmu1eh8u8mOHJI3l2bDqdfU=; b=GfqfoUpzsJtOve6zLd6QoAjrR6fvMHdSlHNBOkzRIR2Y7e9ui2JuWUfukmFOGarZz6+f BfysJvXEleKw6UV0R2U8oosCvUJK/MDbIAmh2qI741SyTvxgkaRv8+9iOccBzQ5UXo7y 1A4ffnbkgGKT0Ad+K9bYWt0K68Q6l/hvlCUb2WkGtpu8SIS21N94YWnPZ/IqrH2cHU53 S5X2f4QlU7aM/HVqzdW8nIW2vOAf7P4opnv1gqa8GPSMG1zw64OYj0RPr+tocfv91olH OM2wPn/Zss5fIS14YR3HOLBXz9AFxPsc5emVoVswm20FVTKuvk3zWUUxw1ZJTXX3HxQC zQ== Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0b-001ae601.pphosted.com with ESMTP id 38f2d4r60v-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 10 May 2021 08:14:03 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 10 May 2021 14:13:57 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Mon, 10 May 2021 14:13:57 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id C51D911DB; Mon, 10 May 2021 13:13:57 +0000 (UTC) From: Charles Keepax To: Subject: [PATCH 05/10] ASoC: cs35l35: Minor error paths fixups Date: Mon, 10 May 2021 14:13:52 +0100 Message-ID: <20210510131357.17170-6-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> References: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: kuvSkuBrjSX-Mq6mN_V2x7E-bIugOhri X-Proofpoint-ORIG-GUID: kuvSkuBrjSX-Mq6mN_V2x7E-bIugOhri X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 spamscore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 adultscore=0 impostorscore=0 malwarescore=0 mlxscore=0 phishscore=0 priorityscore=1501 mlxlogscore=885 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105100092 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, patches@opensource.cirrus.com, lgirdwood@gmail.com, james.schulman@cirrus.com, david.rhodes@cirrus.com 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" Correct some unchecked re-allocations of ret whilst reading the device ID and ensure the hardware state is returned to off on the error paths. Reported-by: Pierre-Louis Bossart Signed-off-by: Charles Keepax --- sound/soc/codecs/cs35l35.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/cs35l35.c b/sound/soc/codecs/cs35l35.c index f20ed838b9580..554b32f388d9a 100644 --- a/sound/soc/codecs/cs35l35.c +++ b/sound/soc/codecs/cs35l35.c @@ -33,6 +33,7 @@ #include #include "cs35l35.h" +#include "cirrus_legacy.h" /* * Some fields take zero as a valid value so use a high bit flag that won't @@ -1471,9 +1472,8 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client, struct cs35l35_private *cs35l35; struct device *dev = &i2c_client->dev; struct cs35l35_platform_data *pdata = dev_get_platdata(dev); - int i; + int i, devid; int ret; - unsigned int devid = 0; unsigned int reg; cs35l35 = devm_kzalloc(dev, sizeof(struct cs35l35_private), GFP_KERNEL); @@ -1552,13 +1552,12 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client, goto err; } /* initialize codec */ - ret = regmap_read(cs35l35->regmap, CS35L35_DEVID_AB, ®); - - devid = (reg & 0xFF) << 12; - ret = regmap_read(cs35l35->regmap, CS35L35_DEVID_CD, ®); - devid |= (reg & 0xFF) << 4; - ret = regmap_read(cs35l35->regmap, CS35L35_DEVID_E, ®); - devid |= (reg & 0xF0) >> 4; + devid = cirrus_read_device_id(cs35l35->regmap, CS35L35_DEVID_AB); + if (devid < 0) { + ret = devid; + dev_err(dev, "Failed to read device ID: %d\n", ret); + goto err; + } if (devid != CS35L35_CHIP_ID) { dev_err(dev, "CS35L35 Device ID (%X). Expected ID %X\n", From patchwork Mon May 10 13:13:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 12248033 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 6C638C433B4 for ; Mon, 10 May 2021 13:18:00 +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 594906121E for ; Mon, 10 May 2021 13:17:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 594906121E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=opensource.cirrus.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 E445A1719; Mon, 10 May 2021 15:17:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E445A1719 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1620652678; bh=0EfUEn7RQHEieeAnkB5ZnTdQ2ZN+9ljDgSFluuLzEcE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=PIKK8CYoRh8LVjEbQbmi5nOSXltDpuDK+c5uYTpGZLGBY9E+fpJB8b4V99mhxxFA5 6IcYy32BIk6QyF1qkYrXOv/UFjbVzXPTb0BjL6obNMqSdC1O3y4DPJpa8YPP0hXiUa 20DYNEVwiAnnCfof33jIJx+z8UEAAkYSxENCkvfc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 531A3F804C1; Mon, 10 May 2021 15:14:23 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BF782F804AC; Mon, 10 May 2021 15:14:19 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 C55FFF802E7 for ; Mon, 10 May 2021 15:14:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C55FFF802E7 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="Ge+D18w0" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14ADD5cl017163; Mon, 10 May 2021 08:14:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=VnoySpN+bzOhwzfk9vr2maK/1NzhkSxMSGSmgYfbXtA=; b=Ge+D18w0KPJs44Tn5OR3hzuCVWQm3ezLdfNKAiIb9Q5DP/Kl8O9RwRXzPLCXrQgCcxPw NUhKM90BDHXUIroljfnmDC3O0hAumfGWbMzypIsJ4dnXnu1gxDCHxcB6Z6Te7JJ8s+jB zhs8EH1W9G3BLukfogwTkpBWErSfX0fHPwFoAqWOTjses2LxMkf5oGAtc8+1RpazUxo6 ttYGONtdAK5I1dMFKzKnCEGG5aB7PJfkFElB9ss6zFJ6YYqwvwK0AzIH6+2NCQc+ddQZ oWye+cI01DdyYqHXAOtdo7oINeH5YlOZXSeBDlcwoxglID9FdMKU6jPs6oAgp1SS00XA UA== Received: from ediex02.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 38f4x181h2-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 10 May 2021 08:14:01 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 10 May 2021 14:13:57 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Mon, 10 May 2021 14:13:57 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id D22EB11DA; Mon, 10 May 2021 13:13:57 +0000 (UTC) From: Charles Keepax To: Subject: [PATCH 06/10] ASoC: cs35l35: Correct errata handling Date: Mon, 10 May 2021 14:13:53 +0100 Message-ID: <20210510131357.17170-7-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> References: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: Yh5rTxPtostlhpJdwddmPc_DGQFHeeEc X-Proofpoint-ORIG-GUID: Yh5rTxPtostlhpJdwddmPc_DGQFHeeEc X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 bulkscore=0 mlxscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105100092 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, patches@opensource.cirrus.com, lgirdwood@gmail.com, james.schulman@cirrus.com, david.rhodes@cirrus.com 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" Currently the check of errata_chk will always evaluate to false since the values tested don't come under the mask used. A shift of the field is missing, add this. Also there is an error in the values tested, they don't match the comment and the value 0x3 is not a valid value for the field in question. Update the value to match the comment. Signed-off-by: Charles Keepax --- sound/soc/codecs/cs35l35.c | 4 ++-- sound/soc/codecs/cs35l35.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/cs35l35.c b/sound/soc/codecs/cs35l35.c index 554b32f388d9a..a4309312e84f3 100644 --- a/sound/soc/codecs/cs35l35.c +++ b/sound/soc/codecs/cs35l35.c @@ -496,10 +496,10 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, * the Class H algorithm does not enable weak-drive operation for * nonzero values of CH_WKFET_DELAY if SP_RATE = 01 or 10 */ - errata_chk = clk_ctl & CS35L35_SP_RATE_MASK; + errata_chk = (clk_ctl & CS35L35_SP_RATE_MASK) >> CS35L35_SP_RATE_SHIFT; if (classh->classh_wk_fet_disable == 0x00 && - (errata_chk == 0x01 || errata_chk == 0x03)) { + (errata_chk == 0x01 || errata_chk == 0x02)) { ret = regmap_update_bits(cs35l35->regmap, CS35L35_CLASS_H_FET_DRIVE_CTL, CS35L35_CH_WKFET_DEL_MASK, diff --git a/sound/soc/codecs/cs35l35.h b/sound/soc/codecs/cs35l35.h index ffb154cd962c2..2117dcb08c467 100644 --- a/sound/soc/codecs/cs35l35.h +++ b/sound/soc/codecs/cs35l35.h @@ -168,6 +168,7 @@ #define CS35L35_SP_SCLKS_48FS 0x0B #define CS35L35_SP_SCLKS_64FS 0x0F #define CS35L35_SP_RATE_MASK 0xC0 +#define CS35L35_SP_RATE_SHIFT 6 #define CS35L35_PDN_BST_MASK 0x06 #define CS35L35_PDN_BST_FETON_SHIFT 1 From patchwork Mon May 10 13:13:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 12248041 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 82628C433ED for ; Mon, 10 May 2021 13:18:17 +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 D213E611CA for ; Mon, 10 May 2021 13:18:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D213E611CA Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=opensource.cirrus.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 4F711172F; Mon, 10 May 2021 15:17:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4F711172F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1620652695; bh=YvRqRZLlsMz2vQBxINLc68YaDlyGk5CmGmDvXANhMbA=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=s/GfhaNIoICGJe50ouS+bqKNdyrHKohLbo/OXiDOulNvo7xOFGOK7UnOjwoEvhFG3 7b/Go0u6itCZRmqGZjZCQY+vZPAwU7tFpyYaN+WytiWO71yjAtGklimBlLR0wf4S7U kynQi8lTzCe2GcodSXv6S9l6iFKctRDhmnSKBU80= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 91EB3F804DF; Mon, 10 May 2021 15:14:24 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CD04BF804AB; Mon, 10 May 2021 15:14:20 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (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 89CEEF8027D for ; Mon, 10 May 2021 15:14:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 89CEEF8027D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="NLgkZ9Gt" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14ADDl4A002119; Mon, 10 May 2021 08:14:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=+kTLTXVuYtWf66VeKN914c2iVk3N1EC2mt91R4r3SRM=; b=NLgkZ9Gt942P/Is846cH99oG1fKGE7AyFZ+uWBHkwVQQYWeWQNs25KSW8Obv158pMp9L JKxcMsAQnRRLQHcY8I5jkLGjJ02sIdE0DCTpzW6TZ1MlVhq91X/TC2P2TkauGomWuXOD yO3BmAEFDWJf/lkssw8LBwAIN+qE8AbzMz3BPztGvFWqHpJxVBkcQDnVggdQ8gQWoC/t F1gK0ggITrL7X7QSJF+huWGg3yqM8gO6oEJY/lawjXMngaU79iQeQCoA+1E9NkRIHPld X/W1JpgNL1FNjN96dZEQhTCdFgoyi9ankmg+JlEpRmLEfhD/oxNX4blIDYogUeAgTQTw EQ== Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0b-001ae601.pphosted.com with ESMTP id 38f2d4r60v-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 10 May 2021 08:14:02 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 10 May 2021 14:13:57 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Mon, 10 May 2021 14:13:57 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id DF6E611CF; Mon, 10 May 2021 13:13:57 +0000 (UTC) From: Charles Keepax To: Subject: [PATCH 07/10] ASoC: cs42l42: Minor error paths fixups Date: Mon, 10 May 2021 14:13:54 +0100 Message-ID: <20210510131357.17170-8-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> References: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: -jQKq9plI-z3wNBHmgdUYakTyjnUVPeN X-Proofpoint-ORIG-GUID: -jQKq9plI-z3wNBHmgdUYakTyjnUVPeN X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 spamscore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 adultscore=0 impostorscore=0 malwarescore=0 mlxscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105100092 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, patches@opensource.cirrus.com, lgirdwood@gmail.com, james.schulman@cirrus.com, david.rhodes@cirrus.com 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" Correct some unchecked re-allocations of ret whilst reading the device ID and ensure the hardware state is returned to off on the error paths. Reported-by: Pierre-Louis Bossart Signed-off-by: Charles Keepax --- sound/soc/codecs/cs42l42.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c index bf982e145e945..594d771336719 100644 --- a/sound/soc/codecs/cs42l42.c +++ b/sound/soc/codecs/cs42l42.c @@ -36,6 +36,7 @@ #include #include "cs42l42.h" +#include "cirrus_legacy.h" static const struct reg_default cs42l42_reg_defaults[] = { { CS42L42_FRZ_CTL, 0x00 }, @@ -1816,8 +1817,7 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client, const struct i2c_device_id *id) { struct cs42l42_private *cs42l42; - int ret, i; - unsigned int devid = 0; + int ret, i, devid; unsigned int reg; cs42l42 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l42_private), @@ -1880,14 +1880,12 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client, "Failed to request IRQ: %d\n", ret); /* initialize codec */ - ret = regmap_read(cs42l42->regmap, CS42L42_DEVID_AB, ®); - devid = (reg & 0xFF) << 12; - - ret = regmap_read(cs42l42->regmap, CS42L42_DEVID_CD, ®); - devid |= (reg & 0xFF) << 4; - - ret = regmap_read(cs42l42->regmap, CS42L42_DEVID_E, ®); - devid |= (reg & 0xF0) >> 4; + devid = cirrus_read_device_id(cs42l42->regmap, CS42L42_DEVID_AB); + if (devid < 0) { + ret = devid; + dev_err(&i2c_client->dev, "Failed to read device ID: %d\n", ret); + goto err_disable; + } if (devid != CS42L42_CHIP_ID) { ret = -ENODEV; From patchwork Mon May 10 13:13:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 12248021 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 866FFC433ED for ; Mon, 10 May 2021 13:15:55 +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 8882561621 for ; Mon, 10 May 2021 13:15:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8882561621 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=opensource.cirrus.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 9246416B4; Mon, 10 May 2021 15:15:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9246416B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1620652552; bh=bZVqf6KJxapLYDDWMfMVTHsX1t3w55m+dxknESl9oiI=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=kX6lViBOsXYngQsshXWujbFTKWU1gyii9z/Y5Ur1su8Hv8QEg9vFeuxR1kivuAiY6 knSEsTrtCb2ZoncYfRD+/FDG1Bwjx1P4Xj29AKVFdiaMuipw8pUYzYkA1fba3ey6La BgErugitPNhhRkFOL3okkCxH5og4AZHopUrIhdVo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E8EECF800B4; Mon, 10 May 2021 15:14:13 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 06207F80475; Mon, 10 May 2021 15:14:11 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (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 EF7DFF8020C for ; Mon, 10 May 2021 15:14:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EF7DFF8020C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="TNVYFByF" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14ADDl4C002119; Mon, 10 May 2021 08:14:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=nyRsAm7uMV9MOsc49IfNltwL8dOdSD1dAHlHoMl4I68=; b=TNVYFByFbjWx2JRb6OC6e23XlPMDkkZUNHC2SxjwWfUaeUWePaKVaBFwC2CcJQZ1exbw 0WZwAh+zwj0xJMqsyTeolvcXHHEoQ2MgOse99hOMRtSCMyWgiW577wDuTcZMTumxzHlx EO9aNP5ZbahjlpQGom4h5Rk3id3jzoOuRw+NQvK8zAJA/Wv+8YW00A0Cd9RRtOLlcqZe c2aViWLLPZ1ToOnOIlETyLqQDgeBnpSD9zdjFK2ZO/cjIE7hIyMtYF+OWX91HpZcm+FZ ZOelJPyBlczg5zJ5KU1iXCBmOHkyQSRYF69ZVVwip4gaKeGluq6Q6Y00Q21r/khj4Ihf PA== Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0b-001ae601.pphosted.com with ESMTP id 38f2d4r60v-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 10 May 2021 08:14:04 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 10 May 2021 14:13:58 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Mon, 10 May 2021 14:13:58 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id EC65C11D1; Mon, 10 May 2021 13:13:57 +0000 (UTC) From: Charles Keepax To: Subject: [PATCH 08/10] ASoC: cs42l73: Minor error paths fixups Date: Mon, 10 May 2021 14:13:55 +0100 Message-ID: <20210510131357.17170-9-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> References: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: pBhn6rQQRbo7zmIX2dIo2I7yiXMdH92A X-Proofpoint-ORIG-GUID: pBhn6rQQRbo7zmIX2dIo2I7yiXMdH92A X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 spamscore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 adultscore=0 impostorscore=0 malwarescore=0 mlxscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105100092 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, patches@opensource.cirrus.com, lgirdwood@gmail.com, james.schulman@cirrus.com, david.rhodes@cirrus.com 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" Correct some unchecked re-allocations of ret whilst reading the device ID and ensure the hardware state is returned to off on the error paths. Reported-by: Pierre-Louis Bossart Signed-off-by: Charles Keepax --- sound/soc/codecs/cs42l73.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/sound/soc/codecs/cs42l73.c b/sound/soc/codecs/cs42l73.c index c3f974ec78e58..da5d77a5f55bb 100644 --- a/sound/soc/codecs/cs42l73.c +++ b/sound/soc/codecs/cs42l73.c @@ -27,6 +27,7 @@ #include #include #include "cs42l73.h" +#include "cirrus_legacy.h" struct sp_config { u8 spc, mmcc, spfs; @@ -1275,8 +1276,7 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, { struct cs42l73_private *cs42l73; struct cs42l73_platform_data *pdata = dev_get_platdata(&i2c_client->dev); - int ret; - unsigned int devid = 0; + int ret, devid; unsigned int reg; u32 val32; @@ -1326,27 +1326,25 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, } /* initialize codec */ - ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_AB, ®); - devid = (reg & 0xFF) << 12; - - ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_CD, ®); - devid |= (reg & 0xFF) << 4; - - ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_E, ®); - devid |= (reg & 0xF0) >> 4; + devid = cirrus_read_device_id(cs42l73->regmap, CS42L73_DEVID_AB); + if (devid < 0) { + ret = devid; + dev_err(&i2c_client->dev, "Failed to read device ID: %d\n", ret); + goto err_reset; + } if (devid != CS42L73_DEVID) { ret = -ENODEV; dev_err(&i2c_client->dev, "CS42L73 Device ID (%X). Expected %X\n", devid, CS42L73_DEVID); - return ret; + goto err_reset; } ret = regmap_read(cs42l73->regmap, CS42L73_REVID, ®); if (ret < 0) { dev_err(&i2c_client->dev, "Get Revision ID failed\n"); - return ret; + goto err_reset; } dev_info(&i2c_client->dev, @@ -1356,8 +1354,14 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, &soc_component_dev_cs42l73, cs42l73_dai, ARRAY_SIZE(cs42l73_dai)); if (ret < 0) - return ret; + goto err_reset; + return 0; + +err_reset: + gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 0); + + return ret; } static const struct of_device_id cs42l73_of_match[] = { From patchwork Mon May 10 13:13:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 12248029 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 16188C433ED for ; Mon, 10 May 2021 13:17:23 +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 16ACA61288 for ; Mon, 10 May 2021 13:17:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 16ACA61288 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=opensource.cirrus.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 5E6DF16F6; Mon, 10 May 2021 15:16:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5E6DF16F6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1620652640; bh=abYkNbhWBX/6Ft2BC5isoCGB408Z/HMlR65KnWXVECc=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=MiHppHjBbeRLShHSnCyDy+pDVnkj15kRLoDbtgpQ4XReHUmvJqwyqfEnEIqnLLuLM /R9cSmW4HMPS9GlzYuMBhyyhktM3lbsA58/kPpNm0K0TJoic/UvO8VgWGCw5wGJaK7 Dmjaaxhjgf+ExFkLbpAQqMEoUB1T0DTPnYYXcDT8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DDC32F804AD; Mon, 10 May 2021 15:14:21 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 81F8CF804AA; Mon, 10 May 2021 15:14:17 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 A90BDF8026B for ; Mon, 10 May 2021 15:14:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A90BDF8026B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="o5I2RIwP" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14ADD5cm017163; Mon, 10 May 2021 08:14:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=r7eYzA13Ft00iVsiic/B2GqdlgN6ba/ZNQlvRcKiZas=; b=o5I2RIwPZyOXmrUROE96PJ7+nncoKffILQuHPaCDyrfHDc/lHoSSUqqP2kOnmbYFFyrg +9gZdZwk1Jd7XYFqDI4Bt0OeURkZL51qj96wq/qKO3IHAaukr2iyCXoix1cv56/2sjxc iAx+SLOAB5r8FozA0PIq4kv9C9nqOLGzGWz9FH/XExOx52NdvsgVbqfpgzLUU6hIX9tN 6iZ5tNPKfYlxRXS90mvg9uNY7uAW18iaELY95hu3Av8SwT+zl+ZATsIK3C/yHEdeKme/ 90lSF7Qh/+fnsO2koCgrzofQUuJkwiw5PBrxxNvsJADj1gPHQbXIyQAukjGyblO/kI5W Zg== Received: from ediex02.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 38f4x181h2-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 10 May 2021 08:14:01 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 10 May 2021 14:13:58 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Mon, 10 May 2021 14:13:58 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 05E3411D8; Mon, 10 May 2021 13:13:58 +0000 (UTC) From: Charles Keepax To: Subject: [PATCH 09/10] ASoC: cs43130: Minor error paths fixups Date: Mon, 10 May 2021 14:13:56 +0100 Message-ID: <20210510131357.17170-10-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> References: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: E5kQsicilk4R7Pktnw_vUtnZiYph7fya X-Proofpoint-ORIG-GUID: E5kQsicilk4R7Pktnw_vUtnZiYph7fya X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 bulkscore=0 mlxscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105100092 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, patches@opensource.cirrus.com, lgirdwood@gmail.com, james.schulman@cirrus.com, david.rhodes@cirrus.com 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" Correct some unchecked re-allocations of ret whilst reading the device ID and ensure the hardware state is returned to off on the error paths. Reported-by: Pierre-Louis Bossart Signed-off-by: Charles Keepax --- sound/soc/codecs/cs43130.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/sound/soc/codecs/cs43130.c b/sound/soc/codecs/cs43130.c index 80bc7c10ed757..642338cdc8b65 100644 --- a/sound/soc/codecs/cs43130.c +++ b/sound/soc/codecs/cs43130.c @@ -36,6 +36,7 @@ #include #include "cs43130.h" +#include "cirrus_legacy.h" static const struct reg_default cs43130_reg_defaults[] = { {CS43130_SYS_CLK_CTL_1, 0x06}, @@ -2424,9 +2425,8 @@ static int cs43130_i2c_probe(struct i2c_client *client, { struct cs43130_private *cs43130; int ret; - unsigned int devid = 0; unsigned int reg; - int i; + int i, devid; cs43130 = devm_kzalloc(&client->dev, sizeof(*cs43130), GFP_KERNEL); if (!cs43130) @@ -2464,20 +2464,21 @@ static int cs43130_i2c_probe(struct i2c_client *client, cs43130->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_LOW); - if (IS_ERR(cs43130->reset_gpio)) - return PTR_ERR(cs43130->reset_gpio); + if (IS_ERR(cs43130->reset_gpio)) { + ret = PTR_ERR(cs43130->reset_gpio); + goto err_supplies; + } gpiod_set_value_cansleep(cs43130->reset_gpio, 1); usleep_range(2000, 2050); - ret = regmap_read(cs43130->regmap, CS43130_DEVID_AB, ®); - - devid = (reg & 0xFF) << 12; - ret = regmap_read(cs43130->regmap, CS43130_DEVID_CD, ®); - devid |= (reg & 0xFF) << 4; - ret = regmap_read(cs43130->regmap, CS43130_DEVID_E, ®); - devid |= (reg & 0xF0) >> 4; + devid = cirrus_read_device_id(cs43130->regmap, CS43130_DEVID_AB); + if (devid < 0) { + ret = devid; + dev_err(&client->dev, "Failed to read device ID: %d\n", ret); + goto err; + } switch (devid) { case CS43130_CHIP_ID: @@ -2517,7 +2518,7 @@ static int cs43130_i2c_probe(struct i2c_client *client, "cs43130", cs43130); if (ret != 0) { dev_err(&client->dev, "Failed to request IRQ: %d\n", ret); - return ret; + goto err; } cs43130->mclk_int_src = CS43130_MCLK_SRC_RCO; @@ -2576,7 +2577,13 @@ static int cs43130_i2c_probe(struct i2c_client *client, CS43130_XSP_3ST_MASK, 0); return 0; + err: + gpiod_set_value_cansleep(cs43130->reset_gpio, 0); +err_supplies: + regulator_bulk_disable(ARRAY_SIZE(cs43130->supplies), + cs43130->supplies); + return ret; } From patchwork Mon May 10 13:13:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 12248031 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 A4A15C433ED for ; Mon, 10 May 2021 13:17:28 +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 A43FB611CA for ; Mon, 10 May 2021 13:17:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A43FB611CA Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=opensource.cirrus.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 06C221708; Mon, 10 May 2021 15:16:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 06C221708 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1620652646; bh=LoTQ3anNESH+pX9p7sHd8H8pOlo8fXuk/UJqPNc8A60=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=PommZWczhleYhsLVBtHb/WWm0jJJ/vs0VIKJOHi/qP+mCZLinSuoiJOBLaIrGUG85 YdVfrCG98mZe+Nvvd9H3I3qNyZBios8pktDBcc8CELNfclYJul0FLs/LPjNfKyadEt WxtzuWhfRM6g6WFTGpl1OexNc3eImhUBcVx2tiao= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B9FD8F804AE; Mon, 10 May 2021 15:14:22 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DA8F5F804AB; Mon, 10 May 2021 15:14:18 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 6C4E5F8027B for ; Mon, 10 May 2021 15:14:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6C4E5F8027B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="nusHwKGh" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14ADD5cn017163; Mon, 10 May 2021 08:14:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=2GV0e3MQBso7VhdrVpeKzynt1wO2jiTI64fXkLTZiwg=; b=nusHwKGhDtcaCoWWi6gIoNjUhPmEMNvyej8umXBvHbKZU5yzgDQ6loU4PLNnRCONOjHc 9EhTXvHaNB1GE2chTz7bA6uip+ZjlG4M5/LHyh6mDzD9Wm/x1gNjt8bZplTXxK7j5i9i 01oL7fst2rTPNS1ogAnD/4M+eKMKhsqIPbWaCVb7aIqA0mznsDhDSV53+xFyjnHkw4Un NbvDRc5LdAAL64ZtP0brZyO7Mr8AkQhF5la3gncJePMV1tIpE8EGnWm5L2HvF+W6/cx5 FF53YnbQp8PZdkQ7BtwqCMZjqe52rAFUlrMqhEK5VgrPVhn080pSGdjpj/t63un/wU1v Qw== Received: from ediex02.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 38f4x181h2-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 10 May 2021 08:14:02 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 10 May 2021 14:13:58 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Mon, 10 May 2021 14:13:58 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 13C1B11CF; Mon, 10 May 2021 13:13:58 +0000 (UTC) From: Charles Keepax To: Subject: [PATCH 10/10] ASoC: cs53l30: Minor error paths fixups Date: Mon, 10 May 2021 14:13:57 +0100 Message-ID: <20210510131357.17170-11-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> References: <20210510131357.17170-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: dcUBSC67Uuh9xZYgJyiYJuRUvtnVYZZr X-Proofpoint-ORIG-GUID: dcUBSC67Uuh9xZYgJyiYJuRUvtnVYZZr X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 bulkscore=0 mlxscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105100092 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, patches@opensource.cirrus.com, lgirdwood@gmail.com, james.schulman@cirrus.com, david.rhodes@cirrus.com 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" Correct some unchecked re-allocations of ret whilst reading the device ID and ensure the hardware state is returned to off on the error paths. Reported-by: Pierre-Louis Bossart Signed-off-by: Charles Keepax --- sound/soc/codecs/cs53l30.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sound/soc/codecs/cs53l30.c b/sound/soc/codecs/cs53l30.c index 3d67cbf9eaaa2..bd33dd048c7ce 100644 --- a/sound/soc/codecs/cs53l30.c +++ b/sound/soc/codecs/cs53l30.c @@ -20,6 +20,7 @@ #include #include "cs53l30.h" +#include "cirrus_legacy.h" #define CS53L30_NUM_SUPPLIES 2 static const char *const cs53l30_supply_names[CS53L30_NUM_SUPPLIES] = { @@ -920,9 +921,8 @@ static int cs53l30_i2c_probe(struct i2c_client *client, const struct device_node *np = client->dev.of_node; struct device *dev = &client->dev; struct cs53l30_private *cs53l30; - unsigned int devid = 0; unsigned int reg; - int ret = 0, i; + int ret = 0, i, devid; u8 val; cs53l30 = devm_kzalloc(dev, sizeof(*cs53l30), GFP_KERNEL); @@ -951,7 +951,7 @@ static int cs53l30_i2c_probe(struct i2c_client *client, GPIOD_OUT_LOW); if (IS_ERR(cs53l30->reset_gpio)) { ret = PTR_ERR(cs53l30->reset_gpio); - goto error; + goto error_supplies; } gpiod_set_value_cansleep(cs53l30->reset_gpio, 1); @@ -968,14 +968,12 @@ static int cs53l30_i2c_probe(struct i2c_client *client, } /* Initialize codec */ - ret = regmap_read(cs53l30->regmap, CS53L30_DEVID_AB, ®); - devid = reg << 12; - - ret = regmap_read(cs53l30->regmap, CS53L30_DEVID_CD, ®); - devid |= reg << 4; - - ret = regmap_read(cs53l30->regmap, CS53L30_DEVID_E, ®); - devid |= (reg & 0xF0) >> 4; + devid = cirrus_read_device_id(cs53l30->regmap, CS53L30_DEVID_AB); + if (devid < 0) { + ret = devid; + dev_err(dev, "Failed to read device ID: %d\n", ret); + goto error; + } if (devid != CS53L30_DEVID) { ret = -ENODEV; @@ -1037,6 +1035,8 @@ static int cs53l30_i2c_probe(struct i2c_client *client, return 0; error: + gpiod_set_value_cansleep(cs53l30->reset_gpio, 0); +error_supplies: regulator_bulk_disable(ARRAY_SIZE(cs53l30->supplies), cs53l30->supplies); return ret;