All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] of: DT Overlay patches to be merged
@ 2014-11-21  1:35 Grant Likely
  2014-11-21  1:35 ` [PATCH 1/8] of: Use vargs in __of_node_alloc Grant Likely
                   ` (7 more replies)
  0 siblings, 8 replies; 23+ messages in thread
From: Grant Likely @ 2014-11-21  1:35 UTC (permalink / raw)
  To: devicetree, linux-kernel, Pantelis Antoniou; +Cc: Rob Herring

I've finally queued up the following core patches for devicetree overlay
support.  The patches have changed a bit since the v8 series that
Pantelis published. Mostly fixups to issues raised on the list.

Please review and let me know if you have any concerns.

There are still several overlay patches that need to be merged to add
support to the i2c and spi busses as well as the configfs interface.
I'll be looking at those patches next.

g.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 1/8] of: Use vargs in __of_node_alloc
  2014-11-21  1:35 [PATCH 0/8] of: DT Overlay patches to be merged Grant Likely
@ 2014-11-21  1:35 ` Grant Likely
  2014-11-21  1:43     ` Joe Perches
  2014-11-21  1:35 ` [PATCH 2/8] of: Refactor __of_node_alloc() into __of_node_dup() Grant Likely
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Grant Likely @ 2014-11-21  1:35 UTC (permalink / raw)
  To: devicetree, linux-kernel, Pantelis Antoniou; +Cc: Rob Herring, Grant Likely

The overlay code needs to construct a new full_name from the parent name
and the node name, but the current method has to allocate and then free
an temporary string which is wasteful. Fix this problem by using vargs
to pass in a format and arguments into __of_node_alloc().

At the same time remove the allocflags argument to __of_node_alloc().
The only users all use GFP_KERNEL, so there is no need to provide it as
an option. If there is ever a need later it can be added back.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
---
 drivers/of/dynamic.c    | 16 ++++++++--------
 drivers/of/of_private.h |  2 +-
 drivers/of/unittest.c   |  6 +++---
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index da2509d639c8..2d452be1200b 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -274,33 +274,33 @@ struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags)
 /**
  * __of_node_alloc() - Create an empty device node dynamically.
  * @full_name:	Full name of the new device node
- * @allocflags:	Allocation flags (typically pass GFP_KERNEL)
  *
  * Create an empty device tree node, suitable for further modification.
  * The node data are dynamically allocated and all the node flags
  * have the OF_DYNAMIC & OF_DETACHED bits set.
  * Returns the newly allocated node or NULL on out of memory error.
  */
-struct device_node *__of_node_alloc(const char *full_name, gfp_t allocflags)
+struct device_node *__of_node_alloc(const char *fmt, ...)
 {
+	va_list vargs;
 	struct device_node *node;
 
-	node = kzalloc(sizeof(*node), allocflags);
+	node = kzalloc(sizeof(*node), GFP_KERNEL);
 	if (!node)
 		return NULL;
-
-	node->full_name = kstrdup(full_name, allocflags);
-	of_node_set_flag(node, OF_DYNAMIC);
-	of_node_set_flag(node, OF_DETACHED);
+	va_start(vargs, fmt);
+	node->full_name = kvasprintf(GFP_KERNEL, fmt, vargs);
+	va_end(vargs);
 	if (!node->full_name)
 		goto err_free;
 
+	of_node_set_flag(node, OF_DYNAMIC);
+	of_node_set_flag(node, OF_DETACHED);
 	of_node_init(node);
 
 	return node;
 
  err_free:
-	kfree(node->full_name);
 	kfree(node);
 	return NULL;
 }
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index 858e0a5d9a11..1e21b1c6de71 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -61,7 +61,7 @@ static inline int of_property_notify(int action, struct device_node *np,
  * own the devtree lock or work on detached trees only.
  */
 struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags);
-struct device_node *__of_node_alloc(const char *full_name, gfp_t allocflags);
+struct device_node *__of_node_alloc(const char *fmt, ...);
 
 extern const void *__of_get_property(const struct device_node *np,
 				     const char *name, int *lenp);
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 082bb2b6a5ad..79630760ea4f 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -449,11 +449,11 @@ static void __init of_selftest_changeset(void)
 	struct of_changeset chgset;
 
 	of_changeset_init(&chgset);
-	n1 = __of_node_alloc("/testcase-data/changeset/n1", GFP_KERNEL);
+	n1 = __of_node_alloc("/testcase-data/changeset/n1");
 	selftest(n1, "testcase setup failure\n");
-	n2 = __of_node_alloc("/testcase-data/changeset/n2", GFP_KERNEL);
+	n2 = __of_node_alloc("/testcase-data/changeset/n2");
 	selftest(n2, "testcase setup failure\n");
-	n21 = __of_node_alloc("/testcase-data/changeset/n2/n21", GFP_KERNEL);
+	n21 = __of_node_alloc("/testcase-data/changeset/n2/n21");
 	selftest(n21, "testcase setup failure %p\n", n21);
 	nremove = of_find_node_by_path("/testcase-data/changeset/node-remove");
 	selftest(nremove, "testcase setup failure\n");
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 2/8] of: Refactor __of_node_alloc() into __of_node_dup()
  2014-11-21  1:35 [PATCH 0/8] of: DT Overlay patches to be merged Grant Likely
  2014-11-21  1:35 ` [PATCH 1/8] of: Use vargs in __of_node_alloc Grant Likely
@ 2014-11-21  1:35 ` Grant Likely
  2014-11-21  1:35 ` [PATCH 3/8] of/resolver: Switch to new local fixups format Grant Likely
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 23+ messages in thread
From: Grant Likely @ 2014-11-21  1:35 UTC (permalink / raw)
  To: devicetree, linux-kernel, Pantelis Antoniou; +Cc: Rob Herring, Grant Likely

Add a node argument to __of_node_alloc() and rename it to
__of_node_dup() so that it can also be used to duplicate a node with
its properties. This is important for the overlay code so that it can
create new nodes without using separate changeset items for every single
property.

At the same time rework the overlay code to use the new function and
drop the extra changeset items.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
---
 drivers/of/dynamic.c    | 40 +++++++++++++++++++++++++++++-----------
 drivers/of/of_private.h |  2 +-
 drivers/of/unittest.c   | 14 ++++++++++----
 3 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index 2d452be1200b..7c095bffef3a 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -272,15 +272,16 @@ struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags)
 }
 
 /**
- * __of_node_alloc() - Create an empty device node dynamically.
- * @full_name:	Full name of the new device node
+ * __of_node_dup() - Duplicate or create an empty device node dynamically.
+ * @fmt: Format string (plus vargs) for new full name of the device node
  *
- * Create an empty device tree node, suitable for further modification.
- * The node data are dynamically allocated and all the node flags
- * have the OF_DYNAMIC & OF_DETACHED bits set.
- * Returns the newly allocated node or NULL on out of memory error.
+ * Create an device tree node, either by duplicating an empty node or by allocating
+ * an empty one suitable for further modification.  The node data are
+ * dynamically allocated and all the node flags have the OF_DYNAMIC &
+ * OF_DETACHED bits set. Returns the newly allocated node or NULL on out of
+ * memory error.
  */
-struct device_node *__of_node_alloc(const char *fmt, ...)
+struct device_node *__of_node_dup(const struct device_node *np, const char *fmt, ...)
 {
 	va_list vargs;
 	struct device_node *node;
@@ -291,17 +292,34 @@ struct device_node *__of_node_alloc(const char *fmt, ...)
 	va_start(vargs, fmt);
 	node->full_name = kvasprintf(GFP_KERNEL, fmt, vargs);
 	va_end(vargs);
-	if (!node->full_name)
-		goto err_free;
+	if (!node->full_name) {
+		kfree(node);
+		return NULL;
+	}
 
 	of_node_set_flag(node, OF_DYNAMIC);
 	of_node_set_flag(node, OF_DETACHED);
 	of_node_init(node);
 
+	/* Iterate over and duplicate all properties */
+	if (np) {
+		struct property *pp, *new_pp;
+		for_each_property_of_node(np, pp) {
+			new_pp = __of_prop_dup(pp, GFP_KERNEL);
+			if (!new_pp)
+				goto err_prop;
+			if (__of_add_property(node, new_pp)) {
+				kfree(new_pp->name);
+				kfree(new_pp->value);
+				kfree(new_pp);
+				goto err_prop;
+			}
+		}
+	}
 	return node;
 
- err_free:
-	kfree(node);
+ err_prop:
+	of_node_put(node); /* Frees the node and properties */
 	return NULL;
 }
 
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index 1e21b1c6de71..5b0599066d59 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -61,7 +61,7 @@ static inline int of_property_notify(int action, struct device_node *np,
  * own the devtree lock or work on detached trees only.
  */
 struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags);
-struct device_node *__of_node_alloc(const char *fmt, ...);
+struct device_node *__of_node_dup(const struct device_node *np, const char *fmt, ...);
 
 extern const void *__of_get_property(const struct device_node *np,
 				     const char *name, int *lenp);
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 79630760ea4f..60eb28422077 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -445,15 +445,15 @@ static void __init of_selftest_changeset(void)
 	struct property *ppadd, padd = { .name = "prop-add", .length = 0, .value = "" };
 	struct property *ppupdate, pupdate = { .name = "prop-update", .length = 5, .value = "abcd" };
 	struct property *ppremove;
-	struct device_node *n1, *n2, *n21, *nremove, *parent;
+	struct device_node *n1, *n2, *n21, *nremove, *parent, *np;
 	struct of_changeset chgset;
 
 	of_changeset_init(&chgset);
-	n1 = __of_node_alloc("/testcase-data/changeset/n1");
+	n1 = __of_node_dup(NULL, "/testcase-data/changeset/n1");
 	selftest(n1, "testcase setup failure\n");
-	n2 = __of_node_alloc("/testcase-data/changeset/n2");
+	n2 = __of_node_dup(NULL, "/testcase-data/changeset/n2");
 	selftest(n2, "testcase setup failure\n");
-	n21 = __of_node_alloc("/testcase-data/changeset/n2/n21");
+	n21 = __of_node_dup(NULL, "%s/%s", "/testcase-data/changeset/n2", "n21");
 	selftest(n21, "testcase setup failure %p\n", n21);
 	nremove = of_find_node_by_path("/testcase-data/changeset/node-remove");
 	selftest(nremove, "testcase setup failure\n");
@@ -481,6 +481,12 @@ static void __init of_selftest_changeset(void)
 	selftest(!of_changeset_apply(&chgset), "apply failed\n");
 	mutex_unlock(&of_mutex);
 
+	/* Make sure node names are constructed correctly */
+	selftest((np = of_find_node_by_path("/testcase-data/changeset/n2/n21")),
+		 "'%s' not added\n", n21->full_name);
+	if (np)
+		of_node_put(np);
+
 	mutex_lock(&of_mutex);
 	selftest(!of_changeset_revert(&chgset), "revert failed\n");
 	mutex_unlock(&of_mutex);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 3/8] of/resolver: Switch to new local fixups format.
  2014-11-21  1:35 [PATCH 0/8] of: DT Overlay patches to be merged Grant Likely
  2014-11-21  1:35 ` [PATCH 1/8] of: Use vargs in __of_node_alloc Grant Likely
  2014-11-21  1:35 ` [PATCH 2/8] of: Refactor __of_node_alloc() into __of_node_dup() Grant Likely
@ 2014-11-21  1:35 ` Grant Likely
  2014-11-21  1:35   ` Grant Likely
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 23+ messages in thread
From: Grant Likely @ 2014-11-21  1:35 UTC (permalink / raw)
  To: devicetree, linux-kernel, Pantelis Antoniou; +Cc: Rob Herring, Grant Likely

From: Pantelis Antoniou <pantelis.antoniou@konsulko.com>

The original resolver format is way too cryptic, switch
to using a tree based format that gets rid of repetitions,
is more compact and readable.

At the same time, update the selftests to using the new local fixups
format.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
[grant.likely: Squashed in testcase changes and merged similar functions]
Signed-off-by: Grant Likely <grant.likely@linaro.org>
---
 drivers/of/resolver.c                  | 128 ++++++++++++++++++++++++++-------
 drivers/of/unittest-data/testcases.dts |  61 +++++++++-------
 2 files changed, 139 insertions(+), 50 deletions(-)

diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index aed7959f800d..640eb4cb46e3 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -111,7 +111,8 @@ static void __of_adjust_tree_phandles(struct device_node *node,
 		__of_adjust_tree_phandles(child, phandle_delta);
 }
 
-static int __of_adjust_phandle_ref(struct device_node *node, struct property *rprop, int value, bool is_delta)
+static int __of_adjust_phandle_ref(struct device_node *node,
+		struct property *rprop, int value)
 {
 	phandle phandle;
 	struct device_node *refnode;
@@ -181,7 +182,7 @@ static int __of_adjust_phandle_ref(struct device_node *node, struct property *rp
 			goto err_fail;
 		}
 
-		phandle = is_delta ? be32_to_cpup(sprop->value + offset) + value : value;
+		phandle = value;
 		*(__be32 *)(sprop->value + offset) = cpu_to_be32(phandle);
 	}
 
@@ -190,36 +191,97 @@ err_fail:
 	return err;
 }
 
