Browse Source

Merge branch 'ztex_S_noauto' into bfgminer

Luke Dashjr 13 years ago
parent
commit
f7faca889d
3 changed files with 18 additions and 1 deletions
  1. 13 1
      driver-ztex.c
  2. 3 0
      fpgautils.c
  3. 2 0
      fpgautils.h

+ 13 - 1
driver-ztex.c

@@ -26,6 +26,8 @@
 
 #include <unistd.h>
 #include <sha2.h>
+
+#include "fpgautils.h"
 #include "miner.h"
 #include "libztex.h"
 
@@ -54,11 +56,12 @@ static void ztex_releaseFpga(struct libztex_device* ztex)
 	}
 }
 
-static void ztex_detect(void)
+static int ztex_autodetect(void)
 {
 	int cnt;
 	int i,j;
 	int fpgacount;
+	int totaldevs = 0;
 	struct libztex_dev_list **ztex_devices;
 	struct libztex_device *ztex_slave;
 	struct cgpu_info *ztex;
@@ -79,6 +82,7 @@ static void ztex_detect(void)
 		applog(LOG_INFO, "%s %u: Found Ztex (ZTEX %s-%u)", ztex->api->name, ztex->device_id, ztex->device_ztex->snString, 1);
 
 		fpgacount = libztex_numberOfFpgas(ztex->device_ztex);
+		totaldevs += fpgacount;
 
 		if (fpgacount > 1)
 			pthread_mutex_init(&ztex->device_ztex->mutex, NULL);
@@ -100,6 +104,14 @@ static void ztex_detect(void)
 
 	if (cnt > 0)
 		libztex_freeDevList(ztex_devices);
+
+	return totaldevs;
+}
+
+static void ztex_detect()
+{
+	// This wrapper ensures users can specify -S ztex:noauto to disable it
+	noserial_detect(ztex_api.dname, ztex_autodetect);
 }
 
 static bool ztex_updateFreq(struct libztex_device* ztex)

+ 3 - 0
fpgautils.c

@@ -131,6 +131,9 @@ _serial_detect(const char*dname, detectone_func_t detectone, autoscan_func_t aut
 		if (!strcmp(s, "noauto"))
 			inhibitauto = true;
 		else
+		if (!detectone)
+		{}  // do nothing
+		else
 		if (detectone(s)) {
 			string_elist_del(iter);
 			inhibitauto = true;

+ 2 - 0
fpgautils.h

@@ -24,6 +24,8 @@ extern int _serial_detect(const char*dname, detectone_func_t, autoscan_func_t, b
 	_serial_detect(dname, detectone, autoscan, false)
 #define serial_detect(dname, detectone)  \
 	_serial_detect(dname, detectone,     NULL, false)
+#define noserial_detect(dname, autoscan)  \
+	_serial_detect(dname, NULL     , autoscan, false)
 extern int serial_autodetect_devserial(detectone_func_t, const char*prodname);
 extern int serial_autodetect_udev     (detectone_func_t, const char*prodname);