From f6dbc6ca9618391e4f30c415a0a09b7af35f7647 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Wed, 1 Jul 2015 00:31:28 +0100 Subject: guess output file format If no output file type is specified via the -O parameter, guess the desired file type by looking at the file name extension. If that provides no useful hints, assume "dtb" as long as the input type is "dts". Any other input type will lead to "dts" being used as the guessed output type. Any explicit specification of the output type will skip this guessing. Signed-off-by: Andre Przywara Signed-off-by: David Gibson --- dtc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'dtc.c') diff --git a/dtc.c b/dtc.c index 53793bf..5fa23c4 100644 --- a/dtc.c +++ b/dtc.c @@ -155,7 +155,7 @@ int main(int argc, char *argv[]) { struct boot_info *bi; const char *inform = NULL; - const char *outform = "dts"; + const char *outform = NULL; const char *outname = "-"; const char *depname = NULL; bool force = false, sort = false; @@ -262,6 +262,15 @@ int main(int argc, char *argv[]) if (inform == NULL) inform = guess_input_format(arg, "dts"); + if (outform == NULL) { + outform = guess_type_by_name(outname, NULL); + if (outform == NULL) { + if (streq(inform, "dts")) + outform = "dtb"; + else + outform = "dts"; + } + } if (streq(inform, "dts")) bi = dt_from_source(arg); else if (streq(inform, "fs")) -- cgit v1.1