Browse Source

fpgautils: Check for devices being claimed before calling detectone from autodetectors

Luke Dashjr 12 years ago
parent
commit
5b5cdff413
1 changed files with 14 additions and 0 deletions
  1. 14 0
      fpgautils.c

+ 14 - 0
fpgautils.c

@@ -100,6 +100,18 @@ bool search_needles(const char *haystack, va_list needles)
 
 
 #define SEARCH_NEEDLES(haystack)  search_needles(haystack, needles)
 #define SEARCH_NEEDLES(haystack)  search_needles(haystack, needles)
 
 
+static
+int _detectone_wrap(const detectone_func_t detectone, const char * const param, const char *fname)
+{
+	if (bfg_claim_serial(NULL, false, param))
+	{
+		applog(LOG_DEBUG, "%s: %s is already claimed, skipping probe", fname, param);
+		return 0;
+	}
+	return detectone(param);
+}
+#define detectone(param)  _detectone_wrap(detectone, param, __func__)
+
 #ifdef HAVE_LIBUDEV
 #ifdef HAVE_LIBUDEV
 static
 static
 int _serial_autodetect_udev(detectone_func_t detectone, va_list needles)
 int _serial_autodetect_udev(detectone_func_t detectone, va_list needles)
@@ -331,6 +343,8 @@ out:
 #	define _serial_autodetect_ftdi(...)  (0)
 #	define _serial_autodetect_ftdi(...)  (0)
 #endif
 #endif
 
 
+#undef detectone
+
 int _serial_autodetect(detectone_func_t detectone, ...)
 int _serial_autodetect(detectone_func_t detectone, ...)
 {
 {
 	int rv;
 	int rv;