Re: [libgpiod][PATCH 4/6] treewide: make drive settings an enum

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 11, 2021 at 3:39 PM Kent Gibson <warthog618@xxxxxxxxx> wrote:
>
> On Mon, Jan 11, 2021 at 02:34:24PM +0100, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx>
> >
> > Open-source and open-drain drive settings are mutually exclusive just like
> > the bias settings. Make them into an enum so that becomes clear.
> >
> > Signed-off-by: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx>
> > ---
> >  bindings/cxx/gpiod.hpp                 | 24 +++++----
> >  bindings/cxx/line.cpp                  | 18 +++----
> >  bindings/cxx/tests/tests-line.cpp      | 45 ++++++----------
> >  bindings/python/gpiodmodule.c          | 73 ++++++++++++++------------
> >  bindings/python/tests/gpiod_py_test.py | 18 +++----
> >  include/gpiod.h                        | 26 +++++----
> >  lib/core.c                             | 12 ++---
> >  tests/tests-line.c                     | 36 ++++++-------
> >  tools/gpioinfo.c                       | 14 ++++-
> >  9 files changed, 134 insertions(+), 132 deletions(-)
> >
> > diff --git a/bindings/cxx/gpiod.hpp b/bindings/cxx/gpiod.hpp
> > index fb675fc..f9c341d 100644
> > --- a/bindings/cxx/gpiod.hpp
> > +++ b/bindings/cxx/gpiod.hpp
> > @@ -332,16 +332,10 @@ public:
> >       GPIOD_API bool is_used(void) const;
> >
> >       /**
> > -      * @brief Check if this line represents an open-drain GPIO.
> > -      * @return True if the line is an open-drain GPIO, false otherwise.
> > +      * @brief Get current drive setting of this line.
> > +      * @return Current drive setting.
> >        */
> > -     GPIOD_API bool is_open_drain(void) const;
> > -
> > -     /**
> > -      * @brief Check if this line represents an open-source GPIO.
> > -      * @return True if the line is an open-source GPIO, false otherwise.
> > -      */
> > -     GPIOD_API bool is_open_source(void) const;
> > +     GPIOD_API int drive(void) const;
> >
> >       /**
> >        * @brief Request this line.
> > @@ -482,6 +476,18 @@ public:
> >               /**< Line's direction setting is output. */
> >       };
> >
> > +     /**
> > +      * @brief Possible drive settings.
> > +      */
> > +     enum : int {
> > +             DRIVE_NONE = 1,
> > +             /**< Drive setting is unknown. */
>
> Unlike bias, the drive setting is never unknown - if zero the pin is
> assumed push-pull.
>
> And to me DRIVE_NONE implies a high impedance state.
>

Indeed, I'll change it to DRIVE_PUSH_PULL then.

Bart



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux