gpioinfo: mark kernel claimed lines as used
PATCH 1/1 gpioinfo: mark kernel claimed lines as used
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".
--- tools/gpioinfo.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
tools/gpioinfo.c +5 -2
@@ -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
Signature · 1 line
2.22.0
wt., 30 lip 2019 o 21:04 Ramon Fried <[email protected]> napisał(a):
Quoted 29 lines
In case where the
GPIOLINE_FLAG_KERNELflag 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 <[email protected]>--- tools/gpioinfo.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)tools/gpioinfo.c +5
-3@@ -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 --
Quoted 2 lines
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
Quoted 29 lines · Bartosz Golaszewski
wt., 30 lip 2019 o 21:04 Ramon Fried <[email protected]> napisał(a):
Quoted 27 lines
In case where the
GPIOLINE_FLAG_KERNELflag 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 <[email protected]>--- tools/gpioinfo.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)tools/gpioinfo.c +5
-2@@ -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 (" " );
Quoted 8 lines
Quoted 4 lines
tools/gpioinfo.c +0
-1prinfo(&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.
Quoted 2 lines
Bart
śr., 31 lip 2019 o 09:48 Ramon Fried <[email protected]> napisał(a):
Quoted 40 lines
Quoted 29 lines · Bartosz Golaszewski
wt., 30 lip 2019 o 21:04 Ramon Fried <[email protected]> napisał(a):
Quoted 27 lines
In case where the
GPIOLINE_FLAG_KERNELflag 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 <[email protected]>--- tools/gpioinfo.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)tools/gpioinfo.c +5
-2@@ -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 (" " );Quoted 8 lines
Quoted 4 lines
tools/gpioinfo.c +0
-1prinfo(&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.
Quoted 5 lines
OK, I'll send v2.
Thanks,
Ramon.Quoted 2 lines
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