All of lore.kernel.org
 help / color / mirror / Atom feed
* [libgpiod] [PATCH] gpioinfo: mark kernel claimed lines as used
@ 2019-07-30 19:04 Ramon Fried
  2019-07-31  7:44 ` Bartosz Golaszewski
  0 siblings, 1 reply; 4+ messages in thread
From: Ramon Fried @ 2019-07-30 19:04 UTC (permalink / raw)
  To: bgolaszewski; +Cc: linus.walleij, linux-gpio, Ramon Fried

In case where the GPIOLINE_FLAG_KERNEL flag was set because of muxing,
The used column was still showing the pin as "unused"
Fix that by writing "used".

Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
---
 tools/gpioinfo.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/gpioinfo.c b/tools/gpioinfo.c
index bb17262..85f8758 100644
--- a/tools/gpioinfo.c
+++ b/tools/gpioinfo.c
@@ -119,8 +119,11 @@ static void list_lines(struct gpiod_chip *chip)
 		     : prinfo(&of, 12, "unnamed");
 		printf(" ");
 
-		consumer ? prinfo(&of, 12, "\"%s\"", consumer)
-			 : prinfo(&of, 12, "unused");
+		if (gpiod_line_is_used(line) && !consumer)
+			prinfo(&of, 12, "used");
+		else
+			consumer ? prinfo(&of, 12, "\"%s\"", consumer)
+				 : prinfo(&of, 12, "unused");
 		printf(" ");
 
 		prinfo(&of, 8, "%s ", direction == GPIOD_LINE_DIRECTION_INPUT
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [libgpiod] [PATCH] gpioinfo: mark kernel claimed lines as used
  2019-07-30 19:04 [libgpiod] [PATCH] gpioinfo: mark kernel claimed lines as used Ramon Fried
@ 2019-07-31  7:44 ` Bartosz Golaszewski
  2019-07-31  7:48   ` Ramon Fried
  0 siblings, 1 reply; 4+ messages in thread
From: Bartosz Golaszewski @ 2019-07-31  7:44 UTC (permalink / raw)
  To: Ramon Fried; +Cc: Linus Walleij, linux-gpio

wt., 30 lip 2019 o 21:04 Ramon Fried <rfried.dev@gmail.com> napisał(a):
>
> In case where the GPIOLINE_FLAG_KERNEL flag was set because of muxing,
> The used column was still showing the pin as "unused"
> Fix that by writing "used".
>
> Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
> ---
>  tools/gpioinfo.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/tools/gpioinfo.c b/tools/gpioinfo.c
> index bb17262..85f8758 100644
> --- a/tools/gpioinfo.c
> +++ b/tools/gpioinfo.c
> @@ -119,8 +119,11 @@ static void list_lines(struct gpiod_chip *chip)
>                      : prinfo(&of, 12, "unnamed");
>                 printf(" ");
>
> -               consumer ? prinfo(&of, 12, "\"%s\"", consumer)
> -                        : prinfo(&of, 12, "unused");
> +               if (gpiod_line_is_used(line) && !consumer)
> +                       prinfo(&of, 12, "used");
> +               else
> +                       consumer ? prinfo(&of, 12, "\"%s\"", consumer)
> +                                : prinfo(&of, 12, "unused");
>                 printf(" ");
>
>                 prinfo(&of, 8, "%s ", direction == GPIOD_LINE_DIRECTION_INPUT
> --
> 2.22.0
>

Good catch! I think we can make it even more readable by first calling
gpiod_line_is_used() and printing 'unused' if it returns false and
then checking the consumer string.

Bart

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [libgpiod] [PATCH] gpioinfo: mark kernel claimed lines as used
  2019-07-31  7:44 ` Bartosz Golaszewski
@ 2019-07-31  7:48   ` Ramon Fried
  2019-07-31  7:50     ` Bartosz Golaszewski
  0 siblings, 1 reply; 4+ messages in thread
From: Ramon Fried @ 2019-07-31  7:48 UTC (permalink / raw)
  To: Bartosz Golaszewski; +Cc: Linus Walleij, linux-gpio

