Browse Source

avalon_clear_readbuf is no longer required.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
e27ca54408
  1. 35
      driver-avalon.c

35
driver-avalon.c

@ -276,25 +276,6 @@ static int avalon_read(int fd, char *buf, ssize_t len)
return 0; return 0;
} }
/* Non blocking clearing of anything in the buffer */
static void avalon_clear_readbuf(int fd)
{
ssize_t ret;
do {
struct timeval timeout;
char buf[AVALON_FTDI_READSIZE];
fd_set rd;
timeout.tv_sec = timeout.tv_usec = 0;
FD_ZERO(&rd);
FD_SET((SOCKETTYPE)fd, &rd);
ret = select(fd + 1, &rd, NULL, NULL, &timeout);
if (ret > 0)
ret = read(fd, buf, AVALON_FTDI_READSIZE);
} while (ret > 0);
}
static int avalon_reset(struct cgpu_info *avalon, int fd) static int avalon_reset(struct cgpu_info *avalon, int fd)
{ {
struct avalon_result ar; struct avalon_result ar;
@ -303,10 +284,7 @@ static int avalon_reset(struct cgpu_info *avalon, int fd)
int ret, i = 0; int ret, i = 0;
struct timespec p; struct timespec p;
/* There's usually a one byte response after opening */ /* Send reset, then check for result */
avalon_clear_readbuf(fd);
/* Reset once, then send command to go idle */
ret = avalon_write(fd, &reset, 1); ret = avalon_write(fd, &reset, 1);
if (unlikely(ret == AVA_SEND_ERROR)) if (unlikely(ret == AVA_SEND_ERROR))
return -1; return -1;
@ -315,6 +293,9 @@ static int avalon_reset(struct cgpu_info *avalon, int fd)
if (unlikely(ret == AVA_GETS_ERROR)) if (unlikely(ret == AVA_GETS_ERROR))
return -1; return -1;
/* What do these sleeps do?? */
p.tv_sec = 0;
p.tv_nsec = AVALON_RESET_PITCH;
nanosleep(&p, NULL); nanosleep(&p, NULL);
buf = (uint8_t *)&ar; buf = (uint8_t *)&ar;
@ -339,11 +320,6 @@ static int avalon_reset(struct cgpu_info *avalon, int fd)
applog(LOG_WARNING, "AVA%d: Reset succeeded", applog(LOG_WARNING, "AVA%d: Reset succeeded",
avalon->device_id); avalon->device_id);
/* What do these sleeps do?? */
p.tv_sec = 0;
p.tv_nsec = AVALON_RESET_PITCH;
nanosleep(&p, NULL);
return 0; return 0;
} }
@ -503,7 +479,6 @@ static bool avalon_detect_one(const char *devpath)
applog(LOG_ERR, "Avalon Detect: Failed to open %s", devpath); applog(LOG_ERR, "Avalon Detect: Failed to open %s", devpath);
return false; return false;
} }
avalon_clear_readbuf(fd);
/* We have a real Avalon! */ /* We have a real Avalon! */
avalon = calloc(1, sizeof(struct cgpu_info)); avalon = calloc(1, sizeof(struct cgpu_info));
@ -788,8 +763,6 @@ static bool avalon_prepare(struct thr_info *thr)
if (unlikely(pthread_cond_init(&info->qcond, NULL))) if (unlikely(pthread_cond_init(&info->qcond, NULL)))
quit(1, "Failed to pthread_cond_init avalon qcond"); quit(1, "Failed to pthread_cond_init avalon qcond");
avalon_clear_readbuf(avalon->device_fd);
if (pthread_create(&info->write_thr, NULL, avalon_send_tasks, (void *)avalon)) if (pthread_create(&info->write_thr, NULL, avalon_send_tasks, (void *)avalon))
quit(1, "Failed to create avalon write_thr"); quit(1, "Failed to create avalon write_thr");

Loading…
Cancel
Save