From nobody Sun Feb 8 16:45:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB41AEC8743 for ; Thu, 7 Sep 2023 17:11:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241573AbjIGRLn (ORCPT ); Thu, 7 Sep 2023 13:11:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230319AbjIGRLj (ORCPT ); Thu, 7 Sep 2023 13:11:39 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E3A91FC2 for ; Thu, 7 Sep 2023 10:11:13 -0700 (PDT) Received: from localhost (unknown [81.18.92.207]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id CFC7466072E5; Thu, 7 Sep 2023 18:10:20 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694106621; bh=LTYQlpYjRWHhuzVTDClSJzTinidzBZZBJA3f8dy37pI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E3FAUF13OSTk1RLs/CeCermnjqevCEIh9qWcOU6CTBhA2Diwt80nW3OLY+wcNeta/ KXRJhZDKaAA/mkDgz3zFMYDXVVys8b/wAAG3PvsJEiyrQ60082aW4vnKySPNU1Hqg8 DWAwMs4kHlVs4t7gxXkxnBIpBRfMwefUPm/ML9LeWpwxY/oIKreIm3e/VWXXEm65Bx mvOasm+2UYtDIToSSL0Gq0oYcSDApcrYuOlCHGf0vk3HLhNmRryd3I0V+qLKANisOn lYlnliflUAhmuZW1TnkmC3g7ecPpQywNDfgqMMd5Zl4akcc3NW2ca526MaJeq4ejTV 90tdf9cBV66cg== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax , Vitaly Rodionov Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v2 02/11] ASoC: cs35l41: Handle mdsync_up reg write errors Date: Thu, 7 Sep 2023 20:10:01 +0300 Message-ID: <20230907171010.1447274-3-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> References: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The return code of regmap_multi_reg_write() call related to "MDSYNC up" sequence is shadowed by the subsequent regmap_read_poll_timeout() invocation, which will hit a timeout in case the write operation above fails. Make sure cs35l41_global_enable() returns the correct error code instead of -ETIMEDOUT. Additionally, to be able to distinguish between the timeouts of wait_for_completion_timeout() and regmap_read_poll_timeout(), print an error message for the former and return immediately. This also avoids having to wait unnecessarily for the second time. Fixes: f8264c759208 ("ALSA: cs35l41: Poll for Power Up/Down rather than wai= ting a fixed delay") Signed-off-by: Cristian Ciocaltea Acked-by: Charles Keepax --- sound/soc/codecs/cs35l41-lib.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sound/soc/codecs/cs35l41-lib.c b/sound/soc/codecs/cs35l41-lib.c index a018f1d98428..a6c6bb23b957 100644 --- a/sound/soc/codecs/cs35l41-lib.c +++ b/sound/soc/codecs/cs35l41-lib.c @@ -1251,15 +1251,18 @@ int cs35l41_global_enable(struct device *dev, struc= t regmap *regmap, enum cs35l4 =20 ret =3D wait_for_completion_timeout(pll_lock, msecs_to_jiffies(1000)); if (ret =3D=3D 0) { - ret =3D -ETIMEDOUT; - } else { - regmap_read(regmap, CS35L41_PWR_CTRL3, &pwr_ctrl3); - pwr_ctrl3 |=3D CS35L41_SYNC_EN_MASK; - cs35l41_mdsync_up_seq[0].def =3D pwr_ctrl3; - ret =3D regmap_multi_reg_write(regmap, cs35l41_mdsync_up_seq, - ARRAY_SIZE(cs35l41_mdsync_up_seq)); + dev_err(dev, "Timed out waiting for pll_lock\n"); + return -ETIMEDOUT; } =20 + regmap_read(regmap, CS35L41_PWR_CTRL3, &pwr_ctrl3); + pwr_ctrl3 |=3D CS35L41_SYNC_EN_MASK; + cs35l41_mdsync_up_seq[0].def =3D pwr_ctrl3; + ret =3D regmap_multi_reg_write(regmap, cs35l41_mdsync_up_seq, + ARRAY_SIZE(cs35l41_mdsync_up_seq)); + if (ret) + return ret; + ret =3D regmap_read_poll_timeout(regmap, CS35L41_IRQ1_STATUS1, int_status, int_status & pup_pdn_mask, 1000, 100000); --=20 2.41.0