Browse Source

Merge commit '335b11e' into littlefury

Conflicts:
	driver-bitfury.c
	libbitfury.c
Luke Dashjr 12 years ago
parent
commit
f3b2642bb5
5 changed files with 9 additions and 25 deletions
  1. 1 12
      driver-bitfury.c
  2. 2 6
      libbitfury.c
  3. 1 1
      libbitfury.h
  4. 2 4
      spidevc.c
  5. 3 2
      spidevc.h

+ 1 - 12
driver-bitfury.c

@@ -32,7 +32,6 @@
 struct device_drv bitfury_drv;
 
 // Forward declarations
-static void bitfury_disable(struct thr_info* thr);
 static bool bitfury_prepare(struct thr_info *thr);
 int calc_stat(time_t * stat_ts, time_t stat, struct timeval now);
 double shares_to_ghashes(int shares, int seconds);
@@ -60,11 +59,6 @@ static void bitfury_detect(void)
 	add_cgpu(bitfury_info);
 }
 
-static uint32_t bitfury_checkNonce(struct work *work, uint32_t nonce)
-{
-	applog(LOG_INFO, "INFO: bitfury_checkNonce");
-}
-
 static int64_t bitfury_scanHash(struct thr_info *thr)
 {
 	static struct bitfury_device *devices; // TODO Move somewhere to appropriate place
@@ -114,7 +108,7 @@ static int64_t bitfury_scanHash(struct thr_info *thr)
 	for (;chip < chip_n; chip++) {
 		if (devices[chip].job_switched) {
 			int i,j;
-			int *res = devices[chip].results;
+			unsigned int *res = devices[chip].results;
 			struct work *work = devices[chip].work;
 			struct work *owork = devices[chip].owork;
 			struct work *o2work = devices[chip].o2work;
@@ -275,11 +269,6 @@ static void bitfury_shutdown(struct thr_info *thr)
 	libbitfury_shutdownChips(thr->cgpu->devices, chip_n);
 }
 
-static void bitfury_disable(struct thr_info *thr)
-{
-	applog(LOG_INFO, "INFO bitfury_disable");
-}
-
 struct device_drv bitfury_drv = {
 	.dname = "bitfury",
 	.name = "BITFURY",

+ 2 - 6
libbitfury.c

@@ -399,15 +399,13 @@ unsigned decnonce(unsigned in)
 int rehash(unsigned char *midstate, unsigned m7,
 			unsigned ntime, unsigned nbits, unsigned nnonce) {
 	unsigned char in[16];
-	unsigned char hash1[32];
 	unsigned int *in32 = (unsigned int *)in;
-	unsigned char hex[65];
+	char hex[65];
 	unsigned int *mid32 = (unsigned int *)midstate;
 	unsigned out32[8];
 	unsigned char *out = (unsigned char *) out32;
 	static unsigned history[512];
 	static unsigned history_p;
-	int i;
 	sha256_ctx ctx;
 
 
@@ -427,7 +425,6 @@ int rehash(unsigned char *midstate, unsigned m7,
 	sha256(out, 32, out);
 
 	if (out32[7] == 0) {
-		bin2hex(hex, midstate, 32);
 		bin2hex(hex, out, 32);
 //		applog(LOG_INFO, "! MS0: %08x, m7: %08x, ntime: %08x, nbits: %08x, nnonce: %08x\n\t\t\t out: %s\n", mid32[0], m7, ntime, nbits, nnonce, hex);
 //		history[history_p] = nnonce;
@@ -449,12 +446,11 @@ void work_to_payload(struct bitfury_payload *p, struct work *w) {
 	p->nbits = bswap_32(*(unsigned *)(flipped_data + 72));
 }
 
-int libbitfury_sendHashData(struct bitfury_device *bf, int chip_n) {
+void libbitfury_sendHashData(struct bitfury_device *bf, int chip_n) {
 	int chip_id;
 	static unsigned second_run;
 
 	for (chip_id = 0; chip_id < chip_n; chip_id++) {
-		unsigned char *hexstr;
 		struct bitfury_device *d = bf + chip_id;
 		unsigned *newbuf = d->newbuf;
 		unsigned *oldbuf = d->oldbuf;

+ 1 - 1
libbitfury.h

@@ -50,7 +50,7 @@ struct bitfury_device {
 };
 
 int libbitfury_readHashData(unsigned int *res);
-int libbitfury_sendHashData(struct bitfury_device *bf, int chip_n);
+void libbitfury_sendHashData(struct bitfury_device *bf, int chip_n);
 void work_to_payload(struct bitfury_payload *p, struct work *w);
 struct timespec t_diff(struct timespec start, struct timespec end);
 int libbitfury_detectChips(struct bitfury_device *devices);

+ 2 - 4
spidevc.c

@@ -100,11 +100,10 @@ void spi_reset(void)
 	SET_GPIO_ALT(9,0);
 }
 
-int spi_txrx(const char *wrbuf, char *rdbuf, int bufsz)
+int spi_txrx(const void *wrbuf, void *rdbuf, size_t bufsz)
 {
 	int fd;
 	int mode, bits, speed, rv, i, j;
-	struct timespec tv;
 	struct spi_ioc_transfer tr[16];
 
 	memset(&tr,0,sizeof(tr));
@@ -176,9 +175,8 @@ void spi_emit_buf_reverse(const char *str, unsigned sz)
 	spibufsz += sz;
 }
 
-void spi_emit_buf(const char *str, unsigned sz)
+void spi_emit_buf(void *str, unsigned sz)
 {
-	unsigned i;
 	if (spibufsz + sz >= SPIMAXSZ) return;
 	memcpy(&spibuf[spibufsz], str, sz); spibufsz += sz;
 }

+ 3 - 2
spidevc.h

@@ -2,12 +2,13 @@
 #define SPIDEVC_H
 
 #include <stdbool.h>
+#include <unistd.h>
 
 /* Initialize SPI using this function */
 bool spi_init(void);
 
 /* TX-RX single frame */
-int spi_txrx(const char *wrbuf, char *rdbuf, int bufsz);
+int spi_txrx(const void *wrbuf, void *rdbuf, size_t bufsz);
 
 /* SPI BUFFER OPS */
 void spi_clear_buf(void);
@@ -16,7 +17,7 @@ unsigned char *spi_gettxbuf(void);
 unsigned spi_getbufsz(void);
 
 void spi_emit_buf_reverse(const char *str, unsigned sz); /* INTERNAL USE: EMIT REVERSED BYTE SEQUENCE DIRECTLY TO STREAM */
-void spi_emit_buf(const char *str, unsigned sz); /* INTERNAL USE: EMIT BYTE SEQUENCE DIRECTLY TO STREAM */
+void spi_emit_buf(void *str, unsigned sz); /* INTERNAL USE: EMIT BYTE SEQUENCE DIRECTLY TO STREAM */
 
 void spi_emit_break(void); /* BREAK CONNECTIONS AFTER RESET */
 void spi_emit_fsync(void); /* FEED-THROUGH TO NEXT CHIP SYNCHRONOUSLY (WITH FLIP-FLOP) */