Skip to contentSkip to conversation

gpioinfo: mark kernel claimed lines as used

PATCH In review Ramon Fried 2 participants 2 messages Jul 31, 2019 – Aug 1, 2019 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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".

---
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(-)
tools/gpioinfo.c +6 -2
index bb17262..ba0327b 100644
@@ -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
Signature · 1 line
2.22.0
#1 lore raw

śr., 31 lip 2019 o 19:38 Ramon Fried <[email protected]> napisał(a):

Quoted 36 lines

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".

---
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(-)
tools/gpioinfo.c +6 -3
index bb17262..ba0327b 100644
@@ -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
--
Quoted 2 lines

2.22.0

Applied with indentation and alignment fixed.

Bart