summaryrefslogtreecommitdiff
path: root/util/sconfig/main.c
diff options
context:
space:
mode:
authorJakub Czapiga <jacz@semihalf.com>2022-12-08 14:33:02 +0100
committerFelix Held <felix-coreboot@felixheld.de>2023-07-03 13:00:19 +0000
commit00d71ffca8d6102326897edd6f6504284635201d (patch)
tree1db0fdefd45af51bc00e366c82f4f9bab7832734 /util/sconfig/main.c
parente01742bf3df1d1d7f74c4f5beac4b1a50110d9ab (diff)
util/sconfig: Improve usage and long options
Move usage function closer to main(), remove excessive printf() calls, use descriptive argument flags. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: If5252de63692c5e43bfbde4d7d93e1d7a84e8dff Reviewed-on: https://review.coreboot.org/c/coreboot/+/70524 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
Diffstat (limited to 'util/sconfig/main.c')
-rw-r--r--util/sconfig/main.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/util/sconfig/main.c b/util/sconfig/main.c
index a246c01c67..2e6188ff56 100644
--- a/util/sconfig/main.c
+++ b/util/sconfig/main.c
@@ -1493,20 +1493,6 @@ static void inherit_subsystem_ids(FILE *file, FILE *head, struct device *dev,
}
}
-static void usage(void)
-{
- printf("usage: sconfig <options>\n");
- printf(" -c | --output_c : Path to output static.c file (required)\n");
- printf(" -r | --output_h : Path to header static.h file (required)\n");
- printf(" -d | --output_d : Path to header static_devices.h file (required)\n");
- printf(" -f | --output_f : Path to header static_fw_config.h file (required)\n");
- printf(" -m | --mainboard_devtree : Path to mainboard devicetree file (required)\n");
- printf(" -o | --override_devtree : Path to override devicetree file (optional)\n");
- printf(" -p | --chipset_devtree : Path to chipset/SOC devicetree file (optional)\n");
-
- exit(1);
-}
-
static void parse_devicetree(const char *file, struct bus *parent)
{
FILE *filec = fopen(file, "r");
@@ -1999,17 +1985,32 @@ static void generate_outputf(FILE *f)
fprintf(f, "\n#endif /* __STATIC_FW_CONFIG_H */\n");
}
+static void usage(const char *name)
+{
+ printf("Usage: %s <options>\n", name);
+ printf("Options:\n"
+ " -c | --output_c : Path to output static.c file (required)\n"
+ " -r | --output_h : Path to header static.h file (required)\n"
+ " -d | --output_d : Path to header static_devices.h file (required)\n"
+ " -f | --output_f : Path to header static_fw_config.h file (required)\n"
+ " -m | --mainboard_devtree : Path to mainboard devicetree file (required)\n"
+ " -o | --override_devtree : Path to override devicetree file (optional)\n"
+ " -p | --chipset_devtree : Path to chipset/SOC devicetree file (optional)\n");
+
+ exit(1);
+}
+
int main(int argc, char **argv)
{
static const struct option long_options[] = {
- { "mainboard_devtree", 1, NULL, 'm' },
- { "override_devtree", 1, NULL, 'o' },
- { "chipset_devtree", 1, NULL, 'p' },
- { "output_c", 1, NULL, 'c' },
- { "output_h", 1, NULL, 'r' },
- { "output_d", 1, NULL, 'd' },
- { "output_f", 1, NULL, 'f' },
- { "help", 1, NULL, 'h' },
+ { "mainboard_devtree", required_argument, NULL, 'm' },
+ { "override_devtree", required_argument, NULL, 'o' },
+ { "chipset_devtree", required_argument, NULL, 'p' },
+ { "output_c", required_argument, NULL, 'c' },
+ { "output_h", required_argument, NULL, 'r' },
+ { "output_d", required_argument, NULL, 'd' },
+ { "output_f", required_argument, NULL, 'f' },
+ { "help", no_argument, NULL, 'h' },
{ }
};
const char *override_devtree = NULL;
@@ -2047,12 +2048,12 @@ int main(int argc, char **argv)
break;
case 'h':
default:
- usage();
+ usage(argv[0]);
}
}
if (!base_devtree || !outputc || !outputh || !outputd || !outputf)
- usage();
+ usage(argv[0]);
if (chipset_devtree) {
/* Use the chipset devicetree as the base, then override