diff options
author | Stephen Warren <swarren@nvidia.com> | 2012-08-07 22:50:15 -0600 |
---|---|---|
committer | Jon Loeliger <jdl@jdl.com> | 2012-09-06 07:51:43 -0500 |
commit | 45013d86197fea96810a7ae1b920d22b4c887688 (patch) | |
tree | 0048099d9141732edb7ab13d84720ef938fec24e /dtc-parser.y | |
parent | 8716901d2215a314504b7df6282aedfcf89da1ea (diff) | |
download | device-tree-compiler-45013d86197fea96810a7ae1b920d22b4c887688.tar.gz |
dtc: Add ability to delete nodes and properties
dtc currently allows the contents of properties to be changed, and the
contents of nodes to be added to. There are situations where removing
properties or nodes may be useful. This change implements the following
syntax to do that:
/ {
/delete-property/ propname;
/delete-node/ nodename;
};
or:
/delete-node/ &noderef;
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'dtc-parser.y')
-rw-r--r-- | dtc-parser.y | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/dtc-parser.y b/dtc-parser.y index 6d5c2c2..f412460 100644 --- a/dtc-parser.y +++ b/dtc-parser.y @@ -62,6 +62,8 @@ static unsigned char eval_char_literal(const char *s); %token DT_MEMRESERVE %token DT_LSHIFT DT_RSHIFT DT_LE DT_GE DT_EQ DT_NE DT_AND DT_OR %token DT_BITS +%token DT_DEL_PROP +%token DT_DEL_NODE %token <propnodename> DT_PROPNODENAME %token <literal> DT_LITERAL %token <literal> DT_CHAR_LITERAL @@ -153,6 +155,17 @@ devicetree: print_error("label or path, '%s', not found", $2); $$ = $1; } + | devicetree DT_DEL_NODE DT_REF ';' + { + struct node *target = get_node_by_ref($1, $3); + + if (!target) + print_error("label or path, '%s', not found", $3); + else + delete_node(target); + + $$ = $1; + } ; nodedef: @@ -182,6 +195,10 @@ propdef: { $$ = build_property($1, empty_data); } + | DT_DEL_PROP DT_PROPNODENAME ';' + { + $$ = build_property_delete($2); + } | DT_LABEL propdef { add_label(&$2->labels, $1); @@ -440,6 +457,10 @@ subnode: { $$ = name_node($2, $1); } + | DT_DEL_NODE DT_PROPNODENAME ';' + { + $$ = name_node(build_node_delete(), $2); + } | DT_LABEL subnode { add_label(&$2->labels, $1); |