Browse Source

Bugfix: bitfury: Fix warnings

Luke Dashjr 12 years ago
parent
commit
335b11e336
5 changed files with 9 additions and 26 deletions
  1. 1 13
      driver-bitfury.c
  2. 2 6
      libbitfury.c
  3. 1 1
      libbitfury.h
  4. 2 4
      spidevc.c
  5. 3 2
      spidevc.h

+ 1 - 13
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);
 
 static void bitfury_detect(void)
@@ -56,12 +55,6 @@ static void bitfury_detect(void)
 }
 
 
-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[100];
@@ -86,7 +79,7 @@ static int64_t bitfury_scanHash(struct thr_info *thr)
 	for (chip = 0; 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 *owork = devices[chip].owork;
 			i = devices[chip].results_n;
 			for (j = i - 1; j >= 0; j--) {
@@ -121,11 +114,6 @@ static void bitfury_shutdown(struct thr_info *thr)
 	applog(LOG_INFO, "INFO bitfury_shutdown");
 }
 
-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

@@ -227,13 +227,11 @@ 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;
-	int i;
 	sha256_ctx ctx;
 
 	memset( &ctx, 0, sizeof( sha256_ctx ) );
@@ -252,7 +250,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);
 		return 1;
@@ -274,12 +271,11 @@ void work_to_payload(struct bitfury_payload *p, struct work *w) {
 	applog(LOG_INFO, "INFO merkle[7]: %08x, ntime: %08x, nbits: %08x", p->m7, p->ntime, p->nbits);
 }
 
-int libbitfury_sendHashData(struct bitfury_device *bf, int chip_n) {
+void libbitfury_sendHashData(struct bitfury_device *bf, int chip_n) {
 	int chip;
 	static unsigned second_run;
 
 	for (chip = 0; chip < chip_n; chip++) {
-		unsigned char *hexstr;
 		struct bitfury_device *d = bf + chip;
 		unsigned *newbuf = d->newbuf;
 		unsigned *oldbuf = d->oldbuf;

+ 1 - 1
libbitfury.h

@@ -28,7 +28,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);
 
 #endif /* __LIBBITFURY_H__ */

+ 2 - 4
spidevc.c

@@ -115,11 +115,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));
@@ -190,9 +189,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) */