[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VfUxuRTFfMOCymrfD2W3JEVC5yK1L6ZrsKeDoWpRmxn7Q@mail.gmail.com>
Date: Fri, 25 Sep 2020 12:43:22 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Kent Gibson <warthog618@...il.com>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
"open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
Bartosz Golaszewski <bgolaszewski@...libre.com>,
Linus Walleij <linus.walleij@...aro.org>,
Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH v9 12/20] gpiolib: cdev: support setting debounce
On Thu, Sep 24, 2020 at 10:49 AM Kent Gibson <warthog618@...il.com> wrote:
> On Wed, Sep 23, 2020 at 07:27:37PM +0300, Andy Shevchenko wrote:
> > On Tue, Sep 22, 2020 at 5:36 AM Kent Gibson <warthog618@...il.com> wrote:
...
> > Shouldn't we rather return 0/1 guaranteed?
> >
> > Perhaps
> >
> > if (active_low)
> > return !value;
> >
> > return !!value;
> >
> > ?
> >
>
> Or just make the return value a bool?
If it's good enough.
...
> > > + /* switch from physical level to logical - if they differ */
> > > + if (test_bit(FLAG_ACTIVE_LOW, &line->desc->flags))
> > > + level = !level;
> >
> > Seems to me a good candidate to have
> >
> > static inline bool convert_with_active_low_respected(desc, value)
> > {
> > if (active_low)
> > return !value;
> > return !!value;
> > }
> Not sure it is worth the effort - it would only be used twice - here
> and in debounced_value() - which is only a couple of lines itself.
I'm thinking about possible candidates to use this...
gpiod_direction_output()
gpiod_get_array_value_complex()
gpiod_get_value()
gpiod_set_value_nocheck()
gpiod_get_value_cansleep()
...I stopped here...
I agree that not all of them are good to be converted (b/c few flags
being tested and it will bring inconsistency), but many deserve the
perhaps separate patch to introduce the above mentioned helper.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists