diff mbox series

[libgpiod,v2] gpioinfo: mark kernel claimed lines as used

Message ID 20190731173814.3400-1-rfried.dev@gmail.com
State New
Headers show
Series [libgpiod,v2] gpioinfo: mark kernel claimed lines as used | expand

Commit Message

Ramon Fried July 31, 2019, 5:38 p.m. UTC
In case where the GPIOLINE_FLAG_KERNEL flag was set
and no consumer string is provided by the kernel,
the used column was still showing the pin as "unused"
Fix that by writing "kernel".

Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
---
v2:
  * Restructure for clarity
  * Print "kernel" if line is used by kernel.
  * Update commit message

 tools/gpioinfo.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Bartosz Golaszewski Aug. 1, 2019, 8:10 a.m. UTC | #1
śr., 31 lip 2019 o 19:38 Ramon Fried <rfried.dev@gmail.com> napisał(a):
>
> In case where the GPIOLINE_FLAG_KERNEL flag was set
> and no consumer string is provided by the kernel,
> the used column was still showing the pin as "unused"
> Fix that by writing "kernel".
>
> Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
> ---
> v2:
>   * Restructure for clarity
>   * Print "kernel" if line is used by kernel.
>   * Update commit message
>
>  tools/gpioinfo.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/tools/gpioinfo.c b/tools/gpioinfo.c
> index bb17262..ba0327b 100644
> --- a/tools/gpioinfo.c
> +++ b/tools/gpioinfo.c
> @@ -119,8 +119,12 @@ 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))
> +                     prinfo(&of, 12, "unused");
> +               else
> +                       consumer ? prinfo(&of, 12, "\"%s\"", consumer)
> +                               : prinfo(&of, 12, "kernel");
> +
>                 printf(" ");
>
>                 prinfo(&of, 8, "%s ", direction == GPIOD_LINE_DIRECTION_INPUT
> --
> 2.22.0
>

Applied with indentation and alignment fixed.

Bart
diff mbox series

Patch

diff --git a/tools/gpioinfo.c b/tools/gpioinfo.c
index bb17262..ba0327b 100644
--- a/tools/gpioinfo.c
+++ b/tools/gpioinfo.c
@@ -119,8 +119,12 @@  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))
+		      prinfo(&of, 12, "unused");
+		else
+			consumer ? prinfo(&of, 12, "\"%s\"", consumer)
+				: prinfo(&of, 12, "kernel");
+
 		printf(" ");
 
 		prinfo(&of, 8, "%s ", direction == GPIOD_LINE_DIRECTION_INPUT