+/* compare nodes taking into account that 'name' strips out the @ part */
+static int __of_node_name_cmp(const struct device_node *dn1,
+		const struct device_node *dn2)
+{
+	const char *n1 = strrchr(dn1->full_name, '/') ? : "/";
+	const char *n2 = strrchr(dn2->full_name, '/') ? : "/";
+
+	return of_node_cmp(n1, n2);
+}
+
 /*
  * Adjust the local phandle references by the given phandle delta.
- * Assumes the existances of a __local_fixups__ node at the root
- * of the tree. Does not take any devtree locks so make sure you
- * call this on a tree which is at the detached state.
+ * Assumes the existances of a __local_fixups__ node at the root.
+ * Assumes that __of_verify_tree_phandle_references has been called.
+ * Does not take any devtree locks so make sure you call this on a tree
+ * which is at the detached state.
  */
 static int __of_adjust_tree_phandle_references(struct device_node *node,
-		int phandle_delta)
+		struct device_node *target, int phandle_delta)
 {
-	struct device_node *child;
-	struct property *rprop;
-	int err;
-
-	/* locate the symbols & fixups nodes on resolve */
-	for_each_child_of_node(node, child)
-		if (of_node_cmp(child->name, "__local_fixups__") == 0)
-			break;
+	struct device_node *child, *childtarget;
+	struct property *rprop, *sprop;
+	int err, i, count;
+	unsigned int off;
+	phandle phandle;
 
-	/* no local fixups */
-	if (!child)
+	if (node == NULL)
 		return 0;
 
-	/* find the local fixups property */
-	for_each_property_of_node(child, rprop) {
+	for_each_property_of_node(node, rprop) {
+
 		/* skip properties added automatically */
-		if (of_prop_cmp(rprop->name, "name") == 0)
+		if (of_prop_cmp(rprop->name, "name") == 0 ||
+		    of_prop_cmp(rprop->name, "phandle") == 0 ||
+		    of_prop_cmp(rprop->name, "linux,phandle") == 0)
 			continue;
 
-		err = __of_adjust_phandle_ref(node, rprop, phandle_delta, true);
-		if (err)
+		if ((rprop->length % 4) != 0 || rprop->length == 0) {
+			pr_err("%s: Illegal property (size) '%s' @%s\n",
+					__func__, rprop->name, node->full_name);
+			return -EINVAL;
+		}
+		count = rprop->length / sizeof(__be32);
+
+		/* now find the target property */
+		for_each_property_of_node(target, sprop) {
+			if (of_prop_cmp(sprop->name, rprop->name) == 0)
+				break;
+		}
+
+		if (sprop == NULL) {
+			pr_err("%s: Could not find target property '%s' @%s\n",
+					__func__, rprop->name, node->full_name);
+			return -EINVAL;
+		}
+
+		for (i = 0; i < count; i++) {
+			off = be32_to_cpu(((__be32 *)rprop->value)[i]);
+			/* make sure the offset doesn't overstep (even wrap) */
+			if (off >= sprop->length ||
+					(off + 4) > sprop->length) {
+				pr_err("%s: Illegal property '%s' @%s\n",
+						__func__, rprop->name,
+						node->full_name);
+				return -EINVAL;
+			}
+
+			if (phandle_delta) {
+				/* adjust */
+				phandle = be32_to_cpu(*(__be32 *)(sprop->value + off));
+				phandle += phandle_delta;
+				*(__be32 *)(sprop->value + off) = cpu_to_be32(phandle);
+			}
+		}
+	}
+
+	for_each_child_of_node(node, child) {
+
+		for_each_child_of_node(target, childtarget)
+			if (__of_node_name_cmp(child, childtarget) == 0)
+				break;
+
+		if (!childtarget) {
+			pr_err("%s: Could not find target child '%s' @%s\n",
+					__func__, child->name, node->full_name);
+			return -EINVAL;
+		}
+
+		err = __of_adjust_tree_phandle_references(child, childtarget,
+				phandle_delta);
+		if (err != 0)
 			return err;
 	}
 
@@ -241,7 +303,7 @@ static int __of_adjust_tree_phandle_references(struct device_node *node,
  */
 int of_resolve_phandles(struct device_node *resolve)
 {
-	struct device_node *child, *refnode;
+	struct device_node *child, *childroot, *refnode;
 	struct device_node *root_sym, *resolve_sym, *resolve_fix;
 	struct property *rprop;
 	const char *refpath;
@@ -255,9 +317,23 @@ int of_resolve_phandles(struct device_node *resolve)
 	/* first we need to adjust the phandles */
 	phandle_delta = of_get_tree_max_phandle() + 1;
 	__of_adjust_tree_phandles(resolve, phandle_delta);
-	err = __of_adjust_tree_phandle_references(resolve, phandle_delta);
-	if (err != 0)
-		return err;
+
+	/* locate the local fixups */
+	childroot = NULL;
+	for_each_child_of_node(resolve, childroot)
+		if (of_node_cmp(childroot->name, "__local_fixups__") == 0)
+			break;
+
+	if (childroot != NULL) {
+		/* resolve root is guaranteed to be the '/' */
+		err = __of_adjust_tree_phandle_references(childroot,
+				resolve, 0);
+		if (err != 0)
+			return err;
+
+		BUG_ON(__of_adjust_tree_phandle_references(childroot,
+				resolve, phandle_delta));
+	}
 
 	root_sym = NULL;
 	resolve_sym = NULL;
@@ -322,7 +398,7 @@ int of_resolve_phandles(struct device_node *resolve)
 		pr_debug("%s: %s phandle is 0x%08x\n",
 				__func__, rprop->name, phandle);
 
-		err = __of_adjust_phandle_ref(resolve, rprop, phandle, false);
+		err = __of_adjust_phandle_ref(resolve, rprop, phandle);
 		if (err)
 			break;
 	}
diff --git a/drivers/of/unittest-data/testcases.dts b/drivers/of/unittest-data/testcases.dts
index 6994e15c24bf..b6bc41b2a185 100644
--- a/drivers/of/unittest-data/testcases.dts
+++ b/drivers/of/unittest-data/testcases.dts
@@ -23,28 +23,41 @@
  * this a kernel-internal data format.
  */
 / { __local_fixups__ {
-	fixup = "/testcase-data/testcase-device2:interrupt-parent:0",
-		"/testcase-data/testcase-device1:interrupt-parent:0",
-		"/testcase-data/interrupts/interrupts-extended0:interrupts-extended:60",
-		"/testcase-data/interrupts/interrupts-extended0:interrupts-extended:52",
-		"/testcase-data/interrupts/interrupts-extended0:interrupts-extended:44",
-		"/testcase-data/interrupts/interrupts-extended0:interrupts-extended:36",
-		"/testcase-data/interrupts/interrupts-extended0:interrupts-extended:24",
-		"/testcase-data/interrupts/interrupts-extended0:interrupts-extended:8",
-		"/testcase-data/interrupts/interrupts-extended0:interrupts-extended:0",
-		"/testcase-data/interrupts/interrupts1:interrupt-parent:0",
-		"/testcase-data/interrupts/interrupts0:interrupt-parent:0",
-		"/testcase-data/interrupts/intmap1:interrupt-map:12",
-		"/testcase-data/interrupts/intmap0:interrupt-map:52",
-		"/testcase-data/interrupts/intmap0:interrupt-map:36",
-		"/testcase-data/interrupts/intmap0:interrupt-map:16",
-		"/testcase-data/interrupts/intmap0:interrupt-map:4",
-		"/testcase-data/phandle-tests/consumer-a:phandle-list-bad-args:12",
-		"/testcase-data/phandle-tests/consumer-a:phandle-list-bad-args:0",
-		"/testcase-data/phandle-tests/consumer-a:phandle-list:56",
-		"/testcase-data/phandle-tests/consumer-a:phandle-list:52",
-		"/testcase-data/phandle-tests/consumer-a:phandle-list:40",
-		"/testcase-data/phandle-tests/consumer-a:phandle-list:24",
-		"/testcase-data/phandle-tests/consumer-a:phandle-list:8",
-		"/testcase-data/phandle-tests/consumer-a:phandle-list:0";
+	testcase-data {
+		phandle-tests {
+			consumer-a {
+				phandle-list = <0x00000000 0x00000008
+						0x00000018 0x00000028
+						0x00000034 0x00000038>;
+				phandle-list-bad-args = <0x00000000 0x0000000c>;
+			};
+		};
+		interrupts {
+			intmap0 {
+				interrupt-map = <0x00000004 0x00000010
+						 0x00000024 0x00000034>;
+			};
+			intmap1 {
+				interrupt-map = <0x0000000c>;
+			};
+			interrupts0 {
+				interrupt-parent = <0x00000000>;
+			};
+			interrupts1 {
+				interrupt-parent = <0x00000000>;
+			};
+			interrupts-extended0 {
+				interrupts-extended = <0x00000000 0x00000008
+						       0x00000018 0x00000024
+						       0x0000002c 0x00000034
+						       0x0000003c>;
+			};
+		};
+		testcase-device1 {
+			interrupt-parent = <0x00000000>;
+		};
+		testcase-device2 {
+			interrupt-parent = <0x00000000>;
+		};
+	};
 }; };
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 4/8] of: Add of_reconfig_get_state_change() of notifier helper.
@ 2014-11-21  1:35   ` Grant Likely
  0 siblings, 0 replies; 23+ messages in thread
From: Grant Likely @ 2014-11-21  1:35 UTC (permalink / raw)
  To: devicetree, linux-kernel, Pantelis Antoniou; +Cc: Rob Herring, Grant Likely

From: Pantelis Antoniou <pantelis.antoniou@konsulko.com>

Introduce of_reconfig_get_state_change() which allows an of notifier
to query about device state changes.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
---
 drivers/of/dynamic.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/of.h   |  1 +
 2 files changed, 97 insertions(+)

diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index 7c095bffef3a..7634c2f69d4a 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -85,6 +85,102 @@ int of_reconfig_notify(unsigned long action, void *p)
 	return notifier_to_errno(rc);
 }
 
+/*
+ * of_reconfig_get_state_change()	- Returns new state of device
+ * @action	- action of the of notifier
+ * @arg		- argument of the of notifier
+ *
+ * Returns the new state of a device based on the notifier used.
+ * Returns 0 on device going from enabled to disabled, 1 on device
+ * going from disabled to enabled and -1 on no change.
+ */
+int of_reconfig_get_state_change(unsigned long action, void *arg)
+{
+	struct device_node *dn;
+	struct property *prop, *old_prop;
+	struct of_prop_reconfig *pr;
+	int is_status, status_state, old_status_state, prev_state, new_state;
+
+	/* figure out if a device should be created or destroyed */
+	dn = NULL;
+	prop = old_prop = NULL;
+	switch (action) {
+	case OF_RECONFIG_ATTACH_NODE:
+	case OF_RECONFIG_DETACH_NODE:
+		dn = arg;
+		prop = of_find_property(dn, "status", NULL);
+		break;
+	case OF_RECONFIG_ADD_PROPERTY:
+	case OF_RECONFIG_REMOVE_PROPERTY:
+		pr = arg;
+		dn = pr->dn;
+		prop = pr->prop;
+		break;
+	case OF_RECONFIG_UPDATE_PROPERTY:
+		pr = arg;
+		dn = pr->dn;
+		prop = pr->prop;
+		old_prop = pr->old_prop;
+		break;
+	default:
+		return -1;	/* don't care */
+	}
+
+	is_status = 0;
+	status_state = -1;
+	old_status_state = -1;
+	prev_state = -1;
+	new_state = -1;
+
+	if (prop && !strcmp(prop->name, "status")) {
+		is_status = 1;
+		status_state = !strcmp(prop->value, "okay") ||
+			       !strcmp(prop->value, "ok");
+		if (old_prop)
+			old_status_state = !strcmp(old_prop->value, "okay") ||
+					   !strcmp(old_prop->value, "ok");
+	}
+
+	switch (action) {
+	case OF_RECONFIG_ATTACH_NODE:
+		prev_state = 0;
+		/* -1 & 0 status either missing or okay */
+		new_state = status_state != 0;
+		break;
+	case OF_RECONFIG_DETACH_NODE:
+		/* -1 & 0 status either missing or okay */
+		prev_state = status_state != 0;
+		new_state = 0;
+		break;
+	case OF_RECONFIG_ADD_PROPERTY:
+		if (is_status) {
+			/* no status property -> enabled (legacy) */
+			prev_state = 1;
+			new_state = status_state;
+		}
+		break;
+	case OF_RECONFIG_REMOVE_PROPERTY:
+		if (is_status) {
+			prev_state = status_state;
+			/* no status property -> enabled (legacy) */
+			new_state = 1;
+		}
+		break;
+	case OF_RECONFIG_UPDATE_PROPERTY:
+		if (is_status) {
+			prev_state = old_status_state != 0;
+			new_state = status_state != 0;
+		}
+		break;
+	}
+
+	if (prev_state == new_state)
+		return -1;
+
+	return new_state;
+}
+EXPORT_SYMBOL_GPL(of_reconfig_get_state_change);
+
 int of_property_notify(int action, struct device_node *np,
 		       struct property *prop, struct property *oldprop)
 {
diff --git a/include/linux/of.h b/include/linux/of.h
index 27635c89d8c2..96f678515d8f 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -327,6 +327,7 @@ struct of_prop_reconfig {
 extern int of_reconfig_notifier_register(struct notifier_block *);
 extern int of_reconfig_notifier_unregister(struct notifier_block *);
 extern int of_reconfig_notify(unsigned long, void *);
+extern int of_reconfig_get_state_change(unsigned long action, void *arg);
 
 extern int of_attach_node(struct device_node *);
 extern int of_detach_node(struct device_node *);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 4/8] of: Add of_reconfig_get_state_change() of notifier helper.
@ 2014-11-21  1:35   ` Grant Likely
  0 siblings, 0 replies; 23+ messages in thread
From: Grant Likely @ 2014-11-21  1:35 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Pantelis Antoniou
  Cc: Rob Herring, Grant Likely

From: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>

Introduce of_reconfig_get_state_change() which allows an of notifier
to query about device state changes.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
Signed-off-by: Grant Likely <grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 drivers/of/dynamic.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/of.h   |  1 +
 2 files changed, 97 insertions(+)

diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index 7c095bffef3a..7634c2f69d4a 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -85,6 +85,102 @@ int of_reconfig_notify(unsigned long action, void *p)
 	return notifier_to_errno(rc);
 }
 
+/*
+ * of_reconfig_get_state_change()	- Returns new state of device
+ * @action	- action of the of notifier
+ * @arg		- argument of the of notifier
+ *
+ * Returns the new state of a device based on the notifier used.
+ * Returns 0 on device going from enabled to disabled, 1 on device
+ * going from disabled to enabled and -1 on no change.
+ */
+int of_reconfig_get_state_change(unsigned long action, void *arg)
+{
+	struct device_node *dn;
+	struct property *prop, *old_prop;
+	struct of_prop_reconfig *pr;
+	int is_status, status_state, old_status_state, prev_state, new_state;
+
+	/* figure out if a device should be created or destroyed */
+	dn = NULL;
+	prop = old_prop = NULL;
+	switch (action) {
+	case OF_RECONFIG_ATTACH_NODE:
+	case OF_RECONFIG_DETACH_NODE:
+		dn = arg;
+		prop = of_find_property(dn, "status", NULL);
+		break;
+	case OF_RECONFIG_ADD_PROPERTY:
+	case OF_RECONFIG_REMOVE_PROPERTY:
+		pr = arg;
+		dn = pr->dn;
+		prop = pr->prop;
+		break;
+	case OF_RECONFIG_UPDATE_PROPERTY:
+		pr = arg;
+		dn = pr->dn;
+		prop = pr->prop;
+		old_prop = pr->old_prop;
+		break;
+	default:
+		return -1;	/* don't care */
+	}
+
+	is_status = 0;
+	status_state = -1;
+	old_status_state = -1;
+	prev_state = -1;
+	new_state = -1;
+
+	if (prop && !strcmp(prop->name, "status")) {
+		is_status = 1;
+		status_state = !strcmp(prop->value, "okay") ||
+			       !strcmp(prop->value, "ok");
+		if (old_prop)
+			old_status_state = !strcmp(old_prop->value, "okay") ||
+					   !strcmp(old_prop->value, "ok");
+	}
+
+	switch (action) {
+	case OF_RECONFIG_ATTACH_NODE:
+		prev_state = 0;
+		/* -1 & 0 status either missing or okay */
+		new_state = status_state != 0;
+		break;
+	case OF_RECONFIG_DETACH_NODE:
+		/* -1 & 0 status either missing or okay */
+		prev_state = status_state != 0;
+		new_state = 0;
+		break;
+	case OF_RECONFIG_ADD_PROPERTY:
+		if (is_status) {
+			/* no status property -> enabled (legacy) */
+			prev_state = 1;
+			new_state = status_state;
+		}
+		break;
+	case OF_RECONFIG_REMOVE_PROPERTY:
+		if (is_status) {
+			prev_state = status_state;
+			/* no status property -> enabled (legacy) */
+			new_state = 1;
+		}
+		break;
+	case OF_RECONFIG_UPDATE_PROPERTY:
+		if (is_status) {
+			prev_state = old_status_state != 0;
+			new_state = status_state != 0;
+		}
+		break;
+	}
+
+	if (prev_state == new_state)
+		return -1;
+
+	return new_state;
+}
+EXPORT_SYMBOL_GPL(of_reconfig_get_state_change);
+
 int of_property_notify(int action, struct device_node *np,
 		       struct property *prop, struct property *oldprop)
 {
diff --git a/include/linux/of.h b/include/linux/of.h
index 27635c89d8c2..96f678515d8f 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -327,6 +327,7 @@ struct of_prop_reconfig {
 extern int of_reconfig_notifier_register(struct notifier_block *);
 extern int of_reconfig_notifier_unregister(struct notifier_block *);
 extern int of_reconfig_notify(unsigned long, void *);
+extern int of_reconfig_get_state_change(unsigned long action, void *arg);
 
 extern int of_attach_node(struct device_node *);
 extern int of_detach_node(struct device_node *);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 5/8] of/overlay: Introduce DT overlay support
  2014-11-21  1:35 [PATCH 0/8] of: DT Overlay patches to be merged Grant Likely
                   ` (3 preceding siblings ...)
  2014-11-21  1:35   ` Grant Likely
@ 2014-11-21  1:35 ` Grant Likely
  2014-11-26 13:11     ` Paul Bolle
  2014-11-21  1:35 ` [PATCH 6/8] of/platform: Add OF_DYNAMIC notifier handler Grant Likely
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Grant Likely @ 2014-11-21  1:35 UTC (permalink / raw)
  To: devicetree, linux-kernel, Pantelis Antoniou; +Cc: Rob Herring, Grant Likely

From: Pantelis Antoniou <pantelis.antoniou@konsulko.com>

Overlays are a method to dynamically modify part of the kernel's
device tree with dynamically loaded data. Add the core functionality to
parse, apply and remove an overlay changeset. The core functionality
takes care of managing the overlay data format and performing the add
and remove. Drivers are expected to use the overlay functionality to
support custom expansion busses commonly found on consumer development
boards like the BeagleBone or Raspberry Pi.

The overlay code uses CONFIG_OF_DYNAMIC changesets to perform the low
level work of modifying the devicetree.

Documentation about internal and APIs is provided in
	Documentation/devicetree/overlay-notes.txt

v2:
- Switch from __of_node_alloc() to __of_node_dup()
- Documentation fixups
- Remove 2-pass processing of properties
- Remove separate ov_lock; just use the DT mutex.
v1:
- Drop delete capability using '-' prefix. The '-' prefixed names
are valid properties and nodes and there is no need for it just yet.
- Do not update special properties - name & phandle ones.
- Change order of node attachment, so that the special property update
works.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
---
 Documentation/devicetree/overlay-notes.txt | 133 +++++++
 drivers/of/Kconfig                         |   7 +
 drivers/of/Makefile                        |   1 +
 drivers/of/overlay.c                       | 562 +++++++++++++++++++++++++++++
 include/linux/of.h                         |  31 ++
 5 files changed, 734 insertions(+)
 create mode 100644 Documentation/devicetree/overlay-notes.txt
 create mode 100644 drivers/of/overlay.c

diff --git a/Documentation/devicetree/overlay-notes.txt b/Documentation/devicetree/overlay-notes.txt
new file mode 100644
index 000000000000..30ae758e3eef
--- /dev/null
+++ b/Documentation/devicetree/overlay-notes.txt
@@ -0,0 +1,133 @@
+Device Tree Overlay Notes
+-------------------------
+
+This document describes the implementation of the in-kernel
+device tree overlay functionality residing in drivers/of/overlay.c and is a
+companion document to Documentation/devicetree/dt-object-internal.txt[1] &
+Documentation/devicetree/dynamic-resolution-notes.txt[2]
+
+How overlays work
+-----------------
+
+A Device Tree's overlay purpose is to modify the kernel's live tree, and
+have the modification affecting the state of the the kernel in a way that
+is reflecting the changes.
+Since the kernel mainly deals with devices, any new device node that result
+in an active device should have it created while if the device node is either
+disabled or removed all together, the affected device should be deregistered.
+
+Lets take an example where we have a foo board with the following base tree
+which is taken from [1].
+
+---- foo.dts -----------------------------------------------------------------
+	/* FOO platform */
+	/ {
+		compatible = "corp,foo";
+
+		/* shared resources */
+		res: res {
+		};
+
+		/* On chip peripherals */
+		ocp: ocp {
+			/* peripherals that are always instantiated */
+			peripheral1 { ... };
+		}
+	};
+---- foo.dts -----------------------------------------------------------------
+
+The overlay bar.dts, when loaded (and resolved as described in [2]) should
+
+---- bar.dts -----------------------------------------------------------------
+/plugin/;	/* allow undefined label references and record them */
+/ {
+	....	/* various properties for loader use; i.e. part id etc. */
+	fragment@0 {
+		target = <&ocp>;
+		__overlay__ {
+			/* bar peripheral */
+			bar {
+				compatible = "corp,bar";
+				... /* various properties and child nodes */
+			}
+		};
+	};
+};
+---- bar.dts -----------------------------------------------------------------
+
+result in foo+bar.dts
+
+---- foo+bar.dts -------------------------------------------------------------
+	/* FOO platform + bar peripheral */
+	/ {
+		compatible = "corp,foo";
+
+		/* shared resources */
+		res: res {
+		};
+
+		/* On chip peripherals */
+		ocp: ocp {
+			/* peripherals that are always instantiated */
+			peripheral1 { ... };
+
+			/* bar peripheral */
+			bar {
+				compatible = "corp,bar";
+				... /* various properties and child nodes */
+			}
+		}
+	};
+---- foo+bar.dts -------------------------------------------------------------
+
+As a result of the the overlay, a new device node (bar) has been created
+so a bar platform device will be registered and if a matching device driver
+is loaded the device will be created as expected.
+
+Overlay in-kernel API
+--------------------------------
+
+The API is quite easy to use.
+
+1. Call of_overlay_create() to create and apply an overlay. The return value
+is a cookie identifying this overlay.
+
+2. Call of_overlay_destroy() to remove and cleanup the overlay previously
+created via the call to of_overlay_create(). Removal of an overlay that
+is stacked by another will not be permitted.
+
+Finally, if you need to remove all overlays in one-go, just call
+of_overlay_destroy_all() which will remove every single one in the correct
+order.
+
+Overlay DTS Format
+------------------
+
+The DTS of an overlay should have the following format:
+
+{
+	/* ignored properties by the overlay */
+
+	fragment@0 {	/* first child node */
+
+		target=<phandle>;	/* phandle target of the overlay */
+	or
+		target-path="/path";	/* target path of the overlay */
+
+		__overlay__ {
+			property-a;	/* add property-a to the target */
+			node-a {	/* add to an existing, or create a node-a */
+				...
+			};
+		};
+	}
+	fragment@1 {	/* second child node */
+		...
+	};
+	/* more fragments follow */
+}
+
+Using the non-phandle based target method allows one to use a base DT which does
+not contain a __symbols__ node, i.e. it was not compiled with the -@ option.
+The __symbols__ node is only required for the target=<phandle> method, since it
+contains the information required to map from a phandle to a tree location.
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index fbe8f8d418f7..18b2e2539f84 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -84,4 +84,11 @@ config OF_RESERVED_MEM
 config OF_RESOLVE
 	bool
 
+config OF_OVERLAY
+	bool
+	depends on OF
+	select OF_DYNAMIC
+	select OF_DEVICE
+	select OF_RESOLVE
+
 endmenu # OF
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index d90553fcd37f..7563f36c71db 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_OF_PCI_IRQ)  += of_pci_irq.o
 obj-$(CONFIG_OF_MTD)	+= of_mtd.o
 obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o
 obj-$(CONFIG_OF_RESOLVE)  += resolver.o
+obj-$(CONFIG_OF_OVERLAY) += overlay.o
 
 CFLAGS_fdt.o = -I$(src)/../../scripts/dtc/libfdt
 CFLAGS_fdt_address.o = -I$(src)/../../scripts/dtc/libfdt
diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
new file mode 100644
index 000000000000..ea63fbd228ed
--- /dev/null
+++ b/drivers/of/overlay.c
@@ -0,0 +1,562 @@
+/*
+ * Functions for working with device tree overlays
+ *
+ * Copyright (C) 2012 Pantelis Antoniou <panto@antoniou-consulting.com>
+ * Copyright (C) 2012 Texas Instruments Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ */
+#undef DEBUG
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/string.h>
+#include <linux/ctype.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+
+#include "of_private.h"
+
+/**
+ * struct of_overlay_info - Holds a single overlay info
+ * @target:	target of the overlay operation
+ * @overlay:	pointer to the overlay contents node
+ *
+ * Holds a single overlay state, including all the overlay logs &
+ * records.
+ */
+struct of_overlay_info {
+	struct device_node *target;
+	struct device_node *overlay;
+};
+
+/**
+ * struct of_overlay - Holds a complete overlay transaction
+ * @node:	List on which we are located
+ * @count:	Count of ovinfo structures
+ * @ovinfo_tab:	Overlay info table (count sized)
+ * @cset:	Changeset to be used
+ *
+ * Holds a complete overlay transaction
+ */
+struct of_overlay {
+	int id;
+	struct list_head node;
+	int count;
+	struct of_overlay_info *ovinfo_tab;
+	struct of_changeset cset;
+};
+
+static int of_overlay_apply_one(struct of_overlay *ov,
+		struct device_node *target, const struct device_node *overlay);
+
+static int of_overlay_apply_single_property(struct of_overlay *ov,
+		struct device_node *target, struct property *prop)
+{
+	struct property *propn, *tprop;
+
+	/* NOTE: Multiple changes of single properties not supported */
+	tprop = of_find_property(target, prop->name, NULL);
+
+	/* special properties are not meant to be updated (silent NOP) */
+	if (of_prop_cmp(prop->name, "name") == 0 ||
+	    of_prop_cmp(prop->name, "phandle") == 0 ||
+	    of_prop_cmp(prop->name, "linux,phandle") == 0)
+		return 0;
+
+	propn = __of_prop_dup(prop, GFP_KERNEL);
+	if (propn == NULL)
+		return -ENOMEM;
+
+	/* not found? add */
+	if (tprop == NULL)
+		return of_changeset_add_property(&ov->cset, target, propn);
+
+	/* found? update */
+	return of_changeset_update_property(&ov->cset, target, propn);
+}
+
+static int of_overlay_apply_single_device_node(struct of_overlay *ov,
+		struct device_node *target, struct device_node *child)
+{
+	const char *cname;
+	struct device_node *tchild, *grandchild;
+	int ret = 0;
+
+	cname = kbasename(child->full_name);
+	if (cname == NULL)
+		return -ENOMEM;
+
+	/* NOTE: Multiple mods of created nodes not supported */
+	tchild = of_get_child_by_name(target, cname);
+	if (tchild != NULL) {
+		/* apply overlay recursively */
+		ret = of_overlay_apply_one(ov, tchild, child);
+		of_node_put(tchild);
+	} else {
+		/* create empty tree as a target */
+		tchild = __of_node_dup(child, "%s/%s", target->full_name, cname);
+		if (!tchild)
+			return -ENOMEM;
+
+		/* point to parent */
+		tchild->parent = target;
+
+		ret = of_changeset_attach_node(&ov->cset, tchild);
+		if (ret)
+			return ret;
+
+		ret = of_overlay_apply_one(ov, tchild, child);
+		if (ret)
+			return ret;
+
+		/* The properties are already copied, now do the child nodes */
+		for_each_child_of_node(child, grandchild) {
+			ret = of_overlay_apply_single_device_node(ov, tchild, grandchild);
+			if (ret) {
+				pr_err("%s: Failed to apply single node @%s/%s\n",
+					__func__, tchild->full_name,
+					grandchild->name);
+				return ret;
+			}
+		}
+	}
+
+	return ret;
+}
+
+/*
+ * Apply a single overlay node recursively.
+ *
+ * Note that the in case of an error the target node is left
+ * in a inconsistent state. Error recovery should be performed
+ * by using the changeset.
+ */
+static int of_overlay_apply_one(struct of_overlay *ov,
+		struct device_node *target, const struct device_node *overlay)
+{
+	struct device_node *child;
+	struct property *prop;
+	int ret;
+
+	for_each_property_of_node(overlay, prop) {
+		ret = of_overlay_apply_single_property(ov, target, prop);
+		if (ret) {
+			pr_err("%s: Failed to apply prop @%s/%s\n",
+				__func__, target->full_name, prop->name);
+			return ret;
+		}
+	}
+
+	for_each_child_of_node(overlay, child) {
+		ret = of_overlay_apply_single_device_node(ov, target, child);
+		if (ret != 0) {
+			pr_err("%s: Failed to apply single node @%s/%s\n",
+					__func__, target->full_name,
+					child->name);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+/**
+ * of_overlay_apply() - Apply @count overlays pointed at by @ovinfo_tab
+ * @ov:		Overlay to apply
+ *
+ * Applies the overlays given, while handling all error conditions
+ * appropriately. Either the operation succeeds, or if it fails the
+ * live tree is reverted to the state before the attempt.
+ * Returns 0, or an error if the overlay attempt failed.
+ */
+static int of_overlay_apply(struct of_overlay *ov)
+{
+	int i, err;
+
+	/* first we apply the overlays atomically */
+	for (i = 0; i < ov->count; i++) {
+		struct of_overlay_info *ovinfo = &ov->ovinfo_tab[i];
+
+		err = of_overlay_apply_one(ov, ovinfo->target, ovinfo->overlay);
+		if (err != 0) {
+			pr_err("%s: overlay failed '%s'\n",
+				__func__, ovinfo->target->full_name);
+			return err;
+		}
+	}
+
+	return 0;
+}
+
+/*
+ * Find the target node using a number of different strategies
+ * in order of preference
+ *
+ * "target" property containing the phandle of the target
+ * "target-path" property containing the path of the target
+ */
+static struct device_node *find_target_node(struct device_node *info_node)
+{
+	const char *path;
+	u32 val;
+	int ret;
+
+	/* first try to go by using the target as a phandle */
+	ret = of_property_read_u32(info_node, "target", &val);
+	if (ret == 0)
+		return of_find_node_by_phandle(val);
+
+	/* now try to locate by path */
+	ret = of_property_read_string(info_node, "target-path", &path);
+	if (ret == 0)
+		return of_find_node_by_path(path);
+
+	pr_err("%s: Failed to find target for node %p (%s)\n", __func__,
+		info_node, info_node->name);
+
+	return NULL;
+}
+
+/**
+ * of_fill_overlay_info() - Fill an overlay info structure
+ * @ov		Overlay to fill
+ * @info_node:	Device node containing the overlay
+ * @ovinfo:	Pointer to the overlay info structure to fill
+ *
+ * Fills an overlay info structure with the overlay information
+ * from a device node. This device node must have a target property
+ * which contains a phandle of the overlay target node, and an
+ * __overlay__ child node which has the overlay contents.
+ * Both ovinfo->target & ovinfo->overlay have their references taken.
+ *
+ * Returns 0 on success, or a negative error value.
+ */
+static int of_fill_overlay_info(struct of_overlay *ov,
+		struct device_node *info_node, struct of_overlay_info *ovinfo)
+{
+	ovinfo->overlay = of_get_child_by_name(info_node, "__overlay__");
+	if (ovinfo->overlay == NULL)
+		goto err_fail;
+
+	ovinfo->target = find_target_node(info_node);
+	if (ovinfo->target == NULL)
+		goto err_fail;
+
+	return 0;
+
+err_fail:
+	of_node_put(ovinfo->target);
+	of_node_put(ovinfo->overlay);
+
+	memset(ovinfo, 0, sizeof(*ovinfo));
+	return -EINVAL;
+}
+
+/**
+ * of_build_overlay_info() - Build an overlay info array
+ * @ov		Overlay to build
+ * @tree:	Device node containing all the overlays
+ *
+ * Helper function that given a tree containing overlay information,
+ * allocates and builds an overlay info array containing it, ready
+ * for use using of_overlay_apply.
+ *
+ * Returns 0 on success with the @cntp @ovinfop pointers valid,
+ * while on error a negative error value is returned.
+ */
+static int of_build_overlay_info(struct of_overlay *ov,
+		struct device_node *tree)
+{
+	struct device_node *node;
+	struct of_overlay_info *ovinfo;
+	int cnt, err;
+
+	/* worst case; every child is a node */
+	cnt = 0;
+	for_each_child_of_node(tree, node)
+		cnt++;
+
+	ovinfo = kcalloc(cnt, sizeof(*ovinfo), GFP_KERNEL);
+	if (ovinfo == NULL)
+		return -ENOMEM;
+
+	cnt = 0;
+	for_each_child_of_node(tree, node) {
+		memset(&ovinfo[cnt], 0, sizeof(*ovinfo));
+		err = of_fill_overlay_info(ov, node, &ovinfo[cnt]);
+		if (err == 0)
+			cnt++;
+	}
+
+	/* if nothing filled, return error */
+	if (cnt == 0) {
+		kfree(ovinfo);
+		return -ENODEV;
+	}
+
+	ov->count = cnt;
+	ov->ovinfo_tab = ovinfo;
+
+	return 0;
+}
+
+/**
+ * of_free_overlay_info() - Free an overlay info array
+ * @ov		Overlay to free the overlay info from
+ * @ovinfo_tab:	Array of overlay_info's to free
+ *
+ * Releases the memory of a previously allocated ovinfo array
+ * by of_build_overlay_info.
+ * Returns 0, or an error if the arguments are bogus.
+ */
+static int of_free_overlay_info(struct of_overlay *ov)
+{
+	struct of_overlay_info *ovinfo;
+	int i;
+
+	/* do it in reverse */
+	for (i = ov->count - 1; i >= 0; i--) {
+		ovinfo = &ov->ovinfo_tab[i];
+
+		of_node_put(ovinfo->target);
+		of_node_put(ovinfo->overlay);
+	}
+	kfree(ov->ovinfo_tab);
+
+	return 0;
+}
+
+static LIST_HEAD(ov_list);
+static DEFINE_IDR(ov_idr);
+
+/**
+ * of_overlay_create() - Create and apply an overlay
+ * @tree:	Device node containing all the overlays
+ *
+ * Creates and applies an overlay while also keeping track
+ * of the overlay in a list. This list can be used to prevent
+ * illegal overlay removals.
+ *
+ * Returns the id of the created overlay, or an negative error number
+ */
+int of_overlay_create(struct device_node *tree)
+{
+	struct of_overlay *ov;
+	int err, id;
+
+	/* allocate the overlay structure */
+	ov = kzalloc(sizeof(*ov), GFP_KERNEL);
+	if (ov == NULL)
+		return -ENOMEM;
+	ov->id = -1;
+
+	INIT_LIST_HEAD(&ov->node);
+
+	of_changeset_init(&ov->cset);
+
+	mutex_lock(&of_mutex);
+
+	id = idr_alloc(&ov_idr, ov, 0, 0, GFP_KERNEL);
+	if (id < 0) {
+		pr_err("%s: idr_alloc() failed for tree@%s\n",
+				__func__, tree->full_name);
+		err = id;
+		goto err_destroy_trans;
+	}
+	ov->id = id;
+
+	/* build the overlay info structures */
+	err = of_build_overlay_info(ov, tree);
+	if (err) {
+		pr_err("%s: of_build_overlay_info() failed for tree@%s\n",
+				__func__, tree->full_name);
+		goto err_free_idr;
+	}
+
+	/* apply the overlay */
+	err = of_overlay_apply(ov);
+	if (err) {
+		pr_err("%s: of_overlay_apply() failed for tree@%s\n",
+				__func__, tree->full_name);
+		goto err_abort_trans;
+	}
+
+	/* apply the changeset */
+	err = of_changeset_apply(&ov->cset);
+	if (err) {
+		pr_err("%s: of_changeset_apply() failed for tree@%s\n",
+				__func__, tree->full_name);
+		goto err_revert_overlay;
+	}
+
+	/* add to the tail of the overlay list */
+	list_add_tail(&ov->node, &ov_list);
+
+	mutex_unlock(&of_mutex);
+
+	return id;
+
+err_revert_overlay:
+err_abort_trans:
+	of_free_overlay_info(ov);
+err_free_idr:
+	idr_remove(&ov_idr, ov->id);
+err_destroy_trans:
+	of_changeset_destroy(&ov->cset);
+	kfree(ov);
+	mutex_unlock(&of_mutex);
+
+	return err;
+}
+EXPORT_SYMBOL_GPL(of_overlay_create);
+
+/* check whether the given node, lies under the given tree */
+static int overlay_subtree_check(struct device_node *tree,
+		struct device_node *dn)
+{
+	struct device_node *child;
+
+	/* match? */
+	if (tree == dn)
+		return 1;
+
+	for_each_child_of_node(tree, child) {
+		if (overlay_subtree_check(child, dn))
+			return 1;
+	}
+
+	return 0;
+}
+
+/* check whether this overlay is the topmost */
+static int overlay_is_topmost(struct of_overlay *ov, struct device_node *dn)
+{
+	struct of_overlay *ovt;
+	struct of_changeset_entry *ce;
+
+	list_for_each_entry_reverse(ovt, &ov_list, node) {
+		/* if we hit ourselves, we're done */
+		if (ovt == ov)
+			break;
+
+		/* check against each subtree affected by this overlay */
+		list_for_each_entry(ce, &ovt->cset.entries, node) {
+			if (overlay_subtree_check(ce->np, dn)) {
+				pr_err("%s: #%d clashes #%d @%s\n",
+					__func__, ov->id, ovt->id,
+					dn->full_name);
+				return 0;
+			}
+		}
+	}
+
+	/* overlay is topmost */
+	return 1;
+}
+
+/*
+ * We can safely remove the overlay only if it's the top-most one.
+ * Newly applied overlays are inserted at the tail of the overlay list,
+ * so a top most overlay is the one that is closest to the tail.
+ *
+ * The topmost check is done by exploiting this property. For each
+ * affected device node in the log list we check if this overlay is
+ * the one closest to the tail. If another overlay has affected this
+ * device node and is closest to the tail, then removal is not permited.
+ */
+static int overlay_removal_is_ok(struct of_overlay *ov)
+{
+	struct of_changeset_entry *ce;
+
+	list_for_each_entry(ce, &ov->cset.entries, node) {
+		if (!overlay_is_topmost(ov, ce->np)) {
+			pr_err("%s: overlay #%d is not topmost\n",
+					__func__, ov->id);
+			return 0;
+		}
+	}
+
+	return 1;
+}
+
+/**
+ * of_overlay_destroy() - Removes an overlay
+ * @id:	Overlay id number returned by a previous call to of_overlay_create
+ *
+ * Removes an overlay if it is permissible.
+ *
+ * Returns 0 on success, or an negative error number
+ */
+int of_overlay_destroy(int id)
+{
+	struct of_overlay *ov;
+	int err;
+
+	mutex_lock(&of_mutex);
+
+	ov = idr_find(&ov_idr, id);
+	if (ov == NULL) {
+		err = -ENODEV;
+		pr_err("%s: Could not find overlay #%d\n",
+				__func__, id);
+		goto out;
+	}
+
+	/* check whether the overlay is safe to remove */
+	if (!overlay_removal_is_ok(ov)) {
+		err = -EBUSY;
+		pr_err("%s: removal check failed for overlay #%d\n",
+				__func__, id);
+		goto out;
+	}
+
+
+	list_del(&ov->node);
+	of_changeset_revert(&ov->cset);
+	of_free_overlay_info(ov);
+	idr_remove(&ov_idr, id);
+	of_changeset_destroy(&ov->cset);
+	kfree(ov);
+
+	err = 0;
+
+out:
+	mutex_unlock(&of_mutex);
+
+	return err;
+}
+EXPORT_SYMBOL_GPL(of_overlay_destroy);
+
+/**
+ * of_overlay_destroy_all() - Removes all overlays from the system
+ *
+ * Removes all overlays from the system in the correct order.
+ *
+ * Returns 0 on success, or an negative error number
+ */
+int of_overlay_destroy_all(void)
+{
+	struct of_overlay *ov, *ovn;
+
+	mutex_lock(&of_mutex);
+
+	/* the tail of list is guaranteed to be safe to remove */
+	list_for_each_entry_safe_reverse(ov, ovn, &ov_list, node) {
+		list_del(&ov->node);
+		of_changeset_revert(&ov->cset);
+		of_free_overlay_info(ov);
+		idr_remove(&ov_idr, ov->id);
+		kfree(ov);
+	}
+
+	mutex_unlock(&of_mutex);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(of_overlay_destroy_all);
diff --git a/include/linux/of.h b/include/linux/of.h
index 96f678515d8f..eedff4685fba 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -23,6 +23,7 @@
 #include <linux/spinlock.h>
 #include <linux/topology.h>
 #include <linux/notifier.h>
+#include <linux/list.h>
 
 #include <asm/byteorder.h>
 #include <asm/errno.h>
@@ -931,4 +932,34 @@ static inline int of_changeset_update_property(struct of_changeset *ocs,
 /* CONFIG_OF_RESOLVE api */
 extern int of_resolve_phandles(struct device_node *tree);
 
+/**
+ * Overlay support
+ */
+
+#ifdef CONFIG_OF_OVERLAY
+
+/* ID based overlays; the API for external users */
+int of_overlay_create(struct device_node *tree);
+int of_overlay_destroy(int id);
+int of_overlay_destroy_all(void);
+
+#else
+
+static inline int of_overlay_create(struct device_node *tree)
+{
+	return -ENOTSUPP;
+}
+
+static inline int of_overlay_destroy(int id)
+{
+	return -ENOTSUPP;
+}
+
+static inline int of_overlay_destroy_all(void)
+{
+	return -ENOTSUPP;
+}
+
+#endif
+
 #endif /* _LINUX_OF_H */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 6/8] of/platform: Add OF_DYNAMIC notifier handler
  2014-11-21  1:35 [PATCH 0/8] of: DT Overlay patches to be merged Grant Likely
                   ` (4 preceding siblings ...)
  2014-11-21  1:35 ` [PATCH 5/8] of/overlay: Introduce DT overlay support Grant Likely
@ 2014-11-21  1:35 ` Grant Likely
  2014-11-21  1:35 ` [PATCH 7/8] of/overlay: Add overlay unittests Grant Likely
  2014-11-21  1:35   ` Grant Likely
  7 siblings, 0 replies; 23+ messages in thread
From: Grant Likely @ 2014-11-21  1:35 UTC (permalink / raw)
  To: devicetree, linux-kernel, Pantelis Antoniou; +Cc: Rob Herring, Grant Likely

From: Pantelis Antoniou <pantelis.antoniou@konsulko.com>

Add OF notifier handler needed for creating/destroying platform devices
according to dynamic runtime changes in the DT live tree.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
---
 drivers/base/platform.c     |  1 +
 drivers/of/platform.c       | 78 +++++++++++++++++++++++++++++++++++++++++++++
 include/linux/of_platform.h | 10 ++++++
 3 files changed, 89 insertions(+)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index b2afc29403f9..c4c02c0e42b6 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1006,6 +1006,7 @@ int __init platform_bus_init(void)
 	error =  bus_register(&platform_bus_type);
 	if (error)
 		device_unregister(&platform_bus);
+	WARN_ON(of_platform_register_reconfig_notifier() != 0);
 	return error;
 }
 
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 656cccf0e680..b6d9a406a75d 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -550,4 +550,82 @@ void of_platform_depopulate(struct device *parent)
 }
 EXPORT_SYMBOL_GPL(of_platform_depopulate);
 
