From: Sean Anderson Date: Tue, 16 Aug 2022 15:16:06 +0000 (-0400) Subject: net: Convert fit verification to use fit_get_data_* X-Git-Url: http://git.dujemihanovic.xyz/html/index.html?a=commitdiff_plain;h=f1061c570112670be3259fff7966caad96c6e2cf;p=u-boot.git net: Convert fit verification to use fit_get_data_* Several ethernet drivers load firmware from FIT images. Convert them to use the fit_get_data helpers. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass Signed-off-by: Peng Fan --- diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c index bc1c31d467..68833f9ddd 100644 --- a/drivers/net/fsl-mc/mc.c +++ b/drivers/net/fsl-mc/mc.c @@ -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 diff --git a/drivers/net/pfe_eth/pfe_firmware.c b/drivers/net/pfe_eth/pfe_firmware.c index 82a4aa89a4..da4f2ca42a 100644 --- a/drivers/net/pfe_eth/pfe_firmware.c +++ b/drivers/net/pfe_eth/pfe_firmware.c @@ -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); } /*