All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: "Linus Walleij" <linus.walleij@linaro.org>,
	"Gunnar Thörnqvist" <gunnar@igl.se>,
	linux-gpio@vger.kernel.org,
	"Bartosz Golaszewski" <bartosz.golaszewski@linaro.org>
Subject: Re: [libgpiod][PATCH v2 2/4] tools: use ppoll() where higher timeout resolution makes sense
Date: Tue, 23 Apr 2024 07:31:42 +0800	[thread overview]
Message-ID: <20240422233142.GA4078@rigel> (raw)
In-Reply-To: <CAMRc=MfJxFYBoVK5GGks-A++n6naLJ31B6-UJBdxiw7gvnfxfQ@mail.gmail.com>

On Mon, Apr 22, 2024 at 08:15:46PM +0200, Bartosz Golaszewski wrote:
> On Wed, Apr 17, 2024 at 9:23 AM Kent Gibson <warthog618@gmail.com> wrote:
> >
> > On Tue, Apr 16, 2024 at 11:52:20PM +0200, Bartosz Golaszewski wrote:
> > >
> > > -             ret = poll(pollfds, resolver->num_chips, cfg.idle_timeout);
> > > +             if (cfg.idle_timeout > 0) {
> > > +                     idle_timeout.tv_sec = cfg.idle_timeout / 1000000;
> > > +                     idle_timeout.tv_nsec =
> > > +                                     (cfg.idle_timeout % 1000000) * 1000;
> > > +             }
> > > +
> > > +             ret = ppoll(pollfds, resolver->num_chips,
> > > +                         cfg.idle_timeout > 0 ? &idle_timeout : NULL, NULL);
> > >               if (ret < 0)
> > >                       die_perror("error polling for events");
> > >
> >
> > One minor nit - I would introduce a timespec pointer initialised to NULL
> > and set to point to idle_timeout within the if rather than repeat the
> > cfg.idle_timeout > 0 test.
> >
>
> Actually we can avoid it by doing it once before we enter the for(;;)
> loop. It's passed by constant pointer to ppoll() anyway and having the
> struct AND pointer to it initialized to NULL sounds more complex than
> it needs to be. I'll do it in v2.
>

Ah, I overlooked the for loop, so you are right that it should be
initialised before that.

> > But that is just personal preference, so either way,
> >
> > Reviewed-by: Kent Gibson <warthog618@gmail.com>
> >
>
> Thanks, I'll keep the tag if you don't mind the above solution?
>

Sure.

Cheers,
Kent.


  reply	other threads:[~2024-04-22 23:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16 21:52 [libgpiod][PATCH v2 0/4] tools: timeout handling improvements Bartosz Golaszewski
2024-04-16 21:52 ` [libgpiod][PATCH v2 1/4] tools: rename timeout to idle_timeout in gpiomon and gpionotify Bartosz Golaszewski
2024-04-16 21:52 ` [libgpiod][PATCH v2 2/4] tools: use ppoll() where higher timeout resolution makes sense Bartosz Golaszewski
2024-04-17  7:23   ` Kent Gibson
2024-04-22 18:15     ` Bartosz Golaszewski
2024-04-22 23:31       ` Kent Gibson [this message]
2024-04-16 21:52 ` [libgpiod][PATCH v2 3/4] tools: allow longer time periods Bartosz Golaszewski
2024-04-16 21:52 ` [libgpiod][PATCH v2 4/4] tools: add minutes as a new supported time unit Bartosz Golaszewski

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=20240422233142.GA4078@rigel \
    --to=warthog618@gmail.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=gunnar@igl.se \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.