On Wed, Jul 31, 2019 at 10:44 AM Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:
>
> wt., 30 lip 2019 o 21:04 Ramon Fried <rfried.dev@gmail.com> napisał(a):
> >
> > In case where the GPIOLINE_FLAG_KERNEL flag was set because of muxing,
> > The used column was still showing the pin as "unused"
> > Fix that by writing "used".
> >
> > Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
> > ---
> >  tools/gpioinfo.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/gpioinfo.c b/tools/gpioinfo.c
> > index bb17262..85f8758 100644
> > --- a/tools/gpioinfo.c
> > +++ b/tools/gpioinfo.c
> > @@ -119,8 +119,11 @@ static void list_lines(struct gpiod_chip *chip)
> >                      : prinfo(&of, 12, "unnamed");
> >                 printf(" ");
> >
> > -               consumer ? prinfo(&of, 12, "\"%s\"", consumer)
> > -                        : prinfo(&of, 12, "unused");
> > +               if (gpiod_line_is_used(line) && !consumer)
> > +                       prinfo(&of, 12, "used");
> > +               else
> > +                       consumer ? prinfo(&of, 12, "\"%s\"", consumer)
> > +                                : prinfo(&of, 12, "unused");
> >                 printf(" ");
> >
> >                 prinfo(&of, 8, "%s ", direction == GPIOD_LINE_DIRECTION_INPUT
> > --
> > 2.22.0
> >
>
> Good catch! I think we can make it even more readable by first calling
> gpiod_line_is_used() and printing 'unused' if it returns false and
> then checking the consumer string.
OK, I'll send v2.
Thanks,
Ramon.
>
> Bart

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [libgpiod] [PATCH] gpioinfo: mark kernel claimed lines as used
  2019-07-31  7:48   ` Ramon Fried
@ 2019-07-31  7:50     ` Bartosz Golaszewski
  0 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2019-07-31  7:50 UTC (permalink / raw)
  To: Ramon Fried; +Cc: Linus Walleij, linux-gpio

śr., 31 lip 2019 o 09:48 Ramon Fried <rfried.dev@gmail.com> napisał(a):
>
> On Wed, Jul 31, 2019 at 10:44 AM Bartosz Golaszewski
> <bgolaszewski@baylibre.com> wrote:
> >
> > wt., 30 lip 2019 o 21:04 Ramon Fried <rfried.dev@gmail.com> napisał(a):
> > >
> > > In case where the GPIOLINE_FLAG_KERNEL flag was set because of muxing,
> > > The used column was still showing the pin as "unused"
> > > Fix that by writing "used".
> > >
> > > Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
> > > ---
> > >  tools/gpioinfo.c | 7 +++++--
> > >  1 file changed, 5 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/tools/gpioinfo.c b/tools/gpioinfo.c
> > > index bb17262..85f8758 100644
> > > --- a/tools/gpioinfo.c
> > > +++ b/tools/gpioinfo.c
> > > @@ -119,8 +119,11 @@ static void list_lines(struct gpiod_chip *chip)
> > >                      : prinfo(&of, 12, "unnamed");
> > >                 printf(" ");
> > >
> > > -               consumer ? prinfo(&of, 12, "\"%s\"", consumer)
> > > -                        : prinfo(&of, 12, "unused");
> > > +               if (gpiod_line_is_used(line) && !consumer)
> > > +                       prinfo(&of, 12, "used");
> > > +               else
> > > +                       consumer ? prinfo(&of, 12, "\"%s\"", consumer)
> > > +                                : prinfo(&of, 12, "unused");
> > >                 printf(" ");
> > >
> > >                 prinfo(&of, 8, "%s ", direction == GPIOD_LINE_DIRECTION_INPUT
> > > --
> > > 2.22.0
> > >
> >
> > Good catch! I think we can make it even more readable by first calling
> > gpiod_line_is_used() and printing 'unused' if it returns false and
> > then checking the consumer string.
> OK, I'll send v2.
> Thanks,
> Ramon.
> >
> > Bart

Cool, I'm also thinking that we need to distinguish somehow regular
consumer strings from lines used by kernel. Maybe a string like
'[kernel]' instead of 'used' would be nice?

Bart

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-07-31  7:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-30 19:04 [libgpiod] [PATCH] gpioinfo: mark kernel claimed lines as used Ramon Fried
2019-07-31  7:44 ` Bartosz Golaszewski
2019-07-31  7:48   ` Ramon Fried
2019-07-31  7:50     ` Bartosz Golaszewski

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.