]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - common/image-fit.c
scsi: move the partition initialization out of the scsi detection
[people/ms/u-boot.git] / common / image-fit.c
index 9468e519dbbe3f4cdd40388d78b146e6132a1fb1..109ecfaaccb79f2a6401938e2180c511e3af9eef 100644 (file)
@@ -777,6 +777,54 @@ int fit_image_get_data(const void *fit, int noffset,
        return 0;
 }
 
+/**
+ * Get 'data-offset' property from a given image node.
+ *
+ * @fit: pointer to the FIT image header
+ * @noffset: component image node offset
+ * @data_offset: holds the data-offset property
+ *
+ * returns:
+ *     0, on success
+ *     -ENOENT if the property could not be found
+ */
+int fit_image_get_data_offset(const void *fit, int noffset, int *data_offset)
+{
+       const fdt32_t *val;
+
+       val = fdt_getprop(fit, noffset, FIT_DATA_OFFSET_PROP, NULL);
+       if (!val)
+               return -ENOENT;
+
+       *data_offset = fdt32_to_cpu(*val);
+
+       return 0;
+}
+
+/**
+ * Get 'data-size' property from a given image node.
+ *
+ * @fit: pointer to the FIT image header
+ * @noffset: component image node offset
+ * @data_size: holds the data-size property
+ *
+ * returns:
+ *     0, on success
+ *     -ENOENT if the property could not be found
+ */
+int fit_image_get_data_size(const void *fit, int noffset, int *data_size)
+{
+       const fdt32_t *val;
+
+       val = fdt_getprop(fit, noffset, FIT_DATA_SIZE_PROP, NULL);
+       if (!val)
+               return -ENOENT;
+
+       *data_size = fdt32_to_cpu(*val);
+
+       return 0;
+}
+
 /**
  * fit_image_hash_get_algo - get hash algorithm name
  * @fit: pointer to the FIT format image header
@@ -1513,12 +1561,6 @@ void fit_conf_print(const void *fit, int noffset, const char *p)
 
 static int fit_image_select(const void *fit, int rd_noffset, int verify)
 {
-#if !defined(USE_HOSTCC) && defined(CONFIG_FIT_IMAGE_POST_PROCESS)
-       const void *data;
-       size_t size;
-       int ret;
-#endif
-
        fit_image_print(fit, rd_noffset, "   ");
 
        if (verify) {
@@ -1530,23 +1572,6 @@ static int fit_image_select(const void *fit, int rd_noffset, int verify)
                puts("OK\n");
        }
 
-#if !defined(USE_HOSTCC) && defined(CONFIG_FIT_IMAGE_POST_PROCESS)
-       ret = fit_image_get_data(fit, rd_noffset, &data, &size);
-       if (ret)
-               return ret;
-
-       /* perform any post-processing on the image data */
-       board_fit_image_post_process((void **)&data, &size);
-
-       /*
-        * update U-Boot's understanding of the "data" property start address
-        * and size according to the performed post-processing
-        */
-       ret = fdt_setprop((void *)fit, rd_noffset, FIT_DATA_PROP, data, size);
-       if (ret)
-               return ret;
-#endif
-
        return 0;
 }
 
@@ -1755,6 +1780,12 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
                bootstage_error(bootstage_id + BOOTSTAGE_SUB_GET_DATA);
                return -ENOENT;
        }
+
+#if !defined(USE_HOSTCC) && defined(CONFIG_FIT_IMAGE_POST_PROCESS)
+       /* perform any post-processing on the image data */
+       board_fit_image_post_process((void **)&buf, &size);
+#endif
+
        len = (ulong)size;
 
        /* verify that image data is a proper FDT blob */