]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - tools/mkimage.c
tools/mkimage: Remove duplicate line of code
[karo-tx-uboot.git] / tools / mkimage.c
index c43b20772694e9d78c880001c4187d2e32d8aaca..1bed93360e8645dd6c2ea22bd6d3b8ce322686c7 100644 (file)
@@ -148,6 +148,8 @@ main (int argc, char **argv)
        int retval = 0;
        struct image_type_params *tparams = NULL;
 
+       /* Init Kirkwood Boot image generation/list support */
+       init_kwb_image_type ();
        /* Init FIT image generation/list support */
        init_fit_image_type ();
        /* Init Default image generation/list support */
@@ -227,6 +229,11 @@ main (int argc, char **argv)
                        case 'f':
                                if (--argc <= 0)
                                        usage ();
+                               /*
+                                * The flattened image tree (FIT) format
+                                * requires a flattened device tree image type
+                                */
+                               params.type = IH_TYPE_FLATDT;
                                params.datafile = *++argv;
                                params.fflag = 1;
                                goto NXTARG;
@@ -290,23 +297,35 @@ NXTARG:           ;
 
        params.imagefile = *argv;
 
-       if (!params.fflag){
-               if (params.lflag) {
-                       ifd = open (params.imagefile, O_RDONLY|O_BINARY);
-               } else {
-                       ifd = open (params.imagefile,
-                               O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666);
-               }
+       if (params.fflag){
+               if (tparams->fflag_handle)
+                       /*
+                        * in some cases, some additional processing needs
+                        * to be done if fflag is defined
+                        *
+                        * For ex. fit_handle_file for Fit file support
+                        */
+                       retval = tparams->fflag_handle(&params);
 
-               if (ifd < 0) {
-                       fprintf (stderr, "%s: Can't open %s: %s\n",
-                               params.cmdname, params.imagefile,
-                               strerror(errno));
-                       exit (EXIT_FAILURE);
-               }
+               if (retval != EXIT_SUCCESS)
+                       exit (retval);
+       }
+
+       if (params.lflag || params.fflag) {
+               ifd = open (params.imagefile, O_RDONLY|O_BINARY);
+       } else {
+               ifd = open (params.imagefile,
+                       O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666);
+       }
+
+       if (ifd < 0) {
+               fprintf (stderr, "%s: Can't open %s: %s\n",
+                       params.cmdname, params.imagefile,
+                       strerror(errno));
+               exit (EXIT_FAILURE);
        }
 
-       if (params.lflag) {
+       if (params.lflag || params.fflag) {
                /*
                 * list header information of existing image
                 */
@@ -343,17 +362,6 @@ NXTARG:            ;
                (void) munmap((void *)ptr, sbuf.st_size);
                (void) close (ifd);
 
-               exit (retval);
-       } else if (params.fflag) {
-               if (tparams->fflag_handle)
-                       /*
-                        * in some cases, some additional processing needs
-                        * to be done if fflag is defined
-                        *
-                        * For ex. fit_handle_file for Fit file support
-                        */
-                       retval = tparams->fflag_handle(&params);
-
                exit (retval);
        }