Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp803754rwn; Thu, 8 Sep 2022 09:01:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR48nU+6mt5Q1KPlMbJxvpmEghUBc7nbFbk3sAYZ1vJmwHiawRjKCeoMs4iY9GuM/hq6eYE2 X-Received: by 2002:a17:902:c94d:b0:16d:c10a:650e with SMTP id i13-20020a170902c94d00b0016dc10a650emr9347105pla.29.1662652869768; Thu, 08 Sep 2022 09:01:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662652869; cv=none; d=google.com; s=arc-20160816; b=g5zrBFojDD1gQoibBQ1eTOD86kEIXddz/yDE3eBjruAUXw9GQDuuEHn2nVoAfqczjN wbdxrKrTkseHLv+EpaUdZ31s4DqzlwkKrJoECws1sQ6kur5FP09DVpNzNolWd9Dv66L6 b9BHZlt6V9FVu9ppyEYz4v6aUr+lJ3FcYf5LTpAzkvtGzG+fh9Bz9vK5g+qXrwWsIf8e uTKn+4ZWTtoeaUal4AXiqsJ/NW13bYQQkvA/Lj01KXCjG4/OYCv0DM75RAkiAZ2DOpHY 0SHR7KoQqcq0JJ8/48J5UIRGjxYXehGa1cv40RWRjQs9QQd5+/E+kDUhdBcUqtUXsfN9 y4GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=evICa2gP1OZP3o4uj2q6UUkKvForG1fKNpFXQceaCWU=; b=cYMdtbapXZ2MlTISytg3ubk6Pu+8x/3FpW7DstvZ8NtF4I4WaMv8dfXVy4Qxj5sR/i XmnxsWJqyncpbIR0ngAGgnpHjQ3ljZbkkc2rP4TkGZgOXowXrxtqeXU7czge4TqXYfHp 6FJxQvijNz3bxXNwoWt9F0B9JZIPhAd80NsgAOvntbfOIcS4ydzVDUz899LnfV+/PtHH /d+upZ6OCqV01W8U23Xc6wcAbOjOHjmSdqX/tNTsN9yRE1kdQlfXXYzDraI0uZ0FE4hV LEu3hc32/7frUiOrHXztoWaiCSLUnHf45MSzfZpk1kLtw/xgNhpCc2MQbr36wcvGTFOR F5rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EqmtlG1E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z15-20020a655a4f000000b00434dbbc86f1si7727730pgs.835.2022.09.08.09.00.54; Thu, 08 Sep 2022 09:01:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EqmtlG1E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232873AbiIHPLy (ORCPT + 99 others); Thu, 8 Sep 2022 11:11:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232620AbiIHPLw (ORCPT ); Thu, 8 Sep 2022 11:11:52 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58C7913B13D for ; Thu, 8 Sep 2022 08:11:50 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id j6-20020a17090a694600b00200bba67dadso2767358pjm.5 for ; Thu, 08 Sep 2022 08:11:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=evICa2gP1OZP3o4uj2q6UUkKvForG1fKNpFXQceaCWU=; b=EqmtlG1EAApXEHPAJtRBAEY3KRn2qNipV7J7wV23a7+9xkZs61Aozim+Aj5IpshuOL RTvka8w/TCO9lBxh7znsR6pIpfOZv+a2P4ITvHmeV/Kq31miqSqcHlha/9ZVtniOdKmT ky5+rrH1c5YDZVrEZFER1XpuSN1YyZ2LKagyU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=evICa2gP1OZP3o4uj2q6UUkKvForG1fKNpFXQceaCWU=; b=1x8mk+hCMTLApsnTq7EKQV3+YbzcA+fqSeGCKK3xD+rczve2Y8o2eGNFZ432XXu4E+ jAI9Kede/wr0BNLcrcyeVSA8kwYEB7AiWwqTLyAC6fiuT7lS3oJui+28J0Ozs0zE++UV IGfH0K+/2SS5mryq2sbK3SniMliM4f3DdoijStcf8UqQd1jH3TDxC4p8EuPwrnmZYZm7 JIWAlzATWVG3Nm0K3lO3SWudAbjLGH3j9RMTiBncogo59fBesFb6L+xbKVa2HcuBxLyc CdH40srtBAi/TlJHCrA1pOs1fL+O6NDtCW8QhJEx56CELbyXr0rt96kEW5Fjmy8dbfWg id6Q== X-Gm-Message-State: ACgBeo370iLlV0lR58IoV8xPmRVCLikQm/yRQUTTDDaUvDaI2iRyAd1n UD+A7q7hPrM9T3GE8dby5yMWrQ== X-Received: by 2002:a17:90a:df13:b0:200:ae8c:700c with SMTP id gp19-20020a17090adf1300b00200ae8c700cmr4784872pjb.203.1662649909840; Thu, 08 Sep 2022 08:11:49 -0700 (PDT) Received: from judyhsiao0523.c.googlers.com.com (21.160.199.104.bc.googleusercontent.com. [104.199.160.21]) by smtp.gmail.com with ESMTPSA id e16-20020aa798d0000000b005360da6b26bsm14892692pfm.159.2022.09.08.08.11.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Sep 2022 08:11:49 -0700 (PDT) From: Judy Hsiao To: Liam Girdwood Cc: Mark Brown , Brian Norris , Jaroslav Kysela , Takashi Iwai , Chen-Yu Tsai , alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Judy Hsiao Subject: [PATCH v1] ASoC: rockchip: i2s: use regmap_read_poll_timeout to poll I2S_CLR Date: Thu, 8 Sep 2022 15:11:42 +0000 Message-Id: <20220908151142.1479810-1-judyhsiao@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use regmap_read_poll_timeout to poll I2S_CLR. It also fixes the 'rockchip-i2s ff070000.i2s; fail to clear' and return -EBUSY 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 --- sound/soc/rockchip/rockchip_i2s.c | 39 +++++++++++++------------------ 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index f5f3540a9e18..02905eec615e 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -163,18 +163,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 = -EBUSY; - break; - } - } + ret = regmap_read_poll_timeout(i2s->regmap, + I2S_CLR, + val, + val != 0, + 20, + 200); + if (ret < 0) + dev_warn(i2s->dev, "fail to clear\n"); } } end: @@ -226,17 +222,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 = -EBUSY; - break; - } - } + ret = regmap_read_poll_timeout(i2s->regmap, + I2S_CLR, + val, + val != 0, + 20, + 200); + if (ret < 0) + dev_warn(i2s->dev, "fail to clear\n"); } } end: -- 2.37.2.789.g6183377224-goog