diff options
author | Teresa Remmet <t.remmet@phytec.de> | 2016-02-25 08:36:48 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-03-01 08:25:48 +0100 |
commit | 11c0f8159d89cc840abed0cbc43497bad6dd99bd (patch) | |
tree | ebf0ff50499e38f4d1170c23f9f240e05a0486c4 /commands/of_fixup_status.c | |
parent | 153c34b34790d89076fc03f3b8798a60c140754b (diff) | |
download | barebox-11c0f8159d89cc840abed0cbc43497bad6dd99bd.tar.gz barebox-11c0f8159d89cc840abed0cbc43497bad6dd99bd.tar.xz |
commands: Add of_fixup_status
of_fixup_status enables or disables the status property of a
given node with a device tree fixup.
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/of_fixup_status.c')
-rw-r--r-- | commands/of_fixup_status.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/commands/of_fixup_status.c b/commands/of_fixup_status.c new file mode 100644 index 0000000000..9a4a619195 --- /dev/null +++ b/commands/of_fixup_status.c @@ -0,0 +1,74 @@ +/* + * of_fixup_status.c - Register a fixup to enable or disable nodes in the + * device tree + * + * Copyright (c) 2014-2016 PHYTEC Messtechnik GmbH + * Author: + * Teresa Remmet + * Wadim Egorov + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <common.h> +#include <of.h> +#include <command.h> +#include <malloc.h> +#include <complete.h> +#include <asm/byteorder.h> +#include <linux/err.h> +#include <getopt.h> +#include <string.h> + +static int do_of_fixup_status(int argc, char *argv[]) +{ + int opt; + bool status = 1; + char *node = NULL; + + while ((opt = getopt(argc, argv, "d")) > 0) { + switch (opt) { + case 'd': + status = 0; + break; + default: + return COMMAND_ERROR_USAGE; + } + } + + if (optind == argc) + return COMMAND_ERROR_USAGE; + + node = xstrdup(argv[optind]); + + of_register_set_status_fixup(node, status); + + return 0; +} + +BAREBOX_CMD_HELP_START(of_fixup_status) +BAREBOX_CMD_HELP_TEXT("Options:") +BAREBOX_CMD_HELP_OPT("-d", "disable node") +BAREBOX_CMD_HELP_OPT("path", "Node path\n") +BAREBOX_CMD_HELP_TEXT("Register a fixup to enable or disable a device tree node.") +BAREBOX_CMD_HELP_TEXT("Nodes are enabled on default. Disabled with -d.") +BAREBOX_CMD_HELP_END + +BAREBOX_CMD_START(of_fixup_status) + .cmd = do_of_fixup_status, + BAREBOX_CMD_DESC("register a fixup to enable or disable node") + BAREBOX_CMD_OPTS("[-d] path") + BAREBOX_CMD_GROUP(CMD_GRP_MISC) + BAREBOX_CMD_COMPLETE(devicetree_file_complete) + BAREBOX_CMD_HELP(cmd_of_fixup_status_help) +BAREBOX_CMD_END |