Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1570197 > unrolled thread
| Started by | Stephen Boyd <stephen.boyd@linaro.org> |
|---|---|
| First post | 2017-01-31 01:10 +0100 |
| Last post | 2017-01-31 01:10 +0100 |
| Articles | 2 — 1 participant |
Back to article view | Back to linux.kernel
[RFC/PATCH 0/4] New style overlay and /expansion/ support Stephen Boyd <stephen.boyd@linaro.org> - 2017-01-31 01:10 +0100
[RFC/PATCH 2/4] dtc: Add syntactic sugar version of overlays Stephen Boyd <stephen.boyd@linaro.org> - 2017-01-31 01:10 +0100
| From | Stephen Boyd <stephen.boyd@linaro.org> |
|---|---|
| Date | 2017-01-31 01:10 +0100 |
| Subject | [RFC/PATCH 0/4] New style overlay and /expansion/ support |
| Message-ID | <t5ubf-28G-3@gated-at.bofh.it> |
This series revives the new style of overlay syntax that never got merged. David said he wanted to handle it outside of the parse phase[1], and he proposed a patch to move overlay application to the livetree phase. I've applied that patch and reworked Pantelis' last two patches for the new style "syntactic sugar" on top[2]. In addition, I've included the new /expansion/ keyword support for overlays that don't reference any labels that are outside of the input file. The new expansion keyword just transforms the unresolved references into strings that go into a new 'target-alias' property instead of the 'target' property. This is in line with what David has proposed on the mailing list a few months ago[3]. RFC part: The current syntax requires a root node or overlays are rejected. Making the root node optional would require some non-trivial rework of the grammar to support it. This means the proposed 'new style' syntax doesn't work without the root node. [1] https://lkml.kernel.org/r/20161125041124.GB12287@umbus.fritz.box [2] https://lkml.kernel.org/r/1481114903-8197-7-git-send-email-pantelis.antoniou@konsulko.com [3] https://lkml.kernel.org/r/20160718142037.GS16769@voom.fritz.box David Gibson (1): Start moving overlay handling from parser into dtc core Pantelis Antoniou (1): tests: Add a test for overlays syntactic sugar Stephen Boyd (2): dtc: Add syntactic sugar version of overlays dtc: Add /expansion/ support checks.c | 2 +- dtc-lexer.l | 6 +++ dtc-parser.y | 68 +++++++++++++++++----------------- dtc.c | 16 +++++++- dtc.h | 20 +++++++++- flattree.c | 2 +- fstree.c | 2 +- livetree.c | 80 +++++++++++++++++++++++++++++++++++++++- tests/overlay_overlay_simple.dts | 3 ++ tests/run_tests.sh | 6 +++ 10 files changed, 163 insertions(+), 42 deletions(-) -- 2.10.0.297.gf6727b0
[toc] | [next] | [standalone]
| From | Stephen Boyd <stephen.boyd@linaro.org> |
|---|---|
| Date | 2017-01-31 01:10 +0100 |
| Subject | [RFC/PATCH 2/4] dtc: Add syntactic sugar version of overlays |
| Message-ID | <t5ubf-28G-7@gated-at.bofh.it> |
| In reply to | #1570197 |
Instead of writing overlays with the target property and
__overlay__ node, i.e.
fragment@0 {
target = <&foo>;
__overlay__ {
bar-property = <0x200>;
};
}
support the syntactic sugar version of overlays where this can
be written as
&foo {
bar-property = <0x200>;
};
and have dtc convert that into a fragment node.
Based on a patch by Pantelis Antoniou.
Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
---
dtc.c | 2 +-
dtc.h | 3 ++-
livetree.c | 40 ++++++++++++++++++++++++++++++++++++----
3 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/dtc.c b/dtc.c
index 91e4c18b891e..d52d6c77a8cd 100644
--- a/dtc.c
+++ b/dtc.c
@@ -63,7 +63,7 @@ static void resolve_overlays(struct dt_info *dti)
struct overlay *o = dti->overlays;
while (o) {
- apply_overlay(dti->dt, o);
+ apply_overlay(dti->dt, o, dti->dtsflags);
o = o->next;
}
}
diff --git a/dtc.h b/dtc.h
index c4eb6421eabf..be75aac1f185 100644
--- a/dtc.h
+++ b/dtc.h
@@ -216,7 +216,8 @@ void append_to_property(struct node *node,
struct overlay *build_overlay(char *target, struct node *dt);
struct overlay *chain_overlay(struct overlay *first, struct overlay *list);
-void apply_overlay(struct node *base, struct overlay *overlay);
+void apply_overlay(struct node *base, struct overlay *overlay,
+ unsigned int dtsflags);
const char *get_unitname(struct node *node);
struct property *get_property(struct node *node, const char *propname);
diff --git a/livetree.c b/livetree.c
index dd51223d1e61..798a87ed587e 100644
--- a/livetree.c
+++ b/livetree.c
@@ -331,14 +331,46 @@ struct overlay *chain_overlay(struct overlay *first, struct overlay *list)
return first;
}
-void apply_overlay(struct node *base, struct overlay *overlay)
+static void add_fragment(struct node *base, struct overlay *overlay)
{
- struct node *target = get_node_by_ref(base, overlay->target);
+ static unsigned int next_fragment = 0;
+ struct node *node;
+ struct property *p;
+ struct data d = empty_data;
+ char *name;
- if (!target)
- die("Couldn't find label or path %s for overlay\n",
+ if (!overlay->dt)
+ die("Deletions not supported at runtime for %s\n",
overlay->target);
+ /* Insert a target = <&phandle> property */
+ d = data_add_marker(d, REF_PHANDLE, overlay->target);
+ d = data_append_integer(d, 0xffffffff, 32);
+
+ p = build_property("target", d);
+
+ xasprintf(&name, "fragment@%u", next_fragment++);
+ name_node(overlay->dt, "__overlay__");
+ node = build_node(p, overlay->dt);
+ name_node(node, name);
+
+ add_child(base, node);
+}
+
+void apply_overlay(struct node *base, struct overlay *overlay,
+ unsigned int dtsflags)
+{
+ struct node *target = get_node_by_ref(base, overlay->target);
+
+ if (!target) {
+ if (dtsflags & DTSF_PLUGIN) {
+ add_fragment(base, overlay);
+ return;
+ } else
+ die("Couldn't find label or path %s for overlay\n",
+ overlay->target);
+ }
+
if (!overlay->dt)
/* Deletion */
delete_node(target);
--
2.10.0.297.gf6727b0
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web