+#ifdef CONFIG_OF_DYNAMIC
+
+static struct notifier_block platform_of_notifier;
+
+static int of_platform_notify(struct notifier_block *nb,
+				unsigned long action, void *arg)
+{
+	struct platform_device *pdev_parent, *pdev;
+	struct device_node *dn;
+	int state;
+	bool children_left;
+
+	state = of_reconfig_get_state_change(action, arg);
+
+	/* no change? */
+	if (state == -1)
+		return NOTIFY_OK;
+
+	switch (action) {
+	case OF_RECONFIG_ATTACH_NODE:
+	case OF_RECONFIG_DETACH_NODE:
+		dn = arg;
+		break;
+	case OF_RECONFIG_ADD_PROPERTY:
+	case OF_RECONFIG_REMOVE_PROPERTY:
+	case OF_RECONFIG_UPDATE_PROPERTY:
+		dn = ((struct of_prop_reconfig *)arg)->dn;
+		break;
+	default:
+		return NOTIFY_OK;
+	}
+
+	if (state) {
+
+		/* verify that the parent is a bus */
+		if (!of_node_check_flag(dn->parent, OF_POPULATED_BUS))
+			return NOTIFY_OK;	/* not for us */
+
+		/* pdev_parent may be NULL when no bus platform device */
+		pdev_parent = of_find_device_by_node(dn->parent);
+		pdev = of_platform_device_create(dn, NULL,
+				pdev_parent ? &pdev_parent->dev : NULL);
+		of_dev_put(pdev_parent);
+
+		if (pdev == NULL) {
+			pr_err("%s: failed to create for '%s'\n",
+					__func__, dn->full_name);
+			/* of_platform_device_create tosses the error code */
+			return notifier_from_errno(-EINVAL);
+		}
+
+	} else {
+
+		/* find our device by node */
+		pdev = of_find_device_by_node(dn);
+		if (pdev == NULL)
+			return NOTIFY_OK;	/* no? not meant for us */
+
+		/* unregister takes one ref away */
+		of_platform_device_destroy(&pdev->dev, &children_left);
+
+		/* and put the reference of the find */
+		of_dev_put(pdev);
+
+	}
+
+	return NOTIFY_OK;
+}
+
+int of_platform_register_reconfig_notifier(void)
+{
+	platform_of_notifier.notifier_call = of_platform_notify;
+	return of_reconfig_notifier_register(&platform_of_notifier);
+}
+EXPORT_SYMBOL_GPL(of_platform_register_reconfig_notifier);
+
+#endif
+
 #endif /* CONFIG_OF_ADDRESS */
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index c2b0627a2317..01fe5d6345fb 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -84,4 +84,14 @@ static inline int of_platform_populate(struct device_node *root,
 static inline void of_platform_depopulate(struct device *parent) { }
 #endif
 
+#ifdef CONFIG_OF_DYNAMIC
+extern int of_platform_register_reconfig_notifier(void);
+#else
+static inline int of_platform_register_reconfig_notifier(void)
+{
+	return 0;
+}
+#endif
+
+
 #endif	/* _LINUX_OF_PLATFORM_H */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 7/8] of/overlay: Add overlay unittests
  2014-11-21  1:35 [PATCH 0/8] of: DT Overlay patches to be merged Grant Likely
                   ` (5 preceding siblings ...)
  2014-11-21  1:35 ` [PATCH 6/8] of/platform: Add OF_DYNAMIC notifier handler Grant Likely
@ 2014-11-21  1:35 ` Grant Likely
  2014-11-21  1:35   ` Grant Likely
  7 siblings, 0 replies; 23+ messages in thread
From: Grant Likely @ 2014-11-21  1:35 UTC (permalink / raw)
  To: devicetree, linux-kernel, Pantelis Antoniou; +Cc: Rob Herring, Grant Likely

From: Pantelis Antoniou <pantelis.antoniou@konsulko.com>

Add unittests for OF overlays.

It tests overlay device addition/removal and whether
the apply revert sequence is correct.

Changes since V1:
* Added local fixups entries.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
---
 Documentation/devicetree/bindings/unittest.txt |  14 +
 drivers/of/unittest-data/testcases.dts         |  16 +
 drivers/of/unittest-data/tests-overlay.dtsi    | 180 +++++++++
 drivers/of/unittest.c                          | 481 +++++++++++++++++++++++++
 4 files changed, 691 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/unittest.txt
 create mode 100644 drivers/of/unittest-data/tests-overlay.dtsi

diff --git a/Documentation/devicetree/bindings/unittest.txt b/Documentation/devicetree/bindings/unittest.txt
new file mode 100644
index 000000000000..0f92a22fddfa
--- /dev/null
+++ b/Documentation/devicetree/bindings/unittest.txt
@@ -0,0 +1,14 @@
+* OF selftest platform device
+
+** selftest
+
+Required properties:
+- compatible: must be "selftest"
+
+All other properties are optional.
+
+Example:
+	selftest {
+		compatible = "selftest";
+		status = "okay";
+	};
diff --git a/drivers/of/unittest-data/testcases.dts b/drivers/of/unittest-data/testcases.dts
index b6bc41b2a185..12f7c3d649c8 100644
--- a/drivers/of/unittest-data/testcases.dts
+++ b/drivers/of/unittest-data/testcases.dts
@@ -13,6 +13,7 @@
 #include "tests-interrupts.dtsi"
 #include "tests-match.dtsi"
 #include "tests-platform.dtsi"
+#include "tests-overlay.dtsi"
 
 /*
  * phandle fixup data - generated by dtc patches that aren't upstream.
@@ -59,5 +60,20 @@
 		testcase-device2 {
 			interrupt-parent = <0x00000000>;
 		};
+		overlay2 {
+			fragment@0 {
+				target = <0x00000000>;
+			};
+		};
+		overlay3 {
+			fragment@0 {
+				target = <0x00000000>;
+			};
+		};
+		overlay4 {
+			fragment@0 {
+				target = <0x00000000>;
+			};
+		};
 	};
 }; };
diff --git a/drivers/of/unittest-data/tests-overlay.dtsi b/drivers/of/unittest-data/tests-overlay.dtsi
new file mode 100644
index 000000000000..75976da22b2e
--- /dev/null
+++ b/drivers/of/unittest-data/tests-overlay.dtsi
@@ -0,0 +1,180 @@
+
+/ {
+	testcase-data {
+		overlay-node {
+
+			/* test bus */
+			selftestbus: test-bus {
+				compatible = "simple-bus";
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				selftest100: test-selftest100 {
+					compatible = "selftest";
+					status = "okay";
+					reg = <100>;
+				};
+
+				selftest101: test-selftest101 {
+					compatible = "selftest";
+					status = "disabled";
+					reg = <101>;
+				};
+
+				selftest0: test-selftest0 {
+					compatible = "selftest";
+					status = "disabled";
+					reg = <0>;
+				};
+
+				selftest1: test-selftest1 {
+					compatible = "selftest";
+					status = "okay";
+					reg = <1>;
+				};
+
+				selftest2: test-selftest2 {
+					compatible = "selftest";
+					status = "disabled";
+					reg = <2>;
+				};
+
+				selftest3: test-selftest3 {
+					compatible = "selftest";
+					status = "okay";
+					reg = <3>;
+				};
+
+				selftest5: test-selftest5 {
+					compatible = "selftest";
+					status = "disabled";
+					reg = <5>;
+				};
+
+				selftest6: test-selftest6 {
+					compatible = "selftest";
+					status = "disabled";
+					reg = <6>;
+				};
+
+				selftest7: test-selftest7 {
+					compatible = "selftest";
+					status = "disabled";
+					reg = <7>;
+				};
+
+				selftest8: test-selftest8 {
+					compatible = "selftest";
+					status = "disabled";
+					reg = <8>;
+				};
+			};
+		};
+
+		/* test enable using absolute target path */
+		overlay0 {
+			fragment@0 {
+				target-path = "/testcase-data/overlay-node/test-bus/test-selftest0";
+				__overlay__ {
+					status = "okay";
+				};
+			};
+		};
+
+		/* test disable using absolute target path */
+		overlay1 {
+			fragment@0 {
+				target-path = "/testcase-data/overlay-node/test-bus/test-selftest1";
+				__overlay__ {
+					status = "disabled";
+				};
+			};
+		};
+
+		/* test enable using label */
+		overlay2 {
+			fragment@0 {
+				target = <&selftest2>;
+				__overlay__ {
+					status = "okay";
+				};
+			};
+		};
+
+		/* test disable using label */
+		overlay3 {
+			fragment@0 {
+				target = <&selftest3>;
+				__overlay__ {
+					status = "disabled";
+				};
+			};
+		};
+
+		/* test insertion of a full node */
+		overlay4 {
+			fragment@0 {
+				target = <&selftestbus>;
+				__overlay__ {
+
+					/* suppress DTC warning */
+					#address-cells = <1>;
+					#size-cells = <0>;
+
+					test-selftest4 {
+						compatible = "selftest";
+						status = "okay";
+						reg = <4>;
+					};
+				};
+			};
+		};
+
+		/* test overlay apply revert */
+		overlay5 {
+			fragment@0 {
+				target-path = "/testcase-data/overlay-node/test-bus/test-selftest5";
+				__overlay__ {
+					status = "okay";
+				};
+			};
+		};
+
+		/* test overlays application and removal in sequence */
+		overlay6 {
+			fragment@0 {
+				target-path = "/testcase-data/overlay-node/test-bus/test-selftest6";
+				__overlay__ {
+					status = "okay";
+				};
+			};
+		};
+		overlay7 {
+			fragment@0 {
+				target-path = "/testcase-data/overlay-node/test-bus/test-selftest7";
+				__overlay__ {
+					status = "okay";
+				};
+			};
+		};
+
+		/* test overlays application and removal in bad sequence */
+		overlay8 {
+			fragment@0 {
+				target-path = "/testcase-data/overlay-node/test-bus/test-selftest8";
+				__overlay__ {
+					status = "okay";
+				};
+			};
+		};
+		overlay9 {
+			fragment@0 {
+				target-path = "/testcase-data/overlay-node/test-bus/test-selftest8";
+				__overlay__ {
+					property-foo = "bar";
+				};
+			};
+		};
+
+	};
+};
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 60eb28422077..849dfd1b9b98 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -17,6 +17,8 @@
 #include <linux/mutex.h>
 #include <linux/slab.h>
 #include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/of_platform.h>
 
 #include "of_private.h"
 
