Browse Source

Bugfix: ztex: Detect through fpgautils so -S noauto correctly inhibits autodetection

Luke Dashjr 13 years ago
parent
commit
84da18061c
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

@@ -25,6 +25,8 @@
 **/
 #include <unistd.h>
 #include <sha2.h>
+
+#include "fpgautils.h"
 #include "miner.h"
 #include "libztex.h"
 
@@ -53,11 +55,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;
@@ -76,6 +79,7 @@ static void ztex_detect(void)
 		add_cgpu(ztex);
 
 		fpgacount = libztex_numberOfFpgas(ztex->device_ztex);
+		totaldevs += fpgacount;
 
 		if (fpgacount > 1)
 			pthread_mutex_init(&ztex->device_ztex->mutex, NULL);
@@ -98,6 +102,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

@@ -130,6 +130,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

@@ -23,6 +23,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);