FreeBSD/sys/dev/nxge/xgehal/xgehal-device.c
/*
 * __hal_device_register_poll
 * @hldev: pointer to xge_hal_device_t structure
 * @reg: register to poll for
 * @op: 0 - bit reset, 1 - bit set
 * @mask: mask for logical "and" condition based on %op
 * @max_millis: maximum time to try to poll in milliseconds
 *
 * Will poll certain register for specified amount of time.
 * Will poll until masked bit is not cleared.
 */


Will poll certain register for specified amount of time.
Will poll until masked bit is not cleared.
Will poll certain register for specified amount of time . Will poll until masked bit is not cleared .
xge_hal_status_e
__hal_device_register_poll(xge_hal_device_t *hldev, u64 *reg,
	           int op, u64 mask, int max_millis)
{
	u64 val64;
	int i = 0;
	xge_hal_status_e ret = XGE_HAL_FAIL;
	xge_os_udelay(10);
	do {
	    val64 = xge_os_pio_mem_read64(hldev->pdev, hldev->regh0, reg);
	    if (op == 0 && !(val64 & mask))
	        return XGE_HAL_OK;
	    else if (op == 1 && (val64 & mask) == mask)
	        return XGE_HAL_OK;
	    xge_os_udelay(100);
	} while (++i <= 9);
	do {
	    val64 = xge_os_pio_mem_read64(hldev->pdev, hldev->regh0, reg);
	    if (op == 0 && !(val64 & mask))
	        return XGE_HAL_OK;
	    else if (op == 1 && (val64 & mask) == mask)
	        return XGE_HAL_OK;
	    xge_os_udelay(1000);
	} while (++i < max_millis);
	return ret;
}
xge_hal_status_e __hal_device_register_poll ( xge_hal_device_t * hldev , u64 * reg , int op , u64 mask , int max_millis ) { u64 val64 ; int i = 0 ; xge_hal_status_e ret = XGE_HAL_FAIL ; xge_os_udelay ( 10 ) ; do { val64 = xge_os_pio_mem_read64 ( hldev -> pdev , hldev -> regh0 , reg ) ; if ( op == 0 && ! ( val64 & mask ) ) return XGE_HAL_OK ; else if ( op == 1 && ( val64 & mask ) == mask ) return XGE_HAL_OK ; xge_os_udelay ( 100 ) ; } while ( ++ i <= 9 ) ; do { val64 = xge_os_pio_mem_read64 ( hldev -> pdev , hldev -> regh0 , reg ) ; if ( op == 0 && ! ( val64 & mask ) ) return XGE_HAL_OK ; else if ( op == 1 && ( val64 & mask ) == mask ) return XGE_HAL_OK ; xge_os_udelay ( 1000 ) ; } while ( ++ i < max_millis ) ; return ret ; }
__hal_device_register_poll
 @hldev: pointer to xge_hal_device_t structure
 @reg: register to poll for
 @op: 0 - bit reset, 1 - bit set
 @mask: mask for logical "and" condition based on %op
 @max_millis: maximum time to try to poll in milliseconds
__hal_device_register_poll @hldev : pointer to xge_hal_device_t structure @reg : register to poll for @op : 0 - bit reset 1 - bit set @mask : mask for logical " and " condition based on %op @max_millis : maximum time to try to poll in milliseconds