Message ID | 20231117154037.67676-1-mstrozek@opensource.cirrus.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp619253vqn; Fri, 17 Nov 2023 07:42:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHJ2UUWncUT82IXzer9QkSLSF6hY0bRGTVyvloIoNLLDscF+H0Oa/LhIvGOtDo5gYLDwgC X-Received: by 2002:a05:6808:2208:b0:3ae:3d0:d74a with SMTP id bd8-20020a056808220800b003ae03d0d74amr29281490oib.52.1700235757727; Fri, 17 Nov 2023 07:42:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700235757; cv=none; d=google.com; s=arc-20160816; b=mBD0xSxfydK9DXlmsZmoYuvhf/FNzgRUt1M1DG8t6LiCVIKiPSfNvZxvNWKu4EH3qh UQvyJbbzpON/KwseaNDkS2cXdYOzq+/hWWlLQ2v28ful788E9Nw5X6GiyZPl6tBsMp/6 OAdWWWXrV1y0Wpa0bUQwteuzbpf+pZEan9VV9dTg0nS1R2VTXorXMjh+HXpFCEoCrZbc +rklxO/lwBkMW0Q7t3UHZVemXHECObr0Io6iaH4f1B53u2s/fMwx/hYLzS5Z5cEP+jQM Ph4ugvAEHP1TYm+1xnQg2ByWp3NRSrhSIsy5zO9AeHgzZ5eF14A/RaeBf5b5yGy16fW8 iy8w== 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=jMxjx8uYfygMEBvu13m8vNG/QwpnvhsuVDVBW53JuLQ=; fh=LYuJYGf9YNBY7QtU4l6y1MQLI+egsdpqtFlsxQi1uB8=; b=s0OIpeSZkjdTJll5sqLFFuANg8pjPu7hD2RnfY4UIl3ED4GkHrCRCTBI2MN/+JMH/q /zgcVlw7XGPu0b7pjctg8L6zMFkGeJu8wtwn9CkT8UDGLIfpIjDCWgZXhNGQfNDfUrWV 09bQ/r0vURkXXWIiCs1rCnJHGjhE2vnvutqS1mwWiCqhD+49HUERAQl/knRVnxOxyHuK lNIZA4jVLxRARZ1FmwfJBL9/oAzJGqOEhzM7ww3a21wii1ogD9/SxealO+AWRloTBRvY DrcXYvEQLMOgpHIG6v/nxvAwHebVNgRT+jArPZQrOwt99GFvhPNeN1Y3KbDwrlVempdx iGag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=NFND+pwk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id 199-20020a6300d0000000b0059f0cebd046si2055136pga.729.2023.11.17.07.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 07:42:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=NFND+pwk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id B87DE8086819; Fri, 17 Nov 2023 07:42:34 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346064AbjKQPlO (ORCPT <rfc822;jaysivo@gmail.com> + 30 others); Fri, 17 Nov 2023 10:41:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346152AbjKQPk6 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 17 Nov 2023 10:40:58 -0500 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1088819A9 for <linux-kernel@vger.kernel.org>; Fri, 17 Nov 2023 07:40:43 -0800 (PST) Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 3AH8U57Q031440; Fri, 17 Nov 2023 09:40:41 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=PODMain02222019; bh=j Mxjx8uYfygMEBvu13m8vNG/QwpnvhsuVDVBW53JuLQ=; b=NFND+pwkfQaGCHEDg hEL3kuAwf0maHl/alm6givWDqRrHHsC+8tsASAjAL3frbGHu8/dqTj5JDp5vJCtk ucWawa/gUoNS+oTrWWF27Io6Kjn3s8AeNcZ12jf9IfDSo36FKlJyiH94OY0j7neZ 2GiENXm/O7YnWPtQXernuM8e9GDEzH470hI/76gFH8pZRIgfqbfvVAfDRLnig++l vzpfEBwSd/jbrRL5iXTbzfjWnZZODTUX0JMiWCFX5GbmVEGo/CduHbRtqPH3Jq0f TdNpgNHvj6eELiSx127YbnEEpohbbQCU/6rs6JpYthbvDTZfnhScSFX34Iwq5Tbo TjdSA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3ua7w2qnn9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Nov 2023 09:40:41 -0600 (CST) 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_256_GCM_SHA384) id 15.2.1118.39; Fri, 17 Nov 2023 15:40:39 +0000 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.2.1118.39 via Frontend Transport; Fri, 17 Nov 2023 15:40:39 +0000 Received: from upx-tgl-008-ubuntu.ad.cirrus.com (upx-tgl-008-ubuntu.ad.cirrus.com [198.90.251.167]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 690F815B9; Fri, 17 Nov 2023 15:40:39 +0000 (UTC) From: Maciej Strozek <mstrozek@opensource.cirrus.com> To: Lee Jones <lee@kernel.org> CC: <patches@opensource.cirrus.com>, <linux-kernel@vger.kernel.org>, "Maciej Strozek" <mstrozek@opensource.cirrus.com> Subject: [PATCH] mfd: wm831x: Remove redundant forever while loop Date: Fri, 17 Nov 2023 15:40:37 +0000 Message-ID: <20231117154037.67676-1-mstrozek@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: Zz1A7v9YFHpkHZtSVefFpphCyF_5_8Hp X-Proofpoint-GUID: Zz1A7v9YFHpkHZtSVefFpphCyF_5_8Hp X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 17 Nov 2023 07:42:34 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782826409926075595 X-GMAIL-MSGID: 1782826409926075595 |
Series |
mfd: wm831x: Remove redundant forever while loop
|
|
Commit Message
Maciej Strozek
Nov. 17, 2023, 3:40 p.m. UTC
Current code excutes only once despite the while loop, so remove the
loop. Also msleep(1) will likely result in a larger sleep, so increase
its value for clarity while keeping the same behaviour.
Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com>
---
drivers/mfd/wm831x-auxadc.c | 46 +++++++++++++++++--------------------
1 file changed, 21 insertions(+), 25 deletions(-)
Comments
On Fri, Nov 17, 2023 at 03:40:37PM +0000, Maciej Strozek wrote: > Current code excutes only once despite the while loop, so remove the > loop. Also msleep(1) will likely result in a larger sleep, so increase > its value for clarity while keeping the same behaviour. > > Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com> > --- Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Thanks, Charles
Hi Maciej,
kernel test robot noticed the following build warnings:
[auto build test WARNING on lee-mfd/for-mfd-next]
[also build test WARNING on lee-leds/for-leds-next lee-mfd/for-mfd-fixes linus/master v6.7-rc1 next-20231117]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Maciej-Strozek/mfd-wm831x-Remove-redundant-forever-while-loop/20231117-234810
base: https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git for-mfd-next
patch link: https://lore.kernel.org/r/20231117154037.67676-1-mstrozek%40opensource.cirrus.com
patch subject: [PATCH] mfd: wm831x: Remove redundant forever while loop
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20231118/202311181257.FLaZt746-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231118/202311181257.FLaZt746-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311181257.FLaZt746-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/mfd/wm831x-auxadc.c: In function 'wm831x_auxadc_read_polled':
>> drivers/mfd/wm831x-auxadc.c:155:23: warning: unused variable 'timeout' [-Wunused-variable]
155 | int ret, src, timeout;
| ^~~~~~~
vim +/timeout +155 drivers/mfd/wm831x-auxadc.c
78bb3688ea1830 Mark Brown 2011-06-07 151
78bb3688ea1830 Mark Brown 2011-06-07 152 static int wm831x_auxadc_read_polled(struct wm831x *wm831x,
78bb3688ea1830 Mark Brown 2011-06-07 153 enum wm831x_auxadc input)
78bb3688ea1830 Mark Brown 2011-06-07 154 {
78bb3688ea1830 Mark Brown 2011-06-07 @155 int ret, src, timeout;
e69b6de181167a Mark Brown 2011-06-02 156
e69b6de181167a Mark Brown 2011-06-02 157 mutex_lock(&wm831x->auxadc_lock);
e69b6de181167a Mark Brown 2011-06-02 158
e69b6de181167a Mark Brown 2011-06-02 159 ret = wm831x_set_bits(wm831x, WM831X_AUXADC_CONTROL,
e69b6de181167a Mark Brown 2011-06-02 160 WM831X_AUX_ENA, WM831X_AUX_ENA);
e69b6de181167a Mark Brown 2011-06-02 161 if (ret < 0) {
e69b6de181167a Mark Brown 2011-06-02 162 dev_err(wm831x->dev, "Failed to enable AUXADC: %d\n", ret);
e69b6de181167a Mark Brown 2011-06-02 163 goto out;
e69b6de181167a Mark Brown 2011-06-02 164 }
e69b6de181167a Mark Brown 2011-06-02 165
e69b6de181167a Mark Brown 2011-06-02 166 /* We force a single source at present */
e69b6de181167a Mark Brown 2011-06-02 167 src = input;
e69b6de181167a Mark Brown 2011-06-02 168 ret = wm831x_reg_write(wm831x, WM831X_AUXADC_SOURCE,
e69b6de181167a Mark Brown 2011-06-02 169 1 << src);
e69b6de181167a Mark Brown 2011-06-02 170 if (ret < 0) {
e69b6de181167a Mark Brown 2011-06-02 171 dev_err(wm831x->dev, "Failed to set AUXADC source: %d\n", ret);
e69b6de181167a Mark Brown 2011-06-02 172 goto out;
e69b6de181167a Mark Brown 2011-06-02 173 }
e69b6de181167a Mark Brown 2011-06-02 174
e69b6de181167a Mark Brown 2011-06-02 175 ret = wm831x_set_bits(wm831x, WM831X_AUXADC_CONTROL,
e69b6de181167a Mark Brown 2011-06-02 176 WM831X_AUX_CVT_ENA, WM831X_AUX_CVT_ENA);
e69b6de181167a Mark Brown 2011-06-02 177 if (ret < 0) {
e69b6de181167a Mark Brown 2011-06-02 178 dev_err(wm831x->dev, "Failed to start AUXADC: %d\n", ret);
e69b6de181167a Mark Brown 2011-06-02 179 goto disable;
e69b6de181167a Mark Brown 2011-06-02 180 }
e69b6de181167a Mark Brown 2011-06-02 181
5e253590978d7f Maciej Strozek 2023-11-17 182 /* If we're not using interrupts then read the
5e253590978d7f Maciej Strozek 2023-11-17 183 * interrupt status register
5e253590978d7f Maciej Strozek 2023-11-17 184 */
5e253590978d7f Maciej Strozek 2023-11-17 185 msleep(20);
e69b6de181167a Mark Brown 2011-06-02 186 ret = wm831x_reg_read(wm831x,
e69b6de181167a Mark Brown 2011-06-02 187 WM831X_INTERRUPT_STATUS_1);
e69b6de181167a Mark Brown 2011-06-02 188 if (ret < 0) {
e69b6de181167a Mark Brown 2011-06-02 189 dev_err(wm831x->dev,
e69b6de181167a Mark Brown 2011-06-02 190 "ISR 1 read failed: %d\n", ret);
e69b6de181167a Mark Brown 2011-06-02 191 goto disable;
e69b6de181167a Mark Brown 2011-06-02 192 }
e69b6de181167a Mark Brown 2011-06-02 193
e69b6de181167a Mark Brown 2011-06-02 194 /* Did it complete? */
e69b6de181167a Mark Brown 2011-06-02 195 if (ret & WM831X_AUXADC_DATA_EINT) {
e69b6de181167a Mark Brown 2011-06-02 196 wm831x_reg_write(wm831x,
e69b6de181167a Mark Brown 2011-06-02 197 WM831X_INTERRUPT_STATUS_1,
e69b6de181167a Mark Brown 2011-06-02 198 WM831X_AUXADC_DATA_EINT);
e69b6de181167a Mark Brown 2011-06-02 199 } else {
e69b6de181167a Mark Brown 2011-06-02 200 dev_err(wm831x->dev,
e69b6de181167a Mark Brown 2011-06-02 201 "AUXADC conversion timeout\n");
e69b6de181167a Mark Brown 2011-06-02 202 ret = -EBUSY;
e69b6de181167a Mark Brown 2011-06-02 203 goto disable;
e69b6de181167a Mark Brown 2011-06-02 204 }
e69b6de181167a Mark Brown 2011-06-02 205
e69b6de181167a Mark Brown 2011-06-02 206 ret = wm831x_reg_read(wm831x, WM831X_AUXADC_DATA);
e69b6de181167a Mark Brown 2011-06-02 207 if (ret < 0) {
e69b6de181167a Mark Brown 2011-06-02 208 dev_err(wm831x->dev,
e69b6de181167a Mark Brown 2011-06-02 209 "Failed to read AUXADC data: %d\n", ret);
e69b6de181167a Mark Brown 2011-06-02 210 goto disable;
e69b6de181167a Mark Brown 2011-06-02 211 }
e69b6de181167a Mark Brown 2011-06-02 212
78bb3688ea1830 Mark Brown 2011-06-07 213 src = ((ret & WM831X_AUX_DATA_SRC_MASK)
e69b6de181167a Mark Brown 2011-06-02 214 >> WM831X_AUX_DATA_SRC_SHIFT) - 1;
e69b6de181167a Mark Brown 2011-06-02 215
e69b6de181167a Mark Brown 2011-06-02 216 if (src == 14)
e69b6de181167a Mark Brown 2011-06-02 217 src = WM831X_AUX_CAL;
e69b6de181167a Mark Brown 2011-06-02 218
e69b6de181167a Mark Brown 2011-06-02 219 if (src != input) {
e69b6de181167a Mark Brown 2011-06-02 220 dev_err(wm831x->dev, "Data from source %d not %d\n",
e69b6de181167a Mark Brown 2011-06-02 221 src, input);
e69b6de181167a Mark Brown 2011-06-02 222 ret = -EINVAL;
e69b6de181167a Mark Brown 2011-06-02 223 } else {
78bb3688ea1830 Mark Brown 2011-06-07 224 ret &= WM831X_AUX_DATA_MASK;
e69b6de181167a Mark Brown 2011-06-02 225 }
e69b6de181167a Mark Brown 2011-06-02 226
e69b6de181167a Mark Brown 2011-06-02 227 disable:
e69b6de181167a Mark Brown 2011-06-02 228 wm831x_set_bits(wm831x, WM831X_AUXADC_CONTROL, WM831X_AUX_ENA, 0);
e69b6de181167a Mark Brown 2011-06-02 229 out:
e69b6de181167a Mark Brown 2011-06-02 230 mutex_unlock(&wm831x->auxadc_lock);
e69b6de181167a Mark Brown 2011-06-02 231 return ret;
e69b6de181167a Mark Brown 2011-06-02 232 }
e69b6de181167a Mark Brown 2011-06-02 233
diff --git a/drivers/mfd/wm831x-auxadc.c b/drivers/mfd/wm831x-auxadc.c index 65b98f3fbd92..49f0ffd68d47 100644 --- a/drivers/mfd/wm831x-auxadc.c +++ b/drivers/mfd/wm831x-auxadc.c @@ -179,32 +179,28 @@ static int wm831x_auxadc_read_polled(struct wm831x *wm831x, goto disable; } - /* If we're not using interrupts then poll the - * interrupt status register */ - timeout = 5; - while (timeout) { - msleep(1); - - ret = wm831x_reg_read(wm831x, - WM831X_INTERRUPT_STATUS_1); - if (ret < 0) { - dev_err(wm831x->dev, - "ISR 1 read failed: %d\n", ret); - goto disable; - } + /* If we're not using interrupts then read the + * interrupt status register + */ + msleep(20); + ret = wm831x_reg_read(wm831x, + WM831X_INTERRUPT_STATUS_1); + if (ret < 0) { + dev_err(wm831x->dev, + "ISR 1 read failed: %d\n", ret); + goto disable; + } - /* Did it complete? */ - if (ret & WM831X_AUXADC_DATA_EINT) { - wm831x_reg_write(wm831x, - WM831X_INTERRUPT_STATUS_1, - WM831X_AUXADC_DATA_EINT); - break; - } else { - dev_err(wm831x->dev, - "AUXADC conversion timeout\n"); - ret = -EBUSY; - goto disable; - } + /* Did it complete? */ + if (ret & WM831X_AUXADC_DATA_EINT) { + wm831x_reg_write(wm831x, + WM831X_INTERRUPT_STATUS_1, + WM831X_AUXADC_DATA_EINT); + } else { + dev_err(wm831x->dev, + "AUXADC conversion timeout\n"); + ret = -EBUSY; + goto disable; } ret = wm831x_reg_read(wm831x, WM831X_AUXADC_DATA);