Re: [libgpiod] [PATCH 18/19] tools: add support for bias flags

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

 



sob., 16 lis 2019 o 16:40 Kent Gibson <warthog618@xxxxxxxxx> napisał(a):
>
> On Fri, Nov 15, 2019 at 10:43:54PM +0800, Kent Gibson wrote:
> > Add support for bias flags to applicable tools - gpioget, gpioset, and
> > gpiomon.
> >
> > Signed-off-by: Kent Gibson <warthog618@xxxxxxxxx>
> > ---
> >  tools/gpioget.c | 24 ++++++++++++++++++++----
> >  tools/gpiomon.c | 28 ++++++++++++++++++++++------
> >  tools/gpioset.c | 26 +++++++++++++++++++++-----
> >  3 files changed, 63 insertions(+), 15 deletions(-)
> >
> > diff --git a/tools/gpioget.c b/tools/gpioget.c
> > index 196ebeb..025811a 100644
> > --- a/tools/gpioget.c
> > +++ b/tools/gpioget.c
> > @@ -17,10 +17,13 @@ static const struct option longopts[] = {
> >       { "help",       no_argument,    NULL,   'h' },
> >       { "version",    no_argument,    NULL,   'v' },
> >       { "active-low", no_argument,    NULL,   'l' },
> > +     { "pull-down",  no_argument,    NULL,   'D' },
> > +     { "pull-up",    no_argument,    NULL,   'U' },
> > +     { "bias-disable", no_argument,  NULL,   'B' },
> >       { GETOPT_NULL_LONGOPT },
> >  };
> >
> > -static const char *const shortopts = "+hvl";
> > +static const char *const shortopts = "+hvlDUB";
> >
> >  static void print_help(void)
> >  {
> > @@ -32,6 +35,9 @@ static void print_help(void)
> >       printf("  -h, --help:\t\tdisplay this message and exit\n");
> >       printf("  -v, --version:\tdisplay the version and exit\n");
> >       printf("  -l, --active-low:\tset the line active state to low\n");
> > +     printf("  -D, --pull-down:\tenable internal pull-down\n");
> > +     printf("  -U, --pull-up:\tenable internal pull-up\n");
> > +     printf("  -B, --bias-disable:\tdisable internal bias\n");
> >  }
> >
> >  int main(int argc, char **argv)
> > @@ -39,6 +45,7 @@ int main(int argc, char **argv)
> >       unsigned int *offsets, i, num_lines;
> >       int *values, optc, opti, rv;
> >       bool active_low = false;
> > +     int flags = 0;
> >       char *device, *end;
> >
> >       for (;;) {
> > @@ -56,6 +63,15 @@ int main(int argc, char **argv)
> >               case 'l':
> >                       active_low = true;
> >                       break;
> > +             case 'D':
> > +                     flags |= GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN;
> > +                     break;
> > +             case 'U':
> > +                     flags |= GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP;
> > +                     break;
> > +             case 'B':
> > +                     flags |= GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE;
> > +                     break;
> >               case '?':
> >                       die("try %s --help", get_progname());
> >               default:
> > @@ -86,9 +102,9 @@ int main(int argc, char **argv)
> >                       die("invalid GPIO offset: %s", argv[i + 1]);
> >       }
> >
>
> Nuts - this is wrong - it should be using the CTXLESS flags, not the
> LINE_REQUEST flags.  That applies to all three of the tools changed.
> I forgot to propagate the last minute CTXLESS changes to the tools.
> And unfortunately we don't have test cases for the tools :-(.

But we do![1]

> I've got a fix in my github branch that I will incorporate into v2.
>
> I'm also wondering if it would be preferable to replace the individual
> bias command line flags with a single bias parameter, e.g. --bias=pull-up
> I've coded that in my github branch as well, if you would care to
> compare.
>
> Let me know if you'd like a v2, otherwise I'll hold off for a few days
> in case something else crops up.

Let me review the rest before that, I'll do this tomorrow.

Bart

>
> Cheers,
> Kent.

[1] https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/tools/gpio-tools-test.bats




[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