lib/fw.c
/**
 * @brief Wait for a firmware download chunk to complete
 * @param[in]  dev      Switchtec device handle
 * @param[out] status   The current download status
 * @return 0 on success, error code on failure
 *
 * Polls the firmware download status waiting until it no longer
 * indicates it's INPROGRESS. Sleeps 5ms between each poll.
 */
@brief Wait for a firmware download chunk to complete
@param[in]  dev      Switchtec device handle
@param[out] status   The current download status
@return 0 on success, error code on failure

Polls the firmware download status waiting until it no longer
indicates it's INPROGRESS. Sleeps 5ms between each poll.
@brief Wait for a firmware download chunk to complete @param [ in ] dev Switchtec device handle @param [ out ] status The current download status @return 0 on success error code on failure Polls the firmware download status waiting until it no longer indicates it ' s INPROGRESS . Sleeps 5ms between each poll .
int switchtec_fw_wait(struct switchtec_dev *dev,
		      enum switchtec_fw_dlstatus *status)
{
	enum mrpc_bg_status bgstatus;
	int ret;
	do {
		usleep(5000);
		ret = switchtec_fw_dlstatus(dev, status, &bgstatus);
		if (ret < 0)
			return ret;
		if (bgstatus == MRPC_BG_STAT_ERROR)
			return SWITCHTEC_DLSTAT_HARDWARE_ERR;
		if (*status == SWITCHTEC_DLSTAT_DOWNLOAD_TIMEOUT)
			return SWITCHTEC_DLSTAT_DOWNLOAD_TIMEOUT;
	} while (bgstatus == MRPC_BG_STAT_INPROGRESS);
	return 0;
}
int switchtec_fw_wait ( struct switchtec_dev * dev , enum switchtec_fw_dlstatus * status ) { enum mrpc_bg_status bgstatus ; int ret ; do { usleep ( 5000 ) ; ret = switchtec_fw_dlstatus ( dev , status , & bgstatus ) ; if ( ret < 0 ) return ret ; if ( bgstatus == MRPC_BG_STAT_ERROR ) return SWITCHTEC_DLSTAT_HARDWARE_ERR ; if ( * status == SWITCHTEC_DLSTAT_DOWNLOAD_TIMEOUT ) return SWITCHTEC_DLSTAT_DOWNLOAD_TIMEOUT ; } while ( bgstatus == MRPC_BG_STAT_INPROGRESS ) ; return 0 ; }
@brief Wait for a firmware download chunk to complete
 @param[in]  dev      Switchtec device handle
 @param[out] status   The current download status
 @return 0 on success, error code on failure
@brief Wait for a firmware download chunk to complete @param [ in ] dev Switchtec device handle @param [ out ] status The current download status @return 0 on success error code on failure
// Delay slightly to avoid interrupting the firmware too much