aboutsummaryrefslogtreecommitdiff
path: root/dtc.c
diff options
context:
space:
mode:
authorAndre Przywara <osp@andrep.de>2015-07-01 00:31:28 +0100
committerDavid Gibson <david@gibson.dropbear.id.au>2015-07-01 13:34:11 +1000
commitf6dbc6ca9618391e4f30c415a0a09b7af35f7647 (patch)
tree9f1ac367321c64ef29f9019bcb4221cef693e5cc /dtc.c
parent5e78dff4248da3f4efe3a399d66b091b97940ddf (diff)
downloaddtc-f6dbc6ca9618391e4f30c415a0a09b7af35f7647.zip
dtc-f6dbc6ca9618391e4f30c415a0a09b7af35f7647.tar.gz
dtc-f6dbc6ca9618391e4f30c415a0a09b7af35f7647.tar.bz2
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 <osp@andrep.de> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'dtc.c')
-rw-r--r--dtc.c11
1 files changed, 10 insertions, 1 deletions
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"))