Browse Source

bitfury: Fix logging to use applog

Luke Dashjr 12 years ago
parent
commit
aeee195d74
4 changed files with 11 additions and 11 deletions
  1. 1 1
      driver-bitfury.c
  2. 1 1
      driver-metabank.c
  3. 6 8
      libbitfury.c
  4. 3 1
      tm_i2c.c

+ 1 - 1
driver-bitfury.c

@@ -205,7 +205,7 @@ int64_t bitfury_scanHash(struct thr_info *thr)
 			snprintf(stat_lines[bitfury->slot] + len, 256 - len, "%.1f-%3.0f ", ghash, bitfury->mhz);
 			snprintf(stat_lines[bitfury->slot] + len, 256 - len, "%.1f-%3.0f ", ghash, bitfury->mhz);
 
 
 			if(sds->short_out_t && ghash < 1.0) {
 			if(sds->short_out_t && ghash < 1.0) {
-				applog(LOG_WARNING, "Chip_id %d FREQ CHANGE\n", chip);
+				applog(LOG_WARNING, "Chip_id %d FREQ CHANGE", chip);
 				send_freq(bitfury->spi, bitfury->slot, bitfury->fasync, bitfury->osc6_bits - 1);
 				send_freq(bitfury->spi, bitfury->slot, bitfury->fasync, bitfury->osc6_bits - 1);
 				cgsleep_ms(1);
 				cgsleep_ms(1);
 				send_freq(bitfury->spi, bitfury->slot, bitfury->fasync, bitfury->osc6_bits);
 				send_freq(bitfury->spi, bitfury->slot, bitfury->fasync, bitfury->osc6_bits);

+ 1 - 1
driver-metabank.c

@@ -54,7 +54,7 @@ struct bitfury_device **metabank_detect_chips(int *out_count) {
 	struct cgpu_info dummy_cgpu;
 	struct cgpu_info dummy_cgpu;
 
 
 	if (tm_i2c_init() < 0) {
 	if (tm_i2c_init() < 0) {
-		printf("I2C init error\n");
+		applog(LOG_DEBUG, "%s: I2C init error", metabank_drv.dname);
 		*out_count = 0;
 		*out_count = 0;
 		return NULL;
 		return NULL;
 	}
 	}

+ 6 - 8
libbitfury.c

@@ -28,6 +28,7 @@
 #include <unistd.h>
 #include <unistd.h>
 #include <string.h>
 #include <string.h>
 
 
+#include "logging.h"
 #include "miner.h"
 #include "miner.h"
 #include "libbitfury.h"
 #include "libbitfury.h"
 
 
@@ -88,10 +89,6 @@ static const unsigned SHA_K[64] = {
         0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
         0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
 };
 };
 
 
-void t_print(struct timespec d_time) {
-	printf(" %ds %.2fms\n", (int)d_time.tv_sec, (double)d_time.tv_nsec / 1000000.0);
-}
-
 
 
 
 
 struct  timespec t_add(struct  timespec  time1, struct  timespec  time2) {
 struct  timespec t_add(struct  timespec  time1, struct  timespec  time2) {
@@ -360,7 +357,8 @@ int rehash(unsigned char *midstate, unsigned m7,
 #ifdef BITFURY_REHASH_DEBUG
 #ifdef BITFURY_REHASH_DEBUG
 		char hex[65];
 		char hex[65];
 		bin2hex(hex, out, 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);
+		applog(LOG_INFO, "! MS0: %08x, m7: %08x, ntime: %08x, nbits: %08x, nnonce: %08x", mid32[0], m7, ntime, nbits, nnonce);
+		applog(LOG_INFO, " out: %s", hex);
 		history[history_p] = nnonce;
 		history[history_p] = nnonce;
 		history_p++; history_p &= 512 - 1;
 		history_p++; history_p &= 512 - 1;
 #endif
 #endif
@@ -488,7 +486,7 @@ void libbitfury_sendHashData1(int chip_id, struct bitfury_device *d)
 					found++;
 					found++;
 				}
 				}
 				if (!found) {
 				if (!found) {
-					printf("AAA Strange: %08x, chip_id: %d\n", pn, chip_id);
+					applog(LOG_WARNING, "AAA Strange: %08x, chip_id: %d", pn, chip_id);
 				}
 				}
 			}
 			}
 		}
 		}
@@ -532,9 +530,9 @@ void libbitfury_sendHashData1(int chip_id, struct bitfury_device *d)
 			mhz = 1.0 / ns * 65.0 * 1000.0;
 			mhz = 1.0 / ns * 65.0 * 1000.0;
 
 
 			if (d->counter1 > 0 && d->counter1 < 0x001FFFFF)
 			if (d->counter1 > 0 && d->counter1 < 0x001FFFFF)
-				printf("AAA chip_id %2d: %llu ms, req1_cycles: %08u,  counter1: %08d, ocounter1: %08d, counter2: %08d, cycles: %08d, ns: %.2f, mhz: %.2f \n", chip_id, period / 1000000ULL, req1_cycles, d->counter1, d->ocounter1, d->counter2, cycles, ns, mhz);
+				applog(LOG_DEBUG, "AAA chip_id %2d: %llu ms, req1_cycles: %08u,  counter1: %08d, ocounter1: %08d, counter2: %08d, cycles: %08d, ns: %.2f, mhz: %.2f ", chip_id, period / 1000000ULL, req1_cycles, d->counter1, d->ocounter1, d->counter2, cycles, ns, mhz);
 			if (ns > 2000.0 || ns < 20) {
 			if (ns > 2000.0 || ns < 20) {
-				printf("AAA %d!Stupid ns chip_id %2d: %llu ms, req1_cycles: %08u,  counter1: %08d, ocounter1: %08d, counter2: %08d, cycles: %08d, ns: %.2f, mhz: %.2f \n", ccase, chip_id, period / 1000000ULL, req1_cycles, d->counter1, d->ocounter1, d->counter2, cycles, ns, mhz);
+				applog(LOG_DEBUG, "AAA %d!Stupid ns chip_id %2d: %llu ms, req1_cycles: %08u,  counter1: %08d, ocounter1: %08d, counter2: %08d, cycles: %08d, ns: %.2f, mhz: %.2f ", ccase, chip_id, period / 1000000ULL, req1_cycles, d->counter1, d->ocounter1, d->counter2, cycles, ns, mhz);
 				ns = 200.0;
 				ns = 200.0;
 			} else {
 			} else {
 				d->ns = ns;
 				d->ns = ns;

+ 3 - 1
tm_i2c.c

@@ -4,6 +4,8 @@
 
 
 #include <linux/i2c.h>
 #include <linux/i2c.h>
 #include <linux/i2c-dev.h>
 #include <linux/i2c-dev.h>
+
+#include "logging.h"
 #include "tm_i2c.h"
 #include "tm_i2c.h"
 
 
 static int tm_i2c_fd;
 static int tm_i2c_fd;
@@ -37,7 +39,7 @@ unsigned int tm_i2c_req(int fd, unsigned char addr, unsigned char cmd, unsigned
 	struct i2c_rdwr_ioctl_data msg_rdwr;
 	struct i2c_rdwr_ioctl_data msg_rdwr;
 	unsigned int ret;
 	unsigned int ret;
 
 
-	//printf("REQ from %02X cmd: %02X\n", addr, cmd);
+	//applog(LOG_DEBUG, "REQ from %02X cmd: %02X", addr, cmd);
 
 
 	tm->cmd = cmd;
 	tm->cmd = cmd;
 	tm->data_lsb = data & 0xFF;
 	tm->data_lsb = data & 0xFF;