diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-09-05 07:32:56 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-09-05 07:32:56 +0200 |
commit | 2fbba4e4d573273034a19703a6d0cbe29c21e418 (patch) | |
tree | 3d8eef5201a6aea5db147479ea8ee329f8f64bf0 | |
parent | c96a4f28318e6465d981d61a3147619d1fb2ae4a (diff) | |
parent | 844670839130c5541f36237ec509169ff636946f (diff) | |
download | barebox-2fbba4e4d573273034a19703a6d0cbe29c21e418.tar.gz barebox-2fbba4e4d573273034a19703a6d0cbe29c21e418.tar.xz |
Merge branch 'for-next/misc'
-rw-r--r-- | commands/of_dump.c | 31 | ||||
-rw-r--r-- | commands/ubi.c | 11 |
2 files changed, 37 insertions, 5 deletions
diff --git a/commands/of_dump.c b/commands/of_dump.c index 315dbbae8c..1222ebfd6b 100644 --- a/commands/of_dump.c +++ b/commands/of_dump.c @@ -35,16 +35,20 @@ static int do_of_dump(int argc, char *argv[]) { int opt; int ret; + int fix = 0; struct device_node *root = NULL, *node, *of_free = NULL; char *dtbfile = NULL; size_t size; const char *nodename; - while ((opt = getopt(argc, argv, "f:")) > 0) { + while ((opt = getopt(argc, argv, "Ff:")) > 0) { switch (opt) { case 'f': dtbfile = optarg; break; + case 'F': + fix = 1; + break; default: return COMMAND_ERROR_USAGE; } @@ -76,6 +80,28 @@ static int do_of_dump(int argc, char *argv[]) of_free = root; } else { root = of_get_root_node(); + + if (fix) { + /* create a copy of internal devicetree */ + void *fdt; + fdt = of_flatten_dtb(root); + root = of_unflatten_dtb(fdt); + + free(fdt); + + if (IS_ERR(root)) { + ret = PTR_ERR(root); + goto out; + } + + of_free = root; + } + } + + if (fix) { + ret = of_fix_tree(root); + if (ret) + goto out; } node = of_find_node_by_path_or_alias(root, nodename); @@ -97,12 +123,13 @@ out: BAREBOX_CMD_HELP_START(of_dump) BAREBOX_CMD_HELP_TEXT("Options:") BAREBOX_CMD_HELP_OPT ("-f dtb", "work on dtb instead of internal devicetree\n") +BAREBOX_CMD_HELP_OPT ("-F", "return fixed devicetree\n") BAREBOX_CMD_HELP_END BAREBOX_CMD_START(of_dump) .cmd = do_of_dump, BAREBOX_CMD_DESC("dump devicetree nodes") - BAREBOX_CMD_OPTS("[-f] [NODE]") + BAREBOX_CMD_OPTS("[-fF] [NODE]") BAREBOX_CMD_GROUP(CMD_GRP_MISC) BAREBOX_CMD_COMPLETE(devicetree_file_complete) BAREBOX_CMD_HELP(cmd_of_dump_help) diff --git a/commands/ubi.c b/commands/ubi.c index d593e71c2a..94da799b8c 100644 --- a/commands/ubi.c +++ b/commands/ubi.c @@ -65,9 +65,13 @@ static int do_ubiattach(int argc, char *argv[]) struct mtd_info_user user; int fd, ret; int vid_hdr_offset = 0; + int devnum = UBI_DEV_NUM_AUTO; - while((opt = getopt(argc, argv, "O:")) > 0) { + while((opt = getopt(argc, argv, "d:O:")) > 0) { switch(opt) { + case 'd': + devnum = simple_strtoul(optarg, NULL, 0); + break; case 'O': vid_hdr_offset = simple_strtoul(optarg, NULL, 0); break; @@ -91,7 +95,7 @@ static int do_ubiattach(int argc, char *argv[]) goto err; } - ret = ubi_attach_mtd_dev(user.mtd, UBI_DEV_NUM_AUTO, vid_hdr_offset, 20); + ret = ubi_attach_mtd_dev(user.mtd, devnum, vid_hdr_offset, 20); if (ret < 0) printf("failed to attach: %s\n", strerror(-ret)); else @@ -104,13 +108,14 @@ err: BAREBOX_CMD_HELP_START(ubiattach) BAREBOX_CMD_HELP_TEXT("Options:") +BAREBOX_CMD_HELP_OPT ("-d DEVNUM", "device number") BAREBOX_CMD_HELP_OPT ("-O OFFS", "VID header offset") BAREBOX_CMD_HELP_END BAREBOX_CMD_START(ubiattach) .cmd = do_ubiattach, BAREBOX_CMD_DESC("attach mtd device to UBI") - BAREBOX_CMD_OPTS("[-O] MTDDEV") + BAREBOX_CMD_OPTS("[-dO] MTDDEV") BAREBOX_CMD_GROUP(CMD_GRP_PART) BAREBOX_CMD_HELP(cmd_ubiattach_help) BAREBOX_CMD_END |