]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: Convert fit verification to use fit_get_data_*
authorSean Anderson <sean.anderson@seco.com>
Tue, 16 Aug 2022 15:16:06 +0000 (11:16 -0400)
committerPeng Fan <peng.fan@nxp.com>
Wed, 7 Sep 2022 05:40:50 +0000 (13:40 +0800)
Several ethernet drivers load firmware from FIT images. Convert them to
use the fit_get_data helpers.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
drivers/net/fsl-mc/mc.c
drivers/net/pfe_eth/pfe_firmware.c

index bc1c31d4675b8200e5ad065e56c85141fddce460..68833f9ddd928641b7d5a315120c42217262bf27 100644 (file)
@@ -137,13 +137,7 @@ int parse_mc_firmware_fit_image(u64 mc_fw_addr,
                                size_t *raw_image_size)
 {
        int format;
-       void *fit_hdr;
-       int node_offset;
-       const void *data;
-       size_t size;
-       const char *uname = "firmware";
-
-       fit_hdr = (void *)mc_fw_addr;
+       void *fit_hdr = (void *)mc_fw_addr;
 
        /* Check if Image is in FIT format */
        format = genimg_get_format(fit_hdr);
@@ -158,26 +152,8 @@ int parse_mc_firmware_fit_image(u64 mc_fw_addr,
                return -EINVAL;
        }
 
-       node_offset = fit_image_get_node(fit_hdr, uname);
-
-       if (node_offset < 0) {
-               printf("fsl-mc: ERR: Bad firmware image (missing subimage)\n");
-               return -ENOENT;
-       }
-
-       /* Verify MC firmware image */
-       if (!(fit_image_verify(fit_hdr, node_offset))) {
-               printf("fsl-mc: ERR: Bad firmware image (bad CRC)\n");
-               return -EINVAL;
-       }
-
-       /* Get address and size of raw image */
-       fit_image_get_data(fit_hdr, node_offset, &data, &size);
-
-       *raw_image_addr = data;
-       *raw_image_size = size;
-
-       return 0;
+       return fit_get_data_node(fit_hdr, "firmware", raw_image_addr,
+                                raw_image_size);
 }
 #endif
 
index 82a4aa89a4d52be3ba26ea644f86d0bd02a5179f..da4f2ca42a5ba97b71a1591d9afa58981369e9fa 100644 (file)
@@ -104,45 +104,7 @@ err:
 static int pfe_get_fw(const void **data,
                      size_t *size, char *fw_name)
 {
-       int conf_node_off, fw_node_off;
-       char *conf_node_name = NULL;
-       char *desc;
-       int ret = 0;
-
-       conf_node_name = PFE_FIRMWARE_FIT_CNF_NAME;
-
-       conf_node_off = fit_conf_get_node(pfe_fit_addr, conf_node_name);
-       if (conf_node_off < 0) {
-               printf("PFE Firmware: %s: no such config\n", conf_node_name);
-               return -ENOENT;
-       }
-
-       fw_node_off = fit_conf_get_prop_node(pfe_fit_addr, conf_node_off,
-                                            fw_name);
-       if (fw_node_off < 0) {
-               printf("PFE Firmware: No '%s' in config\n",
-                      fw_name);
-               return -ENOLINK;
-       }
-
-       if (!(fit_image_verify(pfe_fit_addr, fw_node_off))) {
-               printf("PFE Firmware: Bad firmware image (bad CRC)\n");
-               return -EINVAL;
-       }
-
-       if (fit_image_get_data(pfe_fit_addr, fw_node_off, data, size)) {
-               printf("PFE Firmware: Can't get %s subimage data/size",
-                      fw_name);
-               return -ENOENT;
-       }
-
-       ret = fit_get_desc(pfe_fit_addr, fw_node_off, &desc);
-       if (ret)
-               printf("PFE Firmware: Can't get description\n");
-       else
-               printf("%s\n", desc);
-
-       return ret;
+       return fit_get_data_conf_prop(pfe_fit_addr, fw_name, data, size);
 }
 
 /*