@ -471,40 +471,37 @@ static void rev(unsigned char *s, size_t l)
# define ICA_NONCE_RESTART 1
# define ICA_NONCE_RESTART 1
# define ICA_NONCE_TIMEOUT 2
# define ICA_NONCE_TIMEOUT 2
static int icarus_get_nonce ( struct cgpu_info * icarus , unsigned char * buf , struct timeval * tv_start , struct timeval * tv_finish , struct thr_info * thr , int read_time )
static int icarus_get_nonce ( struct cgpu_info * icarus , unsigned char * buf , struct timeval * tv_start ,
struct timeval * tv_finish , struct thr_info * thr , int read_time )
{
{
struct ICARUS_INFO * info = ( struct ICARUS_INFO * ) ( icarus - > device_data ) ;
struct ICARUS_INFO * info = ( struct ICARUS_INFO * ) ( icarus - > device_data ) ;
struct timeval read_start , read_finish ;
int err , amt , rc ;
int err , amt ;
int rc = 0 , delay ;
int read_amount = ICARUS_READ_SIZE ;
bool first = true ;
cgtime ( tv_start ) ;
while ( true ) {
if ( icarus - > usbinfo . nodev )
if ( icarus - > usbinfo . nodev )
return ICA_NONCE_ERROR ;
return ICA_NONCE_ERROR ;
cgtime ( & read_start ) ;
cgtime ( tv_start ) ;
err = usb_read_ii_timeout ( icarus , info - > intinfo ,
err = usb_read_ii_timeout_cancellable ( icarus , info - > intinfo , ( char * ) buf ,
( char * ) buf , read_amount , & amt ,
ICARUS_READ_SIZE , & amt , read_time ,
info - > timeout , C_GETRESULTS ) ;
C_GETRESULTS ) ;
cgtime ( & read_finish ) ;
cgtime ( tv_finish ) ;
if ( err < 0 & & err ! = LIBUSB_ERROR_TIMEOUT ) {
if ( err < 0 & & err ! = LIBUSB_ERROR_TIMEOUT ) {
applog ( LOG_ERR , " %s%i: Comms error (rerr=%d amt=%d) " ,
applog ( LOG_ERR , " %s%i: Comms error (rerr=%d amt=%d) " , icarus - > drv - > name ,
icarus - > drv - > name , icarus - > device_id , err , amt ) ;
icarus - > device_id , err , amt ) ;
dev_error ( icarus , REASON_DEV_COMMS_ERROR ) ;
dev_error ( icarus , REASON_DEV_COMMS_ERROR ) ;
return ICA_NONCE_ERROR ;
return ICA_NONCE_ERROR ;
}
}
if ( first )
if ( amt > = ICARUS_READ_SIZE )
copy_time ( tv_finish , & read_finish ) ;
if ( amt > = read_amount )
return ICA_NONCE_OK ;
return ICA_NONCE_OK ;
rc = SECTOMS ( tdiff ( & read_finish , tv_start ) ) ;
rc = SECTOMS ( tdiff ( tv_finish , tv_start ) ) ;
if ( rc > = read_time ) {
if ( thr - > work_restart ) {
applog ( LOG_DEBUG , " Icarus Read: Work restart at %d ms " , rc ) ;
return ICA_NONCE_RESTART ;
}
if ( amt > 0 )
if ( amt > 0 )
applog ( LOG_DEBUG , " Icarus Read: Timeout reading for %d ms " , rc ) ;
applog ( LOG_DEBUG , " Icarus Read: Timeout reading for %d ms " , rc ) ;
else
else
@ -512,31 +509,6 @@ static int icarus_get_nonce(struct cgpu_info *icarus, unsigned char *buf, struct
return ICA_NONCE_TIMEOUT ;
return ICA_NONCE_TIMEOUT ;
}
}
if ( thr & & thr - > work_restart ) {
applog ( LOG_DEBUG , " Icarus Read: Work restart at %d ms " , rc ) ;
return ICA_NONCE_RESTART ;
}
if ( amt > 0 ) {
buf + = amt ;
read_amount - = amt ;
first = false ;
}
if ( info - > timeout < ICARUS_WAIT_TIMEOUT ) {
delay = ICARUS_WAIT_TIMEOUT - rc ;
if ( delay > 0 ) {
cgsleep_ms ( delay ) ;
if ( thr & & thr - > work_restart ) {
applog ( LOG_DEBUG , " Icarus Read: Work restart at %d ms " , rc ) ;
return ICA_NONCE_RESTART ;
}
}
}
}
}
static const char * timing_mode_str ( enum timing_mode timing_mode )
static const char * timing_mode_str ( enum timing_mode timing_mode )
{
{
switch ( timing_mode ) {
switch ( timing_mode ) {