linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Paul Nasrat <pnasrat@redhat.com>
To: Hollis Blanchard <hollis@penguinppc.org>
Cc: linuxppc-dev@ozlabs.org, Jon Loeliger <jdl@jdl.com>
Subject: Re: [PATCH] DTC - validation by device_type
Date: Tue, 28 Mar 2006 21:33:31 -0500	[thread overview]
Message-ID: <1143599612.2704.14.camel@enki.eridu> (raw)
In-Reply-To: <66cc5bfb5a367a814fbace8105572658@penguinppc.org>

On Tue, 2006-03-28 at 20:03 -0600, Hollis Blanchard wrote:
> On Mar 28, 2006, at 4:49 PM, Paul Nasrat wrote:
> >
> > It'd be nice to be able to validate by device_type, to ensure that we
> > don't reinvent the wheel (address vs. local-mac-address) and to give
> > embedded designers an added level of sanity checking.
> >
> > Here is a proposed implementation with an implemented check for
> > "network".

> >
> Unless this is some weird style thing, that close brace seems 
> misindented.

No you're not missing anything, both artefacts of how I got there.  Take
2.

As above

Signed-off-by: Paul Nasrat <pnasrat@redhat.com>

diff --git a/livetree.c b/livetree.c
index ef54174..bf8bb56 100644
--- a/livetree.c
+++ b/livetree.c
@@ -441,6 +441,51 @@ static int check_structure(struct node *
 				(propname), (node)->fullpath); \
 	} while (0)
 
+static int check_network(struct node *net)
+{
+
+	int ok = 1;
+	struct property *prop;
+
+	CHECK_HAVE(net, "reg");
+	CHECK_HAVE(net, "local-mac-address");
+	CHECK_HAVE(net, "mac-address");
+	CHECK_HAVE(net, "address-bits");
+
+	return ok;
+}
+
+static struct {
+	char *devtype;
+	int (*check_fn)(struct node *node);
+} devtype_checker_table[] = {
+	{"network", check_network},
+};
+
+static int check_devtypes(struct node *root)
+{
+
+	struct node *child;
+	struct property *prop;
+	int ok = 1;
+	int i;
+
+	for_each_child(root, child) {
+		/* check this node */
+		if ((prop = get_property((child), ("device_type"))))
+			for (i = 0; i < ARRAY_SIZE(devtype_checker_table); i++) {
+				if (streq(prop->val.val, devtype_checker_table[i].devtype))
+					if (! devtype_checker_table[i].check_fn(child)) {
+						ok = 0;
+						break;
+					}
+			}
+		ok = check_devtypes(child);
+	}
+
+	return ok;
+}
+
 static int check_root(struct node *root)
 {
 	struct property *prop;
@@ -716,6 +761,7 @@ int check_device_tree(struct node *dt)
 	ok = ok && check_cpus(dt);
 	ok = ok && check_memory(dt);
 	ok = ok && check_chosen(dt);
+	ok = ok && check_devtypes(dt);
 	if (! ok)
 		return 0;
 

  reply	other threads:[~2006-03-29  2:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-28 22:49 [PATCH] DTC - validation by device_type Paul Nasrat
2006-03-29  2:03 ` Hollis Blanchard
2006-03-29  2:33   ` Paul Nasrat [this message]
2006-04-20 15:35     ` Jon Loeliger
2006-04-24 19:09       ` Paul Nasrat
2006-04-24 20:55         ` Segher Boessenkool
2006-04-24 21:09           ` Paul Nasrat

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=1143599612.2704.14.camel@enki.eridu \
    --to=pnasrat@redhat.com \
    --cc=hollis@penguinppc.org \
    --cc=jdl@jdl.com \
    --cc=linuxppc-dev@ozlabs.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;
as well as URLs for NNTP newsgroup(s).