linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Lee Jones <lee.jones@linaro.org>, <patches@opensource.cirrus.com>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mfd: arizona: Don't use regmap_read_poll_timeout
Date: Mon, 4 Jun 2018 11:55:12 +0100	[thread overview]
Message-ID: <20180604105512.GB18740@imbe.wolfsonmicro.main> (raw)
In-Reply-To: <20180604102719.GA18740@imbe.wolfsonmicro.main>

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

      reply	other threads:[~2018-06-04 10:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-11 13:50 [PATCH] mfd: arizona: Don't use regmap_read_poll_timeout Charles Keepax
2018-06-04  5:44 ` Lee Jones
2018-06-04  9:40   ` Andy Shevchenko
2018-06-04 10:27     ` Charles Keepax
2018-06-04 10:55       ` Charles Keepax [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180604105512.GB18740@imbe.wolfsonmicro.main \
    --to=ckeepax@opensource.cirrus.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).