Browse Source

Merge commit 'b2b3e7e' into bfgminer-4.10.x

Luke Dashjr 10 years ago
parent
commit
5e45ffefe8
4 changed files with 25 additions and 16 deletions
  1. 2 2
      api.c
  2. 11 0
      deviceapi.c
  3. 5 5
      deviceapi.h
  4. 7 9
      miner.c

+ 2 - 2
api.c

@@ -1288,7 +1288,7 @@ static void minerconfig(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __
 	struct api_data *root = NULL;
 	char buf[TMPBUFSIZ];
 	bool io_open;
-	struct driver_registration *reg, *regtmp;
+	struct driver_registration *reg;
 	int pgacount = 0;
 	char *adlinuse = (char *)NO;
 	int i;
@@ -1329,7 +1329,7 @@ static void minerconfig(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __
 #endif
 	);
 
-	BFG_FOREACH_DRIVER_BY_DNAME(reg, regtmp)
+	BFG_FOREACH_DRIVER_BY_DNAME(reg)
 	{
 		const struct device_drv * const drv = reg->drv;
 		tailsprintf(buf, sizeof(buf), " %s", drv->name);

+ 11 - 0
deviceapi.c

@@ -26,6 +26,8 @@
 #include <time.h>
 #include <unistd.h>
 
+#include <utlist.h>
+
 #include "compat.h"
 #include "deviceapi.h"
 #include "logging.h"
@@ -78,8 +80,17 @@ int sort_drv_by_priority(struct driver_registration * const a, struct driver_reg
 void bfg_devapi_init()
 {
 	_bfg_register_driver(NULL);
+#ifdef LL_SORT2
 	LL_SORT2(_bfg_drvreg1, sort_drv_by_dname, next_dname);
 	LL_SORT2(_bfg_drvreg2, sort_drv_by_priority, next_prio);
+#else
+	#define next next_dname
+	LL_SORT(_bfg_drvreg1, sort_drv_by_dname);
+	#undef next
+	#define next next_prio
+	LL_SORT(_bfg_drvreg2, sort_drv_by_priority);
+	#undef next
+#endif
 }
 
 

+ 5 - 5
deviceapi.h

@@ -5,7 +5,7 @@
 #include <stdint.h>
 #include <sys/time.h>
 
-#include <uthash.h>
+#include <utlist.h>
 
 #include "miner.h"
 
@@ -22,10 +22,10 @@ extern struct driver_registration *_bfg_drvreg1;
 extern struct driver_registration *_bfg_drvreg2;
 extern void bfg_devapi_init();
 
-#define BFG_FOREACH_DRIVER_BY_DNAME(reg, tmp)  \
-	LL_FOREACH_SAFE2(_bfg_drvreg1, reg, tmp, next_dname)
-#define BFG_FOREACH_DRIVER_BY_PRIORITY(reg, tmp)  \
-	LL_FOREACH_SAFE2(_bfg_drvreg2, reg, tmp, next_prio)
+#define BFG_FOREACH_DRIVER_BY_DNAME(reg)  \
+	LL_FOREACH2(_bfg_drvreg1, reg, next_dname)
+#define BFG_FOREACH_DRIVER_BY_PRIORITY(reg)  \
+	LL_FOREACH2(_bfg_drvreg2, reg, next_prio)
 
 extern void _bfg_register_driver(const struct device_drv *);
 #define BFG_REGISTER_DRIVER(drv)                \

+ 7 - 9
miner.c

@@ -11748,8 +11748,8 @@ rescan:
 		pthread_join(info->probe_pth, NULL);
 #endif
 	
-	struct driver_registration *reg, *tmp;
-	BFG_FOREACH_DRIVER_BY_PRIORITY(reg, tmp)
+	struct driver_registration *reg;
+	BFG_FOREACH_DRIVER_BY_PRIORITY(reg)
 	{
 		const struct device_drv * const drv = reg->drv;
 		if (!(drv_algo_check(drv) && drv->drv_detect))
@@ -11962,7 +11962,7 @@ void *probe_device_thread(void *p)
 	
 	// if lowlevel device matches specific user assignment, probe requested driver(s)
 	struct string_elist *sd_iter, *sd_tmp;
-	struct driver_registration *dreg, *dreg_tmp;
+	struct driver_registration *dreg;
 	DL_FOREACH_SAFE(scan_devices, sd_iter, sd_tmp)
 	{
 		const char * const dname = sd_iter->string;
@@ -11980,8 +11980,7 @@ void *probe_device_thread(void *p)
 			memcpy(dname_nt, dname, dnamelen);
 			dname_nt[dnamelen] = '\0';
 			
-			struct driver_registration *dreg, *dreg_tmp;
-			BFG_FOREACH_DRIVER_BY_PRIORITY(dreg, dreg_tmp) {
+			BFG_FOREACH_DRIVER_BY_PRIORITY(dreg) {
 				const struct device_drv * const drv = dreg->drv;
 				if (!(drv && drv->lowl_probe && drv_algo_check(drv)))
 					continue;
@@ -11994,7 +11993,7 @@ void *probe_device_thread(void *p)
 	}
 	
 	// probe driver(s) with auto enabled and matching VID/PID/Product/etc of device
-	BFG_FOREACH_DRIVER_BY_PRIORITY(dreg, dreg_tmp)
+	BFG_FOREACH_DRIVER_BY_PRIORITY(dreg)
 	{
 		const struct device_drv * const drv = dreg->drv;
 		
@@ -12074,7 +12073,7 @@ void *probe_device_thread(void *p)
 					_probe_device_match(info, (dname[0] == '@') ? &dname[1] : dname))
 				{
 					bool dont_rescan = false;
-					BFG_FOREACH_DRIVER_BY_PRIORITY(dreg, dreg_tmp)
+					BFG_FOREACH_DRIVER_BY_PRIORITY(dreg)
 					{
 						const struct device_drv * const drv = dreg->drv;
 						if (!drv_algo_check(drv))
@@ -12102,8 +12101,7 @@ void *probe_device_thread(void *p)
 		memcpy(dname_nt, dname, dnamelen);
 		dname_nt[dnamelen] = '\0';
 
-		struct driver_registration *dreg, *dreg_tmp;
-		BFG_FOREACH_DRIVER_BY_PRIORITY(dreg, dreg_tmp) {
+		BFG_FOREACH_DRIVER_BY_PRIORITY(dreg) {
 			const struct device_drv * const drv = dreg->drv;
 			if (!(drv && drv->lowl_probe && drv_algo_check(drv)))
 				continue;