* [libgpiod][PATCH] gpioinfo: print bias flags if set
@ 2020-04-29 12:43 Bartosz Golaszewski
0 siblings, 0 replies; only message in thread
From: Bartosz Golaszewski @ 2020-04-29 12:43 UTC (permalink / raw)
To: Kent Gibson, Linus Walleij; +Cc: linux-gpio, Bartosz Golaszewski
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
When printing line information: check the bias configuration and include
the current value in the 'flags' column of output.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
tools/gpioinfo.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/tools/gpioinfo.c b/tools/gpioinfo.c
index 6f94b4e..67be379 100644
--- a/tools/gpioinfo.c
+++ b/tools/gpioinfo.c
@@ -21,6 +21,21 @@ struct flag {
is_set_func is_set;
};
+static bool line_bias_is_pullup(struct gpiod_line *line)
+{
+ return gpiod_line_bias(line) == GPIOD_LINE_BIAS_PULL_UP;
+}
+
+static bool line_bias_is_pulldown(struct gpiod_line *line)
+{
+ return gpiod_line_bias(line) == GPIOD_LINE_BIAS_PULL_DOWN;
+}
+
+static bool line_bias_is_disabled(struct gpiod_line *line)
+{
+ return gpiod_line_bias(line) == GPIOD_LINE_BIAS_DISABLE;
+}
+
static const struct flag flags[] = {
{
.name = "used",
@@ -34,6 +49,18 @@ static const struct flag flags[] = {
.name = "open-source",
.is_set = gpiod_line_is_open_source,
},
+ {
+ .name = "pull-up",
+ .is_set = line_bias_is_pullup,
+ },
+ {
+ .name = "pull-down",
+ .is_set = line_bias_is_pulldown,
+ },
+ {
+ .name = "bias-disabled",
+ .is_set = line_bias_is_disabled,
+ },
};
static const struct option longopts[] = {
--
2.25.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-04-29 12:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-29 12:43 [libgpiod][PATCH] gpioinfo: print bias flags if set Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).