From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752586AbeFDKzW (ORCPT ); Mon, 4 Jun 2018 06:55:22 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:59750 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752537AbeFDKzS (ORCPT ); Mon, 4 Jun 2018 06:55:18 -0400 Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.cirrus.com Date: Mon, 4 Jun 2018 11:55:12 +0100 From: Charles Keepax To: Andy Shevchenko CC: Lee Jones , , "Linux Kernel Mailing List" Subject: Re: [PATCH] mfd: arizona: Don't use regmap_read_poll_timeout Message-ID: <20180604105512.GB18740@imbe.wolfsonmicro.main> References: <20180511135030.14590-1-ckeepax@opensource.cirrus.com> <20180604054452.GD17993@dell> <20180604102719.GA18740@imbe.wolfsonmicro.main> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20180604102719.GA18740@imbe.wolfsonmicro.main> User-Agent: Mutt/1.5.20 (2009-12-10) X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=850 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806040134 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 04, 2018 at 11:27:19AM +0100, Charles Keepax wrote: > On Mon, Jun 04, 2018 at 12:40:37PM +0300, Andy Shevchenko wrote: > > On Mon, Jun 4, 2018 at 8:44 AM, Lee Jones wrote: > > > On Fri, 11 May 2018, Charles Keepax wrote: > > > > >> + while (true) { > > >> + ret = regmap_read(arizona->regmap, reg, &val); > > >> > > >> + if ((val & mask) == target) > > >> + return 0; > > >> + > > >> + if (ktime_compare(ktime_get(), timeout) > 0) > > >> + break; > > >> + > > >> + usleep_range(ARIZONA_REG_POLL_DELAY_US / 2, > > >> + ARIZONA_REG_POLL_DELAY_US); > > >> + } > > > > >From my point of view infinite loops not good for readability and maintenance. > > Perhaps > > > > do { > > ... > > } while (ktime_compare(...)); > > > > ? > > I would rather not do it that way since then it becomes > impossible to have a single poll with no delays happening. I can > refactor to remove the while(true) but it will make the code a > bit bigger, as I will probably need to duplicate some code > outside the loop. > Looking again I think it is fine if I do the ktime_compare at the top of the loop though. Will respin. Thanks, Charles