mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 03/15] oftree command: Add devicetree probe support
Date: Wed, 12 Sep 2012 22:06:35 +0200	[thread overview]
Message-ID: <1347480407-16865-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1347480407-16865-1-git-send-email-s.hauer@pengutronix.de>

With this the -p option is no longer for parse, but for probe instead.
Using this parses a devicetree given on the command line and probes
the devices found in this tree. Devices which already exist are not
probed again, but instead their device_node is attached to the existing
device.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/Kconfig  |   12 +++++++++++-
 commands/oftree.c |   28 +++++++++++++++-------------
 2 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/commands/Kconfig b/commands/Kconfig
index f2756cc..8a3edfa 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -468,7 +468,17 @@ config CMD_OFTREE
 	tristate
 	select OFTREE
 	prompt "oftree"
-	select FDT
+	help
+	  The oftree command has support for dumping devicetrees and, if
+	  enabled, to probe devices from the devicetree
+
+config CMD_OFTREE_PROBE
+	bool
+	depends on CMD_OFTREE
+	select OFDEVICE
+	prompt "oftree probe support"
+	help
+	  This enables the -p option to probe devices from the devicetree
 
 endmenu
 
diff --git a/commands/oftree.c b/commands/oftree.c
index 77afbc5..6479fa4 100644
--- a/commands/oftree.c
+++ b/commands/oftree.c
@@ -48,7 +48,8 @@ static int do_oftree(int argc, char *argv[])
 	char *file = NULL;
 	const char *node = "/";
 	int dump = 0;
-	int parse = 0;
+	int probe = 0;
+	int ret;
 
 	while ((opt = getopt(argc, argv, "dpfn:")) > 0) {
 		switch (opt) {
@@ -56,7 +57,12 @@ static int do_oftree(int argc, char *argv[])
 			dump = 1;
 			break;
 		case 'p':
-			parse = 1;
+			if (IS_ENABLED(CONFIG_CMD_OFTREE_PROBE)) {
+				probe = 1;
+			} else {
+				printf("oftree device probe support disabled\n");
+				return COMMAND_ERROR_USAGE;
+			}
 			break;
 		case 'f':
 			free(barebox_fdt);
@@ -71,7 +77,7 @@ static int do_oftree(int argc, char *argv[])
 	if (optind < argc)
 		file = argv[optind];
 
-	if (!dump && !parse)
+	if (!dump && !probe)
 		return COMMAND_ERROR_USAGE;
 
 	if (dump) {
@@ -95,7 +101,7 @@ static int do_oftree(int argc, char *argv[])
 		return 0;
 	}
 
-	if (parse) {
+	if (probe) {
 		if (!file)
 			return COMMAND_ERROR_USAGE;
 
@@ -105,17 +111,13 @@ static int do_oftree(int argc, char *argv[])
 			return 1;
 		}
 
-		fdt = xrealloc(fdt, size + 0x8000);
-		fdt_open_into(fdt, fdt, size + 0x8000);
-		if (!fdt) {
-			printf("unable to read %s\n", file);
+		ret = of_parse_dtb(fdt);
+		if (ret) {
+			printf("parse oftree: %s\n", strerror(-ret));
 			return 1;
 		}
 
-		if (barebox_fdt)
-			free(barebox_fdt);
-
-		barebox_fdt = fdt;
+		of_probe();
 	}
 
 	return 0;
@@ -123,7 +125,7 @@ static int do_oftree(int argc, char *argv[])
 
 BAREBOX_CMD_HELP_START(oftree)
 BAREBOX_CMD_HELP_USAGE("oftree [OPTIONS]\n")
-BAREBOX_CMD_HELP_OPT  ("-p <FILE>",  "parse and store oftree from <file>\n")
+BAREBOX_CMD_HELP_OPT  ("-p <FILE>",  "probe devices in oftree from <file>\n")
 BAREBOX_CMD_HELP_OPT  ("-d [FILE]",  "dump oftree from [FILE] or the parsed tree if no file is given\n")
 BAREBOX_CMD_HELP_OPT  ("-f",  "free stored oftree\n")
 BAREBOX_CMD_HELP_END
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2012-09-12 20:07 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-12 20:06 [PATCH] " Sascha Hauer
2012-09-12 20:06 ` [PATCH 01/15] driver: add dev_get_drvdata function Sascha Hauer
2012-09-12 20:06 ` [PATCH 02/15] of: add devicetree probing support Sascha Hauer
2012-09-18 15:48   ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-12 20:06 ` Sascha Hauer [this message]
2012-09-12 20:06 ` [PATCH 04/15] of: Add devicetree partition parsing Sascha Hauer
2012-09-12 20:06 ` [PATCH 05/15] spi: add oftree support Sascha Hauer
2012-09-12 20:06 ` [PATCH 06/15] ARM i.MX: Use platform_device_id for gpio driver Sascha Hauer
2012-09-12 20:06 ` [PATCH 07/15] ARM i.MX: implement clocksource as driver Sascha Hauer
2012-09-17 16:17   ` Sascha Hauer
2012-09-12 20:06 ` [PATCH 08/15] serial i.MX: oftree support Sascha Hauer
2012-09-12 20:06 ` [PATCH 09/15] net fec_imx: " Sascha Hauer
2012-09-12 20:06 ` [PATCH 10/15] spi imx: dt support Sascha Hauer
2012-09-12 20:06 ` [PATCH 11/15] mfd mc13xxx: Add devicetree support Sascha Hauer
2012-09-12 20:06 ` [PATCH 12/15] cfi-flash: Add devicetree probe support Sascha Hauer
2012-09-12 20:06 ` [PATCH 13/15] mci i.MX esdhc: Add oftree support Sascha Hauer
2012-09-12 20:06 ` [PATCH 14/15] ARM i.MX: add devicetree support for gpio driver Sascha Hauer
2012-09-12 20:06 ` [PATCH 15/15] ARM i.MX: Add devicetree support for clocksource driver Sascha Hauer
2012-09-20 18:45 ` [PATCH] devicetree probe support Jean-Christophe PLAGNIOL-VILLARD
2012-09-20 18:51   ` [PATCH 1/1] fb: add it's own bus for fb devices Jean-Christophe PLAGNIOL-VILLARD
2012-09-20 21:17     ` Sascha Hauer

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=1347480407-16865-4-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --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