@@ -930,6 +932,484 @@ static void selftest_data_remove(void)
 	}
 }
 
+#ifdef CONFIG_OF_OVERLAY
+
+static int selftest_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
+
+	if (np == NULL) {
+		dev_err(dev, "No OF data for device\n");
+		return -EINVAL;
+
+	}
+
+	dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name);
+	return 0;
+}
+
+static int selftest_remove(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
+
+	dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name);
+	return 0;
+}
+
+static struct of_device_id selftest_match[] = {
+	{ .compatible = "selftest", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, altera_jtaguart_match);
+
+static struct platform_driver selftest_driver = {
+	.probe			= selftest_probe,
+	.remove			= selftest_remove,
+	.driver = {
+		.name		= "selftest",
+		.owner		= THIS_MODULE,
+		.of_match_table	= of_match_ptr(selftest_match),
+	},
+};
+
+/* get the platform device instantiated at the path */
+static struct platform_device *of_path_to_platform_device(const char *path)
+{
+	struct device_node *np;
+	struct platform_device *pdev;
+
+	np = of_find_node_by_path(path);
+	if (np == NULL)
+		return NULL;
+
+	pdev = of_find_device_by_node(np);
+	of_node_put(np);
+
+	return pdev;
+}
+
+/* find out if a platform device exists at that path */
+static int of_path_platform_device_exists(const char *path)
+{
+	struct platform_device *pdev;
+
+	pdev = of_path_to_platform_device(path);
+	platform_device_put(pdev);
+	return pdev != NULL;
+}
+
+static const char *selftest_path(int nr)
+{
+	static char buf[256];
+
+	snprintf(buf, sizeof(buf) - 1,
+		"/testcase-data/overlay-node/test-bus/test-selftest%d", nr);
+	buf[sizeof(buf) - 1] = '\0';
+
+	return buf;
+}
+
+static const char *overlay_path(int nr)
+{
+	static char buf[256];
+
+	snprintf(buf, sizeof(buf) - 1,
+		"/testcase-data/overlay%d", nr);
+	buf[sizeof(buf) - 1] = '\0';
+
+	return buf;
+}
+
+static const char *bus_path = "/testcase-data/overlay-node/test-bus";
+
+static int of_selftest_apply_overlay(int selftest_nr, int overlay_nr,
+		int *overlay_id)
+{
+	struct device_node *np = NULL;
+	int ret, id = -1;
+
+	np = of_find_node_by_path(overlay_path(overlay_nr));
+	if (np == NULL) {
+		selftest(0, "could not find overlay node @\"%s\"\n",
+				overlay_path(overlay_nr));
+		ret = -EINVAL;
+		goto out;
+	}
+
+	ret = of_overlay_create(np);
+	if (ret < 0) {
+		selftest(0, "could not create overlay from \"%s\"\n",
+				overlay_path(overlay_nr));
+		goto out;
+	}
+	id = ret;
+
+	ret = 0;
+
+out:
+	of_node_put(np);
+
+	if (overlay_id)
+		*overlay_id = id;
+
+	return ret;
+}
+
+/* apply an overlay while checking before and after states */
+static int of_selftest_apply_overlay_check(int overlay_nr, int selftest_nr,
+		int before, int after)
+{
+	int ret;
+
+	/* selftest device must not be in before state */
+	if (of_path_platform_device_exists(selftest_path(selftest_nr))
+			!= before) {
+		selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n",
+				overlay_path(overlay_nr),
+				selftest_path(selftest_nr),
+				!before ? "enabled" : "disabled");
+		return -EINVAL;
+	}
+
+	ret = of_selftest_apply_overlay(overlay_nr, selftest_nr, NULL);
+	if (ret != 0) {
+		/* of_selftest_apply_overlay already called selftest() */
+		return ret;
+	}
+
+	/* selftest device must be to set to after state */
+	if (of_path_platform_device_exists(selftest_path(selftest_nr))
+			!= after) {
+		selftest(0, "overlay @\"%s\" failed to create @\"%s\" %s\n",
+				overlay_path(overlay_nr),
+				selftest_path(selftest_nr),
+				!after ? "enabled" : "disabled");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+/* apply an overlay and then revert it while checking before, after states */
+static int of_selftest_apply_revert_overlay_check(int overlay_nr,
+		int selftest_nr, int before, int after)
+{
+	int ret, ov_id;
+
+	/* selftest device must be in before state */
+	if (of_path_platform_device_exists(selftest_path(selftest_nr))
+			!= before) {
+		selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n",
+				overlay_path(overlay_nr),
+				selftest_path(selftest_nr),
+				!before ? "enabled" : "disabled");
+		return -EINVAL;
+	}
+
+	/* apply the overlay */
+	ret = of_selftest_apply_overlay(overlay_nr, selftest_nr, &ov_id);
+	if (ret != 0) {
+		/* of_selftest_apply_overlay already called selftest() */
+		return ret;
+	}
+
+	/* selftest device must be in after state */
+	if (of_path_platform_device_exists(selftest_path(selftest_nr))
+			!= after) {
+		selftest(0, "overlay @\"%s\" failed to create @\"%s\" %s\n",
+				overlay_path(overlay_nr),
+				selftest_path(selftest_nr),
+				!after ? "enabled" : "disabled");
+		return -EINVAL;
+	}
+
+	ret = of_overlay_destroy(ov_id);
+	if (ret != 0) {
+		selftest(0, "overlay @\"%s\" failed to be destroyed @\"%s\"\n",
+				overlay_path(overlay_nr),
+				selftest_path(selftest_nr));
+		return ret;
+	}
+
+	/* selftest device must be again in before state */
+	if (of_path_platform_device_exists(selftest_path(selftest_nr))
+			!= before) {
+		selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n",
+				overlay_path(overlay_nr),
+				selftest_path(selftest_nr),
+				!before ? "enabled" : "disabled");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+/* test activation of device */
+static void of_selftest_overlay_0(void)
+{
+	int ret;
+
+	/* device should enable */
+	ret = of_selftest_apply_overlay_check(0, 0, 0, 1);
+	if (ret != 0)
+		return;
+
+	selftest(1, "overlay test %d passed\n", 0);
+}
+
+/* test deactivation of device */
+static void of_selftest_overlay_1(void)
+{
+	int ret;
+
+	/* device should disable */
+	ret = of_selftest_apply_overlay_check(1, 1, 1, 0);
+	if (ret != 0)
+		return;
+
+	selftest(1, "overlay test %d passed\n", 1);
+}
+
+/* test activation of device */
+static void of_selftest_overlay_2(void)
+{
+	int ret;
+
+	/* device should enable */
+	ret = of_selftest_apply_overlay_check(2, 2, 0, 1);
+	if (ret != 0)
+		return;
+
+	selftest(1, "overlay test %d passed\n", 2);
+}
+
+/* test deactivation of device */
+static void of_selftest_overlay_3(void)
+{
+	int ret;
+
+	/* device should disable */
+	ret = of_selftest_apply_overlay_check(3, 3, 1, 0);
+	if (ret != 0)
+		return;
+
+	selftest(1, "overlay test %d passed\n", 3);
+}
+
+/* test activation of a full device node */
+static void of_selftest_overlay_4(void)
+{
+	int ret;
+
+	/* device should disable */
+	ret = of_selftest_apply_overlay_check(4, 4, 0, 1);
+	if (ret != 0)
+		return;
+
+	selftest(1, "overlay test %d passed\n", 4);
+}
+
+/* test overlay apply/revert sequence */
+static void of_selftest_overlay_5(void)
+{
+	int ret;
+
+	/* device should disable */
+	ret = of_selftest_apply_revert_overlay_check(5, 5, 0, 1);
+	if (ret != 0)
+		return;
+
+	selftest(1, "overlay test %d passed\n", 5);
+}
+
+/* test overlay application in sequence */
+static void of_selftest_overlay_6(void)
+{
+	struct device_node *np;
+	int ret, i, ov_id[2];
+	int overlay_nr = 6, selftest_nr = 6;
+	int before = 0, after = 1;
+
+	/* selftest device must be in before state */
+	for (i = 0; i < 2; i++) {
+		if (of_path_platform_device_exists(
+					selftest_path(selftest_nr + i))
+				!= before) {
+			selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n",
+					overlay_path(overlay_nr + i),
+					selftest_path(selftest_nr + i),
+					!before ? "enabled" : "disabled");
+			return;
+		}
+	}
+
+	/* apply the overlays */
+	for (i = 0; i < 2; i++) {
+
+		np = of_find_node_by_path(overlay_path(overlay_nr + i));
+		if (np == NULL) {
+			selftest(0, "could not find overlay node @\"%s\"\n",
+					overlay_path(overlay_nr + i));
+			return;
+		}
+
+		ret = of_overlay_create(np);
+		if (ret < 0)  {
+			selftest(0, "could not create overlay from \"%s\"\n",
+					overlay_path(overlay_nr + i));
+			return;
+		}
+		ov_id[i] = ret;
+	}
+
+	for (i = 0; i < 2; i++) {
+		/* selftest device must be in after state */
+		if (of_path_platform_device_exists(
+					selftest_path(selftest_nr + i))
+				!= after) {
+			selftest(0, "overlay @\"%s\" failed @\"%s\" %s\n",
+					overlay_path(overlay_nr + i),
+					selftest_path(selftest_nr + i),
+					!after ? "enabled" : "disabled");
+			return;
+		}
+	}
+
+	for (i = 1; i >= 0; i--) {
+		ret = of_overlay_destroy(ov_id[i]);
+		if (ret != 0) {
+			selftest(0, "overlay @\"%s\" failed destroy @\"%s\"\n",
+					overlay_path(overlay_nr + i),
+					selftest_path(selftest_nr + i));
+			return;
+		}
+	}
+
+	for (i = 0; i < 2; i++) {
+		/* selftest device must be again in before state */
+		if (of_path_platform_device_exists(
+					selftest_path(selftest_nr + i))
+				!= before) {
+			selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n",
+					overlay_path(overlay_nr + i),
+					selftest_path(selftest_nr + i),
+					!before ? "enabled" : "disabled");
+			return;
+		}
+	}
+
+	selftest(1, "overlay test %d passed\n", 6);
+}
+
+/* test overlay application in sequence */
+static void of_selftest_overlay_8(void)
+{
+	struct device_node *np;
+	int ret, i, ov_id[2];
+	int overlay_nr = 8, selftest_nr = 8;
+
+	/* we don't care about device state in this test */
+
+	/* apply the overlays */
+	for (i = 0; i < 2; i++) {
+
+		np = of_find_node_by_path(overlay_path(overlay_nr + i));
+		if (np == NULL) {
+			selftest(0, "could not find overlay node @\"%s\"\n",
+					overlay_path(overlay_nr + i));
+			return;
+		}
+
+		ret = of_overlay_create(np);
+		if (ret < 0)  {
+			selftest(0, "could not create overlay from \"%s\"\n",
+					overlay_path(overlay_nr + i));
+			return;
+		}
+		ov_id[i] = ret;
+	}
+
+	/* now try to remove first overlay (it should fail) */
+	ret = of_overlay_destroy(ov_id[0]);
+	if (ret == 0) {
+		selftest(0, "overlay @\"%s\" was destroyed @\"%s\"\n",
+				overlay_path(overlay_nr + 0),
+				selftest_path(selftest_nr));
+		return;
+	}
+
+	/* removing them in order should work */
+	for (i = 1; i >= 0; i--) {
+		ret = of_overlay_destroy(ov_id[i]);
+		if (ret != 0) {
+			selftest(0, "overlay @\"%s\" not destroyed @\"%s\"\n",
+					overlay_path(overlay_nr + i),
+					selftest_path(selftest_nr));
+			return;
+		}
+	}
+
+	selftest(1, "overlay test %d passed\n", 8);
+}
+
+static void __init of_selftest_overlay(void)
+{
+	struct device_node *bus_np = NULL;
+	int ret;
+
+	ret = platform_driver_register(&selftest_driver);
+	if (ret != 0) {
+		selftest(0, "could not register selftest driver\n");
+		goto out;
+	}
+
+	bus_np = of_find_node_by_path(bus_path);
+	if (bus_np == NULL) {
+		selftest(0, "could not find bus_path \"%s\"\n", bus_path);
+		goto out;
+	}
+
+	ret = of_platform_populate(bus_np, of_default_bus_match_table,
+			NULL, NULL);
+	if (ret != 0) {
+		selftest(0, "could not populate bus @ \"%s\"\n", bus_path);
+		goto out;
+	}
+
+	if (!of_path_platform_device_exists(selftest_path(100))) {
+		selftest(0, "could not find selftest0 @ \"%s\"\n",
+				selftest_path(100));
+		goto out;
+	}
+
+	if (of_path_platform_device_exists(selftest_path(101))) {
+		selftest(0, "selftest1 @ \"%s\" should not exist\n",
+				selftest_path(101));
+		goto out;
+	}
+
+	selftest(1, "basic infrastructure of overlays passed");
+
+	/* tests in sequence */
+	of_selftest_overlay_0();
+	of_selftest_overlay_1();
+	of_selftest_overlay_2();
+	of_selftest_overlay_3();
+	of_selftest_overlay_4();
+	of_selftest_overlay_5();
+	of_selftest_overlay_6();
+	of_selftest_overlay_8();
+
+out:
+	of_node_put(bus_np);
+}
+
+#else
+static inline void __init of_selftest_overlay(void) { }
+#endif
+
 static int __init of_selftest(void)
 {
 	struct device_node *np;
@@ -960,6 +1440,7 @@ static int __init of_selftest(void)
 	of_selftest_parse_interrupts_extended();
 	of_selftest_match_node();
 	of_selftest_platform_populate();
+	of_selftest_overlay();
 
 	/* removing selftest data from live tree */
 	selftest_data_remove();
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 8/8] of: Add debug output for OF_RECONFIG notifiers
@ 2014-11-21  1:35   ` Grant Likely
  0 siblings, 0 replies; 23+ messages in thread
From: Grant Likely @ 2014-11-21  1:35 UTC (permalink / raw)
  To: devicetree, linux-kernel, Pantelis Antoniou; +Cc: Rob Herring, Grant Likely

Add some additional debug output to cover OF_RECONFIG notifier activity.
At the same time, refactor the changeset debug output to use the same
strings as the notifier debug output.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
---
 drivers/of/dynamic.c | 48 ++++++++++++++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 16 deletions(-)

diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index 7634c2f69d4a..de20ae46b370 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -77,10 +77,38 @@ int of_reconfig_notifier_unregister(struct notifier_block *nb)
 }
 EXPORT_SYMBOL_GPL(of_reconfig_notifier_unregister);
 
+#ifdef DEBUG
+const char *action_names[] = {
+	[OF_RECONFIG_ATTACH_NODE] = "ATTACH_NODE",
+	[OF_RECONFIG_DETACH_NODE] = "DETACH_NODE",
+	[OF_RECONFIG_ADD_PROPERTY] = "ADD_PROPERTY",
+	[OF_RECONFIG_REMOVE_PROPERTY] = "REMOVE_PROPERTY",
+	[OF_RECONFIG_UPDATE_PROPERTY] = "UPDATE_PROPERTY",
+};
+#endif
+
 int of_reconfig_notify(unsigned long action, void *p)
 {
 	int rc;
+#ifdef DEBUG
+	struct device_node *dn = p;
+	struct of_prop_reconfig *pr = p;
+
+	switch (action) {
+	case OF_RECONFIG_ATTACH_NODE:
+	case OF_RECONFIG_DETACH_NODE:
+		pr_debug("of/notify %-15s %s\n", action_names[action],
+			dn->full_name);
+		break;
+	case OF_RECONFIG_ADD_PROPERTY:
+	case OF_RECONFIG_REMOVE_PROPERTY:
+	case OF_RECONFIG_UPDATE_PROPERTY:
+		pr_debug("of/notify %-15s %s:%s\n", action_names[action],
+			pr->dn->full_name, pr->prop->name);
+		break;
 
+	}
+#endif
 	rc = blocking_notifier_call_chain(&of_reconfig_chain, action, p);
 	return notifier_to_errno(rc);
 }
@@ -431,27 +459,15 @@ static void __of_changeset_entry_dump(struct of_changeset_entry *ce)
 {
 	switch (ce->action) {
 	case OF_RECONFIG_ADD_PROPERTY:
-		pr_debug("%p: %s %s/%s\n",
-			ce, "ADD_PROPERTY   ", ce->np->full_name,
-			ce->prop->name);
-		break;
 	case OF_RECONFIG_REMOVE_PROPERTY:
-		pr_debug("%p: %s %s/%s\n",
-			ce, "REMOVE_PROPERTY", ce->np->full_name,
-			ce->prop->name);
-		break;
 	case OF_RECONFIG_UPDATE_PROPERTY:
-		pr_debug("%p: %s %s/%s\n",
-			ce, "UPDATE_PROPERTY", ce->np->full_name,
-			ce->prop->name);
+		pr_debug("of/cset<%p> %-15s %s/%s\n", ce, action_names[ce->action],
+			ce->np->full_name, ce->prop->name);
 		break;
 	case OF_RECONFIG_ATTACH_NODE:
-		pr_debug("%p: %s %s\n",
-			ce, "ATTACH_NODE    ", ce->np->full_name);
-		break;
 	case OF_RECONFIG_DETACH_NODE:
-		pr_debug("%p: %s %s\n",
-			ce, "DETACH_NODE    ", ce->np->full_name);
+		pr_debug("of/cset<%p> %-15s %s\n", ce, action_names[ce->action],
+			ce->np->full_name);
 		break;
 	}
 }
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 8/8] of: Add debug output for OF_RECONFIG notifiers
@ 2014-11-21  1:35   ` Grant Likely
  0 siblings, 0 replies; 23+ messages in thread
