lib/fw.c
/**
 * @brief Return firmware information structures for a number of firmware
 *	partitions.
 * @param[in]  dev	Switchtec device handle
 * @param[in]  nr_info 	Number of partitions to retrieve the info for
 * @param[out] info	Pointer to a list of info structs of at least
 *	\p nr_info entries
 * @return 0 on success, error code on failure
 */
@brief Return firmware information structures for a number of firmware
partitions.
@param[in]  dev      Switchtec device handle
@param[in]  nr_info  Number of partitions to retrieve the info for
@param[out] info     Pointer to a list of info structs of at least
\p nr_info entries
@return 0 on success, error code on failure
@brief Return firmware information structures for a number of firmware partitions . @param [ in ] dev Switchtec device handle @param [ in ] nr_info Number of partitions to retrieve the info for @param [ out ] info Pointer to a list of info structs of at least \ p nr_info entries @return 0 on success error code on failure
int switchtec_fw_part_info(struct switchtec_dev *dev, int nr_info,
			   struct switchtec_fw_image_info *info)
{
	int ret;
	int i;
	struct switchtec_fw_footer ftr;
	if (info == NULL || nr_info == 0)
		return -EINVAL;
	for (i = 0; i < nr_info; i++) {
		struct switchtec_fw_image_info *inf = &info[i];
		ret = switchtec_flash_part(dev, inf, inf->type);
		if (ret)
			return ret;
		if (info[i].type == SWITCHTEC_FW_TYPE_NVLOG) {
			inf->version[0] = 0;
			inf->crc = 0;
			continue;
		}
		ret = switchtec_fw_read_footer(dev, inf->image_addr,
					       inf->image_len, &ftr,
					       inf->version,
					       sizeof(inf->version));
		if (ret < 0) {
			inf->version[0] = 0;
			inf->crc = 0xFFFFFFFF;
		} else {
			inf->crc = ftr.image_crc;
		}
	}
	return nr_info;
}
int switchtec_fw_part_info ( struct switchtec_dev * dev , int nr_info , struct switchtec_fw_image_info * info ) { int ret ; int i ; struct switchtec_fw_footer ftr ; if ( info == NULL || nr_info == 0 ) return - EINVAL ; for ( i = 0 ; i < nr_info ; i ++ ) { struct switchtec_fw_image_info * inf = & info [ i ] ; ret = switchtec_flash_part ( dev , inf , inf -> type ) ; if ( ret ) return ret ; if ( info [ i ] . type == SWITCHTEC_FW_TYPE_NVLOG ) { inf -> version [ 0 ] = 0 ; inf -> crc = 0 ; continue ; } ret = switchtec_fw_read_footer ( dev , inf -> image_addr , inf -> image_len , & ftr , inf -> version , sizeof ( inf -> version ) ) ; if ( ret < 0 ) { inf -> version [ 0 ] = 0 ; inf -> crc = 0xFFFFFFFF ; } else { inf -> crc = ftr . image_crc ; } } return nr_info ; }
@brief Return firmware information structures for a number of firmware
      partitions.
@brief Return firmware information structures for a number of firmware partitions .