From nobody Sun Oct 19 06:08:23 2025 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 5E36AC433FE for ; Wed, 19 Oct 2022 09:05:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232384AbiJSJFx (ORCPT ); Wed, 19 Oct 2022 05:05:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232416AbiJSJEN (ORCPT ); Wed, 19 Oct 2022 05:04:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBA15A8352; Wed, 19 Oct 2022 01:57:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 904FF61851; Wed, 19 Oct 2022 08:55:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A13DDC433C1; Wed, 19 Oct 2022 08:55:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169735; bh=goNWUmtCyQy3LmAC5CpO9eeEFfx49WATQu4/du69dXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aJFgXf7OQHapWD5XcM5TNpKGH4ozFCHsbkmvIgTxJEvytG+6Zkau0uF5qqLHAP53S /OwPER1Y+icsXwbHhB3En84b0sN8CGh0q3w0TqBoHF68CPihS1vHYqTXl9jfFRAmeB DaP4hwpYsosMlcYVPLnXYK9fe6y13z6LsMEFETyQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Judy Hsiao , Brian Norris , Mark Brown , Sasha Levin Subject: [PATCH 6.0 389/862] ASoC: rockchip: i2s: use regmap_read_poll_timeout to poll I2S_CLR Date: Wed, 19 Oct 2022 10:27:56 +0200 Message-Id: <20221019083307.129986122@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 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" From: Judy Hsiao [ Upstream commit fbb0ec656ee5ee43b4b3022fd8290707265c52df ] Use regmap_read_poll_timeout to poll I2S_CLR. It also fixes the 'rockchip-i2s ff070000.i2s; fail to clear' when the read of I2S_CLR exceeds the retry limit. Fixes: 0ff9f8b9f592 ("ASoC: rockchip: i2s: Fix error code when fail to read= I2S_CLR") Signed-off-by: Judy Hsiao Reviewed-by: Brian Norris Link: https://lore.kernel.org/r/20220914031234.2250298-1-judyhsiao@chromium= .org Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/rockchip/rockchip_i2s.c | 41 ++++++++++++------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchi= p_i2s.c index f5f3540a9e18..28c86f5e435e 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -126,7 +126,6 @@ static inline struct rk_i2s_dev *to_info(struct snd_soc= _dai *dai) static int rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on) { unsigned int val =3D 0; - int retry =3D 10; int ret =3D 0; =20 spin_lock(&i2s->lock); @@ -163,18 +162,14 @@ static int rockchip_snd_txctrl(struct rk_i2s_dev *i2s= , int on) I2S_CLR_TXC | I2S_CLR_RXC); if (ret < 0) goto end; - regmap_read(i2s->regmap, I2S_CLR, &val); - - /* Should wait for clear operation to finish */ - while (val) { - regmap_read(i2s->regmap, I2S_CLR, &val); - retry--; - if (!retry) { - dev_warn(i2s->dev, "fail to clear\n"); - ret =3D -EBUSY; - break; - } - } + ret =3D regmap_read_poll_timeout(i2s->regmap, + I2S_CLR, + val, + val !=3D 0, + 20, + 200); + if (ret < 0) + dev_warn(i2s->dev, "fail to clear: %d\n", ret); } } end: @@ -188,7 +183,6 @@ static int rockchip_snd_txctrl(struct rk_i2s_dev *i2s, = int on) static int rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on) { unsigned int val =3D 0; - int retry =3D 10; int ret =3D 0; =20 spin_lock(&i2s->lock); @@ -226,17 +220,14 @@ static int rockchip_snd_rxctrl(struct rk_i2s_dev *i2s= , int on) I2S_CLR_TXC | I2S_CLR_RXC); if (ret < 0) goto end; - regmap_read(i2s->regmap, I2S_CLR, &val); - /* Should wait for clear operation to finish */ - while (val) { - regmap_read(i2s->regmap, I2S_CLR, &val); - retry--; - if (!retry) { - dev_warn(i2s->dev, "fail to clear\n"); - ret =3D -EBUSY; - break; - } - } + ret =3D regmap_read_poll_timeout(i2s->regmap, + I2S_CLR, + val, + val !=3D 0, + 20, + 200); + if (ret < 0) + dev_warn(i2s->dev, "fail to clear: %d\n", ret); } } end: --=20 2.35.1