lkml.org 
[lkml]   [2018]   [Jun]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mfd: arizona: Don't use regmap_read_poll_timeout
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 <lee.jones@linaro.org> 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

\
 
 \ /
  Last update: 2018-06-04 12:56    [W:0.046 / U:0.516 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site