Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp10384129pxu; Wed, 30 Dec 2020 00:48:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrb4oobUi2Rqwn9zwhAtgi4tlaDviShuVtktCGr2dJd3qr7le130UBtBBUbj7jYRBR30/N X-Received: by 2002:aa7:d906:: with SMTP id a6mr49859793edr.121.1609318091307; Wed, 30 Dec 2020 00:48:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609318091; cv=none; d=google.com; s=arc-20160816; b=T6xtNL+dhXSv3sJAp8Z/gGuNgBoI97RvHmAPWP9m/2CD5jVzywb32X8W5KTl56Pkv0 jTI07L2eVdz7lh77LnwcOtvfXiOMH8KA7zeQiAAsGz7ahxIMh/oI3hKjls+r2qzLS2G5 Av16kHjkPM4d3YELgYibjDVpL6KAqHGBp8cKmY5R9f+YXb6EcHKcB4NAocBlYoaDNLm+ up3+ZbCYsm75Af5HPp57qkAzQ1zHLx8N5y3A6kgIVfzo//9YcDjp2dIJZuUvxfqB+EbK m+Hi7eMhrcrbBKV7eBDur3a+F4hplvHiLiTRBDpk65WAWuNfF2ldNKTDpupvmg54M/Mw nL9w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=3R1ERgmNM3qK7KpEODo6HssfIHGCLC3Ma42HKg1BwbI=; b=VdZjwLR9nF2otmQ4Rbm+MIvfW0XBxyflQu0SB9QyRvwqgwM5ZSpDYEZ5SWyIdLonmU cA4W8dtJDxYqSVVtHYF/ujmjyZXSLaYqBdsqawWCXvfVleplIfSTFkG9HNIKrMa4lpR6 qAPu+O3r5iN8JlKTlV41kE/WyzbqZa+FB9EBoEE7Q5KsqJJNs3m4rxboDai2rFuy3693 VXkE/bQw6OCR7epkhnB2DOiREucrJ7QxlWrbsTLk+Rv+HPFvu2tJ2a2RF+ohPcHyXswl qzozbq1NXBhAisgy6XUK6bW8aI6EqLxHryQXzlcyYElLgCx+8jUngi1bW+141doB719+ Bm0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c3si23383837eds.266.2020.12.30.00.47.49; Wed, 30 Dec 2020 00:48:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726429AbgL3Ioh (ORCPT + 99 others); Wed, 30 Dec 2020 03:44:37 -0500 Received: from muru.com ([72.249.23.125]:40518 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726350AbgL3Iog (ORCPT ); Wed, 30 Dec 2020 03:44:36 -0500 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 00282812F; Wed, 30 Dec 2020 08:44:07 +0000 (UTC) From: Tony Lindgren To: Amit Kucheria , Daniel Lezcano , Zhang Rui Cc: Eduardo Valentin , Keerthy , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, Adam Ford , Carl Philipp Klemm , Merlijn Wajer , Pavel Machek , Peter Ujfalusi , Sebastian Reichel Subject: [PATCH 2/3] thermal: ti-soc-thermal: Simplify polling with iopoll Date: Wed, 30 Dec 2020 10:43:37 +0200 Message-Id: <20201230084338.19410-2-tony@atomide.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201230084338.19410-1-tony@atomide.com> References: <20201230084338.19410-1-tony@atomide.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We can use iopoll for checking the EOCZ (end of conversion) bit. Cc: Adam Ford Cc: Carl Philipp Klemm Cc: Eduardo Valentin Cc: Merlijn Wajer Cc: Pavel Machek Cc: Peter Ujfalusi Cc: Sebastian Reichel Signed-off-by: Tony Lindgren --- drivers/thermal/ti-soc-thermal/ti-bandgap.c | 30 ++++++++++----------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -27,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -603,8 +603,9 @@ void *ti_bandgap_get_sensor_data(struct ti_bandgap *bgp, int id) static int ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id) { - u32 counter = 1000; struct temp_sensor_registers *tsr; + int error; + u32 val; /* Select continuous or single conversion mode */ if (TI_BANDGAP_HAS(bgp, CONT_MODE_ONLY)) @@ -615,27 +616,24 @@ ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id) /* Start of Conversion = 1 */ RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 1); - /* Wait for EOCZ going up */ tsr = bgp->conf->sensors[id].registers; - while (--counter) { - if (ti_bandgap_readl(bgp, tsr->temp_sensor_ctrl) & - tsr->bgap_eocz_mask) - break; - udelay(1); - } + /* Wait for EOCZ going up */ + error = readl_poll_timeout_atomic(bgp->base + tsr->temp_sensor_ctrl, + val, val & tsr->bgap_eocz_mask, + 1, 1000); + if (error) + dev_warn(bgp->dev, "eocz timed out waiting high\n"); /* Start of Conversion = 0 */ RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 0); /* Wait for EOCZ going down */ - counter = 1000; - while (--counter) { - if (!(ti_bandgap_readl(bgp, tsr->temp_sensor_ctrl) & - tsr->bgap_eocz_mask)) - break; - udelay(1); - } + error = readl_poll_timeout_atomic(bgp->base + tsr->temp_sensor_ctrl, + val, !(val & tsr->bgap_eocz_mask), + 1, 1000); + if (error) + dev_warn(bgp->dev, "eocz timed out waiting low\n"); return 0; } -- 2.29.2