Browse Source

Preformat dev_repr (device representation) and proc_repr (processor representation) once for use everywhere

Luke Dashjr 13 years ago
parent
commit
a76cbd4192
15 changed files with 230 additions and 222 deletions
  1. 9 10
      api.c
  2. 25 25
      driver-bitforce.c
  3. 5 7
      driver-cairnsmore.c
  4. 1 2
      driver-cpu.c
  5. 29 30
      driver-icarus.c
  6. 42 42
      driver-modminer.c
  7. 3 2
      driver-opencl.c
  8. 36 41
      driver-x6500.c
  9. 2 2
      driver-ztex.c
  10. 3 3
      dynclock.c
  11. 2 2
      findnonce.c
  12. 28 28
      fpgautils.c
  13. 1 1
      fpgautils.h
  14. 38 27
      miner.c
  15. 6 0
      miner.h

+ 9 - 10
api.c

@@ -1701,8 +1701,8 @@ static void pgaenable(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char
 
 	struct cgpu_info *cgpu = devices[dev];
 
-	applog(LOG_DEBUG, "API: request to pgaenable pgaid %d device %d %s%u",
-			id, dev, cgpu->api->name, cgpu->device_id);
+	applog(LOG_DEBUG, "API: request to pgaenable pgaid %d device %d %s",
+			id, dev, cgpu->proc_repr_ns);
 
 	if (cgpu->deven != DEV_DISABLED) {
 		message(io_data, MSG_PGALRENA, id, NULL, isjson);
@@ -1758,8 +1758,8 @@ static void pgadisable(struct io_data *io_data, __maybe_unused SOCKETTYPE c, cha
 
 	struct cgpu_info *cgpu = devices[dev];
 
-	applog(LOG_DEBUG, "API: request to pgadisable pgaid %d device %d %s%u",
-			id, dev, cgpu->api->name, cgpu->device_id);
+	applog(LOG_DEBUG, "API: request to pgadisable pgaid %d device %d %s",
+			id, dev, cgpu->proc_repr_ns);
 
 	if (cgpu->deven == DEV_DISABLED) {
 		message(io_data, MSG_PGALRDIS, id, NULL, isjson);
@@ -2009,8 +2009,8 @@ static void gpuenable(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char
 		return;
 	}
 
-	applog(LOG_DEBUG, "API: request to gpuenable gpuid %d %s%u",
-			id, gpus[id].api->name, gpus[id].device_id);
+	applog(LOG_DEBUG, "API: request to gpuenable gpuid %d %s",
+			id, gpus[id].proc_repr_ns);
 
 	if (gpus[id].deven != DEV_DISABLED) {
 		message(io_data, MSG_ALRENA, id, NULL, isjson);
@@ -2054,8 +2054,8 @@ static void gpudisable(struct io_data *io_data, __maybe_unused SOCKETTYPE c, cha
 		return;
 	}
 
-	applog(LOG_DEBUG, "API: request to gpudisable gpuid %d %s%u",
-			id, gpus[id].api->name, gpus[id].device_id);
+	applog(LOG_DEBUG, "API: request to gpudisable gpuid %d %s",
+			id, gpus[id].proc_repr_ns);
 
 	if (gpus[id].deven == DEV_DISABLED) {
 		message(io_data, MSG_ALRDIS, id, NULL, isjson);
@@ -2819,8 +2819,7 @@ static void minerstats(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
 			else
 				extra = NULL;
 
-			sprintf(id, "%s%d", cgpu->api->name, cgpu->device_id);
-			i = itemstats(io_data, i, id, &(cgpu->cgminer_stats), NULL, extra, isjson);
+			i = itemstats(io_data, i, cgpu->proc_repr_ns, &(cgpu->cgminer_stats), NULL, extra, isjson);
 		}
 	}
 

+ 25 - 25
driver-bitforce.c

@@ -144,13 +144,13 @@ static bool bitforce_thread_prepare(struct thr_info *thr)
 	struct timeval now;
 
 	if (unlikely(fdDev == -1)) {
-		applog(LOG_ERR, "BFL%i: Failed to open %s", bitforce->device_id, bitforce->device_path);
+		applog(LOG_ERR, "%"PRIpreprv": Failed to open %s", bitforce->proc_repr, bitforce->device_path);
 		return false;
 	}
 
 	bitforce->device_fd = fdDev;
 
-	applog(LOG_INFO, "BFL%i: Opened %s", bitforce->device_id, bitforce->device_path);
+	applog(LOG_INFO, "%"PRIpreprv": Opened %s", bitforce->proc_repr, bitforce->device_path);
 	gettimeofday(&now, NULL);
 	get_datestamp(bitforce->init, &now);
 
@@ -166,7 +166,7 @@ static void bitforce_clear_buffer(struct cgpu_info *bitforce)
 	if (!fdDev)
 		return;
 
-	applog(LOG_DEBUG, "BFL%i: Clearing read buffer", bitforce->device_id);
+	applog(LOG_DEBUG, "%"PRIpreprv": Clearing read buffer", bitforce->proc_repr);
 
 	mutex_lock(&bitforce->device_mutex);
 	do {
@@ -183,7 +183,7 @@ void bitforce_init(struct cgpu_info *bitforce)
 	char pdevbuf[0x100];
 	char *s;
 
-	applog(LOG_WARNING, "BFL%i: Re-initialising", bitforce->device_id);
+	applog(LOG_WARNING, "%"PRIpreprv": Re-initialising", bitforce->proc_repr);
 
 	bitforce_clear_buffer(bitforce);
 
@@ -197,7 +197,7 @@ void bitforce_init(struct cgpu_info *bitforce)
 	fdDev = BFopen(devpath);
 	if (unlikely(fdDev == -1)) {
 		mutex_unlock(&bitforce->device_mutex);
-		applog(LOG_ERR, "BFL%i: Failed to open %s", bitforce->device_id, devpath);
+		applog(LOG_ERR, "%"PRIpreprv": Failed to open %s", bitforce->proc_repr, devpath);
 		return;
 	}
 
@@ -208,7 +208,7 @@ void bitforce_init(struct cgpu_info *bitforce)
 
 		if (unlikely(!pdevbuf[0])) {
 			mutex_unlock(&bitforce->device_mutex);
-			applog(LOG_ERR, "BFL%i: Error reading/timeout (ZGX)", bitforce->device_id);
+			applog(LOG_ERR, "%"PRIpreprv": Error reading/timeout (ZGX)", bitforce->proc_repr);
 			return;
 		}
 
@@ -218,7 +218,7 @@ void bitforce_init(struct cgpu_info *bitforce)
 
 	if (unlikely(!strstr(pdevbuf, "SHA256"))) {
 		mutex_unlock(&bitforce->device_mutex);
-		applog(LOG_ERR, "BFL%i: Didn't recognise BitForce on %s returned: %s", bitforce->device_id, devpath, pdevbuf);
+		applog(LOG_ERR, "%"PRIpreprv": Didn't recognise BitForce on %s returned: %s", bitforce->proc_repr, devpath, pdevbuf);
 		return;
 	}
 	
@@ -295,7 +295,7 @@ static bool bitforce_get_temp(struct cgpu_info *bitforce)
 	mutex_unlock(&bitforce->device_mutex);
 	
 	if (unlikely(!pdevbuf[0])) {
-		applog(LOG_ERR, "BFL%i: Error: Get temp returned empty string/timed out", bitforce->device_id);
+		applog(LOG_ERR, "%"PRIpreprv": Error: Get temp returned empty string/timed out", bitforce->proc_repr);
 		bitforce->hw_errors++;
 		++hw_errors;
 		return false;
@@ -316,7 +316,7 @@ static bool bitforce_get_temp(struct cgpu_info *bitforce)
 		/* Use the temperature monitor as a kind of watchdog for when
 		 * our responses are out of sync and flush the buffer to
 		 * hopefully recover */
-		applog(LOG_WARNING, "BFL%i: Garbled response probably throttling, clearing buffer", bitforce->device_id);
+		applog(LOG_WARNING, "%"PRIpreprv": Garbled response probably throttling, clearing buffer", bitforce->proc_repr);
 		dev_error(bitforce, REASON_DEV_THROTTLE);
 		/* Count throttling episodes as hardware errors */
 		bitforce->hw_errors++;
@@ -354,13 +354,13 @@ re_send:
 	} else if (unlikely(strncasecmp(pdevbuf, "OK", 2))) {
 		mutex_unlock(&bitforce->device_mutex);
 		if (bitforce->nonce_range) {
-			applog(LOG_WARNING, "BFL%i: Does not support nonce range, disabling", bitforce->device_id);
+			applog(LOG_WARNING, "%"PRIpreprv": Does not support nonce range, disabling", bitforce->proc_repr);
 			bitforce->nonce_range = false;
 			bitforce->sleep_ms *= 5;
 			bitforce->kname = KNAME_WORK;
 			goto re_send;
 		}
-		applog(LOG_ERR, "BFL%i: Error: Send work reports: %s", bitforce->device_id, pdevbuf);
+		applog(LOG_ERR, "%"PRIpreprv": Error: Send work reports: %s", bitforce->proc_repr, pdevbuf);
 		return false;
 	}
 
@@ -391,17 +391,17 @@ re_send:
 
 	if (opt_debug) {
 		s = bin2hex(ob + 8, 44);
-		applog(LOG_DEBUG, "BFL%i: block data: %s", bitforce->device_id, s);
+		applog(LOG_DEBUG, "%"PRIpreprv": block data: %s", bitforce->proc_repr, s);
 		free(s);
 	}
 
 	if (unlikely(!pdevbuf[0])) {
-		applog(LOG_ERR, "BFL%i: Error: Send block data returned empty string/timed out", bitforce->device_id);
+		applog(LOG_ERR, "%"PRIpreprv": Error: Send block data returned empty string/timed out", bitforce->proc_repr);
 		return false;
 	}
 
 	if (unlikely(strncasecmp(pdevbuf, "OK", 2))) {
-		applog(LOG_ERR, "BFL%i: Error: Send block data reports: %s", bitforce->device_id, pdevbuf);
+		applog(LOG_ERR, "%"PRIpreprv": Error: Send block data reports: %s", bitforce->proc_repr, pdevbuf);
 		return false;
 	}
 
@@ -413,8 +413,8 @@ static inline int noisy_stale_wait(unsigned int mstime, struct work*work, bool c
 {
 	int rv = stale_wait(mstime, work, checkend);
 	if (rv)
-		applog(LOG_NOTICE, "BFL%i: Abandoning stale search to restart",
-		       bitforce->device_id);
+		applog(LOG_NOTICE, "%"PRIpreprv": Abandoning stale search to restart",
+		       bitforce->proc_repr);
 	return rv;
 }
 #define noisy_stale_wait(mstime, work, checkend)  noisy_stale_wait(mstime, work, checkend, bitforce)
@@ -444,7 +444,7 @@ static int64_t bitforce_get_result(struct thr_info *thr, struct work *work)
 		timersub(&now, &bitforce->work_start_tv, &elapsed);
 
 		if (elapsed.tv_sec >= BITFORCE_LONG_TIMEOUT_S) {
-			applog(LOG_ERR, "BFL%i: took %lums - longer than %lums", bitforce->device_id,
+			applog(LOG_ERR, "%"PRIpreprv": took %lums - longer than %lums", bitforce->proc_repr,
 				tv_to_ms(elapsed), (unsigned long)BITFORCE_LONG_TIMEOUT_MS);
 			return 0;
 		}
@@ -460,7 +460,7 @@ static int64_t bitforce_get_result(struct thr_info *thr, struct work *work)
 	}
 
 	if (elapsed.tv_sec > BITFORCE_TIMEOUT_S) {
-		applog(LOG_ERR, "BFL%i: took %lums - longer than %lums", bitforce->device_id,
+		applog(LOG_ERR, "%"PRIpreprv": took %lums - longer than %lums", bitforce->proc_repr,
 			tv_to_ms(elapsed), (unsigned long)BITFORCE_TIMEOUT_MS);
 		dev_error(bitforce, REASON_DEV_OVER_HEAT);
 		++bitforce->hw_errors;
@@ -489,14 +489,14 @@ static int64_t bitforce_get_result(struct thr_info *thr, struct work *work)
 		}
 
 		if (delay_time_ms != bitforce->sleep_ms)
-			  applog(LOG_DEBUG, "BFL%i: Wait time changed to: %d, waited %u", bitforce->device_id, bitforce->sleep_ms, bitforce->wait_ms);
+			  applog(LOG_DEBUG, "%"PRIpreprv": Wait time changed to: %d, waited %u", bitforce->proc_repr, bitforce->sleep_ms, bitforce->wait_ms);
 
 		/* Work out the average time taken. Float for calculation, uint for display */
 		bitforce->avg_wait_f += (tv_to_ms(elapsed) - bitforce->avg_wait_f) / TIME_AVG_CONSTANT;
 		bitforce->avg_wait_d = (unsigned int) (bitforce->avg_wait_f + 0.5);
 	}
 
-	applog(LOG_DEBUG, "BFL%i: waited %dms until %s", bitforce->device_id, bitforce->wait_ms, pdevbuf);
+	applog(LOG_DEBUG, "%"PRIpreprv": waited %dms until %s", bitforce->proc_repr, bitforce->wait_ms, pdevbuf);
 	if (!strncasecmp(&pdevbuf[2], "-", 1))
 		return bitforce->nonces;   /* No valid nonce found */
 	else if (!strncasecmp(pdevbuf, "I", 1))
@@ -504,7 +504,7 @@ static int64_t bitforce_get_result(struct thr_info *thr, struct work *work)
 	else if (strncasecmp(pdevbuf, "NONCE-FOUND", 11)) {
 		bitforce->hw_errors++;
 		++hw_errors;
-		applog(LOG_WARNING, "BFL%i: Error: Get result reports: %s", bitforce->device_id, pdevbuf);
+		applog(LOG_WARNING, "%"PRIpreprv": Error: Get result reports: %s", bitforce->proc_repr, pdevbuf);
 		bitforce_clear_buffer(bitforce);
 		return 0;
 	}
@@ -516,7 +516,7 @@ static int64_t bitforce_get_result(struct thr_info *thr, struct work *work)
 		nonce = be32toh(nonce);
 		if (unlikely(bitforce->nonce_range && (nonce >= work->blk.nonce ||
 			(work->blk.nonce > 0 && nonce < work->blk.nonce - bitforce->nonces - 1)))) {
-				applog(LOG_WARNING, "BFL%i: Disabling broken nonce range support", bitforce->device_id);
+				applog(LOG_WARNING, "%"PRIpreprv": Disabling broken nonce range support", bitforce->proc_repr);
 				bitforce->nonce_range = false;
 				work->blk.nonce = 0xffffffff;
 				bitforce->sleep_ms *= 5;
@@ -573,14 +573,14 @@ static int64_t bitforce_scanhash(struct thr_info *thr, struct work *work, int64_
 	if (ret == -1) {
 commerr:
 		ret = 0;
-		applog(LOG_ERR, "BFL%i: Comms error", bitforce->device_id);
+		applog(LOG_ERR, "%"PRIpreprv": Comms error", bitforce->proc_repr);
 		dev_error(bitforce, REASON_DEV_COMMS_ERROR);
 		bitforce->hw_errors++;
 		++hw_errors;
 		BFclose(bitforce->device_fd);
 		int fd = bitforce->device_fd = BFopen(bitforce->device_path);
 		if (fd == -1) {
-			applog(LOG_ERR, "BFL%i: Error reopening", bitforce->device_id);
+			applog(LOG_ERR, "%"PRIpreprv": Error reopening", bitforce->proc_repr);
 			return -1;
 		}
 		/* empty read buffer */
@@ -608,7 +608,7 @@ static bool bitforce_thread_init(struct thr_info *thr)
 	/* Pause each new thread at least 100ms between initialising
 	 * so the devices aren't making calls all at the same time. */
 	wait = thr->id * MAX_START_DELAY_MS;
-	applog(LOG_DEBUG, "BFL%i: Delaying start by %dms", bitforce->device_id, wait / 1000);
+	applog(LOG_DEBUG, "%"PRIpreprv": Delaying start by %dms", bitforce->proc_repr, wait / 1000);
 	nmsleep(wait);
 
 	return true;

+ 5 - 7
driver-cairnsmore.c

@@ -117,9 +117,7 @@ static bool cairnsmore_change_clock_func(struct thr_info *thr, int bestM)
 	// Adjust Hs expectations for frequency change
 	info->Hs = info->Hs * (double)bestM / (double)info->dclk.freqM;
 
-	char repr[0x10];
-	sprintf(repr, "%s %u", cm1->api->name, cm1->device_id);
-	dclk_msg_freqchange(repr, 2.5 * (double)info->dclk.freqM, 2.5 * (double)bestM, NULL);
+	dclk_msg_freqchange(cm1->proc_repr, 2.5 * (double)info->dclk.freqM, 2.5 * (double)bestM, NULL);
 	info->dclk.freqM = bestM;
 
 	return true;
@@ -139,8 +137,8 @@ static bool cairnsmore_init(struct thr_info *thr)
 		info->dclk.freqM =
 		info->dclk.freqMDefault = CAIRNSMORE1_DEFAULT_CLOCK / 2.5;
 		cairnsmore_send_cmd(cm1->device_fd, 0, info->dclk.freqM);
-		applog(LOG_WARNING, "%s %u: Frequency set to %u MHz (range: %u-%u)",
-		       cm1->api->name, cm1->device_id,
+		applog(LOG_WARNING, "%"PRIpreprv": Frequency set to %u MHz (range: %u-%u)",
+		       cm1->proc_repr,
 		       CAIRNSMORE1_DEFAULT_CLOCK, CAIRNSMORE1_MINIMUM_CLOCK, CAIRNSMORE1_MAXIMUM_CLOCK
 		);
 		// The dynamic-clocking firmware connects each FPGA as its own device
@@ -150,8 +148,8 @@ static bool cairnsmore_init(struct thr_info *thr)
 				info->fpga_count = 1;
 		}
 	} else {
-		applog(LOG_WARNING, "%s %u: Frequency scaling not supported",
-			cm1->api->name, cm1->device_id
+		applog(LOG_WARNING, "%"PRIpreprv": Frequency scaling not supported",
+			cm1->proc_repr
 		);
 	}
 	// Commands corrupt the hash state, so next scanhash is a firstrun

+ 1 - 2
driver-cpu.c

@@ -815,7 +815,6 @@ static bool cpu_thread_init(struct thr_info *thr)
 
 static int64_t cpu_scanhash(struct thr_info *thr, struct work *work, int64_t max_nonce)
 {
-	const int thr_id = thr->id;
 	unsigned char hash1[64];
 	uint32_t first_nonce = work->blk.nonce;
 	uint32_t last_nonce;
@@ -844,7 +843,7 @@ CPUSearch:
 
 	/* if nonce found, submit work */
 	if (unlikely(rc)) {
-		applog(LOG_DEBUG, "CPU %d found something?", dev_from_id(thr_id));
+		applog(LOG_DEBUG, "%"PRIpreprv" found something?", thr->cgpu->proc_repr);
 		submit_work_async(work, NULL);
 		work->blk.nonce = last_nonce + 1;
 		goto CPUSearch;

+ 29 - 30
driver-icarus.c

@@ -404,9 +404,9 @@ static void set_timing_mode(int this_option_offset, struct cgpu_info *icarus)
 
 	info->min_data_count = MIN_DATA_COUNT;
 
-	applog(LOG_DEBUG, "%s %u: Init: mode=%s read_count=%d Hs=%e",
-		icarus->api->name,
-		icarus->device_id, timing_mode_str(info->timing_mode), info->read_count, info->Hs);
+	applog(LOG_DEBUG, "%"PRIpreprv": Init: mode=%s read_count=%d Hs=%e",
+		icarus->proc_repr,
+		timing_mode_str(info->timing_mode), info->read_count, info->Hs);
 }
 
 static uint32_t mask(int work_division)
@@ -620,13 +620,13 @@ bool icarus_detect_custom(const char *devpath, struct device_api *api, struct IC
 	icarus->threads = 1;
 	add_cgpu(icarus);
 
-	applog(LOG_INFO, "Found %s %u at %s",
-		icarus->api->name, icarus->device_id,
+	applog(LOG_INFO, "Found %"PRIpreprv" at %s",
+		icarus->proc_repr,
 		devpath);
 
-	applog(LOG_DEBUG, "%s %u: Init: baud=%d work_division=%d fpga_count=%d",
-		icarus->api->name,
-		icarus->device_id, baud, work_division, fpga_count);
+	applog(LOG_DEBUG, "%"PRIpreprv": Init: baud=%d work_division=%d fpga_count=%d",
+		icarus->proc_repr,
+		baud, work_division, fpga_count);
 
 	icarus->cgpu_data = info;
 
@@ -711,7 +711,7 @@ static bool icarus_reopen(struct cgpu_info *icarus, struct icarus_state *state,
 	icarus_close(icarus->device_fd);
 	*fdp = icarus->device_fd = icarus_open(icarus->device_path, info->baud);
 	if (unlikely(-1 == *fdp)) {
-		applog(LOG_ERR, "%s %u: Failed to reopen on %s", icarus->api->name, icarus->device_id, icarus->device_path);
+		applog(LOG_ERR, "%"PRIpreprv": Failed to reopen on %s", icarus->proc_repr, icarus->device_path);
 		dev_error(icarus, REASON_DEV_COMMS_ERROR);
 		state->firstrun = true;
 		return false;
@@ -739,9 +739,9 @@ static bool icarus_start_work(struct thr_info *thr, const unsigned char *ob_bin)
 
 	if (opt_debug) {
 		ob_hex = bin2hex(ob_bin, 64);
-		applog(LOG_DEBUG, "%s %u sent: %s",
-			icarus->api->name,
-			icarus->device_id, ob_hex);
+		applog(LOG_DEBUG, "%"PRIpreprv" sent: %s",
+			icarus->proc_repr,
+			ob_hex);
 		free(ob_hex);
 	}
 
@@ -785,8 +785,8 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 	if (!(memcmp(&ob_bin[56], "\xff\xff\xff\xff", 4)
 	   || memcmp(&ob_bin, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 32))) {
 		// This sequence is used on cairnsmore bitstreams for commands, NEVER send it otherwise
-		applog(LOG_WARNING, "%s %u: Received job attempting to send a command, corrupting it!",
-		       icarus->api->name, icarus->device_id);
+		applog(LOG_WARNING, "%"PRIpreprv": Received job attempting to send a command, corrupting it!",
+		       icarus->proc_repr);
 		ob_bin[56] = 0;
 	}
 	rev(ob_bin, 32);
@@ -885,9 +885,8 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 			estimate_hashes = 0xffffffff;
 
 		if (opt_debug) {
-			applog(LOG_DEBUG, "%s %u no nonce = 0x%08"PRIx64" hashes (%"PRId64".%06lus)",
-					icarus->api->name,
-					icarus->device_id,
+			applog(LOG_DEBUG, "%"PRIpreprv" no nonce = 0x%08"PRIx64" hashes (%"PRId64".%06lus)",
+					icarus->proc_repr,
 					(uint64_t)estimate_hashes,
 					(int64_t)elapsed.tv_sec, (unsigned long)elapsed.tv_usec);
 		}
@@ -915,9 +914,8 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 	hash_count *= info->fpga_count;
 
 	if (opt_debug) {
-		applog(LOG_DEBUG, "%s %u nonce = 0x%08x = 0x%08" PRIx64 " hashes (%"PRId64".%06lus)",
-				icarus->api->name,
-				icarus->device_id,
+		applog(LOG_DEBUG, "%"PRIpreprv" nonce = 0x%08x = 0x%08" PRIx64 " hashes (%"PRId64".%06lus)",
+				icarus->proc_repr,
 				nonce,
 				(uint64_t)hash_count,
 				(int64_t)elapsed.tv_sec, (unsigned long)elapsed.tv_usec);
@@ -926,10 +924,10 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 	if (info->do_default_detection && elapsed.tv_sec >= DEFAULT_DETECT_THRESHOLD) {
 		int MHs = (double)hash_count / ((double)elapsed.tv_sec * 1e6 + (double)elapsed.tv_usec);
 		--info->do_default_detection;
-		applog(LOG_DEBUG, "%s %u: Autodetect device speed: %d MH/s", icarus->api->name, icarus->device_id, MHs);
+		applog(LOG_DEBUG, "%"PRIpreprv": Autodetect device speed: %d MH/s", icarus->proc_repr, MHs);
 		if (MHs <= 370 || MHs > 420) {
 			// Not a real Icarus: enable short timing
-			applog(LOG_WARNING, "%s %u: Seems too %s to be an Icarus; calibrating with short timing", icarus->api->name, icarus->device_id, MHs>380?"fast":"slow");
+			applog(LOG_WARNING, "%"PRIpreprv": Seems too %s to be an Icarus; calibrating with short timing", icarus->proc_repr, MHs>380?"fast":"slow");
 			info->timing_mode = MODE_SHORT;
 			info->do_icarus_timing = true;
 			info->do_default_detection = 0;
@@ -938,18 +936,19 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 		if (MHs <= 380) {
 			// Real Icarus?
 			if (!info->do_default_detection) {
-				applog(LOG_DEBUG, "%s %u: Seems to be a real Icarus", icarus->api->name, icarus->device_id);
+				applog(LOG_DEBUG, "%"PRIpreprv": Seems to be a real Icarus", icarus->proc_repr);
 				info->read_count = (int)(info->fullnonce * TIME_FACTOR) - 1;
 			}
 		}
 		else
 		if (MHs <= 420) {
 			// Enterpoint Cairnsmore1
-			const char *old_name = icarus->api->name;
-			int old_devid = icarus->device_id;
+			size_t old_repr_len = strlen(icarus->proc_repr);
+			char old_repr[old_repr_len + 1];
+			strcpy(old_repr, icarus->proc_repr);
 			convert_icarus_to_cairnsmore(icarus);
 			info->do_default_detection = 0;
-			applog(LOG_WARNING, "%s %u: Detected Cairnsmore1 device, upgrading driver to %s %u", old_name, old_devid, icarus->api->name, icarus->device_id);
+			applog(LOG_WARNING, "%"PRIpreprv": Detected Cairnsmore1 device, upgrading driver to %"PRIpreprv, old_repr, icarus->proc_repr);
 		}
 	}
 
@@ -1041,10 +1040,10 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 			else if (info->timing_mode == MODE_SHORT)
 				info->do_icarus_timing = false;
 
-//			applog(LOG_DEBUG, "%s %u Re-estimate: read_count=%d fullnonce=%fs history count=%d Hs=%e W=%e values=%d hash range=0x%08lx min data count=%u", icarus->api->name, icarus->device_id, read_count, fullnonce, count, Hs, W, values, hash_count_range, info->min_data_count);
-			applog(LOG_DEBUG, "%s %u Re-estimate: Hs=%e W=%e read_count=%d fullnonce=%.3fs",
-					icarus->api->name,
-					icarus->device_id, Hs, W, read_count, fullnonce);
+//			applog(LOG_DEBUG, "%"PRIpreprv" Re-estimate: read_count=%d fullnonce=%fs history count=%d Hs=%e W=%e values=%d hash range=0x%08lx min data count=%u", icarus->proc_repr, read_count, fullnonce, count, Hs, W, values, hash_count_range, info->min_data_count);
+			applog(LOG_DEBUG, "%"PRIpreprv" Re-estimate: Hs=%e W=%e read_count=%d fullnonce=%.3fs",
+					icarus->proc_repr,
+					Hs, W, read_count, fullnonce);
 		}
 		info->history_count++;
 		gettimeofday(&tv_history_finish, NULL);

+ 42 - 42
driver-modminer.c

@@ -170,7 +170,7 @@ modminer_reopen(struct cgpu_info*modminer)
 	close(modminer->device_fd);
 	int fd = serial_open(modminer->device_path, 0, 10, true);
 	if (unlikely(-1 == fd)) {
-		applog(LOG_ERR, "%s %u: Failed to reopen %s", modminer->api->name, modminer->device_id, modminer->device_path);
+		applog(LOG_ERR, "%s: Failed to reopen %s", modminer->dev_repr, modminer->device_path);
 		return false;
 	}
 	modminer->device_fd = fd;
@@ -207,9 +207,9 @@ FD_ZERO(&fds); \
 FD_SET(fd, &fds);  \
 select(fd+1, &fds, NULL, NULL, NULL);  \
 	if (1 != read(fd, buf, 1))  \
-		bailout2(LOG_ERR, "%s %u: Error programming %s (" eng ")", modminer->api->name, modminer->device_id, modminer->device_path);  \
+		bailout2(LOG_ERR, "%s: Error programming %s (" eng ")", modminer->dev_repr, modminer->device_path);  \
 	if (buf[0] != 1)  \
-		bailout2(LOG_ERR, "%s %u: Wrong " eng " programming %s", modminer->api->name, modminer->device_id, modminer->device_path);  \
+		bailout2(LOG_ERR, "%s: Wrong " eng " programming %s", modminer->dev_repr, modminer->device_path);  \
 } while(0)
 
 static bool
@@ -220,14 +220,14 @@ modminer_fpga_upload_bitstream(struct cgpu_info*modminer)
 	char buf[0x100];
 	unsigned long len, flen;
 	char fpgaid = FPGAID_ALL;
-	FILE *f = open_xilinx_bitstream(modminer, BITSTREAM_FILENAME, &len);
+	FILE *f = open_xilinx_bitstream(modminer->api->dname, modminer->dev_repr, BITSTREAM_FILENAME, &len);
 	if (!f)
 		return false;
 
 	flen = len;
 	int fd = modminer->device_fd;
 
-	applog(LOG_WARNING, "%s %u: Programming %s... DO NOT EXIT UNTIL COMPLETE", modminer->api->name, modminer->device_id, modminer->device_path);
+	applog(LOG_WARNING, "%s: Programming %s... DO NOT EXIT UNTIL COMPLETE", modminer->dev_repr, modminer->device_path);
 	buf[0] = MODMINER_PROGRAM;
 	buf[1] = fpgaid;
 	buf[2] = (len >>  0) & 0xff;
@@ -235,27 +235,27 @@ modminer_fpga_upload_bitstream(struct cgpu_info*modminer)
 	buf[4] = (len >> 16) & 0xff;
 	buf[5] = (len >> 24) & 0xff;
 	if (6 != write(fd, buf, 6))
-		bailout2(LOG_ERR, "%s %u: Error programming %s (cmd)", modminer->api->name, modminer->device_id, modminer->device_path);
+		bailout2(LOG_ERR, "%s: Error programming %s (cmd)", modminer->dev_repr, modminer->device_path);
 	status_read("cmd reply");
 	ssize_t buflen;
 	char nextstatus = 10;
 	while (len) {
 		buflen = len < 32 ? len : 32;
 		if (fread(buf, buflen, 1, f) != 1)
-			bailout2(LOG_ERR, "%s %u: File underrun programming %s (%d bytes left)", modminer->api->name, modminer->device_id, modminer->device_path, len);
+			bailout2(LOG_ERR, "%s: File underrun programming %s (%d bytes left)", modminer->dev_repr, modminer->device_path, len);
 		if (write(fd, buf, buflen) != buflen)
-			bailout2(LOG_ERR, "%s %u: Error programming %s (data)", modminer->api->name, modminer->device_id,  modminer->device_path);
+			bailout2(LOG_ERR, "%s: Error programming %s (data)", modminer->dev_repr,  modminer->device_path);
 		state->pdone = 100 - ((len * 100) / flen);
 		if (state->pdone >= nextstatus)
 		{
 			nextstatus += 10;
-			applog(LOG_WARNING, "%s %u: Programming %s... %d%% complete...", modminer->api->name, modminer->device_id, modminer->device_path, state->pdone);
+			applog(LOG_WARNING, "%s: Programming %s... %d%% complete...", modminer->dev_repr, modminer->device_path, state->pdone);
 		}
 		status_read("status");
 		len -= buflen;
 	}
 	status_read("final status");
-	applog(LOG_WARNING, "%s %u: Done programming %s", modminer->api->name, modminer->device_id, modminer->device_path);
+	applog(LOG_WARNING, "%s: Done programming %s", modminer->dev_repr, modminer->device_path);
 
 	return true;
 }
@@ -265,10 +265,10 @@ modminer_device_prepare(struct cgpu_info *modminer)
 {
 	int fd = serial_open(modminer->device_path, 0, 10, true);
 	if (unlikely(-1 == fd))
-		bailout(LOG_ERR, "%s %u: Failed to open %s", modminer->api->name, modminer->device_id, modminer->device_path);
+		bailout(LOG_ERR, "%s: Failed to open %s", modminer->dev_repr, modminer->device_path);
 
 	modminer->device_fd = fd;
-	applog(LOG_INFO, "%s %u: Opened %s", modminer->api->name, modminer->device_id, modminer->device_path);
+	applog(LOG_INFO, "%s: Opened %s", modminer->dev_repr, modminer->device_path);
 
 	struct timeval now;
 	gettimeofday(&now, NULL);
@@ -318,9 +318,9 @@ modminer_change_clock(struct thr_info*thr, bool needlock, signed char delta)
 		mutex_lock(&modminer->device_mutex);
 	fd = modminer->device_fd;
 	if (6 != write(fd, cmd, 6))
-		bailout2(LOG_ERR, "%s %u.%u: Error writing (set frequency)", modminer->api->name, modminer->device_id, fpgaid);
+		bailout2(LOG_ERR, "%s.%u: Error writing (set frequency)", modminer->dev_repr, fpgaid);
 	if (serial_read(fd, &buf, 1) != 1)
-		bailout2(LOG_ERR, "%s %u.%u: Error reading (set frequency)", modminer->api->name, modminer->device_id, fpgaid);
+		bailout2(LOG_ERR, "%s.%u: Error reading (set frequency)", modminer->dev_repr, fpgaid);
 	if (needlock)
 		mutex_unlock(&modminer->device_mutex);
 
@@ -343,7 +343,7 @@ static bool modminer_dclk_change_clock(struct thr_info*thr, int multiplier)
 		return false;
 
 	char repr[0x10];
-	sprintf(repr, "%s %u.%u", modminer->api->name, modminer->device_id, fpgaid);
+	sprintf(repr, "%s.%u", modminer->dev_repr, fpgaid);
 	dclk_msg_freqchange(repr, oldFreq * 2, state->dclk.freqM * 2, NULL);
 	return true;
 }
@@ -365,11 +365,11 @@ static bool _modminer_get_nonce(struct cgpu_info*modminer, char fpgaid, uint32_t
 	char cmd[2] = {MODMINER_CHECK_WORK, fpgaid};
 	
 	if (write(fd, cmd, 2) != 2) {
-		applog(LOG_ERR, "%s %u: Error writing (get nonce %u)", modminer->api->name, modminer->device_id, fpgaid);
+		applog(LOG_ERR, "%s: Error writing (get nonce %u)", modminer->dev_repr, fpgaid);
 		return false;
 	}
 	if (4 != serial_read(fd, nonce, 4)) {
-		applog(LOG_ERR, "%s %u: Short read (get nonce %u)", modminer->api->name, modminer->device_id, fpgaid);
+		applog(LOG_ERR, "%s: Short read (get nonce %u)", modminer->dev_repr, fpgaid);
 		return false;
 	}
 	
@@ -398,34 +398,34 @@ modminer_fpga_init(struct thr_info *thr)
 	cmd[0] = MODMINER_GET_USERCODE;
 	cmd[1] = fpgaid;
 	if (write(fd, cmd, 2) != 2)
-		bailout2(LOG_ERR, "%s %u.%u: Error writing (read USER code)", modminer->api->name, modminer->device_id, fpgaid);
+		bailout2(LOG_ERR, "%s.%u: Error writing (read USER code)", modminer->dev_repr, fpgaid);
 	if (serial_read(fd, buf, 4) != 4)
-		bailout2(LOG_ERR, "%s %u.%u: Error reading (read USER code)", modminer->api->name, modminer->device_id, fpgaid);
+		bailout2(LOG_ERR, "%s.%u: Error reading (read USER code)", modminer->dev_repr, fpgaid);
 
 	if (memcmp(buf, BISTREAM_USER_ID, 4)) {
-		applog(LOG_ERR, "%s %u.%u: FPGA not programmed", modminer->api->name, modminer->device_id, fpgaid);
+		applog(LOG_ERR, "%s.%u: FPGA not programmed", modminer->dev_repr, fpgaid);
 		if (!modminer_fpga_upload_bitstream(modminer))
 			return false;
 	} else if (opt_force_dev_init && modminer->status == LIFE_INIT) {
-		applog(LOG_DEBUG, "%s %u.%u: FPGA is already programmed, but --force-dev-init is set",
-		       modminer->api->name, modminer->device_id, fpgaid);
+		applog(LOG_DEBUG, "%s.%u: FPGA is already programmed, but --force-dev-init is set",
+		       modminer->dev_repr, fpgaid);
 		if (!modminer_fpga_upload_bitstream(modminer))
 			return false;
 	}
 	else
-		applog(LOG_DEBUG, "%s %u.%u: FPGA is already programmed :)", modminer->api->name, modminer->device_id, fpgaid);
+		applog(LOG_DEBUG, "%s.%u: FPGA is already programmed :)", modminer->dev_repr, fpgaid);
 	state->pdone = 101;
 
 	state->dclk.freqM = MODMINER_MAX_CLOCK / 2 + 1;  // Will be reduced immediately
 	while (1) {
 		if (state->dclk.freqM <= MODMINER_MIN_CLOCK / 2)
-			bailout2(LOG_ERR, "%s %u.%u: Hit minimum trying to find acceptable frequencies", modminer->api->name, modminer->device_id, fpgaid);
+			bailout2(LOG_ERR, "%s.%u: Hit minimum trying to find acceptable frequencies", modminer->dev_repr, fpgaid);
 		--state->dclk.freqM;
 		if (!modminer_change_clock(thr, false, 0))
 			// MCU rejected assignment
 			continue;
 		if (!_modminer_get_nonce(modminer, fpgaid, &nonce))
-			bailout2(LOG_ERR, "%s %u.%u: Error detecting acceptable frequencies", modminer->api->name, modminer->device_id, fpgaid);
+			bailout2(LOG_ERR, "%s.%u: Error detecting acceptable frequencies", modminer->dev_repr, fpgaid);
 		if (!memcmp(&nonce, "\x00\xff\xff\xff", 4))
 			// MCU took assignment, but disabled FPGA
 			continue;
@@ -435,10 +435,10 @@ modminer_fpga_init(struct thr_info *thr)
 	state->dclk.freqMaxM = state->dclk.freqM;
 	if (MODMINER_DEF_CLOCK / 2 < state->dclk.freqM) {
 		if (!modminer_change_clock(thr, false, -(state->dclk.freqM * 2 - MODMINER_DEF_CLOCK)))
-			applog(LOG_WARNING, "%s %u.%u: Failed to set desired initial frequency of %u", modminer->api->name, modminer->device_id, fpgaid, MODMINER_DEF_CLOCK);
+			applog(LOG_WARNING, "%s.%u: Failed to set desired initial frequency of %u", modminer->dev_repr, fpgaid, MODMINER_DEF_CLOCK);
 	}
 	state->dclk.freqMDefault = state->dclk.freqM;
-	applog(LOG_WARNING, "%s %u.%u: Frequency set to %u MHz (range: %u-%u)", modminer->api->name, modminer->device_id, fpgaid, state->dclk.freqM * 2, MODMINER_MIN_CLOCK, state->dclk.freqMaxM * 2);
+	applog(LOG_WARNING, "%s.%u: Frequency set to %u MHz (range: %u-%u)", modminer->dev_repr, fpgaid, state->dclk.freqM * 2, MODMINER_MIN_CLOCK, state->dclk.freqMaxM * 2);
 
 	mutex_unlock(&modminer->device_mutex);
 
@@ -513,8 +513,8 @@ static void modminer_get_temperature(struct cgpu_info *modminer, struct thr_info
 					state->last_cutoff_reduced = now;
 					int oldFreq = state->dclk.freqM;
 					if (modminer_reduce_clock(thr, false))
-						applog(LOG_NOTICE, "%s %u.%u: Frequency %s from %u to %u MHz (temp: %d)",
-						       modminer->api->name, modminer->device_id, fpgaid,
+						applog(LOG_NOTICE, "%s.%u: Frequency %s from %u to %u MHz (temp: %d)",
+						       modminer->dev_repr, fpgaid,
 						       (oldFreq > state->dclk.freqM ? "dropped" : "raised "),
 						       oldFreq * 2, state->dclk.freqM * 2,
 						       temperature
@@ -617,15 +617,15 @@ fd_set fds;
 	}
 
 	if (46 != write(fd, state->next_work_cmd, 46))
-		bailout2(LOG_ERR, "%s %u.%u: Error writing (start work)", modminer->api->name, modminer->device_id, fpgaid);
+		bailout2(LOG_ERR, "%s.%u: Error writing (start work)", modminer->dev_repr, fpgaid);
 	gettimeofday(&state->tv_workstart, NULL);
 	state->hashes = 0;
 	status_read("start work");
 	mutex_unlock(&modminer->device_mutex);
 	if (opt_debug) {
 		char *xdata = bin2hex(state->running_work.data, 80);
-		applog(LOG_DEBUG, "%s %u.%u: Started work: %s",
-		       modminer->api->name, modminer->device_id, fpgaid, xdata);
+		applog(LOG_DEBUG, "%s.%u: Started work: %s",
+		       modminer->dev_repr, fpgaid, xdata);
 		free(xdata);
 	}
 
@@ -666,14 +666,14 @@ modminer_process_results(struct thr_info*thr)
 			bad = !test_nonce(work, nonce, false);
 			++immediate_nonces;
 			if (!bad)
-				applog(LOG_DEBUG, "%s %u.%u: Nonce for current  work: %02x%02x%02x%02x",
-				       modminer->api->name, modminer->device_id, fpgaid,
+				applog(LOG_DEBUG, "%s.%u: Nonce for current  work: %02x%02x%02x%02x",
+				       modminer->dev_repr, fpgaid,
 				       NONCE_CHARS(nonce));
 			else
 			if (test_nonce(&state->last_work, nonce, false))
 			{
-				applog(LOG_DEBUG, "%s %u.%u: Nonce for previous work: %02x%02x%02x%02x",
-				       modminer->api->name, modminer->device_id, fpgaid,
+				applog(LOG_DEBUG, "%s.%u: Nonce for previous work: %02x%02x%02x%02x",
+				       modminer->dev_repr, fpgaid,
 				       NONCE_CHARS(nonce));
 				work = &state->last_work;
 				bad = false;
@@ -684,8 +684,8 @@ modminer_process_results(struct thr_info*thr)
 				submit_nonce(thr, work, nonce);
 			}
 			else {
-				applog(LOG_DEBUG, "%s %u.%u: Nonce with H not zero  : %02x%02x%02x%02x",
-				       modminer->api->name, modminer->device_id, fpgaid,
+				applog(LOG_DEBUG, "%s.%u: Nonce with H not zero  : %02x%02x%02x%02x",
+				       modminer->dev_repr, fpgaid,
 				       NONCE_CHARS(nonce));
 				++hw_errors;
 				++modminer->hw_errors;
@@ -708,7 +708,7 @@ modminer_process_results(struct thr_info*thr)
 	uint64_t hashes = (uint64_t)state->dclk.freqM * 2 * (((uint64_t)elapsed.tv_sec * 1000000) + elapsed.tv_usec);
 	if (hashes > 0xffffffff)
 	{
-		applog(LOG_WARNING, "%s %u.%u: Finished work before new one sent", modminer->api->name, modminer->device_id, fpgaid);
+		applog(LOG_WARNING, "%s.%u: Finished work before new one sent", modminer->dev_repr, fpgaid);
 		hashes = 0xffffffff;
 	}
 	if (hashes <= state->hashes)
@@ -814,12 +814,12 @@ static char *modminer_set_device(struct cgpu_info *modminer, char *option, char
 			signed char delta = (multiplier - oldFreqM) * 2;
 			state->dclk.freqMDefault = multiplier;
 			if (unlikely(!modminer_change_clock(thr, true, delta))) {
-				sprintf(replybuf, "Set clock failed: %s %u.%u",
-				        modminer->api->name, modminer->device_id, fpgaid);
+				sprintf(replybuf, "Set clock failed: %s.%u",
+				        modminer->dev_repr, fpgaid);
 				return replybuf;
 			}
 
-			sprintf(repr, "%s %u.%u", modminer->api->name, modminer->device_id, fpgaid);
+			sprintf(repr, "%s.%u", modminer->dev_repr, fpgaid);
 			dclk_msg_freqchange(repr, oldFreqM * 2, state->dclk.freqM * 2, " on user request");
 		}
 

+ 3 - 2
driver-opencl.c

@@ -862,8 +862,9 @@ retry:
 			mhash_base = false;
 		}
 
-		wlog("GPU %d: %.1f / %.1f %sh/s | A:%d  R:%d  HW:%d  U:%.2f/m  I:%d\n",
-			gpu, displayed_rolling, displayed_total, mhash_base ? "M" : "K",
+		wlog("%"PRIpreprv": %.1f / %.1f %sh/s | A:%d  R:%d  HW:%d  U:%.2f/m  I:%d\n",
+			cgpu->proc_repr,
+			displayed_rolling, displayed_total, mhash_base ? "M" : "K",
 			cgpu->accepted, cgpu->rejected, cgpu->hw_errors,
 			cgpu->utility, cgpu->intensity);
 #ifdef HAVE_ADL

+ 36 - 41
driver-x6500.c

@@ -213,14 +213,14 @@ x6500_fpga_upload_bitstream(struct cgpu_info *x6500, struct jtag_port *jp1)
 	unsigned char *pdone = (unsigned char*)x6500->cgpu_data - 1;
 	struct ft232r_device_handle *ftdi = jp1->a->ftdi;
 
-	FILE *f = open_xilinx_bitstream(x6500, X6500_BITSTREAM_FILENAME, &len);
+	FILE *f = open_xilinx_bitstream(x6500->api->dname, x6500->dev_repr, X6500_BITSTREAM_FILENAME, &len);
 	if (!f)
 		return false;
 
 	flen = len;
 
-	applog(LOG_WARNING, "%s %u: Programming %s...",
-	       x6500->api->name, x6500->device_id, x6500->device_path);
+	applog(LOG_WARNING, "%s: Programming %s...",
+	       x6500->dev_repr, x6500->device_path);
 	x6500->status = LIFE_INIT;
 	
 	// "Magic" jtag_port configured to access both FPGAs concurrently
@@ -242,8 +242,8 @@ x6500_fpga_upload_bitstream(struct cgpu_info *x6500, struct jtag_port *jp1)
 			i = 0xd0;  // Re-set JPROGRAM while reading status
 			jtag_read(jp, JTAG_REG_IR, &i, 6);
 		} while (i & 8);
-		applog(LOG_DEBUG, "%s %u.%u: JPROGRAM ready",
-		       x6500->api->name, x6500->device_id, j);
+		applog(LOG_DEBUG, "%s%c: JPROGRAM ready",
+		       x6500->dev_repr, 'a' + j);
 	}
 	x6500_jtag_set(jp, 0x11);
 	jtag_write(jp, JTAG_REG_IR, "\xa0", 6);  // CFG_IN
@@ -251,7 +251,7 @@ x6500_fpga_upload_bitstream(struct cgpu_info *x6500, struct jtag_port *jp1)
 	sleep(1);
 	
 	if (fread(buf, 32, 1, f) != 1)
-		bailout2(LOG_ERR, "%s %u: File underrun programming %s (%lu bytes left)", x6500->api->name, x6500->device_id, x6500->device_path, len);
+		bailout2(LOG_ERR, "%s: File underrun programming %s (%lu bytes left)", x6500->dev_repr, x6500->device_path, len);
 	jtag_swrite(jp, JTAG_REG_DR, buf, 256);
 	len -= 32;
 	
@@ -269,13 +269,13 @@ x6500_fpga_upload_bitstream(struct cgpu_info *x6500, struct jtag_port *jp1)
 	while (len) {
 		buflen = len < 32 ? len : 32;
 		if (fread(buf, buflen, 1, f) != 1)
-			bailout2(LOG_ERR, "%s %u: File underrun programming %s (%lu bytes left)", x6500->api->name, x6500->device_id, x6500->device_path, len);
+			bailout2(LOG_ERR, "%s: File underrun programming %s (%lu bytes left)", x6500->dev_repr, x6500->device_path, len);
 		jtag_swrite_more(jp, buf, buflen * 8, len == (unsigned long)buflen);
 		*pdone = 100 - ((len * 100) / flen);
 		if (*pdone >= nextstatus)
 		{
 			nextstatus += 25;
-			applog(LOG_WARNING, "%s %u: Programming %s... %d%% complete...", x6500->api->name, x6500->device_id, x6500->device_path, *pdone);
+			applog(LOG_WARNING, "%s: Programming %s... %d%% complete...", x6500->dev_repr, x6500->device_path, *pdone);
 		}
 		len -= buflen;
 	}
@@ -297,7 +297,7 @@ x6500_fpga_upload_bitstream(struct cgpu_info *x6500, struct jtag_port *jp1)
 	if (!(i & 4))
 		return false;
 	
-	applog(LOG_WARNING, "%s %u: Done programming %s", x6500->api->name, x6500->device_id, x6500->device_path);
+	applog(LOG_WARNING, "%s: Done programming %s", x6500->dev_repr, x6500->device_path);
 	*pdone = 101;
 
 	return true;
@@ -319,7 +319,6 @@ static bool x6500_dclk_change_clock(struct thr_info *thr, int multiplier)
 {
 	struct cgpu_info *x6500 = thr->cgpu;
 	pthread_mutex_t *mutexp = &x6500->device->device_mutex;
-	char fpgaid = x6500->proc_id;
 	struct x6500_fpga_data *fpga = thr->cgpu_data;
 	uint8_t oldFreq = fpga->dclk.freqM;
 
@@ -330,9 +329,7 @@ static bool x6500_dclk_change_clock(struct thr_info *thr, int multiplier)
 	}
 	mutex_unlock(mutexp);
 
-	char repr[0x10];
-	sprintf(repr, "%s %u.%u", x6500->api->name, x6500->device_id, fpgaid);
-	dclk_msg_freqchange(repr, oldFreq * 2, fpga->dclk.freqM * 2, NULL);
+	dclk_msg_freqchange(x6500->proc_repr, oldFreq * 2, fpga->dclk.freqM * 2, NULL);
 	return true;
 }
 
@@ -360,16 +357,16 @@ static bool x6500_fpga_init(struct thr_info *thr)
 	mutex_lock(mutexp);
 	if (!jtag_reset(jp)) {
 		mutex_unlock(mutexp);
-		applog(LOG_ERR, "%s %u: JTAG reset failed",
-		       x6500->api->name, x6500->device_id);
+		applog(LOG_ERR, "%s: JTAG reset failed",
+		       x6500->dev_repr);
 		return false;
 	}
 	
 	i = jtag_detect(jp);
 	if (i != 1) {
 		mutex_unlock(mutexp);
-		applog(LOG_ERR, "%s %u: JTAG detect returned %d",
-		       x6500->api->name, x6500->device_id, i);
+		applog(LOG_ERR, "%s: JTAG detect returned %d",
+		       x6500->dev_repr, i);
 		return false;
 	}
 	
@@ -379,24 +376,24 @@ static bool x6500_fpga_init(struct thr_info *thr)
 	 && jtag_reset(jp)
 	)) {
 		mutex_unlock(mutexp);
-		applog(LOG_ERR, "%s %u: JTAG error reading user code",
-		       x6500->api->name, x6500->device_id);
+		applog(LOG_ERR, "%s: JTAG error reading user code",
+		       x6500->dev_repr);
 		return false;
 	}
 	
 	if (memcmp(buf, X6500_BITSTREAM_USERID, 4)) {
-		applog(LOG_ERR, "%s %u.%u: FPGA not programmed",
-		       x6500->api->name, x6500->device_id, fpgaid);
+		applog(LOG_ERR, "%"PRIprepr": FPGA not programmed",
+		       x6500->proc_repr);
 		if (!x6500_fpga_upload_bitstream(x6500, jp))
 			return false;
 	} else if (opt_force_dev_init && x6500->status == LIFE_INIT) {
-		applog(LOG_DEBUG, "%s %u.%u: FPGA is already programmed, but --force-dev-init is set",
-		       x6500->api->name, x6500->device_id, fpgaid);
+		applog(LOG_DEBUG, "%"PRIprepr": FPGA is already programmed, but --force-dev-init is set",
+		       x6500->proc_repr);
 		if (!x6500_fpga_upload_bitstream(x6500, jp))
 			return false;
 	} else
-		applog(LOG_DEBUG, "%s %u.%u: FPGA is already programmed :)",
-		       x6500->api->name, x6500->device_id, fpgaid);
+		applog(LOG_DEBUG, "%s"PRIprepr": FPGA is already programmed :)",
+		       x6500->proc_repr);
 	
 	dclk_prepare(&fpga->dclk);
 	x6500_change_clock(thr, X6500_DEFAULT_CLOCK / 2);
@@ -405,15 +402,15 @@ static bool x6500_fpga_init(struct thr_info *thr)
 	mutex_unlock(mutexp);
 
 	if (i)
-		applog(LOG_WARNING, "%s %u.%u: Flushed %d nonces from buffer at init",
-		       x6500->api->name, x6500->device_id, fpgaid, i);
+		applog(LOG_WARNING, "%"PRIprepr": Flushed %d nonces from buffer at init",
+		       x6500->proc_repr, i);
 
 	fpga->dclk.minGoodSamples = 3;
 	fpga->freqMaxMaxM =
 	fpga->dclk.freqMaxM = X6500_MAXIMUM_CLOCK / 2;
 	fpga->dclk.freqMDefault = fpga->dclk.freqM;
-	applog(LOG_WARNING, "%s %u.%u: Frequency set to %u MHz (range: %u-%u)",
-	       x6500->api->name, x6500->device_id, fpgaid,
+	applog(LOG_WARNING, "%"PRIprepr": Frequency set to %u MHz (range: %u-%u)",
+	       x6500->proc_repr,
 	       fpga->dclk.freqM * 2,
 	       X6500_MINIMUM_CLOCK,
 	       fpga->dclk.freqMaxM * 2);
@@ -496,8 +493,8 @@ void x6500_get_temperature(struct cgpu_info *x6500)
 				fpga->last_cutoff_reduced = now;
 				int oldFreq = fpga->dclk.freqM;
 				if (x6500_change_clock(thr, oldFreq - 1))
-					applog(LOG_NOTICE, "%s %u.%u: Frequency dropped from %u to %u MHz (temp: %.1fC)",
-					       x6500->api->name, x6500->device_id, i,
+					applog(LOG_NOTICE, "%"PRIprepr": Frequency dropped from %u to %u MHz (temp: %.1fC)",
+					       x6500->proc_repr,
 					       oldFreq * 2, fpga->dclk.freqM * 2,
 					       fpga->temp
 					);
@@ -589,7 +586,6 @@ bool x6500_start_work(struct thr_info *thr, struct work *work)
 	pthread_mutex_t *mutexp = &x6500->device->device_mutex;
 	struct x6500_fpga_data *fpga = thr->cgpu_data;
 	struct jtag_port *jp = &fpga->jtag;
-	char fpgaid = x6500->proc_id;
 
 	mutex_lock(mutexp);
 
@@ -607,8 +603,8 @@ bool x6500_start_work(struct thr_info *thr, struct work *work)
 
 	if (opt_debug) {
 		char *xdata = bin2hex(work->data, 80);
-		applog(LOG_DEBUG, "%s %u.%u: Started work: %s",
-		       x6500->api->name, x6500->device_id, fpgaid, xdata);
+		applog(LOG_DEBUG, "%"PRIprepr": Started work: %s",
+		       x6500->proc_repr, xdata);
 		free(xdata);
 	}
 
@@ -635,7 +631,6 @@ int64_t x6500_process_results(struct thr_info *thr, struct work *work)
 	pthread_mutex_t *mutexp = &x6500->device->device_mutex;
 	struct x6500_fpga_data *fpga = thr->cgpu_data;
 	struct jtag_port *jtag = &fpga->jtag;
-	char fpgaid = x6500->proc_id;
 
 	struct timeval tv_now;
 	int64_t hashes;
@@ -651,19 +646,19 @@ int64_t x6500_process_results(struct thr_info *thr, struct work *work)
 			bad = !test_nonce(work, nonce, false);
 			if (!bad) {
 				submit_nonce(thr, work, nonce);
-				applog(LOG_DEBUG, "%s %u.%u: Nonce for current  work: %08lx",
-				       x6500->api->name, x6500->device_id, fpgaid,
+				applog(LOG_DEBUG, "%"PRIprepr": Nonce for current  work: %08lx",
+				       x6500->proc_repr,
 				       (unsigned long)nonce);
 
 				dclk_gotNonces(&fpga->dclk);
 			} else if (test_nonce(&fpga->prevwork, nonce, false)) {
 				submit_nonce(thr, &fpga->prevwork, nonce);
-				applog(LOG_DEBUG, "%s %u.%u: Nonce for PREVIOUS work: %08lx",
-				       x6500->api->name, x6500->device_id, fpgaid,
+				applog(LOG_DEBUG, "%"PRIprepr": Nonce for PREVIOUS work: %08lx",
+				       x6500->proc_repr,
 				       (unsigned long)nonce);
 			} else {
-				applog(LOG_DEBUG, "%s %u.%u: Nonce with H not zero  : %08lx",
-				       x6500->api->name, x6500->device_id, fpgaid,
+				applog(LOG_DEBUG, "%"PRIprepr": Nonce with H not zero  : %08lx",
+				       x6500->proc_repr,
 				       (unsigned long)nonce);
 				++hw_errors;
 				++x6500->hw_errors;

+ 2 - 2
driver-ztex.c

@@ -69,10 +69,10 @@ static struct cgpu_info *ztex_setup(struct libztex_device *dev, int j)
 	ztex->threads = 1;
 	dev->fpgaNum = j;
 	add_cgpu(ztex);
-	sprintf(ztex->device_ztex->repr, "%s %u", ztex->api->name, ztex->device_id);
+	strcpy(ztex->device_ztex->repr, ztex->proc_repr);
 	sprintf(fpganame, "%s-%u", ztex->device_ztex->snString, j+1);
 	ztex->name = strdup(fpganame);
-	applog(LOG_INFO, "%s %u: Found Ztex (ZTEX %s)", ztex->api->name, ztex->device_id, fpganame);
+	applog(LOG_INFO, "%"PRIpreprv": Found Ztex (ZTEX %s)", ztex->proc_repr, fpganame);
 
 	return ztex;
 }

+ 3 - 3
dynclock.c

@@ -22,7 +22,7 @@ void dclk_prepare(struct dclk_data *data)
 
 void dclk_msg_freqchange(const char *repr, int oldFreq, int newFreq, const char *tail)
 {
-	applog(LOG_NOTICE, "%s: Frequency %s from %u to %u MHz%s",
+	applog(LOG_NOTICE, "%"PRIpreprv": Frequency %s from %u to %u MHz%s",
 	       repr,
 	       (oldFreq > newFreq ? "dropped" : "raised "),
 	       oldFreq, newFreq,
@@ -70,8 +70,8 @@ bool dclk_updateFreq(struct dclk_data *data, dclk_change_clock_func_t changecloc
 	while (maxM < data->freqMaxM && data->errorWeight[maxM + 1] > 100)
 		maxM++;
 	if ((bestM < (1.0 - DCLK_OVERHEATTHRESHOLD) * maxM) && bestM < maxM - 1) {
-		applog(LOG_ERR, "%s %u: frequency drop of %.1f%% detect. This may be caused by overheating. FPGA is shut down to prevent damage.",
-		       cgpu->api->name, cgpu->device_id,
+		applog(LOG_ERR, "%"PRIpreprv": frequency drop of %.1f%% detect. This may be caused by overheating. FPGA is shut down to prevent damage.",
+		       cgpu->proc_repr,
 		       (1.0 - 1.0 * bestM / maxM) * 100);
 		return false;
 	}

+ 2 - 2
findnonce.c

@@ -153,8 +153,8 @@ static void *postcalc_hash(void *userdata)
 	/* To prevent corrupt values in FOUND from trying to read beyond the
 	 * end of the res[] array */
 	if (unlikely(pcd->res[FOUND] & ~FOUND)) {
-		applog(LOG_WARNING, "%s%d: invalid nonce count - HW error",
-				thr->cgpu->api->name, thr->cgpu->device_id);
+		applog(LOG_WARNING, "%"PRIpreprv": invalid nonce count - HW error",
+				thr->cgpu->proc_repr);
 		hw_errors++;
 		thr->cgpu->hw_errors++;
 		pcd->res[FOUND] &= FOUND;

+ 28 - 28
fpgautils.c

@@ -806,51 +806,51 @@ FILE *open_bitstream(const char *dname, const char *filename)
 
 #define check_magic(L)  do {  \
 	if (1 != fread(buf, 1, 1, f))  \
-		bailout(LOG_ERR, "%s %u: Error reading firmware ('%c')",  \
-		        cgpu->api->name, cgpu->device_id, L);  \
+		bailout(LOG_ERR, "%s: Error reading firmware ('%c')",  \
+		        repr, L);  \
 	if (buf[0] != L)  \
-		bailout(LOG_ERR, "%s %u: Firmware has wrong magic ('%c')",  \
-		        cgpu->api->name, cgpu->device_id, L);  \
+		bailout(LOG_ERR, "%s: Firmware has wrong magic ('%c')",  \
+		        repr, L);  \
 } while(0)
 
 #define read_str(eng)  do {  \
 	if (1 != fread(buf, 2, 1, f))  \
-		bailout(LOG_ERR, "%s %u: Error reading firmware (" eng " len)",  \
-		        cgpu->api->name, cgpu->device_id);  \
+		bailout(LOG_ERR, "%s: Error reading firmware (" eng " len)",  \
+		        repr);  \
 	len = (ubuf[0] << 8) | ubuf[1];  \
 	if (len >= sizeof(buf))  \
-		bailout(LOG_ERR, "%s %u: Firmware " eng " too long",  \
-		        cgpu->api->name, cgpu->device_id);  \
+		bailout(LOG_ERR, "%s: Firmware " eng " too long",  \
+		        repr);  \
 	if (1 != fread(buf, len, 1, f))  \
-		bailout(LOG_ERR, "%s %u: Error reading firmware (" eng ")",  \
-		        cgpu->api->name, cgpu->device_id);  \
+		bailout(LOG_ERR, "%s: Error reading firmware (" eng ")",  \
+		        repr);  \
 	buf[len] = '\0';  \
 } while(0)
 
-FILE *open_xilinx_bitstream(struct cgpu_info *cgpu, const char *fwfile, unsigned long *out_len)
+FILE *open_xilinx_bitstream(const char *dname, const char *repr, const char *fwfile, unsigned long *out_len)
 {
 	char buf[0x100];
 	unsigned char *ubuf = (unsigned char*)buf;
 	unsigned long len;
 	char *p;
 
-	FILE *f = open_bitstream(cgpu->api->dname, fwfile);
+	FILE *f = open_bitstream(dname, fwfile);
 	if (!f)
-		bailout(LOG_ERR, "%s %u: Error opening firmware file %s",
-		        cgpu->api->name, cgpu->device_id, fwfile);
+		bailout(LOG_ERR, "%s: Error opening firmware file %s",
+		        repr, fwfile);
 	if (1 != fread(buf, 2, 1, f))
-		bailout(LOG_ERR, "%s %u: Error reading firmware (magic)",
-		        cgpu->api->name, cgpu->device_id);
+		bailout(LOG_ERR, "%s: Error reading firmware (magic)",
+		        repr);
 	if (buf[0] || buf[1] != 9)
-		bailout(LOG_ERR, "%s %u: Firmware has wrong magic (9)",
-		        cgpu->api->name, cgpu->device_id);
+		bailout(LOG_ERR, "%s: Firmware has wrong magic (9)",
+		        repr);
 	if (-1 == fseek(f, 11, SEEK_CUR))
-		bailout(LOG_ERR, "%s %u: Firmware seek failed",
-		        cgpu->api->name, cgpu->device_id);
+		bailout(LOG_ERR, "%s: Firmware seek failed",
+		        repr);
 	check_magic('a');
 	read_str("design name");
-	applog(LOG_DEBUG, "%s %u: Firmware file %s info:",
-	       cgpu->api->name, cgpu->device_id, fwfile);
+	applog(LOG_DEBUG, "%s: Firmware file %s info:",
+	       repr, fwfile);
 	applog(LOG_DEBUG, "  Design name: %s", buf);
 	p = strrchr(buf, ';') ?: buf;
 	p = strrchr(buf, '=') ?: p;
@@ -858,11 +858,11 @@ FILE *open_xilinx_bitstream(struct cgpu_info *cgpu, const char *fwfile, unsigned
 		++p;
 	unsigned long fwusercode = (unsigned long)strtoll(p, &p, 16);
 	if (p[0] != '\0')
-		bailout(LOG_ERR, "%s %u: Bad usercode in firmware file",
-		        cgpu->api->name, cgpu->device_id);
+		bailout(LOG_ERR, "%s: Bad usercode in firmware file",
+		        repr);
 	if (fwusercode == 0xffffffff)
-		bailout(LOG_ERR, "%s %u: Firmware doesn't support user code",
-		        cgpu->api->name, cgpu->device_id);
+		bailout(LOG_ERR, "%s: Firmware doesn't support user code",
+		        repr);
 	applog(LOG_DEBUG, "  Version: %u, build %u", (unsigned)((fwusercode >> 8) & 0xff), (unsigned)(fwusercode & 0xff));
 	check_magic('b');
 	read_str("part number");
@@ -875,8 +875,8 @@ FILE *open_xilinx_bitstream(struct cgpu_info *cgpu, const char *fwfile, unsigned
 	applog(LOG_DEBUG, "  Build time: %s", buf);
 	check_magic('e');
 	if (1 != fread(buf, 4, 1, f))
-		bailout(LOG_ERR, "%s %u: Error reading firmware (data len)",
-		        cgpu->api->name, cgpu->device_id);
+		bailout(LOG_ERR, "%s: Error reading firmware (data len)",
+		        repr);
 	len = ((unsigned long)ubuf[0] << 24) | ((unsigned long)ubuf[1] << 16) | (ubuf[2] << 8) | ubuf[3];
 	applog(LOG_DEBUG, "  Bitstream size: %lu", len);
 

+ 1 - 1
fpgautils.h

@@ -46,6 +46,6 @@ extern ssize_t _serial_read(int fd, char *buf, size_t buflen, char *eol);
 #define serial_close(fd)  close(fd)
 
 extern FILE *open_bitstream(const char *dname, const char *filename);
-extern FILE *open_xilinx_bitstream(struct cgpu_info *cgpu, const char *fwfile, unsigned long *out_len);
+extern FILE *open_xilinx_bitstream(const char *dname, const char *repr, const char *fwfile, unsigned long *out_len);
 
 #endif

+ 38 - 27
miner.c

@@ -424,7 +424,7 @@ static void sharelog(const char*disposition, const struct work*work)
 	data = bin2hex(work->data, sizeof(work->data));
 
 	// timestamp,disposition,target,pool,dev,thr,sharehash,sharedata
-	rv = snprintf(s, sizeof(s), "%lu,%s,%s,%s,%s%u,%u,%s,%s\n", t, disposition, target, pool->rpc_url, cgpu->api->name, cgpu->device_id, thr_id, hash, data);
+	rv = snprintf(s, sizeof(s), "%lu,%s,%s,%s,%s,%u,%s,%s\n", t, disposition, target, pool->rpc_url, cgpu->proc_repr_ns, thr_id, hash, data);
 	free(target);
 	free(hash);
 	free(data);
@@ -976,8 +976,8 @@ static void load_temp_config()
 		else
 			cgpu->targettemp = cgpu->cutofftemp + target_off;
 		
-		applog(LOG_DEBUG, "%s %u: Set temperature config: target=%d cutoff=%d",
-		       cgpu->api->name, cgpu->device_id,
+		applog(LOG_DEBUG, "%"PRIprepr": Set temperature config: target=%d cutoff=%d",
+		       cgpu->proc_repr,
 		       cgpu->targettemp, cgpu->cutofftemp);
 	}
 	if (cutoff_n != temp_cutoff_str && cutoff_n[0])
@@ -2163,7 +2163,7 @@ static void get_statline(char *buf, struct cgpu_info *cgpu)
 		utility_to_hashrate(cgpu->utility_diff1),
 		H2B_SPACED);
 
-	sprintf(buf, "%s%d ", cgpu->api->name, cgpu->device_id);
+	sprintf(buf, "%s ", cgpu->proc_repr_ns);
 	if (cgpu->api->get_statline_before)
 		cgpu->api->get_statline_before(buf, cgpu);
 	else
@@ -2288,7 +2288,7 @@ static void curses_print_devstatus(int thr_id)
 
 	if (wmove(statuswin, ypos, 0) == ERR)
 		return;
-	wprintw(statuswin, " %s %*d: ", cgpu->api->name, dev_width, cgpu->device_id);
+	wprintw(statuswin, " %"PRIprepr": ", cgpu->proc_repr);
 	if (cgpu->api->get_statline_before) {
 		logline[0] = '\0';
 		cgpu->api->get_statline_before(logline, cgpu);
@@ -2524,11 +2524,11 @@ share_result(json_t *val, json_t *res, json_t *err, const struct work *work,
 		applog(LOG_DEBUG, "PROOF OF WORK RESULT: true (yay!!!)");
 		if (!QUIET) {
 			if (total_pools > 1)
-				applog(LOG_NOTICE, "Accepted %s %s %d pool %d %s%s",
-				       hashshow, cgpu->api->name, cgpu->device_id, work->pool->pool_no, resubmit ? "(resubmit)" : "", worktime);
+				applog(LOG_NOTICE, "Accepted %s %"PRIpreprv" pool %d %s%s",
+				       hashshow, cgpu->proc_repr, work->pool->pool_no, resubmit ? "(resubmit)" : "", worktime);
 			else
-				applog(LOG_NOTICE, "Accepted %s %s %d %s%s",
-				       hashshow, cgpu->api->name, cgpu->device_id, resubmit ? "(resubmit)" : "", worktime);
+				applog(LOG_NOTICE, "Accepted %s %"PRIpreprv" %s%s",
+				       hashshow, cgpu->proc_repr, resubmit ? "(resubmit)" : "", worktime);
 		}
 		sharelog("accept", work);
 		if (opt_shares && total_accepted >= opt_shares) {
@@ -2608,8 +2608,8 @@ share_result(json_t *val, json_t *res, json_t *err, const struct work *work,
 				}
 			}
 
-			applog(LOG_NOTICE, "Rejected %s %s %d %s%s %s%s",
-			       hashshow, cgpu->api->name, cgpu->device_id, where, reason, resubmit ? "(resubmit)" : "", worktime);
+			applog(LOG_NOTICE, "Rejected %s %"PRIpreprv" %s%s %s%s",
+			       hashshow, cgpu->proc_repr, where, reason, resubmit ? "(resubmit)" : "", worktime);
 			sharelog(disposition, work);
 		}
 
@@ -6419,8 +6419,8 @@ void submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
 		case TNR_BAD:
 		{
 			struct cgpu_info *cgpu = thr->cgpu;
-			applog(LOG_WARNING, "%s %u: invalid nonce - HW error",
-			       cgpu->api->name, cgpu->device_id);
+			applog(LOG_WARNING, "%"PRIpreprv": invalid nonce - HW error",
+			       cgpu->proc_repr);
 			mutex_lock(&stats_lock);
 			++hw_errors;
 			++thr->cgpu->hw_errors;
@@ -6492,7 +6492,7 @@ void *miner_thread(void *userdata)
 	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
 
 	char threadname[20];
-	snprintf(threadname, 20, "miner_%s%d.%d", api->name, cgpu->device_id, mythr->device_thread);
+	snprintf(threadname, 20, "miner_%s", cgpu->proc_repr_ns);
 	RenameThread(threadname);
 
 	gettimeofday(&getwork_start, NULL);
@@ -6571,12 +6571,12 @@ void *miner_thread(void *userdata)
 				}
 
 				if (scanhash_working && opt_restart) {
-					applog(LOG_ERR, "%s %u failure, attempting to reinitialize", api->name, cgpu->device_id);
+					applog(LOG_ERR, "%"PRIpreprv" failure, attempting to reinitialize", cgpu->proc_repr);
 					scanhash_working = false;
 					cgpu->reinit_backoff = 5.2734375;
 					hashes = 0;
 				} else {
-					applog(LOG_ERR, "%s %u failure, disabling!", api->name, cgpu->device_id);
+					applog(LOG_ERR, "%"PRIpreprv" failure, disabling!", cgpu->proc_repr);
 					cgpu->deven = DEV_RECOVER_ERR;
 					goto disabled;
 				}
@@ -7102,7 +7102,7 @@ static void *watchdog_thread(void __maybe_unused *userdata)
 					break;
 			}
 			enum dev_enable *denable;
-			char dev_str[8];
+			char *dev_str = cgpu->proc_repr;
 			int gpu;
 
 			if (cgpu->api->get_stats)
@@ -7110,7 +7110,6 @@ static void *watchdog_thread(void __maybe_unused *userdata)
 
 			gpu = cgpu->device_id;
 			denable = &cgpu->deven;
-			sprintf(dev_str, "%s%d", cgpu->api->name, gpu);
 
 #ifdef HAVE_ADL
 			if (adl_active && cgpu->has_adl)
@@ -7131,8 +7130,8 @@ static void *watchdog_thread(void __maybe_unused *userdata)
 			else
 			if (*denable == DEV_RECOVER_ERR) {
 				if (opt_restart && difftime(time(NULL), cgpu->device_last_not_well) > cgpu->reinit_backoff) {
-					applog(LOG_NOTICE, "Attempting to reinitialize %s %u",
-					       cgpu->api->name, cgpu->device_id);
+					applog(LOG_NOTICE, "Attempting to reinitialize %s",
+					       dev_str);
 					if (cgpu->reinit_backoff < 300)
 						cgpu->reinit_backoff *= 2;
 					device_recovered(cgpu);
@@ -7142,8 +7141,8 @@ static void *watchdog_thread(void __maybe_unused *userdata)
 			else
 			if (*denable == DEV_RECOVER) {
 				if (opt_restart && cgpu->temp < cgpu->targettemp) {
-					applog(LOG_NOTICE, "%s %u recovered to temperature below target, re-enabling",
-					       cgpu->api->name, cgpu->device_id);
+					applog(LOG_NOTICE, "%s recovered to temperature below target, re-enabling",
+					       dev_str);
 					device_recovered(cgpu);
 				}
 				cgpu->device_last_not_well = time(NULL);
@@ -7153,8 +7152,8 @@ static void *watchdog_thread(void __maybe_unused *userdata)
 			else
 			if (cgpu->temp > cgpu->cutofftemp)
 			{
-				applog(LOG_WARNING, "%s %u hit thermal cutoff limit, disabling!",
-				       cgpu->api->name, cgpu->device_id);
+				applog(LOG_WARNING, "%s hit thermal cutoff limit, disabling!",
+				       dev_str);
 				*denable = DEV_RECOVER;
 
 				dev_error(cgpu, REASON_DEV_THERMAL_CUTOFF);
@@ -7648,20 +7647,32 @@ bool add_cgpu(struct cgpu_info*cgpu)
 		cgpu->procs = 1;
 	lpcount = cgpu->procs;
 	cgpu->device = cgpu;
+	cgpu->dev_repr = malloc(6);
+	sprintf(cgpu->dev_repr, "%s%2u", cgpu->api->name, cgpu->device_id % 100);
+	strcpy(cgpu->proc_repr, cgpu->dev_repr);
+	sprintf(cgpu->proc_repr_ns, "%s%u", cgpu->api->name, cgpu->device_id);
 	devices = realloc(devices, sizeof(struct cgpu_info *) * (total_devices + lpcount + 1));
 	devices[total_devices++] = cgpu;
 	
 	if (lpcount > 1)
 	{
+		int ns;
 		int tpp = cgpu->threads / lpcount;
 		struct cgpu_info **nlp_p, *slave;
 		
+		// Note, strcpy instead of assigning a byte to get the \0 too
+		strcpy(&cgpu->proc_repr[5], "a");
+		ns = strlen(cgpu->proc_repr_ns);
+		strcpy(&cgpu->proc_repr_ns[ns], "a");
+		
 		nlp_p = &cgpu->next_proc;
 		for (int i = 1; i < lpcount; ++i)
 		{
 			slave = malloc(sizeof(*slave));
 			*slave = *cgpu;
 			slave->proc_id = i;
+			slave->proc_repr[5] += i;
+			slave->proc_repr_ns[ns] += i;
 			slave->threads = tpp;
 			devices[total_devices++] = slave;
 			*nlp_p = slave;
@@ -7953,9 +7964,9 @@ int main(int argc, char *argv[])
 		for (i = 0; i < total_devices; ++i) {
 			struct cgpu_info *cgpu = devices[i];
 			if (cgpu->name)
-				applog(LOG_ERR, " %2d. %s %d: %s (driver: %s)", i, cgpu->api->name, cgpu->device_id, cgpu->name, cgpu->api->dname);
+				applog(LOG_ERR, " %2d. %"PRIprepr": %s (driver: %s)", i, cgpu->proc_repr, cgpu->name, cgpu->api->dname);
 			else
-				applog(LOG_ERR, " %2d. %s %d (driver: %s)", i, cgpu->api->name, cgpu->device_id, cgpu->api->dname);
+				applog(LOG_ERR, " %2d. %"PRIprepr" (driver: %s)", i, cgpu->proc_repr, cgpu->api->dname);
 		}
 		quit(0, "%d devices listed", total_devices);
 	}
@@ -8167,7 +8178,7 @@ begin_bench:
 
 			thr->q = tq_new();
 			if (!thr->q)
-				quit(1, "tq_new failed in starting %s%d mining thread (#%d)", cgpu->api->name, cgpu->device_id, i);
+				quit(1, "tq_new failed in starting %"PRIpreprv" mining thread (#%d)", cgpu->proc_repr, i);
 
 			/* Enable threads for devices set not to mine but disable
 			 * their queue in case we wish to enable them later */

+ 6 - 0
miner.h

@@ -376,14 +376,20 @@ struct cgminer_pool_stats {
 	uint64_t net_bytes_received;
 };
 
+#define PRIprepr "-6s"
+#define PRIpreprv "s"
+
 struct cgpu_info {
 	int cgminer_id;
 	const struct device_api *api;
 	const char *devtype;
 	int device_id;
+	char *dev_repr;
 	const char *name;
 	int procs;
 	int proc_id;
+	char proc_repr[8];
+	char proc_repr_ns[8];
 	struct cgpu_info *device;
 	struct cgpu_info *next_proc;
 	const char *device_path;