From: Grant Likely @ 2014-11-21  1:35 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Pantelis Antoniou
  Cc: Rob Herring, Grant Likely

Add some additional debug output to cover OF_RECONFIG notifier activity.
At the same time, refactor the changeset debug output to use the same
strings as the notifier debug output.

Signed-off-by: Grant Likely <grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 drivers/of/dynamic.c | 48 ++++++++++++++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 16 deletions(-)

diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index 7634c2f69d4a..de20ae46b370 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -77,10 +77,38 @@ int of_reconfig_notifier_unregister(struct notifier_block *nb)
 }
 EXPORT_SYMBOL_GPL(of_reconfig_notifier_unregister);
 
+#ifdef DEBUG
+const char *action_names[] = {
+	[OF_RECONFIG_ATTACH_NODE] = "ATTACH_NODE",
+	[OF_RECONFIG_DETACH_NODE] = "DETACH_NODE",
+	[OF_RECONFIG_ADD_PROPERTY] = "ADD_PROPERTY",
+	[OF_RECONFIG_REMOVE_PROPERTY] = "REMOVE_PROPERTY",
+	[OF_RECONFIG_UPDATE_PROPERTY] = "UPDATE_PROPERTY",
+};
+#endif
+
 int of_reconfig_notify(unsigned long action, void *p)
 {
 	int rc;
+#ifdef DEBUG
+	struct device_node *dn = p;
+	struct of_prop_reconfig *pr = p;
+
+	switch (action) {
+	case OF_RECONFIG_ATTACH_NODE:
+	case OF_RECONFIG_DETACH_NODE:
+		pr_debug("of/notify %-15s %s\n", action_names[action],
+			dn->full_name);
+		break;
+	case OF_RECONFIG_ADD_PROPERTY:
+	case OF_RECONFIG_REMOVE_PROPERTY:
+	case OF_RECONFIG_UPDATE_PROPERTY:
+		pr_debug("of/notify %-15s %s:%s\n", action_names[action],
+			pr->dn->full_name, pr->prop->name);
+		break;
 
+	}
+#endif
 	rc = blocking_notifier_call_chain(&of_reconfig_chain, action, p);
 	return notifier_to_errno(rc);
 }
