Browse Source

Bugfix: scan-serial: Compare dev_t as well

Luke Dashjr 12 years ago
parent
commit
39c448d6a4
3 changed files with 16 additions and 6 deletions
  1. 2 3
      fpgautils.c
  2. 1 0
      fpgautils.h
  3. 13 3
      miner.c

+ 2 - 3
fpgautils.c

@@ -100,7 +100,7 @@ void clear_detectone_meta_info(void)
 	};
 }
 
-static char *_vcom_unique_id(const char *);
+#define _vcom_unique_id(devpath)  devpath_to_devid(devpath)
 
 struct lowlevel_device_info *_vcom_devinfo_findorcreate(struct lowlevel_device_info ** const devinfo_list, const char * const devpath)
 {
@@ -795,8 +795,7 @@ struct device_drv *bfg_claim_any2(struct device_drv * const api, const char * co
 	return bfg_claim_any(api, verbose, devpath);
 }
 
-static
-char *_vcom_unique_id(const char * const devpath)
+char *devpath_to_devid(const char * const devpath)
 {
 #ifndef WIN32
 	char *devs = malloc(6 + (sizeof(dev_t) * 2) + 1);

+ 1 - 0
fpgautils.h

@@ -25,6 +25,7 @@ extern struct detectone_meta_info_t *_detectone_meta_info();
 #define detectone_meta_info (*_detectone_meta_info())
 extern void clear_detectone_meta_info(void);
 
+extern char *devpath_to_devid(const char *);
 extern bool vcom_lowl_probe_wrapper(const struct lowlevel_device_info *, detectone_func_t);
 
 extern int _serial_autodetect(detectone_func_t, ...);

+ 13 - 3
miner.c

@@ -10322,9 +10322,19 @@ void *probe_device_thread(void *p)
 		if (!colon)
 			continue;
 		const char * const ser = &colon[1];
-		if (!(info->serial && !strcasecmp(ser, info->serial))
-		  || (info->path && !strcasecmp(ser, info->path)))
-			continue;
+		if (!(true
+			|| (info->serial && !strcasecmp(ser, info->serial))
+			|| (info->path   && !strcasecmp(ser, info->path  ))
+		))
+		{
+			char *devid = devpath_to_devid(ser);
+			if (!devid)
+				continue;
+			const bool different = strcmp(info->devid, devid);
+			free(devid);
+			if (different)
+				continue;
+		}
 		const size_t dnamelen = (colon - dname);
 		if (_probe_device_internal(info, dname, dnamelen))
 			return NULL;