Skip to contentSkip to conversation

fdtput: add delete node and property function

PATCH Superseded Wang Long 2 participants 3 messages Jan 15, 2015 – Jan 19, 2015 2 messages not in the archive

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Wang Long

author
#0 lore raw

PATCH v2 1/1 fdtput: add delete node and property function

add the delete node and property function for fdtput.

usage:
1) delete nodes
fdtput -r <options> <dt file> [<node>...]
2) delete properties
fdtput -d <options> <dt file> <node> [<property>...]

---
 fdtput.c           | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 tests/run_tests.sh | 22 +++++++++++++
 2 files changed, 113 insertions(+), 2 deletions(-)
fdtput.c +91 -2
index 2a8d674..a7aaca4 100644
@@ -32,6 +32,8 @@
 enum oper_type {
 	OPER_WRITE_PROP,		/* Write a property in a node */
 	OPER_CREATE_NODE,		/* Create a new node */
+	OPER_DELETE_NODE,		/* Delete a node */
+	OPER_DELETE_PROP,		/* Delete a property in a node */
 };
 
 struct display_info {
@@ -270,11 +272,66 @@ static int create_node(char **blob, const char *node_name)
 	return 0;
 }
 
+/**
+ * Delete a property of a node in the fdt.
+ *
+ * @param blob		FDT blob to write into
+ * @param node_name	Name of node which the delete property belongs to
+ * @param prop_name	Name of property to delete
+ * @return 0 on success, or -1 on failure
+ */
+static int delete_prop(char *blob, const char *node_name, const char *prop_name)
+{
+	int node = 0;
+
+	node = fdt_path_offset(blob, node_name);
+	if (node < 0) {
+		report_error(node_name, -1, node);
+		return -1;
+	}
+
+	node = fdt_delprop(blob, node, prop_name);
+
+	if (node < 0) {
+		report_error(node_name, -1, node);
+		return -1;
+	}
+
+	return 0;
+}
+
+/**
+ * Delete a node in the fdt.
+ *
+ * @param blob		FDT blob to write into
+ * @param node_name	Name of node to delete
+ * @return 0 on success, or -1 on failure
+ */
+static int delete_node(char *blob, const char *node_name)
+{
+	int node = 0;
+
+	node = fdt_path_offset(blob, node_name);
+	if (node < 0) {
+		report_error(node_name, -1, node);
+		return -1;
+	}
+
+	node = fdt_del_node(blob, node);
+	if (node < 0) {
+		report_error(node_name, -1, node);
+		return -1;
+	}
+
+	return 0;
+}
+
 static int do_fdtput(struct display_info *disp, const char *filename,
 		    char **arg, int arg_count)
 {
 	char *value;
 	char *blob;
+	char *node;
 	int len, ret = 0;
 
 	blob = utilfdt_read(filename);
@@ -302,6 +359,15 @@ static int do_fdtput(struct display_info *disp, const char *filename,
 				ret = create_node(&blob, *arg);
 		}
 		break;
+	case OPER_DELETE_NODE:
+		for (; ret >= 0 && arg_count--; arg++)
+			ret = delete_node(blob, *arg);
+		break;
+	case OPER_DELETE_PROP:
+		node = *arg;
+		for (; ret >= 0 && arg_count-- > 1; arg++)
+			ret = delete_prop(blob, node, arg[1]);
+		break;
 	}
 	if (ret >= 0) {
 		fdt_pack(blob);
@@ -312,17 +378,22 @@ static int do_fdtput(struct display_info *disp, const char *filename,
 	return ret;
 }
 
+
 /* Usage related data. */
 static const char usage_synopsis[] =
 	"write a property value to a device tree\n"
 	"	fdtput <options> <dt file> <node> <property> [<value>...]\n"
 	"	fdtput -c <options> <dt file> [<node>...]\n"
+	"	fdtput -r <options> <dt file> [<node>...]\n"
+	"	fdtput -d <options> <dt file> <node> [<property>...]\n"
 	"\n"
 	"The command line arguments are joined together into a single value.\n"
 	USAGE_TYPE_MSG;
-static const char usage_short_opts[] = "cpt:v" USAGE_COMMON_SHORT_OPTS;
+static const char usage_short_opts[] = "crdpt:v" USAGE_COMMON_SHORT_OPTS;
 static struct option const usage_long_opts[] = {
 	{"create",           no_argument, NULL, 'c'},
+	{"remove",	     no_argument, NULL, 'r'},
+	{"delete",	     no_argument, NULL, 'd'},
 	{"auto-path",        no_argument, NULL, 'p'},
 	{"type",              a_argument, NULL, 't'},
 	{"verbose",          no_argument, NULL, 'v'},
@@ -330,6 +401,8 @@ static struct option const usage_long_opts[] = {
 };
 static const char * const usage_opts_help[] = {
 	"Create nodes if they don't already exist",
+	"Delete nodes if they already exist",
+	"Delete perporties if they already exist",
 	"Automatically create nodes as needed for the node path",
 	"Type of data",
 	"Display each value decoded from command line",
@@ -348,7 +421,6 @@ int main(int argc, char *argv[])
 	while ((opt = util_getopt_long()) != EOF) {
 		/*
 		 * TODO: add options to:
-		 * - delete property
 		 * - delete node (optionally recursively)
 		 * - rename node
 		 * - pack fdt before writing
@@ -360,6 +432,12 @@ int main(int argc, char *argv[])
 		case 'c':
 			disp.oper = OPER_CREATE_NODE;
 			break;
+		case 'r':
+			disp.oper = OPER_DELETE_NODE;
+			break;
+		case 'd':
+			disp.oper = OPER_DELETE_PROP;
+			break;
 		case 'p':
 			disp.auto_path = 1;
 			break;
@@ -390,6 +468,17 @@ int main(int argc, char *argv[])
 			usage("missing property");
 	}
 
+	if (disp.oper == OPER_DELETE_NODE)
+		if (argc < 1)
+			usage("missing node");
+
+	if (disp.oper == OPER_DELETE_PROP) {
+		if (argc < 1)
+			usage("missing node");
+		if (argc < 2)
+			usage("missing property");
+	}
+
 	if (do_fdtput(&disp, filename, argv, argc))
 		return 1;
 	return 0;
tests/run_tests.sh +22 -0
index ace6e4f..c5856d9 100755
@@ -610,6 +610,28 @@ fdtput_tests () {
     run_wrap_test $DTPUT $dtb -cp /chosen
     run_wrap_test $DTPUT $dtb -cp /chosen/son
 
+    # Start again with a fresh dtb
+    run_dtc_test -O dtb -p $(stat -c %s $text) -o $dtb $dts
+
+    # Node delete
+    run_wrap_test $DTPUT $dtb -c /chosen/node1 /chosen/node2 /chosen/node3
+    run_fdtget_test "node3\nnode2\nnode1" $dtb -l  /chosen
+    run_wrap_test $DTPUT $dtb -r /chosen/node1 /chosen/node2
+    run_fdtget_test "node3" $dtb -l  /chosen
+
+    # Delete the non-existent node
+    run_wrap_error_test $DTPUT $dtb -r /non-existent/node
+
+    # Property delete
+    run_fdtput_test "eva" $dtb /chosen/ name "" -ts "eva"
+    run_fdtput_test "016" $dtb /chosen/ age  "" -ts "016"
+    run_fdtget_test "age\nname\nbootargs\nlinux,platform" $dtb -p  /chosen
+    run_wrap_test $DTPUT $dtb -d /chosen/ name age
+    run_fdtget_test "bootargs\nlinux,platform" $dtb -p  /chosen
+
+    # Delete the non-existent property
+    run_wrap_error_test $DTPUT $dtb -d /chosen   non-existent-prop
+
     # TODO: Add tests for verbose mode?
 }
 
Signature · 6 lines
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1421308536-140275-1-git-send-email-long.wanglong-hv44wF8Li93QT0dZR+AlfA@public.gmane.org

#2 lore raw

Hi Wang,

Quoted 19 lines · Wang Long

add the delete node and property function for fdtput.

usage:
1) delete nodes
fdtput -r <options> <dt file> [<node>...]
2) delete properties
fdtput -d <options> <dt file> <node> [<property>...]

---
 fdtput.c           | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 tests/run_tests.sh | 22 +++++++++++++
 2 files changed, 113 insertions(+), 2 deletions(-)
fdtput.c +0 -0
index 2a8d674..a7aaca4 100644

fdtput.c line 35

Quoted 4 lines
fdtput.c +1 -0
@@ -32,6 +32,8 @@
 enum oper_type {
        OPER_WRITE_PROP,                /* Write a property in a node */
        OPER_CREATE_NODE,               /* Create a new node */
+       OPER_DELETE_NODE,               /* Delete a node */

nit: It might be better to use REMOVE instead of delete everywhere in the code for the node-removal case. Just a suggestion though, it is fine as it is.

Quoted 112 lines
fdtput.c +71 -1
+       OPER_DELETE_PROP,               /* Delete a property in a node */
 };
 
 struct display_info {
@@ -270,11 +272,66 @@ static int create_node(char **blob, const char *node_name)
        return 0;
 }
 
+/**
+ * Delete a property of a node in the fdt.
+ *
+ * @param blob         FDT blob to write into
+ * @param node_name    Name of node which the delete property belongs to
+ * @param prop_name    Name of property to delete
+ * @return 0 on success, or -1 on failure
+ */
+static int delete_prop(char *blob, const char *node_name, const char *prop_name)
+{
+       int node = 0;
+
+       node = fdt_path_offset(blob, node_name);
+       if (node < 0) {
+               report_error(node_name, -1, node);
+               return -1;
+       }
+
+       node = fdt_delprop(blob, node, prop_name);
+
+       if (node < 0) {
+               report_error(node_name, -1, node);
+               return -1;
+       }
+
+       return 0;
+}
+
+/**
+ * Delete a node in the fdt.
+ *
+ * @param blob         FDT blob to write into
+ * @param node_name    Name of node to delete
+ * @return 0 on success, or -1 on failure
+ */
+static int delete_node(char *blob, const char *node_name)
+{
+       int node = 0;
+
+       node = fdt_path_offset(blob, node_name);
+       if (node < 0) {
+               report_error(node_name, -1, node);
+               return -1;
+       }
+
+       node = fdt_del_node(blob, node);
+       if (node < 0) {
+               report_error(node_name, -1, node);
+               return -1;
+       }
+
+       return 0;
+}
+
 static int do_fdtput(struct display_info *disp, const char *filename,
                    char **arg, int arg_count)
 {
        char *value;
        char *blob;
+       char *node;
        int len, ret = 0;
 
        blob = utilfdt_read(filename);
@@ -302,6 +359,15 @@ static int do_fdtput(struct display_info *disp, const char *filename,
                                ret = create_node(&blob, *arg);
                }
                break;
+       case OPER_DELETE_NODE:
+               for (; ret >= 0 && arg_count--; arg++)
+                       ret = delete_node(blob, *arg);
+               break;
+       case OPER_DELETE_PROP:
+               node = *arg;
+               for (; ret >= 0 && arg_count-- > 1; arg++)
+                       ret = delete_prop(blob, node, arg[1]);
+               break;
        }
        if (ret >= 0) {
                fdt_pack(blob);
@@ -312,17 +378,22 @@ static int do_fdtput(struct display_info *disp, const char *filename,
        return ret;
 }
 
+
 /* Usage related data. */
 static const char usage_synopsis[] =
        "write a property value to a device tree\n"
        "       fdtput <options> <dt file> <node> <property> [<value>...]\n"
        "       fdtput -c <options> <dt file> [<node>...]\n"
+       "       fdtput -r <options> <dt file> [<node>...]\n"
+       "       fdtput -d <options> <dt file> <node> [<property>...]\n"
        "\n"
        "The command line arguments are joined together into a single value.\n"
        USAGE_TYPE_MSG;
-static const char usage_short_opts[] = "cpt:v" USAGE_COMMON_SHORT_OPTS;
+static const char usage_short_opts[] = "crdpt:v" USAGE_COMMON_SHORT_OPTS;
 static struct option const usage_long_opts[] = {
        {"create",           no_argument, NULL, 'c'},
+       {"remove",           no_argument, NULL, 'r'},
+       {"delete",           no_argument, NULL, 'd'},
        {"auto-path",        no_argument, NULL, 'p'},
        {"type",              a_argument, NULL, 't'},
        {"verbose",          no_argument, NULL, 'v'},

fdtput.c static struct option const usage_long_opts[] = { · line 404

Quoted 4 lines
fdtput.c +1 -0
@@ -330,6 +401,8 @@ static struct option const usage_long_opts[] = {
 };
 static const char * const usage_opts_help[] = {
        "Create nodes if they don't already exist",
+       "Delete nodes if they already exist",

Perhaps 'Delete nodes (and any subnodes) ...' so it is clear that subnodes will be deleted also.

fdtput.c static struct option const usage_long_opts[] = { · line 405

Quoted 1 line
fdtput.c +1 -0
+       "Delete perporties if they already exist",

properties

fdtput.c int main(int argc, char *argv[]) · line 424

Quoted 9 lines
fdtput.c +0 -1
        "Automatically create nodes as needed for the node path",
        "Type of data",
        "Display each value decoded from command line",
@@ -348,7 +421,6 @@ int main(int argc, char *argv[])
        while ((opt = util_getopt_long()) != EOF) {
                /*
                 * TODO: add options to:
-                * - delete property
                 * - delete node (optionally recursively)

You can remove this line too, right?

Quoted 16 lines
fdtput.c +6 -0
                 * - rename node
                 * - pack fdt before writing
@@ -360,6 +432,12 @@ int main(int argc, char *argv[])
                case 'c':
                        disp.oper = OPER_CREATE_NODE;
                        break;
+               case 'r':
+                       disp.oper = OPER_DELETE_NODE;
+                       break;
+               case 'd':
+                       disp.oper = OPER_DELETE_PROP;
+                       break;
                case 'p':
                        disp.auto_path = 1;
                        break;

fdtput.c int main(int argc, char *argv[]) · line 473

Quoted 6 lines
fdtput.c +3 -0
@@ -390,6 +468,17 @@ int main(int argc, char *argv[])
                        usage("missing property");
        }
 
+       if (disp.oper == OPER_DELETE_NODE)
+               if (argc < 1)
+                       usage("missing node");

I don't think you need/want this check, since if no nodes are specified, it can't simply do nothing. This is how -c works, and fdtget.

fdtput.c int main(int argc, char *argv[]) · line 479

Quoted 6 lines
fdtput.c +6 -0
+
+       if (disp.oper == OPER_DELETE_PROP) {
+               if (argc < 1)
+                       usage("missing node");
+               if (argc < 2)
+                       usage("missing property");

Here I think you want the first check but not the second, since the tool takes a list of properties to delete, and I think an empty list should be valid.

Quoted 26 lines
fdtput.c +2 -0
+       }
+
 
 
        if (do_fdtput(&disp, filename, argv, argc))
                return 1;
        return 0;
tests/run_tests.sh +11 -0
index ace6e4f..c5856d9 100755
@@ -610,6 +610,28 @@ fdtput_tests () {
     run_wrap_test $DTPUT $dtb -cp /chosen
     run_wrap_test $DTPUT $dtb -cp /chosen/son
 
+    # Start again with a fresh dtb
+    run_dtc_test -O dtb -p $(stat -c %s $text) -o $dtb $dts
+
+    # Node delete
+    run_wrap_test $DTPUT $dtb -c /chosen/node1 /chosen/node2 /chosen/node3
+    run_fdtget_test "node3\nnode2\nnode1" $dtb -l  /chosen
+    run_wrap_test $DTPUT $dtb -r /chosen/node1 /chosen/node2
+    run_fdtget_test "node3" $dtb -l  /chosen
+
+    # Delete the non-existent node
+    run_wrap_error_test $DTPUT $dtb -r /non-existent/node

tests/run_tests.sh fdtput_tests () { · line 633

Quoted 10 lines
tests/run_tests.sh +10 -0
+
+    # Property delete
+    run_fdtput_test "eva" $dtb /chosen/ name "" -ts "eva"
+    run_fdtput_test "016" $dtb /chosen/ age  "" -ts "016"
+    run_fdtget_test "age\nname\nbootargs\nlinux,platform" $dtb -p  /chosen
+    run_wrap_test $DTPUT $dtb -d /chosen/ name age
+    run_fdtget_test "bootargs\nlinux,platform" $dtb -p  /chosen
+
+    # Delete the non-existent property
+    run_wrap_error_test $DTPUT $dtb -d /chosen   non-existent-prop

These tests look good to me.

tests/run_tests.sh fdtput_tests () { · line 636

Quoted 3 lines
tests/run_tests.sh +1 -0
+
     # TODO: Add tests for verbose mode?
 }

Regards,
Simon
--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAPnjgZ1aGDx50GgQsJc8mCmP+OW_HCw7tjthV0wxPGM9NsebAA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#4 lore raw
Quoted 17 lines · Simon Glass

Hi Wang,

Quoted 14 lines · Wang Long

add the delete node and property function for fdtput.

usage:
1) delete nodes
fdtput -r <options> <dt file> [<node>...]
2) delete properties
fdtput -d <options> <dt file> <node> [<property>...]

---
 fdtput.c           | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 tests/run_tests.sh | 22 +++++++++++++
 2 files changed, 113 insertions(+), 2 deletions(-)
Quoted 14 lines

fdtput.c line 35

Quoted 9 lines
fdtput.c +1 -0
index 2a8d674..a7aaca4 100644
@@ -32,6 +32,8 @@
 enum oper_type {
        OPER_WRITE_PROP,                /* Write a property in a node */
        OPER_CREATE_NODE,               /* Create a new node */
+       OPER_DELETE_NODE,               /* Delete a node */

nit: It might be better to use REMOVE instead of delete everywhere in the code for the node-removal case. Just a suggestion though, it is fine as it is.

ok, use REMOVE for node and DELETE for porperty.

Quoted 111 lines
Quoted 111 lines
fdtput.c +71 -1
+       OPER_DELETE_PROP,               /* Delete a property in a node */
 };
 
 struct display_info {
@@ -270,11 +272,66 @@ static int create_node(char **blob, const char *node_name)
        return 0;
 }
 
+/**
+ * Delete a property of a node in the fdt.
+ *
+ * @param blob         FDT blob to write into
+ * @param node_name    Name of node which the delete property belongs to
+ * @param prop_name    Name of property to delete
+ * @return 0 on success, or -1 on failure
+ */
+static int delete_prop(char *blob, const char *node_name, const char *prop_name)
+{
+       int node = 0;
+
+       node = fdt_path_offset(blob, node_name);
+       if (node < 0) {
+               report_error(node_name, -1, node);
+               return -1;
+       }
+
+       node = fdt_delprop(blob, node, prop_name);
+
+       if (node < 0) {
+               report_error(node_name, -1, node);
+               return -1;
+       }
+
+       return 0;
+}
+
+/**
+ * Delete a node in the fdt.
+ *
+ * @param blob         FDT blob to write into
+ * @param node_name    Name of node to delete
+ * @return 0 on success, or -1 on failure
+ */
+static int delete_node(char *blob, const char *node_name)
+{
+       int node = 0;
+
+       node = fdt_path_offset(blob, node_name);
+       if (node < 0) {
+               report_error(node_name, -1, node);
+               return -1;
+       }
+
+       node = fdt_del_node(blob, node);
+       if (node < 0) {
+               report_error(node_name, -1, node);
+               return -1;
+       }
+
+       return 0;
+}
+
 static int do_fdtput(struct display_info *disp, const char *filename,
                    char **arg, int arg_count)
 {
        char *value;
        char *blob;
+       char *node;
        int len, ret = 0;
 
        blob = utilfdt_read(filename);
@@ -302,6 +359,15 @@ static int do_fdtput(struct display_info *disp, const char *filename,
                                ret = create_node(&blob, *arg);
                }
                break;
+       case OPER_DELETE_NODE:
+               for (; ret >= 0 && arg_count--; arg++)
+                       ret = delete_node(blob, *arg);
+               break;
+       case OPER_DELETE_PROP:
+               node = *arg;
+               for (; ret >= 0 && arg_count-- > 1; arg++)
+                       ret = delete_prop(blob, node, arg[1]);
+               break;
        }
        if (ret >= 0) {
                fdt_pack(blob);
@@ -312,17 +378,22 @@ static int do_fdtput(struct display_info *disp, const char *filename,
        return ret;
 }
 
+
 /* Usage related data. */
 static const char usage_synopsis[] =
        "write a property value to a device tree\n"
        "       fdtput <options> <dt file> <node> <property> [<value>...]\n"
        "       fdtput -c <options> <dt file> [<node>...]\n"
+       "       fdtput -r <options> <dt file> [<node>...]\n"
+       "       fdtput -d <options> <dt file> <node> [<property>...]\n"
        "\n"
        "The command line arguments are joined together into a single value.\n"
        USAGE_TYPE_MSG;
-static const char usage_short_opts[] = "cpt:v" USAGE_COMMON_SHORT_OPTS;
+static const char usage_short_opts[] = "crdpt:v" USAGE_COMMON_SHORT_OPTS;
 static struct option const usage_long_opts[] = {
        {"create",           no_argument, NULL, 'c'},
+       {"remove",           no_argument, NULL, 'r'},
+       {"delete",           no_argument, NULL, 'd'},
        {"auto-path",        no_argument, NULL, 'p'},
        {"type",              a_argument, NULL, 't'},
        {"verbose",          no_argument, NULL, 'v'},
Quoted 8 lines

fdtput.c static struct option const usage_long_opts[] = { · line 404

Quoted 5 lines
fdtput.c +1 -0
@@ -330,6 +401,8 @@ static struct option const usage_long_opts[] = {
 };
 static const char * const usage_opts_help[] = {
        "Create nodes if they don't already exist",
+       "Delete nodes if they already exist",

Perhaps 'Delete nodes (and any subnodes) ...' so it is clear that subnodes will be deleted also.

ok, i will change this description.

Quoted 4 lines

fdtput.c static struct option const usage_long_opts[] = { · line 405

Quoted 2 lines
fdtput.c +1 -0
+       "Delete perporties if they already exist",

properties

Sorry for this spelling mistake

thanks

Quoted 12 lines

fdtput.c int main(int argc, char *argv[]) · line 424

Quoted 10 lines
fdtput.c +0 -1
        "Automatically create nodes as needed for the node path",
        "Type of data",
        "Display each value decoded from command line",
@@ -348,7 +421,6 @@ int main(int argc, char *argv[])
        while ((opt = util_getopt_long()) != EOF) {
                /*
                 * TODO: add options to:
-                * - delete property
                 * - delete node (optionally recursively)

You can remove this line too, right?

ok, i forgot to delete this line.

Quoted 35 lines
Quoted 17 lines
fdtput.c +6 -0
                 * - rename node
                 * - pack fdt before writing
@@ -360,6 +432,12 @@ int main(int argc, char *argv[])
                case 'c':
                        disp.oper = OPER_CREATE_NODE;
                        break;
+               case 'r':
+                       disp.oper = OPER_DELETE_NODE;
+                       break;
+               case 'd':
+                       disp.oper = OPER_DELETE_PROP;
+                       break;
                case 'p':
                        disp.auto_path = 1;
                        break;

fdtput.c int main(int argc, char *argv[]) · line 473

Quoted 6 lines
fdtput.c +3 -0
@@ -390,6 +468,17 @@ int main(int argc, char *argv[])
                        usage("missing property");
        }
 
+       if (disp.oper == OPER_DELETE_NODE)
+               if (argc < 1)
+                       usage("missing node");

I don't think you need/want this check, since if no nodes are specified, it can't simply do nothing. This is how -c works, and fdtget.

fdtput.c int main(int argc, char *argv[]) · line 479

Quoted 6 lines
fdtput.c +6 -0
+
+       if (disp.oper == OPER_DELETE_PROP) {
+               if (argc < 1)
+                       usage("missing node");
+               if (argc < 2)
+                       usage("missing property");
Quoted 4 lines

Here I think you want the first check but not the second, since the tool takes a list of properties to delete, and I think an empty list should be valid.

ok, if the empty list is valid, there is no need for the check code of the OPER_DELETE_NODE. we only check the node argument for OPER_DELETE_PROP.

thanks

Quoted 39 lines
Quoted 26 lines
fdtput.c +2 -0
+       }
+
 
 
        if (do_fdtput(&disp, filename, argv, argc))
                return 1;
        return 0;
tests/run_tests.sh +11 -0
index ace6e4f..c5856d9 100755
@@ -610,6 +610,28 @@ fdtput_tests () {
     run_wrap_test $DTPUT $dtb -cp /chosen
     run_wrap_test $DTPUT $dtb -cp /chosen/son
 
+    # Start again with a fresh dtb
+    run_dtc_test -O dtb -p $(stat -c %s $text) -o $dtb $dts
+
+    # Node delete
+    run_wrap_test $DTPUT $dtb -c /chosen/node1 /chosen/node2 /chosen/node3
+    run_fdtget_test "node3\nnode2\nnode1" $dtb -l  /chosen
+    run_wrap_test $DTPUT $dtb -r /chosen/node1 /chosen/node2
+    run_fdtget_test "node3" $dtb -l  /chosen
+
+    # Delete the non-existent node
+    run_wrap_error_test $DTPUT $dtb -r /non-existent/node

tests/run_tests.sh fdtput_tests () { · line 633

Quoted 10 lines
tests/run_tests.sh +10 -0
+
+    # Property delete
+    run_fdtput_test "eva" $dtb /chosen/ name "" -ts "eva"
+    run_fdtput_test "016" $dtb /chosen/ age  "" -ts "016"
+    run_fdtget_test "age\nname\nbootargs\nlinux,platform" $dtb -p  /chosen
+    run_wrap_test $DTPUT $dtb -d /chosen/ name age
+    run_fdtget_test "bootargs\nlinux,platform" $dtb -p  /chosen
+
+    # Delete the non-existent property
+    run_wrap_error_test $DTPUT $dtb -d /chosen   non-existent-prop

These tests look good to me.

Quoted 9 lines

tests/run_tests.sh fdtput_tests () { · line 636

Quoted 3 lines
tests/run_tests.sh +1 -0
+
     # TODO: Add tests for verbose mode?
 }

Regards,
Simon

.

Best Regards
Wang Long

--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html