@@ -431,27 +459,15 @@ static void __of_changeset_entry_dump(struct of_changeset_entry *ce)
 {
 	switch (ce->action) {
 	case OF_RECONFIG_ADD_PROPERTY:
-		pr_debug("%p: %s %s/%s\n",
-			ce, "ADD_PROPERTY   ", ce->np->full_name,
-			ce->prop->name);
-		break;
 	case OF_RECONFIG_REMOVE_PROPERTY:
-		pr_debug("%p: %s %s/%s\n",
-			ce, "REMOVE_PROPERTY", ce->np->full_name,
-			ce->prop->name);
-		break;
 	case OF_RECONFIG_UPDATE_PROPERTY:
-		pr_debug("%p: %s %s/%s\n",
-			ce, "UPDATE_PROPERTY", ce->np->full_name,
-			ce->prop->name);
+		pr_debug("of/cset<%p> %-15s %s/%s\n", ce, action_names[ce->action],
+			ce->np->full_name, ce->prop->name);
 		break;
 	case OF_RECONFIG_ATTACH_NODE:
-		pr_debug("%p: %s %s\n",
-			ce, "ATTACH_NODE    ", ce->np->full_name);
-		break;
 	case OF_RECONFIG_DETACH_NODE:
-		pr_debug("%p: %s %s\n",
-			ce, "DETACH_NODE    ", ce->np->full_name);
+		pr_debug("of/cset<%p> %-15s %s\n", ce, action_names[ce->action],
+			ce->np->full_name);
 		break;
 	}
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/8] of: Use vargs in __of_node_alloc
@ 2014-11-21  1:43     ` Joe Perches
  0 siblings, 0 replies; 23+ messages in thread
From: Joe Perches @ 2014-11-21  1:43 UTC (permalink / raw)
  To: Grant Likely; +Cc: devicetree, linux-kernel, Pantelis Antoniou, Rob Herring

On Fri, 2014-11-21 at 01:35 +0000, Grant Likely wrote:
> The overlay code needs to construct a new full_name from the parent name
> and the node name, but the current method has to allocate and then free
> an temporary string which is wasteful. Fix this problem by using vargs
> to pass in a format and arguments into __of_node_alloc().
[]
> diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
[]
> @@ -61,7 +61,7 @@ static inline int of_property_notify(int action, struct device_node *np,
>   * own the devtree lock or work on detached trees only.
>   */
>  struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags);
> -struct device_node *__of_node_alloc(const char *full_name, gfp_t allocflags);

Please add

__printf(1, 2)
> +struct device_node *__of_node_alloc(const char *fmt, ...);



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/8] of: Use vargs in __of_node_alloc
@ 2014-11-21  1:43     ` Joe Perches
  0 siblings, 0 replies; 23+ messages in thread
