From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 2/2] gpiolib: add command to dump the current gpio status
Date: Fri, 21 Dec 2012 14:26:09 +0100 [thread overview]
Message-ID: <1356096369-14523-2-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1356096369-14523-1-git-send-email-plagnioj@jcrosoft.com>
This will allow to known which gpio is requested by what
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
drivers/gpio/gpio.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/gpio/gpio.c b/drivers/gpio/gpio.c
index ed9f923..d37f5a0 100644
--- a/drivers/gpio/gpio.c
+++ b/drivers/gpio/gpio.c
@@ -1,4 +1,6 @@
#include <common.h>
+#include <command.h>
+#include <complete.h>
#include <gpio.h>
#include <errno.h>
#include <malloc.h>
@@ -198,3 +200,38 @@ int gpio_get_num(struct device_d *dev, int gpio)
return -ENODEV;
}
+
+#ifdef CONFIG_CMD_GPIO
+static int do_gpiolib(int argc, char *argv[])
+{
+ int i;
+
+ printf("gpiolib: gpio lists\n");
+ printf("%*crequested label\n", 11, ' ');
+
+ for (i = 0; i < ARCH_NR_GPIOS; i++) {
+ struct gpio_info *gi = &gpio_desc[i];
+
+ if (!gi->chip)
+ continue;
+
+ printf("gpio %*d: %*s %s\n", 4,
+ i, 9, gi->requested ? "true" : "false",
+ gi->label ? gi->label : "");
+ }
+
+ return 0;
+}
+
+BAREBOX_CMD_HELP_START(gpiolib)
+BAREBOX_CMD_HELP_USAGE("gpiolib\n")
+BAREBOX_CMD_HELP_SHORT("dump current registered gpio\n");
+BAREBOX_CMD_HELP_END
+
+BAREBOX_CMD_START(gpiolib)
+ .cmd = do_gpiolib,
+ .usage = "dump current registered gpio",
+ BAREBOX_CMD_HELP(cmd_gpiolib_help)
+ BAREBOX_CMD_COMPLETE(empty_complete)
+BAREBOX_CMD_END
+#endif
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-12-21 13:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-21 13:25 [PATCH 0/2 v2] gpiolib: add request and free support Jean-Christophe PLAGNIOL-VILLARD
2012-12-21 13:26 ` [PATCH 1/2 v2] gpiolib: add gpio_request and gpio_free support Jean-Christophe PLAGNIOL-VILLARD
2012-12-21 13:26 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-12-22 18:40 ` [PATCH 0/2 v2] gpiolib: add request and free support Sascha Hauer
-- strict thread matches above, loose matches on Subject: below --
2012-12-20 13:12 [PATCH 0/2] " Jean-Christophe PLAGNIOL-VILLARD
2012-12-20 14:23 ` [PATCH 1/2] gpiolib: add gpio_request and gpio_free support Jean-Christophe PLAGNIOL-VILLARD
2012-12-20 14:24 ` [PATCH 2/2] gpiolib: add command to dump the current gpio status Jean-Christophe PLAGNIOL-VILLARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1356096369-14523-2-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox