Skip to content

Commit

Permalink
Use cg_memcpy throughtout bitfury driver
Browse files Browse the repository at this point in the history
  • Loading branch information
ckolivas committed Mar 4, 2015
1 parent 8714203 commit 619528d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions driver-bitfury.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ static bool bf1_getinfo(struct cgpu_info *bitfury, struct bitfury_info *info)
return false;
}
info->version = buf[1];
memcpy(&info->product, buf + 2, 8);
memcpy(&info->serial, buf + 10, 4);
cg_memcpy(&info->product, buf + 2, 8);
cg_memcpy(&info->serial, buf + 10, 4);
bitfury->unique_id = bin2hex((unsigned char *)buf + 10, 4);

applog(LOG_INFO, "%s %d: Getinfo returned version %d, product %s serial %s", bitfury->drv->name,
Expand Down Expand Up @@ -731,8 +731,8 @@ static bool bxm_reset_bitfury(struct cgpu_info *bitfury)
buf[0] = WRITE_BYTES_SPI0;
buf[1] = (uint8_t)16 - (uint8_t)1;
buf[2] = 0;
memcpy(&buf[3], rst_buf, 8);
memcpy(&buf[11], rst_buf, 8);
cg_memcpy(&buf[3], rst_buf, 8);
cg_memcpy(&buf[11], rst_buf, 8);
err = usb_write(bitfury, buf, 19, &amount, C_BXM_RESET);
if (err || amount != 19)
return false;
Expand Down Expand Up @@ -1204,8 +1204,8 @@ static int64_t bf1_scan(struct thr_info *thr, struct cgpu_info *bitfury,
}

buf[0] = 'W';
memcpy(buf + 1, work->midstate, 32);
memcpy(buf + 33, work->data + 64, 12);
cg_memcpy(buf + 1, work->midstate, 32);
cg_memcpy(buf + 33, work->data + 64, 12);

/* New results may spill out from the latest work, making us drop out
* too early so read whatever we get for the first half nonce and then
Expand Down Expand Up @@ -1254,7 +1254,7 @@ static int64_t bf1_scan(struct thr_info *thr, struct cgpu_info *bitfury,
uint32_t nonce;

/* Ignore state & switched data in results for now. */
memcpy(&nonce, readbuf + i + 3, 4);
cg_memcpy(&nonce, readbuf + i + 3, 4);
nonce = decnonce(nonce);

rd_lock(&bitfury->qlock);
Expand Down
14 changes: 7 additions & 7 deletions libbitfury.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014 Con Kolivas
* Copyright 2014-2015 Con Kolivas
* Copyright 2013 Andrew Smith
* Copyright 2013 bitfury
*
Expand Down Expand Up @@ -85,7 +85,7 @@ static bool atrvec_set;

void bitfury_work_to_payload(struct bitfury_payload *p, struct work *work)
{
memcpy(p->midstate, work->midstate, 32);
cg_memcpy(p->midstate, work->midstate, 32);
p->m7 = *(unsigned int *)(work->data + 64);
p->ntime = *(unsigned int *)(work->data + 68);
p->nbits = *(unsigned int *)(work->data + 72);
Expand Down Expand Up @@ -172,7 +172,7 @@ void spi_add_buf(struct bitfury_info *info, const void *buf, const int sz)
applog(LOG_WARNING, "SPI bufsize overflow!");
return;
}
memcpy(&info->spibuf[info->spibufsz], buf, sz);
cg_memcpy(&info->spibuf[info->spibufsz], buf, sz);
info->spibufsz += sz;
}

Expand Down Expand Up @@ -293,7 +293,7 @@ bool ftdi_spi_txrx(struct cgpu_info *bitfury, struct bitfury_info *info)
buf[0] = READ_WRITE_BYTES_SPI0;
buf[1] = length & 0x00FF;
buf[2] = (length & 0xFF00) >> 8;
memcpy(&buf[3], info->spibuf, info->spibufsz);
cg_memcpy(&buf[3], info->spibuf, info->spibufsz);
info->spibufsz += 3;
err = usb_write(bitfury, buf, info->spibufsz, &amount, C_BXM_SPITX);
if (err || amount != (int)info->spibufsz) {
Expand Down Expand Up @@ -347,7 +347,7 @@ bool libbitfury_sendHashData(struct thr_info *thr, struct cgpu_info *bitfury,
unsigned int localvec[20];

/* Programming next value */
memcpy(localvec, p, 20 * 4);
cg_memcpy(localvec, p, 20 * 4);
ms3steps(localvec);

spi_clear_buf(info);
Expand All @@ -357,7 +357,7 @@ bool libbitfury_sendHashData(struct thr_info *thr, struct cgpu_info *bitfury,
if (!info->spi_txrx(bitfury, info))
return false;

memcpy(newbuf, info->spibuf + 4 + chip_n, 17 * 4);
cg_memcpy(newbuf, info->spibuf + 4 + chip_n, 17 * 4);

info->job_switched[chip_n] = newbuf[16] != oldbuf[16];

Expand All @@ -376,7 +376,7 @@ bool libbitfury_sendHashData(struct thr_info *thr, struct cgpu_info *bitfury,
}
}
}
memcpy(oldbuf, newbuf, 17 * 4);
cg_memcpy(oldbuf, newbuf, 17 * 4);
}
} else
info->second_run[chip_n] = true;
Expand Down

0 comments on commit 619528d

Please sign in to comment.