From: Joe Perches @ 2014-11-21  1:43 UTC (permalink / raw)
  To: Grant Likely
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Pantelis Antoniou,
	Rob Herring

On Fri, 2014-11-21 at 01:35 +0000, Grant Likely wrote:
> The overlay code needs to construct a new full_name from the parent name
> and the node name, but the current method has to allocate and then free
> an temporary string which is wasteful. Fix this problem by using vargs
> to pass in a format and arguments into __of_node_alloc().
[]
> diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
[]
> @@ -61,7 +61,7 @@ static inline int of_property_notify(int action, struct device_node *np,
>   * own the devtree lock or work on detached trees only.
>   */
>  struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags);
> -struct device_node *__of_node_alloc(const char *full_name, gfp_t allocflags);

Please add

__printf(1, 2)
> +struct device_node *__of_node_alloc(const char *fmt, ...);


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/8] of: Use vargs in __of_node_alloc
  2014-11-21  1:43     ` Joe Perches
  (?)
@ 2014-11-24 22:26     ` Grant Likely
  -1 siblings, 0 replies; 23+ messages in thread
From: Grant Likely @ 2014-11-24 22:26 UTC (permalink / raw)
  To: Joe Perches
  Cc: devicetree, Linux Kernel Mailing List, Pantelis Antoniou, Rob Herring

On Fri, Nov 21, 2014 at 1:43 AM, Joe Perches <joe@perches.com> wrote:
> On Fri, 2014-11-21 at 01:35 +0000, Grant Likely wrote:
>> The overlay code needs to construct a new full_name from the parent name
>> and the node name, but the current method has to allocate and then free
>> an temporary string which is wasteful. Fix this problem by using vargs
>> to pass in a format and arguments into __of_node_alloc().
> []
>> diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
> []
>> @@ -61,7 +61,7 @@ static inline int of_property_notify(int action, struct device_node *np,
>>   * own the devtree lock or work on detached trees only.
>>   */
>>  struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags);
>> -struct device_node *__of_node_alloc(const char *full_name, gfp_t allocflags);
>
> Please add
>
> __printf(1, 2)
>> +struct device_node *__of_node_alloc(const char *fmt, ...);

Fixed, thanks.

g.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/8] of/overlay: Introduce DT overlay support
@ 2014-11-26 13:11     ` Paul Bolle
  0 siblings, 0 replies; 23+ messages in thread
From: Paul Bolle @ 2014-11-26 13:11 UTC (permalink / raw)
  To: Grant Likely
  Cc: Valentin Rothberg, devicetree, linux-kernel, Pantelis Antoniou,
	Rob Herring

On Fri, 2014-11-21 at 01:35 +0000, Grant Likely wrote:
> From: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> 
> Overlays are a method to dynamically modify part of the kernel's
> device tree with dynamically loaded data. Add the core functionality to
> parse, apply and remove an overlay changeset. The core functionality
> takes care of managing the overlay data format and performing the add
> and remove. Drivers are expected to use the overlay functionality to
> support custom expansion busses commonly found on consumer development
> boards like the BeagleBone or Raspberry Pi.
> 
> The overlay code uses CONFIG_OF_DYNAMIC changesets to perform the low
> level work of modifying the devicetree.
> 
> Documentation about internal and APIs is provided in
> 	Documentation/devicetree/overlay-notes.txt
> 
> v2:
> - Switch from __of_node_alloc() to __of_node_dup()
> - Documentation fixups
> - Remove 2-pass processing of properties
> - Remove separate ov_lock; just use the DT mutex.
> v1:
> - Drop delete capability using '-' prefix. The '-' prefixed names
> are valid properties and nodes and there is no need for it just yet.
> - Do not update special properties - name & phandle ones.
> - Change order of node attachment, so that the special property update
> works.
> 
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> Signed-off-by: Grant Likely <grant.likely@linaro.org>

Now commit 7518b5890d8a ("of/overlay: Introduce DT overlay support"),
included in today's linux-next (next-20141126).

>  Documentation/devicetree/overlay-notes.txt | 133 +++++++
>  drivers/of/Kconfig                         |   7 +
>  drivers/of/Makefile                        |   1 +
>  drivers/of/overlay.c                       | 562 +++++++++++++++++++++++++++++
>  include/linux/of.h                         |  31 ++
>  5 files changed, 734 insertions(+)
>  create mode 100644 Documentation/devicetree/overlay-notes.txt
>  create mode 100644 drivers/of/overlay.c
> 
>[...]
> diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
> index fbe8f8d418f7..18b2e2539f84 100644
> --- a/drivers/of/Kconfig
> +++ b/drivers/of/Kconfig
> @@ -84,4 +84,11 @@ config OF_RESERVED_MEM
>  config OF_RESOLVE
>  	bool
>  
> +config OF_OVERLAY
> +	bool
> +	depends on OF
> +	select OF_DYNAMIC
> +	select OF_DEVICE

There's currently no Kconfig symbol OF_DEVICE. So this select is now a
nop. Will that symbol be added in a future patch?

> +	select OF_RESOLVE
> +
>  endmenu # OF


Paul Bolle


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/8] of/overlay: Introduce DT overlay support
@ 2014-11-26 13:11     ` Paul Bolle
  0 siblings, 0 replies; 23+ messages in thread
From: Paul Bolle @ 2014-11-26 13:11 UTC (permalink / raw)
  To: Grant Likely
  Cc: Valentin Rothberg, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Pantelis Antoniou,
	Rob Herring

On Fri, 2014-11-21 at 01:35 +0000, Grant Likely wrote:
> From: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
> 
> Overlays are a method to dynamically modify part of the kernel's
> device tree with dynamically loaded data. Add the core functionality to
> parse, apply and remove an overlay changeset. The core functionality
> takes care of managing the overlay data format and performing the add
> and remove. Drivers are expected to use the overlay functionality to
> support custom expansion busses commonly found on consumer development
> boards like the BeagleBone or Raspberry Pi.
> 
> The overlay code uses CONFIG_OF_DYNAMIC changesets to perform the low
> level work of modifying the devicetree.
> 
> Documentation about internal and APIs is provided in
> 	Documentation/devicetree/overlay-notes.txt
> 
> v2:
> - Switch from __of_node_alloc() to __of_node_dup()
> - Documentation fixups
> - Remove 2-pass processing of properties
> - Remove separate ov_lock; just use the DT mutex.
> v1:
> - Drop delete capability using '-' prefix. The '-' prefixed names
> are valid properties and nodes and there is no need for it just yet.
> - Do not update special properties - name & phandle ones.
> - Change order of node attachment, so that the special property update
> works.
> 
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
> Signed-off-by: Grant Likely <grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Now commit 7518b5890d8a ("of/overlay: Introduce DT overlay support"),
included in today's linux-next (next-20141126).

>  Documentation/devicetree/overlay-notes.txt | 133 +++++++
>  drivers/of/Kconfig                         |   7 +
>  drivers/of/Makefile                        |   1 +
>  drivers/of/overlay.c                       | 562 +++++++++++++++++++++++++++++
>  include/linux/of.h                         |  31 ++
>  5 files changed, 734 insertions(+)
>  create mode 100644 Documentation/devicetree/overlay-notes.txt
>  create mode 100644 drivers/of/overlay.c
> 
>[...]
> diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
> index fbe8f8d418f7..18b2e2539f84 100644
> --- a/drivers/of/Kconfig
> +++ b/drivers/of/Kconfig
> @@ -84,4 +84,11 @@ config OF_RESERVED_MEM
>  config OF_RESOLVE
>  	bool
>  
> +config OF_OVERLAY
> +	bool
> +	depends on OF
> +	select OF_DYNAMIC
> +	select OF_DEVICE

There's currently no Kconfig symbol OF_DEVICE. So this select is now a
nop. Will that symbol be added in a future patch?

> +	select OF_RESOLVE
> +
>  endmenu # OF


Paul Bolle

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/8] of/overlay: Introduce DT overlay support
  2014-11-26 13:11     ` Paul Bolle
  (?)
@ 2014-11-26 15:18     ` Grant Likely
  2014-11-26 16:57         ` Paul Bolle
  -1 siblings, 1 reply; 23+ messages in thread
From: Grant Likely @ 2014-11-26 15:18 UTC (permalink / raw)
  To: Paul Bolle
  Cc: Valentin Rothberg, devicetree, Linux Kernel Mailing List,
	Pantelis Antoniou, Rob Herring

On Wed, Nov 26, 2014 at 1:11 PM, Paul Bolle <pebolle@tiscali.nl> wrote:
> On Fri, 2014-11-21 at 01:35 +0000, Grant Likely wrote:
>> From: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
>>
>> Overlays are a method to dynamically modify part of the kernel's
>> device tree with dynamically loaded data. Add the core functionality to
>> parse, apply and remove an overlay changeset. The core functionality
>> takes care of managing the overlay data format and performing the add
>> and remove. Drivers are expected to use the overlay functionality to
>> support custom expansion busses commonly found on consumer development
>> boards like the BeagleBone or Raspberry Pi.
>>
>> The overlay code uses CONFIG_OF_DYNAMIC changesets to perform the low
>> level work of modifying the devicetree.
>>
>> Documentation about internal and APIs is provided in
>>       Documentation/devicetree/overlay-notes.txt
>>
>> v2:
>> - Switch from __of_node_alloc() to __of_node_dup()
>> - Documentation fixups
>> - Remove 2-pass processing of properties
>> - Remove separate ov_lock; just use the DT mutex.
>> v1:
>> - Drop delete capability using '-' prefix. The '-' prefixed names
>> are valid properties and nodes and there is no need for it just yet.
>> - Do not update special properties - name & phandle ones.
>> - Change order of node attachment, so that the special property update
>> works.
>>
>> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
>> Signed-off-by: Grant Likely <grant.likely@linaro.org>
>
> Now commit 7518b5890d8a ("of/overlay: Introduce DT overlay support"),
> included in today's linux-next (next-20141126).

Yes, I pushed it out yesterday. Beyond merely stating a fact, I don't
understand what you're trying to point out here. Is this commit
causing a problem?

>>[...]
>> diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
>> index fbe8f8d418f7..18b2e2539f84 100644
>> --- a/drivers/of/Kconfig
>> +++ b/drivers/of/Kconfig
>> @@ -84,4 +84,11 @@ config OF_RESERVED_MEM
>>  config OF_RESOLVE
>>       bool
>>
>> +config OF_OVERLAY
>> +     bool
>> +     depends on OF
>> +     select OF_DYNAMIC
>> +     select OF_DEVICE
>
> There's currently no Kconfig symbol OF_DEVICE. So this select is now a
> nop. Will that symbol be added in a future patch?

That's a hanger-on from an earlier version of the patch. I'll apply a
fixup patch to remove it.

g.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/8] of/overlay: Introduce DT overlay support
@ 2014-11-26 16:57         ` Paul Bolle
  0 siblings, 0 replies; 23+ messages in thread
From: Paul Bolle @ 2014-11-26 16:57 UTC (permalink / raw)
  To: Grant Likely
  Cc: Valentin Rothberg, devicetree, Linux Kernel Mailing List,
	Pantelis Antoniou, Rob Herring

On Wed, 2014-11-26 at 15:18 +0000, Grant Likely wrote:
> On Wed, Nov 26, 2014 at 1:11 PM, Paul Bolle <pebolle@tiscali.nl> wrote:
> > On Fri, 2014-11-21 at 01:35 +0000, Grant Likely wrote:
> >> From: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> >>
> >> Overlays are a method to dynamically modify part of the kernel's
> >> device tree with dynamically loaded data. Add the core functionality to
> >> parse, apply and remove an overlay changeset. The core functionality
> >> takes care of managing the overlay data format and performing the add
> >> and remove. Drivers are expected to use the overlay functionality to
> >> support custom expansion busses commonly found on consumer development
> >> boards like the BeagleBone or Raspberry Pi.
> >>
> >> The overlay code uses CONFIG_OF_DYNAMIC changesets to perform the low
> >> level work of modifying the devicetree.
> >>
> >> Documentation about internal and APIs is provided in
> >>       Documentation/devicetree/overlay-notes.txt
> >>
> >> v2:
> >> - Switch from __of_node_alloc() to __of_node_dup()
> >> - Documentation fixups
> >> - Remove 2-pass processing of properties
> >> - Remove separate ov_lock; just use the DT mutex.
> >> v1:
> >> - Drop delete capability using '-' prefix. The '-' prefixed names
> >> are valid properties and nodes and there is no need for it just yet.
> >> - Do not update special properties - name & phandle ones.
> >> - Change order of node attachment, so that the special property update
> >> works.
> >>
> >> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> >> Signed-off-by: Grant Likely <grant.likely@linaro.org>
> >
> > Now commit 7518b5890d8a ("of/overlay: Introduce DT overlay support"),
> > included in today's linux-next (next-20141126).
> 
> Yes, I pushed it out yesterday. Beyond merely stating a fact, I don't
> understand what you're trying to point out here. Is this commit
> causing a problem?

Yes, the issue I pointed out in my next remark.

And I add a boring line like that to my messages to make sure its
readers (which could be me, in case nothing happens within a week or
two) have all the facts at hand when handling them. It spares them the
trouble to look up these facts themselves.

Perhaps this lines was ambiguous. Should I rephrase it? Please note that
I usually use proper sentences. This one was a bit blunt. 

> >>[...]
> >> diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
> >> index fbe8f8d418f7..18b2e2539f84 100644
> >> --- a/drivers/of/Kconfig
> >> +++ b/drivers/of/Kconfig
> >> @@ -84,4 +84,11 @@ config OF_RESERVED_MEM
> >>  config OF_RESOLVE
> >>       bool
> >>
> >> +config OF_OVERLAY
> >> +     bool
> >> +     depends on OF
> >> +     select OF_DYNAMIC
> >> +     select OF_DEVICE
> >
> > There's currently no Kconfig symbol OF_DEVICE. So this select is now a
> > nop. Will that symbol be added in a future patch?
> 
> That's a hanger-on from an earlier version of the patch. I'll apply a
> fixup patch to remove it.

I've seen your fixup already. It turns out OF_DEVICE is a symbol that
was removed in v3.11.

Thanks!


