From: Ramon Fried <rfried.dev@gmail.com>
Date: Wed, 31 Jul 2019 17:38:14 +0000 (+0300)
Subject: gpioinfo: mark kernel claimed lines as used
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=c8437f94d3515d32a837f376cecd521eee268836;p=qemu-gpiodev%2Flibgpiod.git

gpioinfo: mark kernel claimed lines as used

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>
[Bartosz:
  - fixed indentation and alignment
  - tweaked the commit message formatting]
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---

diff --git a/tools/gpioinfo.c b/tools/gpioinfo.c
index bb17262..8a1d00d 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