Paul Bolle


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/8] of/overlay: Introduce DT overlay support
@ 2014-11-26 16:57         ` Paul Bolle
  0 siblings, 0 replies; 23+ messages in thread
From: Paul Bolle @ 2014-11-26 16:57 UTC (permalink / raw)
  To: Grant Likely
  Cc: Valentin Rothberg, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Linux Kernel Mailing List, Pantelis Antoniou, Rob Herring

On Wed, 2014-11-26 at 15:18 +0000, Grant Likely wrote:
> On Wed, Nov 26, 2014 at 1:11 PM, Paul Bolle <pebolle-IWqWACnzNjzz+pZb47iToQ@public.gmane.org> wrote:
> > On Fri, 2014-11-21 at 01:35 +0000, Grant Likely wrote:
> >> From: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
> >>
> >> Overlays are a method to dynamically modify part of the kernel's
> >> device tree with dynamically loaded data. Add the core functionality to
> >> parse, apply and remove an overlay changeset. The core functionality
> >> takes care of managing the overlay data format and performing the add
> >> and remove. Drivers are expected to use the overlay functionality to
> >> support custom expansion busses commonly found on consumer development
> >> boards like the BeagleBone or Raspberry Pi.
> >>
> >> The overlay code uses CONFIG_OF_DYNAMIC changesets to perform the low
> >> level work of modifying the devicetree.
> >>
> >> Documentation about internal and APIs is provided in
> >>       Documentation/devicetree/overlay-notes.txt
> >>
> >> v2:
> >> - Switch from __of_node_alloc() to __of_node_dup()
> >> - Documentation fixups
> >> - Remove 2-pass processing of properties
> >> - Remove separate ov_lock; just use the DT mutex.
> >> v1:
> >> - Drop delete capability using '-' prefix. The '-' prefixed names
> >> are valid properties and nodes and there is no need for it just yet.
> >> - Do not update special properties - name & phandle ones.
> >> - Change order of node attachment, so that the special property update
> >> works.
> >>
> >> Signed-off-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
> >> Signed-off-by: Grant Likely <grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> >
> > Now commit 7518b5890d8a ("of/overlay: Introduce DT overlay support"),
> > included in today's linux-next (next-20141126).
> 
> Yes, I pushed it out yesterday. Beyond merely stating a fact, I don't
> understand what you're trying to point out here. Is this commit
> causing a problem?

Yes, the issue I pointed out in my next remark.

And I add a boring line like that to my messages to make sure its
readers (which could be me, in case nothing happens within a week or
two) have all the facts at hand when handling them. It spares them the
trouble to look up these facts themselves.

Perhaps this lines was ambiguous. Should I rephrase it? Please note that
I usually use proper sentences. This one was a bit blunt. 

> >>[...]
> >> diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
> >> index fbe8f8d418f7..18b2e2539f84 100644
> >> --- a/drivers/of/Kconfig
> >> +++ b/drivers/of/Kconfig
> >> @@ -84,4 +84,11 @@ config OF_RESERVED_MEM
> >>  config OF_RESOLVE
> >>       bool
> >>
> >> +config OF_OVERLAY
> >> +     bool
> >> +     depends on OF
> >> +     select OF_DYNAMIC
> >> +     select OF_DEVICE
> >
> > There's currently no Kconfig symbol OF_DEVICE. So this select is now a
> > nop. Will that symbol be added in a future patch?
> 
> That's a hanger-on from an earlier version of the patch. I'll apply a
> fixup patch to remove it.

I've seen your fixup already. It turns out OF_DEVICE is a symbol that
was removed in v3.11.

Thanks!


Paul Bolle

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/8] of/overlay: Introduce DT overlay support
  2014-11-26 16:57         ` Paul Bolle
@ 2014-11-28  0:07           ` Grant Likely
  -1 siblings, 0 replies; 23+ messages in thread
From: Grant Likely @ 2014-11-28  0:07 UTC (permalink / raw)
  To: Paul Bolle
  Cc: Valentin Rothberg, devicetree, Linux Kernel Mailing List,
	Pantelis Antoniou, Rob Herring

On Wed, 26 Nov 2014 17:57:05 +0100
, Paul Bolle <pebolle@tiscali.nl>
 wrote:
> On Wed, 2014-11-26 at 15:18 +0000, Grant Likely wrote:
> > On Wed, Nov 26, 2014 at 1:11 PM, Paul Bolle <pebolle@tiscali.nl> wrote:
> > > On Fri, 2014-11-21 at 01:35 +0000, Grant Likely wrote:
> > >> From: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> > >>
> > >> Overlays are a method to dynamically modify part of the kernel's
> > >> device tree with dynamically loaded data. Add the core functionality to
> > >> parse, apply and remove an overlay changeset. The core functionality
> > >> takes care of managing the overlay data format and performing the add
> > >> and remove. Drivers are expected to use the overlay functionality to
> > >> support custom expansion busses commonly found on consumer development
> > >> boards like the BeagleBone or Raspberry Pi.
> > >>
> > >> The overlay code uses CONFIG_OF_DYNAMIC changesets to perform the low
> > >> level work of modifying the devicetree.
> > >>
> > >> Documentation about internal and APIs is provided in
> > >>       Documentation/devicetree/overlay-notes.txt
> > >>
> > >> v2:
> > >> - Switch from __of_node_alloc() to __of_node_dup()
> > >> - Documentation fixups
> > >> - Remove 2-pass processing of properties
> > >> - Remove separate ov_lock; just use the DT mutex.
> > >> v1:
> > >> - Drop delete capability using '-' prefix. The '-' prefixed names
> > >> are valid properties and nodes and there is no need for it just yet.
> > >> - Do not update special properties - name & phandle ones.
> > >> - Change order of node attachment, so that the special property update
> > >> works.
> > >>
> > >> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> > >> Signed-off-by: Grant Likely <grant.likely@linaro.org>
> > >
> > > Now commit 7518b5890d8a ("of/overlay: Introduce DT overlay support"),
> > > included in today's linux-next (next-20141126).
> > 
> > Yes, I pushed it out yesterday. Beyond merely stating a fact, I don't
> > understand what you're trying to point out here. Is this commit
> > causing a problem?
> 
> Yes, the issue I pointed out in my next remark.
> 
> And I add a boring line like that to my messages to make sure its
> readers (which could be me, in case nothing happens within a week or
> two) have all the facts at hand when handling them. It spares them the
> trouble to look up these facts themselves.
> 
> Perhaps this lines was ambiguous. Should I rephrase it? Please note that
> I usually use proper sentences. This one was a bit blunt. 

I was confused because the statement above wasn't in reference to
anything in particular. It was just a statement. If you had said
something like "Today's linux-next has the following problem caused by
commit 7518b5890 ('...')", then I think it would have been clearer.

> 
> > >>[...]
> > >> diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
> > >> index fbe8f8d418f7..18b2e2539f84 100644
> > >> --- a/drivers/of/Kconfig
> > >> +++ b/drivers/of/Kconfig
> > >> @@ -84,4 +84,11 @@ config OF_RESERVED_MEM
> > >>  config OF_RESOLVE
> > >>       bool
> > >>
> > >> +config OF_OVERLAY
> > >> +     bool
> > >> +     depends on OF
> > >> +     select OF_DYNAMIC
> > >> +     select OF_DEVICE
> > >
> > > There's currently no Kconfig symbol OF_DEVICE. So this select is now a
> > > nop. Will that symbol be added in a future patch?
> > 
> > That's a hanger-on from an earlier version of the patch. I'll apply a
> > fixup patch to remove it.
> 
> I've seen your fixup already. It turns out OF_DEVICE is a symbol that
> was removed in v3.11.

Thanks for the testing and bug report.

g.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/8] of/overlay: Introduce DT overlay support
@ 2014-11-28  0:07           ` Grant Likely
  0 siblings, 0 replies; 23+ messages in thread
From: Grant Likely @ 2014-11-28  0:07 UTC (permalink / raw)
  To: Paul Bolle
  Cc: Valentin Rothberg, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Linux Kernel Mailing List, Pantelis Antoniou, Rob Herring

On Wed, 26 Nov 2014 17:57:05 +0100
, Paul Bolle <pebolle-IWqWACnzNjzz+pZb47iToQ@public.gmane.org>
 wrote:
> On Wed, 2014-11-26 at 15:18 +0000, Grant Likely wrote:
> > On Wed, Nov 26, 2014 at 1:11 PM, Paul Bolle <pebolle-IWqWACnzNjzz+pZb47iToQ@public.gmane.org> wrote:
> > > On Fri, 2014-11-21 at 01:35 +0000, Grant Likely wrote:
> > >> From: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
> > >>
> > >> Overlays are a method to dynamically modify part of the kernel's
> > >> device tree with dynamically loaded data. Add the core functionality to
> > >> parse, apply and remove an overlay changeset. The core functionality
> > >> takes care of managing the overlay data format and performing the add
> > >> and remove. Drivers are expected to use the overlay functionality to
> > >> support custom expansion busses commonly found on consumer development
> > >> boards like the BeagleBone or Raspberry Pi.
> > >>
> > >> The overlay code uses CONFIG_OF_DYNAMIC changesets to perform the low
> > >> level work of modifying the devicetree.
> > >>
> > >> Documentation about internal and APIs is provided in
> > >>       Documentation/devicetree/overlay-notes.txt
> > >>
> > >> v2:
> > >> - Switch from __of_node_alloc() to __of_node_dup()
> > >> - Documentation fixups
> > >> - Remove 2-pass processing of properties
> > >> - Remove separate ov_lock; just use the DT mutex.
> > >> v1:
> > >> - Drop delete capability using '-' prefix. The '-' prefixed names
> > >> are valid properties and nodes and there is no need for it just yet.
> > >> - Do not update special properties - name & phandle ones.
> > >> - Change order of node attachment, so that the special property update
> > >> works.
> > >>
> > >> Signed-off-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
> > >> Signed-off-by: Grant Likely <grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> > >
> > > Now commit 7518b5890d8a ("of/overlay: Introduce DT overlay support"),
> > > included in today's linux-next (next-20141126).
> > 
> > Yes, I pushed it out yesterday. Beyond merely stating a fact, I don't
> > understand what you're trying to point out here. Is this commit
> > causing a problem?
> 
> Yes, the issue I pointed out in my next remark.
> 
> And I add a boring line like that to my messages to make sure its
> readers (which could be me, in case nothing happens within a week or
> two) have all the facts at hand when handling them. It spares them the
> trouble to look up these facts themselves.
> 
> Perhaps this lines was ambiguous. Should I rephrase it? Please note that
> I usually use proper sentences. This one was a bit blunt. 

I was confused because the statement above wasn't in reference to
anything in particular. It was just a statement. If you had said
something like "Today's linux-next has the following problem caused by
commit 7518b5890 ('...')", then I think it would have been clearer.

> 
> > >>[...]
> > >> diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
> > >> index fbe8f8d418f7..18b2e2539f84 100644
> > >> --- a/drivers/of/Kconfig
> > >> +++ b/drivers/of/Kconfig
> > >> @@ -84,4 +84,11 @@ config OF_RESERVED_MEM
> > >>  config OF_RESOLVE
> > >>       bool
> > >>
> > >> +config OF_OVERLAY
> > >> +     bool
> > >> +     depends on OF
> > >> +     select OF_DYNAMIC
> > >> +     select OF_DEVICE
> > >
> > > There's currently no Kconfig symbol OF_DEVICE. So this select is now a
> > > nop. Will that symbol be added in a future patch?
> > 
> > That's a hanger-on from an earlier version of the patch. I'll apply a
> > fixup patch to remove it.
> 
> I've seen your fixup already. It turns out OF_DEVICE is a symbol that
> was removed in v3.11.

Thanks for the testing and bug report.

g.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/8] of/overlay: Introduce DT overlay support
@ 2014-11-28  8:57             ` Paul Bolle
  0 siblings, 0 replies; 23+ messages in thread
From: Paul Bolle @ 2014-11-28  8:57 UTC (permalink / raw)
  To: Grant Likely
  Cc: Valentin Rothberg, devicetree, Linux Kernel Mailing List,
	Pantelis Antoniou, Rob Herring

On Fri, 2014-11-28 at 00:07 +0000, Grant Likely wrote:
> I was confused because the statement above wasn't in reference to
> anything in particular. It was just a statement. If you had said
> something like "Today's linux-next has the following problem caused by
> commit 7518b5890 ('...')", then I think it would have been clearer.

I see. I'll try to use a clearer stock phrase in the future.

Thanks,


Paul Bolle


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/8] of/overlay: Introduce DT overlay support
@ 2014-11-28  8:57             ` Paul Bolle
  0 siblings, 0 replies; 23+ messages in thread
From: Paul Bolle @ 2014-11-28  8:57 UTC (permalink / raw)
  To: Grant Likely
  Cc: Valentin Rothberg, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Linux Kernel Mailing List, Pantelis Antoniou, Rob Herring

On Fri, 2014-11-28 at 00:07 +0000, Grant Likely wrote:
> I was confused because the statement above wasn't in reference to
> anything in particular. It was just a statement. If you had said
> something like "Today's linux-next has the following problem caused by
> commit 7518b5890 ('...')", then I think it would have been clearer.

I see. I'll try to use a clearer stock phrase in the future.

Thanks,


Paul Bolle

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2014-11-28  8:57 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-21  1:35 [PATCH 0/8] of: DT Overlay patches to be merged Grant Likely
2014-11-21  1:35 ` [PATCH 1/8] of: Use vargs in __of_node_alloc Grant Likely
2014-11-21  1:43   ` Joe Perches
2014-11-21  1:43     ` Joe Perches
2014-11-24 22:26     ` Grant Likely
2014-11-21  1:35 ` [PATCH 2/8] of: Refactor __of_node_alloc() into __of_node_dup() Grant Likely
2014-11-21  1:35 ` [PATCH 3/8] of/resolver: Switch to new local fixups format Grant Likely
2014-11-21  1:35 ` [PATCH 4/8] of: Add of_reconfig_get_state_change() of notifier helper Grant Likely
2014-11-21  1:35   ` Grant Likely
2014-11-21  1:35 ` [PATCH 5/8] of/overlay: Introduce DT overlay support Grant Likely
2014-11-26 13:11   ` Paul Bolle
2014-11-26 13:11     ` Paul Bolle
2014-11-26 15:18     ` Grant Likely
2014-11-26 16:57       ` Paul Bolle
2014-11-26 16:57         ` Paul Bolle
2014-11-28  0:07         ` Grant Likely
2014-11-28  0:07           ` Grant Likely
2014-11-28  8:57           ` Paul Bolle
2014-11-28  8:57             ` Paul Bolle
2014-11-21  1:35 ` [PATCH 6/8] of/platform: Add OF_DYNAMIC notifier handler Grant Likely
2014-11-21  1:35 ` [PATCH 7/8] of/overlay: Add overlay unittests Grant Likely
2014-11-21  1:35 ` [PATCH 8/8] of: Add debug output for OF_RECONFIG notifiers Grant Likely
2014-11-21  1:35   ` Grant Likely

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.